rewrite_tex3d_calls

Function rewrite_tex3d_calls 

Source
pub(crate) fn rewrite_tex3d_calls(src: &str) -> String
Expand description

Rewrite tex3D(<sampler>, <uvw>) to a real 3D textureSample against the noise-volume bindings.

An earlier implementation collapsed every tex3D to a 2D GetPixel(uvw.xy) fallback — that kept the shader compiling but produced wrong output for any preset that relied on noisevol’s true volumetric variance (many in-the-wild comps reference sampler_noisevol_hq). Now that the renderer actually binds 3D noise textures, the rewriter routes the known names onto them and only falls back for unknown sampler names.

Return type: vec4. HLSL’s tex3D returns float4 and presets often store the result in float4 noise2 = tex3D(...); and read .w later — textureSample of a texture_3d<f32> is already vec4.