So I have an object called ‘Cube’ with this python code
import bge
scene = bge.logic.getCurrentScene()
objList = scene.objects
obj = objList['Cube']
VertexShader = """
uniform mat4 myMatrix;
void main() // all vertex shaders define a main() function
{
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
// this line transforms the predefined attribute gl_Vertex
// of type vec4 with the predefined uniform
// gl_ModelViewProjectionMatrix of type mat4 and stores
// the result in the predefined output variable gl_Position
// of type vec4. (gl_ModelViewProjectionMatrix combines
// the viewing transformation, modeling transformation and
// projection transformation in one matrix.)
}
"""
FragmentShader = """
uniform mat4 myMatrix;
void main()
{
gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
// this fragment shader just sets the output color to opaque
// red (red = 1.0, green = 0.0, blue = 0.0, alpha = 1.0)
}
"""
mesh = obj.meshes[0]
mat = mesh.materials[0]
if hasattr( mat, 'getMaterialIndex') == True:
shader = mat.getShader()
if shader != None:
shader.setSource(VertexShader, FragmentShader, True)
identMatrix = ([1,0,0,0], [0,1,0,0], [0,0,1,0], [0,0,0,1])
shader.setUniformMatrix4("myMatrix", identMatrix, True)
But when I run this I got this error on shader.setUniforms’s line: Bl_shader, first string argument is not a valid uniform value
What am I doing wrong???