DepthToColorProgram

Packs a 24-bit normalized depth-buffer value into the red, green and blue channels of an RGBA8 color attachment so it can be retrieved with glReadPixels(GL_RGBA, GL_UNSIGNED_BYTE). WebGL1 / GLES2 do not allow reading depth-component textures with glReadPixels, so the engine renders the pick-pass depth texture through this program onto a colour attachment, then unpacks the bytes on the CPU.

Encoding: red carries the high byte, green the middle byte, blue the low byte. The 24-bit pack matches DEPTH24's source precision on WebGL2 / GLES3+ — see earth.worldwind.draw.DrawContext.ensurePickFramebuffer. WebGL1 / GLES2 depth attachments are at most 16-bit so the low byte is zero there; the unpack is identical either way.

The vertex shader expects a unit-square triangle strip at attribute 0 (see earth.worldwind.draw.DrawContext.unitSquareBuffer) and rasterises the full output framebuffer. loadUvScale must be called every blit with viewport.size / depthTexture.size to clamp vUV to the rendered region of the (oversized) depth texture.

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 loadUvScale(scaleX: Float, scaleY: Float)
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