simvx.graphics.renderer.colour_grading

Colour grading pass: LUT-based colour correction via compute shader.

Module Contents

Classes

ColourGradingPass

Compute-based colour grading: LUT lookup + brightness/contrast/saturation/temperature.

Functions

create_lut_sampler

Create a trilinear, clamp-to-edge sampler for a 3D LUT.

upload_lut_3d

Upload an (size, size, size, 4) uint8 LUT as a 3D sampled image.

Data

API

simvx.graphics.renderer.colour_grading.__all__

[‘ColourGradingPass’, ‘create_lut_sampler’, ‘upload_lut_3d’]

simvx.graphics.renderer.colour_grading.log

‘getLogger(…)’

class simvx.graphics.renderer.colour_grading.ColourGradingPass(engine: Any)

Compute-based colour grading: LUT lookup + brightness/contrast/saturation/temperature.

Operates in-place on the HDR colour image. Apply after fog, before tone mapping.

Initialization

setup(width: int, height: int, colour_view: Any, *, pool: Any) None

Initialize colour grading pipeline and upload default neutral LUT.

pool is the command pool the neutral LUT’s staging copy is recorded into; see :func:upload_lut_3d for which pool a caller owes.

set_lut(lut_data: numpy.ndarray, *, pool: Any) None

Upload a new 3D LUT texture. Shape should be (size, size, size, 4) uint8.

pool is the command pool the staging copy is recorded into; see

Func:

upload_lut_3d for which pool a caller owes.

render(cmd: Any) None

Dispatch colour grading compute shader. Call after fog, before tonemap.

Args: cmd: Active command buffer (outside any render pass).

resize(width: int, height: int, colour_view: Any) None

Update descriptors for new dimensions.

cleanup() None

Release all GPU resources.

simvx.graphics.renderer.colour_grading.create_lut_sampler(device: Any) Any

Create a trilinear, clamp-to-edge sampler for a 3D LUT.

Matches the web runtime’s LUT sampler (linear mag/min, clamp on all three axes) so desktop and web sample identical texels for the same LUT data.

simvx.graphics.renderer.colour_grading.upload_lut_3d(engine: Any, lut_data: numpy.ndarray, *, pool: Any) tuple[Any, Any, Any]

Upload an (size, size, size, 4) uint8 LUT as a 3D sampled image.

Returns (image, memory, view). The format is VK_FORMAT_R8G8B8A8_UNORM with a VK_IMAGE_VIEW_TYPE_3D view, the byte-for-byte match for the web runtime’s rgba8unorm 3D LUT texture. The image is left in SHADER_READ_ONLY_OPTIMAL, ready for either a fragment or compute sampler.

pool is supplied by the caller rather than read off engine because which pool is correct depends on when the call happens, and only the caller knows. A LUT registered while the game is running reaches this from the main thread while a pipelined render thread may be recording, so it must be the engine’s upload pool, taken as with engine.upload_ctx as pool. A LUT seeded during renderer setup, before any render thread exists, uses the same pool as the render targets built beside it. Reading engine.ctx.command_pool here would silently pick the frame pool for both, and allocating from a pool another thread is recording into is undefined behaviour.