Hi,
I’m having problems with multi-pass rendering… I guess I’m forgetting some command or I’m just putting the opengl calls in wrong order, but I couldn’t get my model in the screen.
Ok, I’m trying multi-pass render for lights, so I’m making a first pass to fill the depth buffer, after I paint the ambient, and finally I blend the lights… but it doesn’t work.
Here you have a pseudo-code of my program.
First pass, framebuffer with depth buffer:
glBindFramebuffer(GL_FRAMEBUFFER, multirender_fbo_);
glEnable(GL_DEPTH_TEST);
glDepthMask(GL_TRUE);
glDepthFunc(GL_LEQUAL);
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
glClearColor(0.f, 0.f, 0.25f, 0.f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glUseProgram(ambient_program);
DrawScene();
Second pass, ambient color:
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
glClearColor(0.f, 0.f, 0.25f, 0.f);
glClear(GL_COLOR_BUFFER_BIT);
DrawScene();
Third pass, lights:
glDepthMask(GL_FALSE);
glDepthFunc(GL_EQUAL);
glEnable(GL_BLEND);
glBlendEquation(GL_FUNC_ADD);
glBlendFunc(GL_ONE, GL_ONE);
glUseProgram(light_program_);
DrawScene();
This only paints the color of glClear()… anything more.
I try to make different things, as create a renderBuffer color inside the frameBuffer, paint the color in the first step, copy the framebuffer into the screen with glBlitFrameBuffer and try
to blend the lights… doesn’t work neither. Also, I tried to paint the ambient color using the configuration of the third pass, enabling blend and using GL_EQUAL etc… but doesn’t paint
anything neither… I tried different configurations, and only “works” (because doesn’t work properly) if I comment in the third pass all the functions related with the frameBuffer…
The problem is that configuration paint me everything transparent…
So if anyone can help me, I will appreciate! Thank you very much!