|
setUniform1fsetUniform1f(name, fx)Names a float value and passes it from the main program to the vertex or fragment program.name: Type:
string
fx:Type: float
Sample Code# define the main part of the programdef main():# get the current scenescene = GameLogic.getCurrentScene()# get a list of the objects in the sceneobjList = scene.objects# Get the object you want to useobj = objList['OBCube']# Only one mesh on this Cubemesh = obj.meshes[0]# only one material on this meshmat = mesh.materials[0]# Using Blender GLSL Materials or Blender Multitexture Materials?if hasattr( mat, 'getMaterialIndex') == True:#Get shader envelopeshader = mat.getShader()# shader envelope created?if shader != None:# set the shadershader.setSource(VertexProgram, FragmentProgram, True)# name a float variable and pass it to shadershader.setUniform1f("redChannel", 0.0)####### end of main program def# Import OpenGL glsl code as a stringVertexProgram = """ |