BL_Shader(EXP_PyObjectPlus)¶
base class — EXP_PyObjectPlus
-
class
BL_Shader
(EXP_PyObjectPlus)¶ BL_Shader is a class used to compile and use custom shaders scripts. It supports vertex, fragment and geometry shader scripts. The shader is compiled with a generated header for the three shaders scripts. This header set the
#version
directive, so the user must not define his own #version.-
enabled
¶ Set shader enabled to use.
Type: boolean
-
objectCallbacks
¶ The list of python callbacks executed when the shader is used to render an object. All the functions can expect as argument the object currently rendered.
def callback(object): print("render object %r" % object.name)
Type: list of functions and/or methods
-
bindCallbacks
¶ The list of python callbacks executed when the shader is begin used to render.
Type: list of functions and/or methods
-
setUniformfv
(name, fList)¶ Set a uniform with a list of float values
Parameters: - name (string) – the uniform name
- fList (list[float]) – a list (2, 3 or 4 elements) of float values
-
getFragmentProg
()¶ Returns the fragment program.
Returns: The fragment program. Return type: string
-
getVertexProg
()¶ Get the vertex program.
Returns: The vertex program. Return type: string
-
isValid
()¶ Check if the shader is valid.
Returns: True if the shader is valid Return type: boolean
-
setAttrib
(enum)¶ Set attribute location. (The parameter is ignored a.t.m. and the value of “tangent” is always used.)
Parameters: enum (integer) – attribute location value
-
setSampler
(name, index)¶ Set uniform texture sample index.
Parameters: - name (string) – Uniform name
- index (integer) – Texture sample index.
-
setSource
(vertexProgram, fragmentProgram, apply)¶ Set the vertex and fragment programs
Parameters: - vertexProgram (string) – Vertex program
- fragmentProgram (string) – Fragment program
- apply (boolean) – Enable the shader.
-
setSourceList
(sources, apply)¶ Set the vertex, fragment and geometry shader programs.
Parameters: - sources (dict) –
Dictionary of all programs. The keys
vertex
,fragment
andgeometry
represent shader programs of the same name.geometry
is an optional program. This dictionary can be similar to:sources = { "vertex" : vertexProgram, "fragment" : fragmentProgram, "geometry" : geometryProgram }
- apply (boolean) – Enable the shader.
- sources (dict) –
-
setUniform1f
(name, fx)¶ Set a uniform with 1 float value.
Parameters: - name (string) – the uniform name
- fx (float) – Uniform value
-
setUniform1i
(name, ix)¶ Set a uniform with an integer value.
Parameters: - name (string) – the uniform name
- ix (integer) – the uniform value
-
setUniform2f
(name, fx, fy)¶ Set a uniform with 2 float values
Parameters: - name (string) – the uniform name
- fx (float) – first float value
- fy (float) – second float value
-
setUniform2i
(name, ix, iy)¶ Set a uniform with 2 integer values
Parameters: - name (string) – the uniform name
- ix (integer) – first integer value
- iy (integer) – second integer value
-
setUniform3f
(name, fx, fy, fz)¶ Set a uniform with 3 float values.
Parameters: - name (string) – the uniform name
- fx (float) – first float value
- fy (float) – second float value
- fz (float) – third float value
-
setUniform3i
(name, ix, iy, iz)¶ Set a uniform with 3 integer values
Parameters: - name (string) – the uniform name
- ix (integer) – first integer value
- iy (integer) – second integer value
- iz (integer) – third integer value
-
setUniform4f
(name, fx, fy, fz, fw)¶ Set a uniform with 4 float values.
Parameters: - name (string) – the uniform name
- fx (float) – first float value
- fy (float) – second float value
- fz (float) – third float value
- fw (float) – fourth float value
-
setUniform4i
(name, ix, iy, iz, iw)¶ Set a uniform with 4 integer values
Parameters: - name (string) – the uniform name
- ix (integer) – first integer value
- iy (integer) – second integer value
- iz (integer) – third integer value
- iw (integer) – fourth integer value
-
setUniformDef
(name, type)¶ Define a new uniform
Parameters: - name (string) – the uniform name
- type (integer) – uniform type, one of these constants
-
setUniformMatrix3
(name, mat, transpose)¶ Set a uniform with a 3x3 matrix value
Parameters: - name (string) – the uniform name
- mat (3x3 matrix) – A 3x3 matrix [[f, f, f], [f, f, f], [f, f, f]]
- transpose (boolean) – set to True to transpose the matrix
-
setUniformMatrix4
(name, mat, transpose)¶ Set a uniform with a 4x4 matrix value
Parameters: - name (string) – the uniform name
- mat (4x4 matrix) – A 4x4 matrix [[f, f, f, f], [f, f, f, f], [f, f, f, f], [f, f, f, f]]
- transpose (boolean) – set to True to transpose the matrix
-
setUniformiv
(name, iList)¶ Set a uniform with a list of integer values
Parameters: - name (string) – the uniform name
- iList (list[integer]) – a list (2, 3 or 4 elements) of integer values
-
setUniformEyef
(name)¶ Set a uniform with a float value that reflects the eye being render in stereo mode: 0.0 for the left eye, 0.5 for the right eye. In non stereo mode, the value of the uniform is fixed to 0.0. The typical use of this uniform is in stereo mode to sample stereo textures containing the left and right eye images in a top-bottom order.
Parameters: name (string) – the uniform name
-
validate
()¶ Validate the shader object.
-