MTOON_TRANSFER_FOG_AND_LIGHTINGを切り出した

This commit is contained in:
notargs
2023-05-11 17:56:48 +09:00
parent d33327eba9
commit 7e92cd82fc
2 changed files with 23 additions and 17 deletions

View File

@@ -42,23 +42,7 @@ Varyings MToonVertex(const Attributes v) // v is UnityCG macro specified name.
output.tangentWS = half4(MToon_TransformObjectToWorldDir(v.tangentOS), tangentSign);
#endif
#ifdef MTOON_URP
OUTPUT_LIGHTMAP_UV(input.texcoord1, unity_LightmapST, output.lightmapUV);
OUTPUT_SH(output.normalWS.xyz, output.vertexSH);
half3 vertexLight = VertexLighting(output.positionWS, output.normalWS);
half fogFactor = ComputeFogFactor(output.pos.z);
output.fogFactorAndVertexLight = half4(fogFactor, vertexLight);
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
VertexPositionInputs vertexInput = GetVertexPositionInputs(v.vertex.xyz);
output.shadowCoord = GetShadowCoord(vertexInput);
#endif
#else
UNITY_TRANSFER_FOG(output, output.pos);
UNITY_TRANSFER_LIGHTING(output, v.texcoord1.xy);
#endif
MTOON_TRANSFER_FOG_AND_LIGHTING(output, output.pos, v.texcoord1.xy, v.vertex.xyz);
return output;
}

View File

@@ -81,6 +81,28 @@
#endif
// Transfer fog and lighting
#ifdef MTOON_URP
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
#define MTOON_TRANSFER_FOG_AND_LIGHTING(o, outpos, coord, vertex) \
OUTPUT_LIGHTMAP_UV(coord.xy, unity_LightmapST, output.lightmapUV); \
OUTPUT_SH(output.normalWS.xyz, output.vertexSH); \
output.fogFactorAndVertexLight = half4(ComputeFogFactor(outpos.z), VertexLighting(output.positionWS, output.normalWS)); \
output.shadowCoord = GetShadowCoord(GetVertexPositionInputs(vertex.xyz));
#else
#define MTOON_TRANSFER_FOG_AND_LIGHTING(o, outpos, coord, vertex) \
OUTPUT_LIGHTMAP_UV(coord.xy, unity_LightmapST, output.lightmapUV); \
OUTPUT_SH(output.normalWS.xyz, output.vertexSH); \
output.fogFactorAndVertexLight = half4(ComputeFogFactor(outpos.z), VertexLighting(output.positionWS, output.normalWS));
#endif
#else
#define MTOON_TRANSFER_FOG_AND_LIGHTING(o, outpos, coord, vertex) \
UNITY_TRANSFER_FOG(o, outpos); \
UNITY_TRANSFER_LIGHTING(o, coord.xy);
#endif
// SampleSH
inline half3 MToon_SampleSH(half3 normalWS)
{