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,

“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.