title: Implementing environment mapping and IBL for deferred shading
body: <p>Our deferred renderer reached to a point where we need to apply environment maps &amp; IBL to push the quality to a higher level ( As you can see the cubemaps are clearly missing ):
  <img src="https://i.stack.imgur.com/9Q0tU.jpg" alt="Missing cubemaps" /></p>
  <p>After a couple of hours of research on this topic i still found no solution which makes me really happy.</p>
  <h2>This is what i found so far</h2>
  <ol>
  <li>Additional forward pass whichs result is added to the LA-Buffer. This looks like a bad idea somehow, we use deferred shading to avoid multiple passes and then render everything again for cubemapping &amp; IBL. But at least we could use the existing GBuffer-Data ( inc. depth ) to render the objects and the selection of the used cubemap can be easily done on the CPU.</li>
  <li>Render a fullscreen plane and perform some crazy selection of the right cubemap in the shader ( what is done on the CPU in the shader ). This seems even more bad than rendering everything again, the glsl shader is going to be huge. Even if i implement tiled-deferred-rendering ( not done yet ), it still seems to be a bad idea.</li>
  <li>Also storing the cubemap information directly into the GBuffer of the first pass is not applicable in my renderer. I've used all components of my 3 buffers ( 3 to stay compatible with ES 3.0 ), and already used compression on the color values ( YCoCg ) and the normals ( Spheremap Transform ).</li>
  <li>Last but not least the very simple and not really a good solution: Use a single cubemap and apply it on the hole scene. This is not really a option, because this is going to have a huge impact on the quality.</li>
  </ol>
  <p>I want to know if another approach exists for environment cubemapping. If not what is the best approach of them. My personal favorite is the second one so far even if this requires rendering the whole scene again ( At least on devices which only support 4 rendertargets ).</p>