I’m currently writing a raycasting program with GLSL to render volume graphics. To do this I send two textures to the shader, one containing the volume data (3D sampler) and one containing the “end position” of the ray (2D sampler).
Since I’m quite a beginner at GLSL I’ve run into some basic problems already at the compilation stage.
The shader program seems to have a problem with me having two samplers, this is from the info log:
“Validation failed - samplers of different types are bound to the same texture image unit.”
gl_TexCoord = gl_TextureMatrix * gl_MultiTexCoord0;
gl_FrontColor = gl_Color;
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
uniform sampler3D VolumeData;
uniform sampler2D BackfaceData;
vec3 RayStart = gl_Color.xyz;
vec3 RayEnd = texture2D(BackfaceData, gl_TexCoord.xy).xyz;
gl_FragColor = VoxColor;
*VertexText = textFileRead(“vert.vsh”),
*FragmentText = textFileRead(“frag.vsh”);
VertexShader = glCreateShader(GL_VERTEX_SHADER);
glShaderSource(VertexShader, 1, &VertexText, 0);
FragmentShader = glCreateShader(GL_FRAGMENT_SHADER);
glShaderSource(FragmentShader, 1, &FragmentText, 0);
ShaderProgram = glCreateProgram();
I found a reference to this error in OpenGLwiki but the instructions on how to fix it is somewhat strange since it says the error occurs at linking and you fix it by assigning the samplers after linking. I’ve tried assigning the samplers before linking (glLinkProgram) but the problem remains.
The shaders’ log return no error.
When compiling the shaders with Typhoon Labs no errors are returned, this makes me believe the problem is in my program. Before CreateShaders is calles glew and glut are initialized.
Thank you for your help!