|
|
|
|
|
|
float2 uv : TEXCOORD0; |
|
|
|
float4 lightmapUVOrVertexSH : TEXCOORD1; // holds either lightmapUV or vertex SH. depending on LIGHTMAP_ON |
|
|
|
float3 posWS : TEXCOORD2; |
|
|
|
half3 normal : TEXCOORD3; |
|
|
|
half3 tangent : TEXCOORD4; |
|
|
|
half3 binormal : TEXCOORD5; |
|
|
|
half4 normal : TEXCOORD3; // xyz: normal, w: viewDir.x |
|
|
|
half4 tangent : TEXCOORD4; // xyz: tangent, w: viewDir.y |
|
|
|
half4 binormal : TEXCOORD5; // xyz: binormal, w: viewDir.w |
|
|
|
#else |
|
|
|
half3 normal : TEXCOORD3; |
|
|
|
half3 viewDir : TEXCOORD6; |
|
|
|
half3 viewDir : TEXCOORD6; |
|
|
|
float4 shadowCoord : TEXCOORD8; |
|
|
|
float4 shadowCoord : TEXCOORD8; |
|
|
|
|
|
|
|
float4 clipPos : SV_POSITION; |
|
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID |
|
|
|
|
|
|
inputData.positionWS = IN.posWS.xyz; |
|
|
|
|
|
|
|
#ifdef _NORMALMAP |
|
|
|
inputData.normalWS = TangentToWorldNormal(normalTS, IN.tangent, IN.binormal, IN.normal); |
|
|
|
half3 viewDir = half3(IN.tangent.w, IN.binormal.w, IN.normal.w); |
|
|
|
inputData.normalWS = TangentToWorldNormal(normalTS, IN.tangent.xyz, IN.binormal.xyz, IN.normal.xyz); |
|
|
|
half3 viewDir = IN.viewDir; |
|
|
|
inputData.viewDirectionWS = IN.viewDir; |
|
|
|
inputData.viewDirectionWS = viewDir; |
|
|
|
inputData.viewDirectionWS = normalize(IN.viewDir); |
|
|
|
inputData.viewDirectionWS = normalize(viewDir); |
|
|
|
#endif |
|
|
|
|
|
|
|
inputData.shadowCoord = IN.shadowCoord; |
|
|
|
|
|
|
|
|
|
|
o.posWS = TransformObjectToWorld(v.vertex.xyz); |
|
|
|
o.clipPos = TransformWorldToHClip(o.posWS); |
|
|
|
#ifdef _NORMALMAP |
|
|
|
half3 viewDir = SafeNormalize(GetCameraPositionWS() - o.posWS); |
|
|
|
o.normal.w = viewDir.x; |
|
|
|
o.tangent.w = viewDir.y; |
|
|
|
o.binormal.w = viewDir.z; |
|
|
|
#else |
|
|
|
#endif |
|
|
|
|
|
|
|
// initializes o.normal and if _NORMALMAP also o.tangent and o.binormal |
|
|
|
OUTPUT_NORMAL(v, o); |
|
|
|
|
|
|
// The following funcions initialize |
|
|
|
OUTPUT_LIGHTMAP_UV(v.lightmapUV, unity_LightmapST, o.lightmapUVOrVertexSH); |
|
|
|
OUTPUT_SH(o.normal, o.lightmapUVOrVertexSH); |
|
|
|
OUTPUT_SH(o.normal.xyz, o.lightmapUVOrVertexSH); |
|
|
|
half3 vertexLight = VertexLighting(o.posWS, o.normal); |
|
|
|
half3 vertexLight = VertexLighting(o.posWS, o.normal.xyz); |
|
|
|
half fogFactor = ComputeFogFactor(o.clipPos.z); |
|
|
|
o.fogFactorAndVertexLight = half4(fogFactor, vertexLight); |
|
|
|
o.shadowCoord = ComputeShadowCoord(o.clipPos); |
|
|
|