Surface3DProjection Shader Program
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
imageProjectionby the tile's local-frame translation, producingimageProjectionLocal- 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
mvpMatrixAND a perspectiveimageClipvarying =imageProjectionLocal * vec4(pointA.xyz, 1.0).Fragment shader divides
imageClip.xy / imageClip.wfor perspective-correct UV in image space, appliestexCoordMatrix(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
Properties
Functions
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.
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.
Frees any resources associated with this instance. After this method returns the rendering resource is invalid, and any associated GL object is deleted.