diff options
| author | yum <yum.food.vr@gmail.com> | 2025-11-03 11:57:59 -0800 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2025-11-03 11:57:59 -0800 |
| commit | 46b30ed654b00746c131e575232f6f012d4e5004 (patch) | |
| tree | 6864c5be8f872af719cf2b907dbb179351761018 | |
| parent | f21483d8fe302ea952e6b5426c74c8d4713a6b4f (diff) | |
fix normals in deformed ray marcher
| -rw-r--r-- | ray_marching.cginc | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/ray_marching.cginc b/ray_marching.cginc index f6f4bab..fe48f2c 100644 --- a/ray_marching.cginc +++ b/ray_marching.cginc @@ -105,10 +105,12 @@ void ray_march(inout v2f i) { #if defined(_VERTEX_DEFORMATION) // TODO optimize, we don't need to pass in `dummy`. - float3 dummy = 0; - float3 tmp_pos = ro; - undeform_normal(tmp_pos, dummy, rd); - rd = normalize(rd); + { + float3 dummy = 0; + float3 tmp_pos = ro; + undeform_normal(tmp_pos, dummy, rd); + rd = normalize(rd); + } #endif const float kMinDist = _Ray_Marching_Min_Dist; @@ -157,6 +159,13 @@ void ray_march(inout v2f i) { } #endif +#if defined(_VERTEX_DEFORMATION) + { + float3 tmp_pos = ro; + deform_normal(tmp_pos, lclNorm, lclTan); + } +#endif + i.objPos = lclPos; i.normal = lclNorm; i.tangent.xyz = lclTan; |
