shader
FreeBodyEngine.graphics.shader
#
Shader(vertex_source, fragment_source, generator, injector=Injector(), geometry_source=None)
#
Backend-agnostic compiled shader: compiles FBUSL vertex/fragment(/geometry)
source through generator into backend GLSL. Building a runnable GPU
program from that GLSL, and binding uniforms/buffers to it, is left to a
concrete subclass (e.g. GLShader).
Compiles vertex_source/fragment_source (and geometry_source,
if given) through generator via FBUSL. The original sources are
kept alongside the compiled output so rebuild() and dev-mode hot
reload (see Material.reload_shader()) can recompile from the same
inputs, or from freshly re-fetched ones, without needing them passed
in again.
data = {}
instance-attribute
#
fbusl_fragment_source = compile(fragment_source, ShaderType.FRAGMENT, generator, injector)
instance-attribute
#
fbusl_geometry_source = None
instance-attribute
#
fbusl_vertex_source = compile(vertex_source, ShaderType.VERTEX, generator, injector)
instance-attribute
#
fragment_source = fragment_source
instance-attribute
#
generator = generator
instance-attribute
#
geometry_source = geometry_source
instance-attribute
#
vertex_source = vertex_source
instance-attribute
#
get_uniform(name)
#
Returns this shader's internal record for uniform name - its
shape is backend-specific (e.g. GLShader returns location/type
metadata, not the uniform's current value).
rebuild(injector=Injector(), vertex_source=None, fragment_source=None, geometry_source=...)
#
Recompiles this shader in place. vertex_source/fragment_source
default to this shader's existing ones; geometry_source defaults
to the existing one unchanged (via the ... sentinel, since None
is itself a valid "no geometry shader" value).
set_buffer(name, data)
#
Binds data to the buffer block declared as name in this
shader's source.
set_uniform(name, value)
#
Sets uniform name to value.
use()
#
Activates this shader as the current GPU program for subsequent draw calls.