GPU Shader Utilities (gpu.shader)¶
This module provides access to GPUShader internal functions.
Built-in shaders
All built-in shaders have the mat4 ModelViewProjectionMatrix uniform.
The value of it can only be modified using the gpu.matrix module.
- 2D_UNIFORM_COLOR
- Attributes
vec3 pos
- Uniforms
vec4 color
- 2D_FLAT_COLOR
- Attributes
vec3 pos, vec4 color
- Uniforms
none
- 2D_SMOOTH_COLOR
- Attributes
vec3 pos, vec4 color
- Uniforms
none
- 2D_IMAGE
- Attributes
vec3 pos, vec2 texCoord
- Uniforms
sampler2D image
- 3D_UNIFORM_COLOR
- Attributes
vec3 pos
- Uniforms
vec4 color
- 3D_FLAT_COLOR
- Attributes
vec3 pos, vec4 color
- Uniforms
none
- 3D_SMOOTH_COLOR
- Attributes
vec3 pos, vec4 color
- Uniforms
none
- gpu.shader.code_from_builtin(pygpu_shader_name)¶
Exposes the internal shader code for query.
- Parameters
pygpu_shader_name (str) –
One of these builtin shader names:
2D_UNIFORM_COLOR2D_FLAT_COLOR2D_SMOOTH_COLOR2D_IMAGE3D_UNIFORM_COLOR3D_FLAT_COLOR3D_SMOOTH_COLOR
- Returns
Vertex, fragment and geometry shader codes.
- Return type
dict
- gpu.shader.from_builtin(pygpu_shader_name)¶
Shaders that are embedded in the blender internal code. They all read the uniform
mat4 ModelViewProjectionMatrix, which can be edited by thegpu.matrixmodule. For more details, you can check the shader code with thegpu.shader.code_from_builtin()function.- Parameters
pygpu_shader_name (str) –
One of these builtin shader names:
2D_UNIFORM_COLOR2D_FLAT_COLOR2D_SMOOTH_COLOR2D_IMAGE3D_UNIFORM_COLOR3D_FLAT_COLOR3D_SMOOTH_COLOR
- Returns
Shader object corresponding to the given name.
- Return type
bpy.types.GPUShader
- gpu.shader.unbind()¶
Unbind the bound shader object.