
setNumberOfPasses(num)
- Sets the number of times the shader is applied to the material.
num:
- number of passes
- Type: integer
Note:
- Shaders work with Viewport Shading GLSL and Viewport Shading Multitexture.
- Shaders don't work with Viewport Shading Singletexture.

Sample Code
############################# set the number of passes
############## main program
def main():
# import bge
import bge
# get the current controller
cont = bge.logic.getCurrentController()
# get object that owns this controller
obj = cont.owner
# Get a list of the mesh
meshList = obj.meshes
# Get the first mesh on the object
mesh = meshList[0]
# only one material on mesh
mat = mesh.materials[0]
# Using Blender GLSL Materials or Blender Multitexture Materials?
if hasattr( mat, 'getMaterialIndex') == True:
import bge
# get the current controller
cont = bge.logic.getCurrentController()
# get object that owns this controller
obj = cont.owner
# Get a list of the mesh
meshList = obj.meshes
# Get the first mesh on the object
mesh = meshList[0]
# only one material on mesh
mat = mesh.materials[0]
# Using Blender GLSL Materials or Blender Multitexture Materials?
if hasattr( mat, 'getMaterialIndex') == True:
# get shader envelope
shader = mat.getShader()
# did it get the shader envelope?
if shader != None:
shader = mat.getShader()
# did it get the shader envelope?
if shader != None:
# set the source and use it
shader.setSource(VertexProgram,FragmentProgram, True)
# set number of passes to 3
shader.setNumberOfPasses(3)
shader.setSource(VertexProgram,FragmentProgram, True)
# set number of passes to 3
shader.setNumberOfPasses(3)
####### end of main program
VertexProgram = """
void main()
{
// OpenGL glsl code
gl_Position = ftransform();
}
"""
FragmentProgram = """
void main()
{
// set color to green
gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);
}
"""
############ Run Program
main()