pygfx.renderers.wgpu.BaseShader
- class pygfx.renderers.wgpu.BaseShader(wobject, **kwargs)
Bases:
ShaderInterface
Base shader object to compose and template shaders using jinja2.
Templating variables can be provided as kwargs, set (and get) as attributes, or passed as kwargs to
generate_wgsl()
.- get_code()
Implement this to compose the total (but still templated) shader. This method is called by
generate_wgsl()
.
- generate_wgsl(**kwargs)
Generate the final WGSL. Calls get_code() and then resolves the templating variables, varyings, and depth output.
- define_bindings(bindgroup, bindings_dict)
Define a collection of bindings organized in a dict.
- define_binding(bindgroup, index, binding)
Define a uniform, buffer, sampler, or texture.
The binding must be a Binding object. The code that defines the binding will be inserted in
pygfx.std.wgsl
.
- define_colormap(texture, texcoords, interpolation='linear')
Define the given texture as the colormap to be used to lookup the final color from the (per-vertex or per-face) texcoords. In the WGSL the colormap can be sampled using
sample_colormap()
. Returns a list of bindings.
- define_img_colormap(texture, interpolation='linear')
Define the given texture view as the colormap to be used to lookup the final color from the image data. In the WGSL the colormap can be sampled using
sample_colormap()
. Returns a list of bindings.