0
\$\begingroup\$

I am following this great tutorial but I have many questions.

Let's see if I understand the basic idea.

1. I must create the same number of FBOs that lights (maximum 8).
2. I must create the same number of depth textures (shadow maps) that FBOs.
3. For every FBO I must perform offscreen render (render to texture, drawing the scene from the point of view of each of the lights, maximum 8 times).

Is this correct or can I use just a texture with multiple FBOs, or fbo with various textures or how?

Assuming you use the idea above, how should the final render of the scene?

glUseProgram(programa);
  glUniformli(shadowM0,4);
  glActivateTexture(GL_TEXTURE4);
  glBindTexture(GL_TEXTURE_2D,depthT0);
  //Draw Escene?

  glUniformli(shadowM1,5);
  glActivateTexture(GL_TEXTURE5);
  glBindTexture(GL_TEXTURE_2D,depthT1);
  //Draw Escene?

  glUniformli(shadowM2,6);
  glActivateTexture(GL_TEXTURE6);
  glBindTexture(GL_TEXTURE_2D,depthT2);
  //Draw Escene?

  ...
glUseProgram(0);

Is this okay? I think not, because it uses a lot of resources and the scene would have to be drawn up to 7 times. (One per light source and shadow mapping).

Well but then how should the render scene with multiple light sources and shadows?

\$\endgroup\$
  • \$\begingroup\$ It would be clearer to limit questions to one at a time. \$\endgroup\$ – Anko Mar 23 '14 at 13:00
0
\$\begingroup\$

In a forward a rendering approach (aka the built-in simple methods like you describe), it is correct to say that the scene must be rendered once per light.

To achieve better performance with multiple lights, you need to use specialized rendering approaches via shaders that can accumulate multiple lights in one pass. The most popular of these techniques is Deferred Rendering, but there are some other less popular approaches as well.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.