From 1784064c7a39a69203e8975167addf1915f940bd Mon Sep 17 00:00:00 2001 From: yum Date: Tue, 17 Mar 2026 15:49:21 -0700 Subject: Add faster 3-in 1-out hasher for domain warping Goes from ~1.7 ms/frame to ~1.1 ms/frame in 10-octave microbenchmark. --- pbr.cginc | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'pbr.cginc') diff --git a/pbr.cginc b/pbr.cginc index e0cf64f..dac9e1f 100755 --- a/pbr.cginc +++ b/pbr.cginc @@ -132,8 +132,19 @@ void apply_marble(float3 world_pos, inout float3 albedo) { uvw += offset; +#if 1 float3 noise = domain_warp_procedural(uvw, _Marble_Strength, _Marble_Octaves, _Marble_Lacunarity, _Marble_Gain); +#elif 1 + float3 noise = hash31_fast(uvw*32); +#elif 0 + float3 noise = value_noise3(uvw); +#elif 0 + float3 noise = value_noise_3d_tex(_Marble_Noise, trilinear_repeat_s, uvw); +#else + float3 noise = domain_warp_3d_tex(_Marble_Noise, trilinear_repeat_s, uvw, + _Marble_Strength, _Marble_Octaves, _Marble_Lacunarity, _Marble_Gain); +#endif noise = _Marble_Post_Ramp.Sample(linear_clamp_s, float2(noise.x, 0)); @@ -153,12 +164,7 @@ void apply_kintsugi(float3 world_pos, inout float3 albedo, inout float smoothnes uvw += warp; #endif -#if defined(_KINTSUGI_PROCEDURAL) float mask = voronoi_edge_distance(uvw) + 0.5f; -#else - float mask = _Kintsugi_Noise.Sample(aniso4_trilinear_repeat_s, uvw); -#endif - float width = max(fwidth(mask) * 0.5f, _Kintsugi_Width); float threshold = _Kintsugi_Threshold; mask = smoothstep(threshold - width, threshold + width, mask); -- cgit v1.2.3