SurfaceTextureProgram

Surface tile / surface texture program. Composites up to TEXTURE_UNITS imagery textures over a terrain tile in a single geometry pass: the fragment shader transforms the tile-local texture coordinate per attached texture (scale + translation), masks fragments outside each texture's sub-rectangle and blends the stack front-to-back in-shader. Terrain geometry is therefore drawn once per batch of textures instead of once per texture.

A single GLSL source carries both the no-shadow (default) and the shadow-aware paths, gated by a #define SHADOWS_ENABLED preprocessor symbol that shadowsEnabled toggles. The sentinel subclass SurfaceTextureProgramShadow - selected by get when an earth.worldwind.layer.shadow.ShadowLayer is in the layer list - exists only to give the cache a distinct kotlin.reflect.KClass key for the shadow-aware variant.

Inheritors

Constructors

Link copied to clipboard
constructor(shadowsEnabled: Boolean = false)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard

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

Link copied to clipboard
open override var shadowUploadStamp: Long

Frame stamp of the last ShadowState whose uniforms were uploaded into this program. GL uniforms are program-state and persist across draw calls, so once a program has been loaded with the current frame's cascades it doesn't need to be loaded again until the cascades change. Implementations declare this as a plain var field, default -1L.

Functions

Link copied to clipboard
fun enablePickMode(enable: Boolean)
Link copied to clipboard

Uploads the first count batch slots packed by setBatchTexture.

Link copied to clipboard
fun loadColor(color: Color)
Link copied to clipboard
Link copied to clipboard
open override fun loadShadowDisabled()

Disables shadow sampling. Receivers' fragments fall through to a fixed 1.0 visibility.

Link copied to clipboard
open override fun loadShadowEnabled(state: ShadowState)

Enables shadow sampling and uploads the cascade matrices, split depths, texel sizes, light direction and fade distance from state. Cascade sampler bindings (GL_TEXTURE1..4) are baked in at program init time; the caller is responsible for binding the matching cascade depth textures to those units before invoking this method — applyShadowReceiverUniforms does both in lockstep.

Link copied to clipboard
fun loadTerrainRelief(strength: Float, lightDirection: Vec3?)

Forwards to ShadowReceiverUniforms.loadTerrainRelief; a no-op on the no-shadow variant.

Link copied to clipboard

Sets the tile-local -> world translation for the next draw call. Per-tile because each terrain tile uses its own local frame; loaded each iteration of the tile loop. Drawables only call this when earth.worldwind.draw.DrawContext.shadowState is non-null, so the call doesn't happen on no-shadow frames at all.

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
fun setBatchTexture(k: Int, texCoordMatrix: Matrix3, terrainSector: Sector, textureSector: Sector, opacity: Float)

Packs batch slot k from the texture's coordinate transform and the terrain/texture sectors: the tile-local -> image scale+translation and the texture's coverage rectangle in tile-local coordinates. texCoordMatrix must be axis-aligned affine (scale + translation, e.g. a vertical flip); rotation and shear terms are ignored.

Link copied to clipboard