Encapsulates a GPU shader and its associated render state. Access via the 'shaders' submodule.
Shader(fragment_base_path: str | PathLike[str], uniform_buffer_count: int = 0, sampler_count: int = 1, storage_buffer_sizes: Sequence[int] = []) → ShaderShader(fragment_base_path: str | PathLike[str], uniform_buffer_count: int = 0, sampler_count: int = 1, storage_buffer_sizes: Sequence[int] = []) → Shader
Encapsulates a GPU shader and its associated render state.
bind() → Nonebind() → NoneBinds this shader state to the current render pass, making it active for subsequent draw calls.
Raises
RuntimeError : If the shader state cannot be bound.unbind() → Noneunbind() → NoneUnbinds the current shader state, reverting to the default render state.
set_uniform(binding: int, data: Buffer) → Noneset_uniform(binding: int, data: Buffer) → NoneSet uniform data for the fragment shader at the specified binding point.
Args
binding : Uniform buffer binding index.data : Buffer-compatible object containing the uniform bytes.Raises
TypeError : If the object does not provide compatible uniform data.RuntimeError : If the uniform data cannot be set.set_storage_buffer_data(binding: int, data: Buffer) → Noneset_storage_buffer_data(binding: int, data: Buffer) → NoneSets the data for a data storage buffer for the fragment shader at the specified binding.
Currently untested with GLSL.
Args
binding : Shader storage buffer binding.data : Buffer-compatible object containing the bytes to be given to the shader buffer.Raises
TypeError : If the object does not provide compatible storage buffer data.RuntimeError : If the storage buffer data cannot be set.set_texture_sampler(binding: int, texture: Texture, sampler: Sampler) → Noneset_texture_sampler(binding: int, texture: Texture, sampler: Sampler) → NoneSet the texture and sampler used for a fragment shader texture binding.
Args
binding : Sampler binding index.texture : Texture to bind. Must have the ShaderSampled usage flag.sampler : Sampler to use for the texture.Raises
RuntimeError : If the texture is not usable as a shader resource.ValueError : If the binding index is out of range.