From d7e9d92d0501a84de103fdfd0c938f53e11c3e6e Mon Sep 17 00:00:00 2001 From: notargs Date: Wed, 26 Apr 2023 14:57:22 +0900 Subject: [PATCH] =?UTF-8?q?=E8=AD=A6=E5=91=8A=E3=82=92=E6=BD=B0=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../VRM10/vrmc_materials_mtoon_forward_vertex.hlsl | 4 ++-- .../VRM10/vrmc_materials_mtoon_geometry_vertex.hlsl | 8 ++++---- .../VRM10/vrmc_materials_mtoon_lighting_mtoon.hlsl | 6 +++--- .../VRM10/vrmc_materials_mtoon_lighting_unity.hlsl | 2 +- 4 files changed, 10 insertions(+), 10 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 3419a1113..5cb9fa706 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 @@ -29,7 +29,7 @@ Varyings MToonVertex(const Attributes v) // v is UnityCG macro specified name. { const VertexPositionInfo position = MToon_GetOutlineVertex(v.vertex.xyz, normalize(v.normalOS), output.uv); output.pos = position.positionCS; - output.positionWS = position.positionWS; + output.positionWS = position.positionWS.xyz; #ifdef MTOON_URP output.normalWS = TransformObjectToWorldNormal(-v.normalOS); @@ -41,7 +41,7 @@ Varyings MToonVertex(const Attributes v) // v is UnityCG macro specified name. { const VertexPositionInfo position = MToon_GetVertex(v.vertex.xyz); output.pos = position.positionCS; - output.positionWS = position.positionWS; + output.positionWS = position.positionWS.xyz; #ifdef MTOON_URP output.normalWS = TransformObjectToWorldNormal(v.normalOS); diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_geometry_vertex.hlsl b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_geometry_vertex.hlsl index 0e8210fed..b6853a52a 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_geometry_vertex.hlsl +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_geometry_vertex.hlsl @@ -22,7 +22,7 @@ inline half MToon_GetOutlineVertex_OutlineWidth(const float2 uv) { if (MToon_IsParameterMapOn()) { - return _OutlineWidth * UNITY_SAMPLE_TEX2D_LOD(_OutlineWidthTex, uv, 0); + return _OutlineWidth * UNITY_SAMPLE_TEX2D_LOD(_OutlineWidthTex, uv, 0).x; } else { @@ -68,7 +68,7 @@ inline VertexPositionInfo MToon_GetOutlineVertex(const float3 positionOS, const output.positionWS = float4(positionWS + normalWS * outlineWidth, 1); #ifdef MTOON_URP - output.positionCS = TransformWorldToHClip(output.positionWS); + output.positionCS = TransformWorldToHClip(output.positionWS.xyz); #else output.positionCS = UnityWorldToClipPos(output.positionWS); #endif @@ -117,7 +117,7 @@ inline VertexPositionInfo MToon_GetOutlineVertex(const float3 positionOS, const output.positionWS = mul(unity_ObjectToWorld, float4(positionOS * 0.001, 1)); #ifdef MTOON_URP - output.positionCS = TransformWorldToHClip(output.positionWS); + output.positionCS = TransformWorldToHClip(output.positionWS.xyz); #else output.positionCS = UnityWorldToClipPos(output.positionWS); #endif @@ -132,7 +132,7 @@ inline VertexPositionInfo MToon_GetVertex(const float3 positionOS) output.positionWS = mul(unity_ObjectToWorld, float4(positionOS, 1)); #ifdef MTOON_URP - output.positionCS = TransformWorldToHClip(output.positionWS); + output.positionCS = TransformWorldToHClip(output.positionWS.xyz); #else output.positionCS = UnityWorldToClipPos(output.positionWS); #endif diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_lighting_mtoon.hlsl b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_lighting_mtoon.hlsl index 11a5053a8..d60367a02 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_lighting_mtoon.hlsl +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_lighting_mtoon.hlsl @@ -56,7 +56,7 @@ inline half GetMToonLighting_Shade(const UnityLighting lighting, const MToonInpu if (MToon_IsForwardBasePass()) { const half shadeInput = lerp(-1, 1, mtoon_linearstep(-1, 1, dotNL)); - return mtoon_linearstep(-1.0 + shadeToony, +1.0 - shadeToony, shadeInput + shadeShift) * lighting.directLightAttenuation; + return mtoon_linearstep(-1.0 + shadeToony, +1.0 - shadeToony, shadeInput + shadeShift) * lighting.directLightAttenuation.x; } else { @@ -69,7 +69,7 @@ inline half GetMToonLighting_Shadow(const UnityLighting lighting, const half dot { if (MToon_IsPbrCorrectOn()) { - return lighting.directLightAttenuation * step(0, dotNL); + return lighting.directLightAttenuation.x * step(0, dotNL); } if (MToon_IsForwardBasePass()) @@ -81,7 +81,7 @@ inline half GetMToonLighting_Shadow(const UnityLighting lighting, const half dot // heuristic term for weak lights. // 0.5: heuristic. // min(0, dotNL) + 1: darken if (dotNL < 0) by using half lambert. - return lighting.directLightAttenuation * 0.5 * (min(0, dotNL) + 1); + return lighting.directLightAttenuation.x * 0.5 * (min(0, dotNL) + 1); } } diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_lighting_unity.hlsl b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_lighting_unity.hlsl index b2cae2c93..e1607b3d7 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_lighting_unity.hlsl +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_lighting_unity.hlsl @@ -34,7 +34,7 @@ UnityLighting GetUnityLighting(const Varyings input, const half3 normalWS) float4 shadowCoord = float4(0, 0, 0, 0); #endif - float shadowMask = SAMPLE_SHADOWMASK(input.lightmapUV); + half4 shadowMask = SAMPLE_SHADOWMASK(input.lightmapUV); Light mainLight = GetMainLight(shadowCoord, input.positionWS, shadowMask); const half3 lightDir = mainLight.direction;