Shader bodies for a post effect, one per backend, each defining the function run for every pixel
WGSL: fn effect(uv: vec2<f32>) -> vec4<f32>
GLSL: vec4 effect(vec2 uv)
uv runs from 0 to 1 across the view's viewport, the right way up for the pass's target. The
fragment can call these helpers, the first three only when the pass has the matching read
(FullscreenPassOptions#reads):
sampleColor(uv) and sampleColorLod(uv, lod): the colour input, the LOD form reading mips
when the input has them (PostEffect#inputMips); inputTexel(): one texel of that
input as a UV step
sampleColor2(uv): the second colour input, such as a scene output
sampleDepth(uv): raw scene depth; viewPos(uv): the view-space position there;
depthTexel(): one depth texel as a UV step, coarser than texel() when the effect runs at a
finer resolution than the scene
linearDepth(d): linear depth from a raw depth value. It and viewPos assume a perspective
camera, and give wrong values under an orthographic one.
texel(): one pixel of the pass's target as a UV step
viewTexel(): one physical pixel of the view on screen as a UV step, for a size that has to
look the same at any View3D.resolution and in any pass of the effect
Declared uniforms are fx.<name> in WGSL and plain <name> in GLSL. To project samples of your
own, fxh.uFxClip in WGSL and uFxClip in GLSL hold (near, far, projection[0], projection[5]),
set so that viewPos and points projected with them are in view space, Y up, on both backends.
Shader bodies for a post effect, one per backend, each defining the function run for every pixel
fn effect(uv: vec2<f32>) -> vec4<f32>vec4 effect(vec2 uv)uvruns from 0 to 1 across the view's viewport, the right way up for the pass's target. The fragment can call these helpers, the first three only when the pass has the matching read (FullscreenPassOptions#reads):sampleColor(uv)andsampleColorLod(uv, lod): the colour input, the LOD form reading mips when the input has them (PostEffect#inputMips);inputTexel(): one texel of that input as a UV stepsampleColor2(uv): the second colour input, such as a scene outputsampleDepth(uv): raw scene depth;viewPos(uv): the view-space position there;depthTexel(): one depth texel as a UV step, coarser thantexel()when the effect runs at a finer resolution than the scenelinearDepth(d): linear depth from a raw depth value. It andviewPosassume a perspective camera, and give wrong values under an orthographic one.texel(): one pixel of the pass's target as a UV stepviewTexel(): one physical pixel of the view on screen as a UV step, for a size that has to look the same at anyView3D.resolutionand in any pass of the effectDeclared uniforms are
fx.<name>in WGSL and plain<name>in GLSL. To project samples of your own,fxh.uFxClipin WGSL anduFxClipin GLSL hold (near, far, projection[0], projection[5]), set so thatviewPosand points projected with them are in view space, Y up, on both backends.