c++ - Is their an alternative to Stencil Pass -


at moment i've implemented deferred rendering using opengl simple now. i'm having major performance issues due using stencil pass @ moment (at least in current way use it). i've been using ogldev.atspace tutorial (only got 2 links per post atm sorry!) reference alongside few dozen tidbits of information other articles.

it works like:

  1. gbuffer pass (render geometry , fill normals, diffuse, ambient etc.)
  2. for each light 2a) stencil pass 2b) light pass
  3. swap screen

the thing using stencil pass in fashion incurring huge costs, need swap between light pass mode , stencil mode every light in scene. that's lot of gl state swaps.

an alternate method without stencil pass this:

  1. gbuffer fill
  2. set light pass
  3. compute lights
  4. swap screen

doing skips need swap of opengl states (and buffer clears etc.) each light in scene.

i've tested/profiled using codexl , basic fps's std::cout'ng. state change functions using stencil pass method take 44% of gl calls (in comparison 6% draw , 6% textures), buffer swaps/clears etc cost fair % more. when go second method gl state changes drop 2.98% , others drop fair margin well. fps changes drastically example have 65~ lights in scene, dynamically moving. stencil pass gives me around 20-30 fps if i'm lucky in release mode (with rendering taking majority of total time). second method gives me 71~ (with rendering taking smaller part of total time).

now why not use second method? well, causes serious lighting issues don't first. have no idea how rid of them. here's example:

2nd non-stencil version (it bleeds , overlaps onto things outside range): http://imgur.com/bnn9sp2

1st stencil version (how should look): http://imgur.com/kvgrwh2

so main question is, there way avoid using stencil pass (and use similar first without graphical glitch) without changing algorithm tiled deferred rendering?

and if not, alternate deferred rendering method, isn't of jump style of deferred renderer i'm using?

getting rid of stencil pass isn't new problem me, looking alternative 6 months or when first implemented , thought might bit of overhead had in mind. couldn't find @ time , still can't.

another tecnique wich used in doom3 lighting following:

http://fabiensanglard.net/doom3/renderer.php

for each light     render geometry affected 1 light     accumulate light result (clamping 255) 

as optimization can add scissor test render visible part of geometry each light.

the advantage of on stencil lights can complex light calculations if want, or keep simple lights. , whole work gpu, don't have redundant state changes (you setup 1 shader only, 1 vbo , re-draw each time changin uniform parameters of light , scissor test area). don't need g-buffer.


Comments