BL_Shader(EXP_PyObjectPlus)
base class — EXP_PyObjectPlus
- class bge.types.BL_Shader
BL_Shader is a class used to compile and use custom shaders scripts. This header set the
#version
directive, so the user must not define his own #version. Since 0.3.0, this class is only used with custom 2D filters.- enabled
Set shader enabled to use.
- Type:
boolean
- objectCallbacks
Deprecated since version 0.3.0: 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
Deprecated since version 0.3.0: 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
- delSource()
Deprecated since version 0.3.0: Clear the shader. Use this method before the source is changed with
setSource
.- 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)
Deprecated since version 0.3.0: Set attribute location. (The parameter is ignored a.t.m. and the value of “tangent” is always used.)
- arg enum:
attribute location value
- type enum:
integer
- setSampler(name, index)
Set uniform texture sample index.
- Parameters:
name (string) – Uniform name
index (integer) – Texture sample index.
- setSource(vertexProgram, fragmentProgram, apply)
Deprecated since version 0.3.0: Set the vertex and fragment programs
- arg vertexProgram:
Vertex program
- type vertexProgram:
string
- arg fragmentProgram:
Fragment program
- type fragmentProgram:
string
- arg apply:
Enable the shader.
- type apply:
boolean
- setSourceList(sources, apply)
Deprecated since version 0.3.0: Set the vertex, fragment and geometry shader programs.
- arg sources:
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 }
- type sources:
dict
- arg apply:
Enable the shader.
- type apply:
boolean
- 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)
Deprecated since version 0.3.0: 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.
- arg name:
the uniform name
- type name:
string
- validate()
Validate the shader object.