Surface3DProjectionShaderProgram

Surface-projection shader that drapes a source image onto terrain via a 4x4 camera-frustum matrix in WGS84 ECEF, evaluated per fragment. Companion to SurfaceQuadShaderProgram (the 2D-homography path); used by the 3D path on earth.worldwind.shape.ProjectedMediaSurface when the shape carries an imageProjection matrix.

Pipeline per terrain tile:

  • CPU pre-multiplies the world-space imageProjection by the tile's local-frame translation, producing imageProjectionLocal - a tile-local matrix that maps a terrain vertex's tile-local 3D position to image clip space. Keeps the per-vertex math in float-precise small magnitudes; world ECEF coordinates would lose sub-metre precision in single-precision float.

  • Vertex shader emits gl_Position via the standard mvpMatrix AND a perspective imageClip varying = imageProjectionLocal * vec4(pointA.xyz, 1.0).

  • Fragment shader divides imageClip.xy / imageClip.w for perspective-correct UV in image space, applies texCoordMatrix (e.g. the source texture's vertical flip), samples the source texture. Discards fragments behind the camera (imageClip.w <= 0) and outside the unit-square image bounds (UV < 0 or > 1) so only terrain inside the camera's frustum receives the image.

No skin-texture stage: this shader runs the source texture directly against the terrain triangulation. That trades the surface-drawable's batching ability for correct projection on relief-heavy terrain.

Inheritors

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard

Indicates the approximate size of the OpenGL resources referenced by this GPU program.

Functions

Link copied to clipboard
fun loadColor(color: Color)
Link copied to clipboard
fun loadFadeMargin(fadeMargin: Float)

Soft-edge fade margin in normalised UV units (0..0.5). 0 (default) renders a hard cutoff at the unit-square boundary - the cheapest path, since the shader's uniform-controlled branch then skips the fade math entirely. Non-zero values ramp alpha 0..1 across the inner 0..fadeMargin strip on each side, blending the projection into surrounding terrain.

Link copied to clipboard

Tile-local image projection: world-ECEF imageProjection premultiplied by a translation to the current terrain tile's vertex origin. Recomputed per tile by the drawable so per-vertex math stays float-precise. Skips the upload when the matrix matches the previously uploaded value - common for static photos and paused video that re-bind the same surface drawable every render frame.

Link copied to clipboard
Link copied to clipboard
fun loadOpacity(opacity: Float)
Link copied to clipboard
Link copied to clipboard
open override fun release(dc: DrawContext)

Frees any resources associated with this instance. After this method returns the rendering resource is invalid, and any associated GL object is deleted.

Link copied to clipboard