diff options
| author | yum <yum.food.vr@gmail.com> | 2023-08-12 18:55:50 -0700 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2023-08-12 18:55:50 -0700 |
| commit | 92b814a787a996653d72cc3077d3228670fa083c (patch) | |
| tree | 5392887ba3c7fca5aa6ae591a3fb3cebc84a2892 | |
| parent | 5d44c186691f42a8a64c895c67079ebe2515ea71 (diff) | |
Workaround: use STT mesh to write depth buffer
There's some bug around using the raymarched world position to write the
depth buffer. I wasn't able to find it quickly, so for now, use the
original world position to write the depth buffer.
| -rw-r--r-- | Shaders/ray_march.cginc | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/Shaders/ray_march.cginc b/Shaders/ray_march.cginc index 579041b..529418a 100644 --- a/Shaders/ray_march.cginc +++ b/Shaders/ray_march.cginc @@ -29,7 +29,7 @@ float _Frame_Smoothness; float _Frame_Emissive; #define MY_COORD_SCALE 100 -#define MY_COORD_SCALE_INV 1.0 / 100 +#define MY_COORD_SCALE_INV 1.0 / MY_COORD_SCALE #define OBJ_SPACE_TO_MINE \ float4x4( \ MY_COORD_SCALE, 0, 0, 0, \ @@ -278,10 +278,14 @@ float4 stt_ray_march(float3 ro, float3 rd, inout v2f v2f_i, inout float depth) { float total_distance_traveled = 0.0; const float MINIMUM_HIT_DISTANCE = .00002 * MY_COORD_SCALE; - const float MAXIMUM_TRACE_DISTANCE = .5 * MY_COORD_SCALE; + const float MAXIMUM_TRACE_DISTANCE = 2 * MY_COORD_SCALE; float3 current_position = 0; float distance_to_closest = 1; + // TODO(yum) remove + float3 old_world_pos = v2f_i.worldPos; + depth = getWorldSpaceDepth(old_world_pos); + #define STT_RAY_MARCH_STEPS 48 float obj_id; float2 text_uv; @@ -314,7 +318,8 @@ float4 stt_ray_march(float3 ro, float3 rd, inout v2f v2f_i, inout float depth) frame += _Frame_Color * _Frame_Emissive; frame = clamp(frame, 0, 1); - depth = getWorldSpaceDepth(mul(MY_SPACE_TO_WORLD, float4(current_position, 1.0)).xyz); + // TODO(yum) restore + //depth = getWorldSpaceDepth(v2f_i.worldPos); [forcecase] switch ((int) obj_id) { |
