For example, let's assume I'm rendering cascaded shadow mapping, but for whatever reason, instead of one of the typical approach, I do the following:

  • Render the lowest resolution shadowmap

  • Copy part of the shadowmap to the next shadowmap, covering a smaller area(and thus more dense)

  • Compute a stencil mask based on different points' distance from camera, e.g. more detail on edges, and on points closer to the camera, reusing the old shadowmap elsewhere.

  • Render the next, higher-density shadowmap with the aforementioned stencil.

What performance can I realistically expect from that? If only 50% of the pixels(or should I say fragments here?) pass the stencil test, do I save 50% of the rendering time, less, none?

If this is a poor example, my fallback question scenario is a static scene, where the previous frame's result is reprojected, with an error accumulator in alpha, and a stencil mask is computed based on misses or too high error rates(e.g. position of the previous frame's reprojected pixel is too far from the new target pixel).

  • 1
    $\begingroup$ about saving processing power: computergraphics.stackexchange.com/q/259/137 $\endgroup$ – ratchet freak Dec 3 '15 at 10:22
  • $\begingroup$ @ratchetfreak Interesting post. Stenciling isn't conditionals, though. $\endgroup$ – Llamageddon Dec 3 '15 at 11:57
  • 1
    $\begingroup$ But the GPU still groups (at least) 2x2 pixels together even if 3 out of 4 will fail the stencil test. $\endgroup$ – ratchet freak Dec 3 '15 at 12:02
  • $\begingroup$ Are you certain about that? I'd imagine that that's what happens for conditionals, while with stenciles, the GPU is a bit smarter about it. $\endgroup$ – Llamageddon Dec 3 '15 at 12:36
  • 2
    $\begingroup$ @Llamageddon Pixel shaders are always packed together in 2x2 quads, because a pixel shader that doesn't sample at least one texture is a rare thing indeed. But if you are doing depth-only rendering, that matters less. Also, for what it's worth, shadow rendering is traditionally bound by vertices, so in traditional high-vertex-count situations this probably won't help. Also don't forget that you'd be writing to every pixel's stencil just to skip writing to that same pixel's depth (unless your pixel shader is complex). $\endgroup$ – John Calsbeek Dec 3 '15 at 15:37

Your Answer

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

Browse other questions tagged or ask your own question.