shader_program

GLSL Shader program compilation and uniform management.

This module manages the ModernGL shader programs used for rendering the world, UI, and post-processing effects. It loads vertex and fragment shaders from disk, compiles them, and provides a central interface for updating dynamic uniforms (like camera matrices, fog density, and time of day) every frame.

class shader_program.ShaderProgram(app)[source]

Bases: object

Compiles, links, and manages all GLSL shader programs used by the engine.

Handles sending static and dynamic uniform data (view matrices, lighting, fog) to the GPU to ensure visuals react appropriately to player movement and time.

Parameters:

app (Any) – The main application context containing the ModernGL instance.

set_uniforms_on_init()[source]

Initializes static shader uniforms (like texture assignments, texture mapping arrays, and basic projection matrices) that only need to be uploaded once.

Return type:

None

update()[source]

Updates dynamic uniforms every frame. Sends the camera’s view matrix, calculates dynamic sun direction/fog density based on the day-night cycle, and syncs UI animations (like mining progress).

Return type:

None

get_program(shader_name)[source]

Helper function to load and compile a matching pair of .vert and .frag shader files from disk.

Parameters:

shader_name (str)

Return type:

Any