|
|
|
|
|
|
{ |
|
|
|
float2 uv : TEXCOORD0; |
|
|
|
DECLARE_LIGHTMAP_OR_SH(lightmapUV, vertexSH, 1); |
|
|
|
float3 posWS : TEXCOORD2; |
|
|
|
float4 posWSShininess : TEXCOORD2; // xyz: posWS, w: Shininess * 128 |
|
|
|
half4 binormal : TEXCOORD5; // xyz: binormal, w: viewDir.w |
|
|
|
half4 binormal : TEXCOORD5; // xyz: binormal, w: viewDir.z |
|
|
|
#else |
|
|
|
half3 normal : TEXCOORD3; |
|
|
|
half3 viewDir : TEXCOORD6; |
|
|
|
|
|
|
|
|
|
|
void InitializeInputData(LightweightVertexOutput IN, half3 normalTS, out InputData inputData) |
|
|
|
{ |
|
|
|
inputData.positionWS = IN.posWS.xyz; |
|
|
|
inputData.positionWS = IN.posWSShininess.xyz; |
|
|
|
half3 viewDir = half3(IN.tangent.w, IN.binormal.w, IN.normal.w); |
|
|
|
half3 viewDir = half3(IN.normal.w, IN.tangent.w, IN.binormal.w); |
|
|
|
inputData.normalWS = TangentToWorldNormal(normalTS, IN.tangent.xyz, IN.binormal.xyz, IN.normal.xyz); |
|
|
|
#else |
|
|
|
half3 viewDir = IN.viewDir; |
|
|
|
|
|
|
|
|
|
|
o.uv = TRANSFORM_TEX(v.texcoord, _MainTex); |
|
|
|
|
|
|
|
o.posWS = TransformObjectToWorld(v.vertex.xyz); |
|
|
|
o.clipPos = TransformWorldToHClip(o.posWS); |
|
|
|
o.posWSShininess.xyz = TransformObjectToWorld(v.vertex.xyz); |
|
|
|
o.posWSShininess.w = _Shininess * 128.0; |
|
|
|
o.clipPos = TransformWorldToHClip(o.posWSShininess.xyz); |
|
|
|
half3 viewDir = GetCameraPositionWS() - o.posWS; |
|
|
|
half3 viewDir = GetCameraPositionWS() - o.posWSShininess.xyz; |
|
|
|
#if !SHADER_HINT_NICE_QUALITY |
|
|
|
// Normalize in vertex and avoid renormalizing it in frag to save ALU. |
|
|
|
viewDir = SafeNormalize(viewDir); |
|
|
|
|
|
|
OUTPUT_LIGHTMAP_UV(v.lightmapUV, unity_LightmapST, o.lightmapUV); |
|
|
|
OUTPUT_SH(o.normal.xyz, o.vertexSH); |
|
|
|
|
|
|
|
half3 vertexLight = VertexLighting(o.posWS, o.normal.xyz); |
|
|
|
half3 vertexLight = VertexLighting(o.posWSShininess.xyz, o.normal.xyz); |
|
|
|
half fogFactor = ComputeFogFactor(o.clipPos.z); |
|
|
|
o.fogFactorAndVertexLight = half4(fogFactor, vertexLight); |
|
|
|
o.shadowCoord = ComputeShadowCoord(o.clipPos); |
|
|
|
|
|
|
|
|
|
|
half3 emission = Emission(uv); |
|
|
|
half4 specularGloss = SpecularGloss(uv, diffuseAlpha.a); |
|
|
|
half shininess = _Shininess * 128.0h; |
|
|
|
half shininess = IN.posWSShininess.w; |
|
|
|
|
|
|
|
InputData inputData; |
|
|
|
InitializeInputData(IN, normalTS, inputData); |
|
|
|