Part of the Khronos Group

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 6 of 6

Thread: OpenGL, offscreen hard shadows calculation with stencil

Threaded View

  1. #1
    Intern Contributor
    Join Date
    Dec 2011

    OpenGL, offscreen hard shadows calculation with stencil

    I am trying to figure it out if and how would be possible to calculate hard shadows from multiple light-sources off-screen.

    preamble: scene is very complex, up to several million of triangles, up to hundred different light-sources, lights, material and depth enabled and maximum precision (at least 10kx10k pixel ground resolution). Shadows are nothing else than planar projected shadow, that is I am rendering the objects themselves by pre-multiplying by a shadow matrix (given a light-source position and a plane). Multiple objects, multiple light-sources but just a single plane.

    For this reason real-time is impossible. Also impossible is to think about an incremental stencil value, since I have only one byte (255 useful values) and I may have more than 255 light-sources.

    Therefore my idea was to render off-screen (to texture or render-buffer image).

    For each light source, I calculate my shadow matrix and apply it. Then I render my first object with a specific stencil number (i.e. 1). Then I render my second object. I need to render it only where the stencil number is 1 and I need to zero all the other pixels, because I am interested in the hard shadow only. Then the third object and so on. At the end I repeat all the process for the second light source and so on.

    Is it possible? Better texture or render-buffer image? Once hard shadow is calculated I need to retrieve it back on the cpu to analyze it and render it also on the ground in my scene.

    Ideally I would need only the stencil buffer attached to my FBO but they say here

    Stencil NEVER EVER MAKE A STENCIL buffer. All GPUs and all drivers do not support an independent stencil buffer. If you need a stencil buffer, then you need to make a Depth=24, Stencil=8 buffer, also called D24S8. Please search for the example about GL_EXT_packed_depth_stencil on this age.

    Is this still valid today?

    Looking around, I found here a way of zeroing all the other pixels by render a full screen polygon between each object, but I wonder if there is anything more efficient..?
    Last edited by elect; 03-12-2013 at 12:19 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts