Hello!
I just tried to get simplest GLSL (with 1 texture) shader working with panda3d. And I find lots of problems with correct input names for shader.
Finally I got it working with code above, hope someone will find it usefull.
Does anybody have other working sample? Is this problem the same as in [url]GLSL shader problem]?
Vertex shader:
attribute vec2 p3d_MultiTexCoord0;
attribute vec4 p3d_Vertex;
varying vec2 texcoord0;
void main() {
gl_Position = gl_ModelViewProjectionMatrix * p3d_Vertex;
texcoord0 = p3d_MultiTexCoord0;
}
And fragment shader
varying vec2 texcoord0;
uniform sampler2D p3d_Texture0;
void main() {
gl_FragColor = texture2D(p3d_Texture0, texcoord0);
}
As you see, I have used p3d_Vertex instead of gl_Vertex in vertex shader - with gl_Vertex object disappears. Also I must to use p3d_Texture0 and p3d_MultiTexCoord0 to get access to texture and uv data. All attempts to get textures working with gl_MultiTexCoord0 are failed (object disappear again or drawn all black or shader ignored silently). Trying to pass texcoords from vertex to fragment shader with gl_TexCoord[0] failed silently also.
All working names are obtained after reading glShaderContext_src.cxx where shader inputs binding occurs. It has intresting line:
if (param_name.substr(0, 3) == "gl_") {
// We shouldn't bind anything to these.
} else if (param_name.substr(0, 4) == "p3d_") {
noprefix = param_name.substr(4);
... lots of binding code here, including normals, colors etc.
, which will bind only p3d_ prefixed attribs. I am not into OpenGL, but looks strange?
Thanks
UPDATE. I am using 1.8.0