Luxar Viewer API Documentation - v2026.9.22
    Preparing search index...

    Module rendering/materials/_shared/glass-partition-tsl

    TSL twin of glass-partition.ts: the per-fragment depth partition of the emissive data around refract_data glass, for the WebGPURenderer graphs (native WebGPU and its WebGL2 fallback).

    Two things differ from the GLSL side, both forced by TSL:

    1. The fragment's own window depth is a varying. Every Luxar data graph replaces the vertex stage (material.vertexNode), so three's positionView-derived depth nodes would read a quad-corner attribute, and no TSL node exposes fragCoord.z. The vertex body assigns its clip zw to clipDepthVarying; per fragment z / w is the rasterizer's own screen-linear depth (perspective-correct interpolation of z and of w cancel), remapped to window depth by GlassFragmentDepthNode according to the renderer's coordinate system — z/w already IS window depth under WebGPUCoordinateSystem, z/w * 0.5 + 0.5 under WebGL's. Window depth in [0, 1] is the one quantity both conventions share with the depth texture, so the compare needs no further care.
    2. The depth texture is sampled at screenUV, exactly as three's own viewportDepthTexture does: screenUV is top-left-origin on both backends and TextureNode Y-flips a depth texture on the GLSL builder (_flipYUniform), so the same graph is orientation-correct on WGSL and on the WebGL2 fallback. A depth texture's node type is float, so the sample IS the depth (no .r).

    The guard emits its two Discards onto the CALLER's stack — it must be called inside the fragment Fn body, first — rather than through a nested Fn, the same rule the other shared helpers in tsl-helpers.ts follow.

    GlassFragmentDepthNode
    GlassPartitionTSLNodes
    glassPartitionNodes
    glassPartitionNodesFromUniforms
    clipDepthVarying
    glassPartitionGuardTSL