From 51893ebe4ec2b695376ffdc954b2dce617205f8c Mon Sep 17 00:00:00 2001 From: Masataka SUMI Date: Thu, 2 Dec 2021 23:28:56 +0900 Subject: [PATCH] =?UTF-8?q?Screen=20=E5=BA=A7=E6=A8=99=E7=B3=BB=E3=81=AE?= =?UTF-8?q?=E7=B7=9A=E5=B9=85=E3=81=AE=E3=83=9E=E3=82=A4=E3=82=B0=E3=83=AC?= =?UTF-8?q?=E3=83=BC=E3=82=B7=E3=83=A7=E3=83=B3=E3=83=9F=E3=82=B9=E3=82=92?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Runtime/Migration/Materials/MigrationMToonMaterial.cs | 4 +++- .../Resources/VRM10/vrmc_materials_mtoon_geometry_vertex.hlsl | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Assets/VRM10/Runtime/Migration/Materials/MigrationMToonMaterial.cs b/Assets/VRM10/Runtime/Migration/Materials/MigrationMToonMaterial.cs index d14bd3c65..8068dd0f3 100644 --- a/Assets/VRM10/Runtime/Migration/Materials/MigrationMToonMaterial.cs +++ b/Assets/VRM10/Runtime/Migration/Materials/MigrationMToonMaterial.cs @@ -298,7 +298,9 @@ namespace UniVRM10 break; case OutlineWidthMode.ScreenCoordinates: dst.OutlineWidthMode = UniGLTF.Extensions.VRMC_materials_mtoon.OutlineWidthMode.screenCoordinates; - dst.OutlineWidthFactor = mtoon.Definition.Outline.OutlineWidthValue * oneHundredth; + // NOTE: 従来は、縦幅の半分を 100% としたときの % の値だった。 + // 1.0 では縦幅を 1 としたときの値とするので、 1/200 する。 + dst.OutlineWidthFactor = mtoon.Definition.Outline.OutlineWidthValue * oneHundredth * 0.5f; break; default: throw new ArgumentOutOfRangeException($"OutlineWidthMode: {(int)mtoon.Definition.Outline.OutlineWidthMode}"); 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 44dac0c9b..77dbc0167 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 @@ -49,12 +49,14 @@ inline VertexPositionInfo MToon_GetOutlineVertex(const float3 positionOS, const const half3 normalVS = MToon_GetObjectToViewNormal(normalOS); const half3 normalCS = TransformViewToProjection(normalVS.xyz); + const float clipSpaceHeight = 2.0f; const float widthScaledMaxMeter = 1.0f; + half2 normalProjectedCS = normalize(normalCS.xy); // NOTE: VR などの高視野角カメラでは、純粋な実装では太くなりすぎる. // よって 1m 以上離れたら、それ以上太くならないようにする. const half outlineWidthMultiplier = outlineWidth * min(positionCS.w, widthScaledMaxMeter); - normalProjectedCS *= outlineWidthMultiplier; + normalProjectedCS *= clipSpaceHeight * outlineWidthMultiplier; normalProjectedCS.x *= aspect; // NOTE: カメラ方向軸を向く法線を持つ頂点が XY 方向にだけずれると困るので、それを抑制する. normalProjectedCS.xy *= saturate(1 - normalVS.z * normalVS.z);