diff options
| author | yum <yum.food.vr@gmail.com> | 2026-01-14 18:58:57 -0800 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2026-01-14 19:04:41 -0800 |
| commit | b7b7f43ce5b4377aa44688f6e60d6ee2e9a61b98 (patch) | |
| tree | b0b8f2a35a027ed1881adccd626f200926a41567 | |
| parent | ba0d61e1e38c06758947936f2524b172d33471e2 (diff) | |
Impostors: fix view dependent blending
| -rw-r--r-- | impostor.cginc | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/impostor.cginc b/impostor.cginc index 1245a1c..bdb24e7 100644 --- a/impostor.cginc +++ b/impostor.cginc @@ -12,10 +12,8 @@ float _Cutoff; float _SphereRadius; float3 _ImpostorMainCameraPos; -#ifndef IMPOSTOR_SHADOW_PASS float4 _Color; float _DebugMode; -#endif float2 HemiOctEncode(float3 N) { N.y = max(N.y, 1e-4); @@ -197,11 +195,11 @@ float4 frag(v2f i) : SV_Target { #endif float3 center = i.centerPos; - // For lattice lookup, we need the reverse view direction. - // Lattice points are indexed by outward direction (origin → lattice). - // We want lattice points whose inward direction (lattice → origin) matches the view ray. - // So we lookup using -viewDir to find lattice points pointing opposite to the ray. - float3 viewOS = normalize(mul((float3x3)unity_WorldToObject, -viewDir)); + // For lattice lookup, use the camera-to-impostor-center direction (matches billboard orientation). + // Using the per-fragment view ray (camera→quad point) causes the selected lattice points/weights + // to vary across the billboard, which reads as "not smooth" while moving around the impostor. + float3 centerToCamWS = normalize(camPos - center); + float3 viewOS = normalize(mul((float3x3)unity_WorldToObject, centerToCamWS)); // Get continuous grid position and find the 3 frames float gridRes = (float)_GridResolution; |
