simvx.graphics.renderer.colour_grading¶
Colour grading pass: LUT-based colour correction via compute shader.
Module Contents¶
Classes¶
Compute-based colour grading: LUT lookup + brightness/contrast/saturation/temperature. |
Functions¶
Create a trilinear, clamp-to-edge sampler for a 3D LUT. |
|
Upload an |
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.
poolis the command pool the neutral LUT’s staging copy is recorded into; see :func:upload_lut_3dfor 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.
poolis the command pool the staging copy is recorded into; see- Func:
upload_lut_3dfor 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 isVK_FORMAT_R8G8B8A8_UNORMwith aVK_IMAGE_VIEW_TYPE_3Dview, the byte-for-byte match for the web runtime’srgba8unorm3D LUT texture. The image is left inSHADER_READ_ONLY_OPTIMAL, ready for either a fragment or compute sampler.poolis supplied by the caller rather than read offenginebecause 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 aswith 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. Readingengine.ctx.command_poolhere would silently pick the frame pool for both, and allocating from a pool another thread is recording into is undefined behaviour.