-
GLSL Volume Rendering, with Ray Casting
I am building an application for volume rendering, with the help of GLSL raycasting.
I am getting the start and end points of a ray with the help of a GLSL shader and storing the vertices in their respective FBO's, and then passing that to my ray cast shader.
For some reason my ray cast result texture is not rendering. I checked if the FBO's were being setup correctly by rendering the textures that contain the start and end points of the ray. That is rendering. But the result is not. I was wondering if it could be because I have no lights setup.
I have rewritten my ray cast shader like 10 times now. I even checked it by simply using the code provided on this, http://prideout.net/blog/?p=60
If anybody has any idea, what is wrong, please let me know, thank you.
-
Super Moderator
OpenGL Lord
If your ray cast shader outputs a fixed bright color (not black, not white), do you see it ?
If yes, then add back parts of your shader until you narrow the problem.
If not, then check how you render the result texture, post code, etc.
-
Okay I have narrowed down the problem to something to do with my frame buffer object, glActiveTexture(). When I use ActiveTexture(), texture does not get rendered. Here's the code I use to render. I have been racking my head, just cannot figure it out.
<code>
// Ray Start (Render to FBO)
glBindFramebuffer(GL_FRAMEBUFFER, rayStartFbo);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glEnable(GL_CULL_FACE);
glCullFace(GL_FRONT);
glUseProgram(rayVertexProgram);
drawQuads(1.0, 1.0, 1.0);
glUseProgram(0);
glDisable(GL_CULL_FACE);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_2D, rayStartTex);
// Ray Stop (Render to FBO)
glBindFramebuffer(GL_FRAMEBUFFER, rayStopFbo);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
glUseProgram(rayVertexProgram);
drawQuads(1.0, 1.0, 1.0);
glUseProgram(0);
glDisable(GL_CULL_FACE);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glActiveTexture(GL_TEXTURE3);
glBindTexture(GL_TEXTURE_2D, rayStopTex);
// Ray Cast (Render to FBO)
glBindFramebuffer(GL_FRAMEBUFFER, resultFbo);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glUseProgram(rayCasterProgram);
utilities.setUniform("Volume", 0);
utilities.setUniform("Gradient", 1);
utilities.setUniform("RayStart", 2);
utilities.setUniform("RayStop", 3);
utilities.setUniform("IsoValue", isoValue);
utilities.setUniform("Absorption", absorption);
drawQuads(1.0, 1.0, 1.0);
glUseProgram(0);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Render to Quad
glBindTexture(GL_TEXTURE_2D, resultTex);
glEnable(GL_TEXTURE_2D);
reshapeOrtho(width, height);
//glColor4f(1.0, 1.0, 1.0, 1.0);
drawFullscreenQuad();
glDisable(GL_TEXTURE_2D);</code>
-
This is the method I call for setting my uniforms.
void Utilities::setUniform(const char* name, int value)
{
GLuint program;
glGetIntegerv(GL_CURRENT_PROGRAM, (GLint*) &program);
GLint location = glGetUniformLocation(program, name);
glUniform1i(location, value);
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules