Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import bge
- cont = bge.logic.getCurrentController()
- bge.logic.setLogicTicRate(60.0)
- act = cont.actuators['objTimer']
- if act.value == '':
- time = 0.0
- if act.value != '':
- time = float(act.value)
- if time < 60.0:
- time += 0.01
- if time == 60.0:
- time = 0
- act.value = str(time)
- VertexShader = """
- varying vec4 texCoords;
- void main() // all vertex shaders define a main() function
- {
- texCoords = gl_MultiTexCoord0; // in this case equal to gl_Vertex
- 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 = """
- varying vec4 texCoords;
- uniform float time;
- void main()
- {
- //gl_FragColor = texture2D(textureUnit, texCoords * 2.);
- gl_FragColor = vec4(1.0, 0.0 + time, 0.0, 1.0);
- // red, green, blue, alpha
- }
- """
- mesh = cont.owner.meshes[0]
- for mat in mesh.materials:
- shader = mat.getShader()
- if shader != None:
- if not shader.isValid():
- shader.setSource(VertexShader, FragmentShader, 1)
- #shader.setSampler('textureUnit', 0)
- shader.setUniform1f('time',time)
- print(time)
Advertisement
Add Comment
Please, Sign In to add comment