Fragment Shader: how to usoe the defaut?

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!

Sadly you can’t run a custom vertex shader with blender’s fragment shader in the bge.
You only can run custom shaders together.
And even if you use a custom fragment shader you have no access to all material features like shadowmaps (delay bug), Environment lighting…

This incompatibility is a big pain in my opinion because it makes the whole custom shaders thing a little bit useless for most cases. :frowning:

Nevertheless I learned some things with it. :smiley:

If you go in the advanced editor you can use "

 tags" (The # symbol in the editor panel).

Oh, this is bad: / Thanks for your reply!