From 02e7742c0f394cb08aab0e1bd86caf9df831481a Mon Sep 17 00:00:00 2001 From: Masataka SUMI Date: Thu, 2 Dec 2021 23:51:46 +0900 Subject: [PATCH] =?UTF-8?q?=E8=A6=96=E9=8C=90=E5=8F=B0=E5=B9=B3=E9=9D=A2?= =?UTF-8?q?=E3=81=AE=E9=AB=98=E3=81=95=E3=82=92=E7=94=A8=E3=81=84=E3=81=A6?= =?UTF-8?q?=E3=80=81FoV=20=E3=81=A8=E8=B7=9D=E9=9B=A2=E3=81=AB=E5=BF=9C?= =?UTF-8?q?=E3=81=98=E3=81=A6=E3=82=B9=E3=82=B1=E3=83=BC=E3=83=AB=E5=80=A4?= =?UTF-8?q?=E3=81=8C=E3=81=84=E3=81=84=E6=84=9F=E3=81=98=E3=81=AB=E3=81=AA?= =?UTF-8?q?=E3=82=8B=20Screen=20=E5=BA=A7=E6=A8=99=E7=B3=BB=E8=BC=AA?= =?UTF-8?q?=E9=83=AD=E7=B7=9A=E3=81=AE=E3=82=A2=E3=83=AB=E3=82=B4=E3=83=AA?= =?UTF-8?q?=E3=82=BA=E3=83=A0=E3=82=92=E5=B0=8E=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vrmc_materials_mtoon_geometry_vertex.hlsl | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) 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 77dbc0167..af5180181 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,13 +49,17 @@ 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; + const float maxViewFrustumPlaneHeight = 2.0f; + const float invTangentHalfVerticalFov = unity_CameraProjection[1][1]; + // NOTE: viewFrustumPlaneHeight = tan(halfFov) * viewDirDistance * 2.0 + // -> viewDirDistance = viewFrustumPlaneHeight / (tan(halfFov) * 2.0) + const float widthScaledMaxMeter = maxViewFrustumPlaneHeight * invTangentHalfVerticalFov * 0.5f; + // NOTE: VR などの高視野角カメラでは、純粋な実装では太くなりすぎる. + // よってある距離での視錐台平面が高さ 2m 以上になったらスケールをやめる. + const half outlineWidthMultiplier = outlineWidth * min(positionCS.w, widthScaledMaxMeter); half2 normalProjectedCS = normalize(normalCS.xy); - // NOTE: VR などの高視野角カメラでは、純粋な実装では太くなりすぎる. - // よって 1m 以上離れたら、それ以上太くならないようにする. - const half outlineWidthMultiplier = outlineWidth * min(positionCS.w, widthScaledMaxMeter); + const float clipSpaceHeight = 2.0f; normalProjectedCS *= clipSpaceHeight * outlineWidthMultiplier; normalProjectedCS.x *= aspect; // NOTE: カメラ方向軸を向く法線を持つ頂点が XY 方向にだけずれると困るので、それを抑制する.