From 7e92cd82fc38c3d2cbafaa42820ee80f990336f5 Mon Sep 17 00:00:00 2001 From: notargs Date: Thu, 11 May 2023 17:56:48 +0900 Subject: [PATCH] =?UTF-8?q?MTOON=5FTRANSFER=5FFOG=5FAND=5FLIGHTING?= =?UTF-8?q?=E3=82=92=E5=88=87=E3=82=8A=E5=87=BA=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vrmc_materials_mtoon_forward_vertex.hlsl | 18 +-------------- .../vrmc_materials_mtoon_render_pipeline.hlsl | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_forward_vertex.hlsl b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_forward_vertex.hlsl index fc2fe47fd..4a9a3927b 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_forward_vertex.hlsl +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_forward_vertex.hlsl @@ -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; } diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_render_pipeline.hlsl b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_render_pipeline.hlsl index 441b94543..bcc46dc8b 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_render_pipeline.hlsl +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_render_pipeline.hlsl @@ -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) {