USER_COMP_HELPERS

Constant USER_COMP_HELPERS 

Source
const USER_COMP_HELPERS: &str = r#"
fn GetPixel(uv: vec2<f32>) -> vec3<f32> {
    return textureSample(sampler_main_texture, sampler_main, uv).rgb;
}

// MD2 alias — many in-the-wild comp shaders call GetMain(uv) instead of
// GetPixel(uv). Same semantics: sample the main render target.
fn GetMain(uv: vec2<f32>) -> vec3<f32> {
    return textureSample(sampler_main_texture, sampler_main, uv).rgb;
}

// Blur-pyramid samplers. MD2 stores the three Gaussian-blurred copies of
// the warp output in a compressed range `[blurN_min, blurN_max]` (the
// engine writes these uniforms each frame); the canonical `GetBlurN(uv)`
// helper re-expands that range to `[0, 1]` before handing it to the user
// shader. Without this remap, presets that depend on the implicit clamp
// (`color * GetBlur1(uv)`) saturate near full-white or full-black even on
// quiet content, throwing the visual balance MD2 is tuned for.
fn GetBlur1(uv: vec2<f32>) -> vec3<f32> {
    let sample = textureSample(sampler_blur1_texture, sampler_main, uv).rgb;
    return mix(vec3<f32>(blur1_min), vec3<f32>(blur1_max), sample);
}

fn GetBlur2(uv: vec2<f32>) -> vec3<f32> {
    let sample = textureSample(sampler_blur2_texture, sampler_main, uv).rgb;
    return mix(vec3<f32>(blur2_min), vec3<f32>(blur2_max), sample);
}

fn GetBlur3(uv: vec2<f32>) -> vec3<f32> {
    let sample = textureSample(sampler_blur3_texture, sampler_main, uv).rgb;
    return mix(vec3<f32>(blur3_min), vec3<f32>(blur3_max), sample);
}

/// MD2 luminance helper. 78 / 168 in-the-wild comp shaders call `lum(c)`
/// to weight the perceptual brightness of a sample. The MD2 source uses a
/// Rec. 601-ish weight `(0.32, 0.49, 0.29)` (note: not exactly normalised);
/// we mirror the weights so visual output stays close to the reference.
fn lum(c: vec3<f32>) -> f32 {
    return dot(c, vec3<f32>(0.32, 0.49, 0.29));
}
"#;
Expand description

MD2 helper functions every comp shader expects to find at module scope.

GetPixel(uv) returns the current main texture sample as vec3<f32> — the canonical MD2 convention is to discard alpha at the comp stage.

GetBlur1/2/3(uv) sample the cumulative Gaussian-blur pyramid produced by [BlurPipeline] each frame. The vast majority of in-the-wild comp shaders reference at least one GetBlur* — without a real pyramid they would degrade to GetPixel and lose the soft-halo look the preset depends on.