Hi all,
i’m interested in GLSL shader scripting and read about the new support for GLSL in Panda. I made a quick test for passing values from the application to the shader and found erratic behaviour.
In my code below I pass a uniform float variable “test” with value 1.0 to the fragment shader that should lead to a yellow colored sphere object. Sometimes I see yellow, but other times the sphere is red, as if “test” is 0.0.
You might have to start the script several times to see the behaviour. What am I doing wrong?
I’m using a self compiled Panda from cvs from September 21st on Linux 64Bit.
Thanks,
Sanne
glsltest.py:
import direct.directbase.DirectStart
from panda3d.core import *
vertshader = "simple.vert"
fragshader = "simple.frag"
testobject = loader.loadModel("smiley")
testobject.reparentTo(render)
shader = Shader.load(Shader.SLGLSL, vertshader, fragshader)
testobject.setShader(shader)
testobject.setShaderInput("test", 1.0)
camera.setPos(0,-10,0)
base.disableMouse()
base.accept("escape", exit)
base.run()
simple.vert:
void main() {
gl_Position = ftransform();
}
simple.frag:
uniform float test;
void main() {
gl_FragColor = vec4(1.0, test, 0.0, 1.0);
}