Files
BozoEngine/docs/native-image-processing.md
Thomas MartinandClaude Opus 5.5 f4a5cdf96d Depth colours: an RGBA table for the native depth lookup
ImageProcessing::depthColours reads depthWeights as 64 RGBA entries (alpha
1.0 = the GS's 0x80), the index clamped to 63, replacing the texel. With
Blend::DestinationBySource this is a port's depth fog: a ramp colour added
and the scene scaled by the ramp's alpha (VP2S: the Lost Forest haze).
Hashed only when set, so existing frame digests are unchanged. Two
admission guards, a digest check and a GPU case.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-19 20:15:49 +01:00

2.6 KiB

Native image processing

Material::ImageProcessing describes PC image operations supplied by a port. It has no dependency on console command streams, hardware register state or console image layouts. Renderer::draw copies the parameters into the frame; subsequent producer edits cannot change a published draw. Disabled operations leave existing frame digests unchanged.

  • A symmetric separable convolution has radius 1..16, a centre coefficient and one coefficient for each positive offset. Both sides use the same coefficient. step is a normalized source-image displacement. The port supplies normalized coefficients if it wants an energy-preserving kernel. Sampling uses LOD zero.
  • depthLookup produces grayscale RGB from the current main framebuffer depth. Its index is clamp(floor((1-windowDepth)*depthScale),0,255). Each table entry is normalized to 0..1. The depth image is a private OpenGL copy taken before this batch, not a delayed CPU depth query. This operation excludes convolution. With depthColours, depthWeights holds 64 RGBA entries (each 0..1, alpha 1.0 being the GS's 0x80) and the index is clamped to 63; the entry replaces the texel. With Blend::DestinationBySource this adds a depth fog colour and attenuates the scene by the entry's alpha.
  • alphaSource multiplies output alpha by another auxiliary image's green channel, with clamp(green*alphaScale,0,1). The source must have a producer in the current frame and cannot be the draw target. It samples bilinearly in destination framebuffer coordinates. Ordinary alpha blending can then combine colour and opacity images without changing the main depth attachment.
  • targetWidth/targetHeight optionally set a batch's auxiliary image dimensions. They travel with the draw, so a later port resize cannot change earlier work. Existing global target sizes remain the default. A shared-depth target must match main-frame dimensions. A resized image is cleared before its first draw.

Image operations require frame draws; overlay admission rejects them. Invalid indices, dimensions, coefficients, table values and nonfinite parameters fail before publication. Frame digests include each active operation's values.

native_image_processing covers immutable publication, digest changes and mutation-free admission failures. With BOZO_APP=ON, the hidden video-only native_image_processing_gpu fixture checks an exact three-tap kernel, current depth lookup, independent opacity images, target resizing and optional shader state reset. It initializes no host input. No game data is required.