simvx.core.graphics.shader¶
Shader — pure source code (no GPU dependencies).
Backends (SDL3, Vulkan) handle compilation to GPU code.
Module Contents¶
Classes¶
Describes a shader resource binding (uniforms, samplers, etc.). |
|
Shader source code. Backend-agnostic. |
API¶
- class simvx.core.graphics.shader.ShaderResource¶
Describes a shader resource binding (uniforms, samplers, etc.).
- name: str¶
None
- binding: int¶
None
- type: str¶
None
- size: int¶
0
- class simvx.core.graphics.shader.Shader(source: str, stage: str, entrypoint: str = 'main', defines: dict[str, str | int | bool] | None = None)¶
Shader source code. Backend-agnostic.
Stores GLSL source and metadata. Backends compile to SPIR-V or native GPU code.
Example: vert_src = “layout(location=0) in vec3 pos; void main() { … }” frag_src = “uniform vec4 color; void main() { … }”
shader = Shader(vert_src, "vertex") # Then backend compiles it when rendering
Initialization
Initialize shader with GLSL source.
Args: source: GLSL source code (not a file path) stage: “vertex” or “fragment” entrypoint: Shader entry point function name defines: Preprocessor defines {“DEFINE”: “value”}
- property is_vertex: bool¶
- property is_fragment: bool¶
- to_dict() dict¶
Serialize to dict for storage.
- classmethod from_dict(d: dict) simvx.core.graphics.shader.Shader¶
Deserialize from dict.
- classmethod from_file(path: str | pathlib.Path, stage: str) simvx.core.graphics.shader.Shader¶
Load GLSL source from file.