SightlineReceiverGlsl

Reusable GLSL fragments that any program can splice into its fragment shader to make its own pixels modulate against the active sightline's depth cube. Mirrors earth.worldwind.layer.shadow.ShadowReceiverGlsl for sun shadows.

The vertex shader pulls in VERTEX_DECLARATIONS and calls emitSightlineVaryings(vertex) once per vertex (vertex is the position sightlineLocalMatrix expects — camera-relative world for embedded receivers, tile-origin-relative for the terrain overlay pass). The fragment shader pulls in FRAGMENT_DECLARATIONS and calls computeSightlineTint() to get a premultiplied RGBA — vec4(0) means "no tint". Compose it over the surface colour:

vec4 tint = computeSightlineTint(); gl_FragColor.rgb = gl_FragColor.rgb * (1.0 - tint.a) + tint.rgb; gl_FragColor.a = max(gl_FragColor.a, tint.a);

Occlusion is resolved against a depth cube map (see DrawContext.sightlineDepthCubeTexture): the fragment's sightline-local direction picks the cube texel, and the fragment's own window depth along the dominant face axis is compared against the stored hardware depth with a 3x3 binomial tent PCF — the same design as the cascaded sun shadows, including the WW_SHADOW_SAMPLERS hardware depth-compare variant (samplerCubeShadow, one compare per tap in the sampler) with the in-shader step compare as the GLSL ES 1.00 fallback.

Receivers gate the splice with #ifdef SIGHTLINE_ENABLED so a single GLSL source supports both the receiver-aware and base variants.

Properties

Link copied to clipboard

Block to splice into the fragment shader. Provides computeSightlineTint which returns the premultiplied tint to blend into the surface colour.

Link copied to clipboard

Preprocessor define enabled by each receiver program's sightlineEnabled flag.

Link copied to clipboard

Block to splice into the vertex shader. sightlineLocalMatrix maps the caller's vertex position into the sightline-local frame (Z = up, origin at the sightline); the caller computes its own gl_Position alongside.