Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by LW · Jul 19, 2017 at 11:39 PM · shadercghlslfragment

Where Is UNITY_POSITION(pos) Defined?

Hi All,

I was hoping to copy and modify the following fragment shader in UnityStandardCoreForwardSimple.cginc:

 half4 fragForwardBaseSimpleInternal (VertexOutputBaseSimple i)
 {
     UNITY_APPLY_DITHER_CROSSFADE(i.pos.xy);
 
     FragmentCommonData s = FragmentSetupSimple(i);
 
     UnityLight mainLight = MainLightSimple(i, s);
 
     #if !defined(LIGHTMAP_ON) && defined(_NORMALMAP)
     half ndotl = saturate(dot(s.tangentSpaceNormal, i.tangentSpaceLightDir));
     #else
     half ndotl = saturate(dot(s.normalWorld, mainLight.dir));
     #endif
 
     //we can't have worldpos here (not enough interpolator on SM 2.0) so no shadow fade in that case.
     half shadowMaskAttenuation = UnitySampleBakedOcclusion(i.ambientOrLightmapUV, 0);
     half realtimeShadowAttenuation = SHADOW_ATTENUATION(i);
     half atten = UnityMixRealtimeAndBakedShadows(realtimeShadowAttenuation, shadowMaskAttenuation, 0);
 
     half occlusion = Occlusion(i.tex.xy);
     half rl = dot(REFLECTVEC_FOR_SPECULAR(i, s), LightDirForSpecular(i, mainLight));
 
     UnityGI gi = FragmentGI (s, occlusion, i.ambientOrLightmapUV, atten, mainLight);
     half3 attenuatedLightColor = gi.light.color * ndotl;
 
     half3 c = BRDF3_Indirect(s.diffColor, s.specColor, gi.indirect, PerVertexGrazingTerm(i, s), PerVertexFresnelTerm(i));
     c += BRDF3DirectSimple(s.diffColor, s.specColor, s.smoothness, rl) * attenuatedLightColor;
     c += Emission(i.tex.xy);
 
     UNITY_APPLY_FOG(i.fogCoord, c);
 
     return OutputForward (half4(c, 1), s.alpha);
 }

But I get an error stating it doesn't recognize VertexOutputBaseSimple. If I include that it reads, "unrecognized identifier UNITY_POSITION(pos)".

If anyone can point me in the correct direction I would greatly appreciate it!

Thanks,

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Bunny83 · Jul 20, 2017 at 09:33 AM

"UNITY_POSITION" doesn't exist in any cg include that is shipped with Unity. You can't just copy a single method out of an include file. You can of course copy and paste the method into your own shader and "rename" that method. In addition you should simply include that file in your shader (that's the main point of include files -.-)

So do a

 #include "UnityStandardCoreForwardSimple.cginc"

at the top of your CG code and keep in mind when you copy that method in order to apply some changes to it, you should rename it.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image LW · Jul 20, 2017 at 01:14 PM 0
Share

Hi @Bunny83 , yeah I tried that earlier and it spawned more errors including tangentToWorldAndPackedData from the s.posWorld = IN_WORLDPOS(i); line in the file (function: FragmentCommonData FragmentSetupSimple(VertexOutputBaseSimple i) { ... }).

I was hoping to basically just pull over the fragment and write a modification into the standard shader but I'm encountering some hurdles I can't leap so I was just hoping someone could point me toward a direction I could move in.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

104 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Access to svPosition in fragment shader 1 Answer

Projected Texture Shader Issues 1 Answer

how to approach instanceID in shader? 0 Answers

How do you change Point Size in Direct3d 11 shader? 1 Answer

Stop shader values from being clamped 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges