From 6c14b619fc3c0e61fca2c366682641b2ba5f490e Mon Sep 17 00:00:00 2001 From: Masataka SUMI Date: Thu, 2 Dec 2021 23:10:58 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=A2=E3=83=B3=E3=83=81=E3=82=A8=E3=83=AA?= =?UTF-8?q?=E3=82=A2=E3=82=B7=E3=83=B3=E3=82=B0=E5=AF=BE=E7=AD=96=E3=81=AF?= =?UTF-8?q?=E3=81=97=E3=81=AA=E3=81=84=E3=80=82=20=E3=81=8A=E3=81=9D?= =?UTF-8?q?=E3=82=89=E3=81=8FMToon=20=E3=81=AB=E5=95=8F=E9=A1=8C=E3=81=8C?= =?UTF-8?q?=E3=81=82=E3=82=8B=E3=82=8F=E3=81=91=E3=81=A7=E3=81=AF=E3=81=AA?= =?UTF-8?q?=E3=81=8F=E3=80=81=E5=8D=98=E3=81=AB=20MSAA=20=E3=82=92?= =?UTF-8?q?=E3=81=8B=E3=81=91=E3=81=A6=E3=81=84=E3=81=AA=E3=81=84=E3=80=81?= =?UTF-8?q?=E3=81=AA=E3=81=A9=E3=81=8C=E8=80=83=E3=81=88=E3=82=89=E3=82=8C?= =?UTF-8?q?=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vrmc_materials_mtoon_geometry_vertex.hlsl | 15 +++------------ 1 file changed, 3 insertions(+), 12 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 fdac157d1..d914ac1da 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 @@ -34,15 +34,8 @@ inline VertexPositionInfo MToon_GetOutlineVertex(const float3 positionOS, const const half3 normalWS = UnityObjectToWorldNormal(normalOS); const half outlineWidth = MToon_GetOutlineVertex_OutlineWidth(uv); - const float viewDirWS = length(MToon_GetWorldSpaceViewDir(positionWS)); - const float tangentHalfVerticalFov = 1.0f / unity_CameraProjection[1][1]; - const float onePixelWidth = tangentHalfVerticalFov * viewDirWS * 2.0f / _ScreenParams.y; - // NOTE: 線幅が World Space で一定なので、カメラから離れるとすぐに 1 pixel 未満になりエリアシングしてしまう. - // よって 1.5 pixel 未満から徐々に輪郭線を細くし、1 pixel 未満では幅ゼロにする. - const float antiAliasingOutlineWidth = mtoon_linearstep(onePixelWidth, onePixelWidth * minWidthInPixel, outlineWidth) * outlineWidth; - VertexPositionInfo output; - output.positionWS = float4(positionWS + normalWS * antiAliasingOutlineWidth, 1); + output.positionWS = float4(positionWS + normalWS * outlineWidth, 1); output.positionCS = UnityWorldToClipPos(output.positionWS); return output; } @@ -64,10 +57,8 @@ inline VertexPositionInfo MToon_GetOutlineVertex(const float3 positionOS, const half2 normalProjectedCS = normalize(normalCS.xy); // NOTE: VR などの高視野角カメラでは、純粋な実装では太くなりすぎる. // よって 1m 以上離れたら、それ以上太くならないようにする. - // また、World Coords 輪郭線と同様のエリアシング対策もする. - const half multiplier = outlineWidth * min(positionCS.w, widthScaledMaxMeter); - const half antiAliasingMultiplier = mtoon_linearstep(onePixelMultiplier, onePixelMultiplier * minWidthInPixel, multiplier) * multiplier; - normalProjectedCS *= antiAliasingMultiplier; + const half outlineWidthMultiplier = outlineWidth * min(positionCS.w, widthScaledMaxMeter); + normalProjectedCS *= outlineWidthMultiplier; normalProjectedCS.x *= aspect; // NOTE: カメラ方向軸を向く法線を持つ頂点が XY 方向にだけずれると困るので、それを抑制する. normalProjectedCS.xy *= saturate(1 - normalVS.z * normalVS.z);