Hello guys!
I’m a programmer for a long time (python, C++), and I’ve started to study Graphics Computers in my University, and I decided to try something in BGE too (GLSL).
And I wanna run a Vertex Shader, WITHOUT reset the default blender’s Fragment Shader… In other words: I wanna run a simple code in the Vertex Shader and keep the original blender’s material… How can I do this?
My code:
from bge import logic as gc = g.getCurrentController()
o = c.owner
I wanna run this…
VertexShader = “”"
uniform float time;
void main() {
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex + sin(time + gl_Vertex.z);
}
“”"
Using the blender’s default FShader…
FragmentShader = “”"
void main() {
// I don’t wanna play with this!!!
}
“”"
mesh = o.meshes[0]
for mat in mesh.materials:
…shader = mat.getShader()
…if shader != None:
…if not shader.isValid():
…shader.setSource(VertexShader, FragmentShader, 1)
…shader.setUniform1f(‘time’, o[“timer”]*2)
PS: How can I paste code in this forum like the other guys? oO Ignore the dots (.) for identation. LOL
I’m kinda newbie writing and understanding Shaders yet… (My University uses OpenGL 2 to teach… :/)
Tks!