2
\$\begingroup\$

I'm creating a physically based renderer but I am a bit confused on how to put together standard lighting with IBL, since like I'm doing now I think it's wrong.

Right now, for each light, I evaluate it's contribution to the scene lighting combined with IBL lighting (I use both the light contribution and diffuse and specular coming from the IBL) but like this I sum the IBL contribution for each light, and I don't think it's right.

To put together standard lighting with IBL, do I need to process all the lights alone and then, in another step, bake into the scene the IBL? I think this would be more correct.

\$\endgroup\$
2
\$\begingroup\$

The cubemaps used in Image Based Lighting should only contribute to the scene once because they don't represent light coming from a single light source like your point lights for example, but from every direction from the environment. This means that they should be added to the light buffer only once, which you could do in either of these passes:

  • In the object shader: If you are using forward rendering, it should be added to the object in the directional light pass (or the ambient light pass if you don't have a dirlight in the scene). In case of deferred rendering, you only do the object shader once for each object anyway, so this is trivial. In this case you also need to write the light texture which could be a no-go if you are using a different size from your gbuffer.
  • Lighting pass: In case of deferred rendering, you could do this in one of the lighting passes. It would be best if you didn't have to create a new pass for this, like if you know for sure that you always have one directional light, you can just add the IBL contribution right there. If this is not the case, you should add the IBLs in a separate full-screen pass. In case of tiled deferred rendering it would be trivial to add the IBLs when calculating the rest of the lights I imagine.

If you have more IBL light probes, you most likely want to combine them somehow. To blend them among themselves, you should use some sort of blend mode which is not additive, like alpha blending. The combined light probe should then be additively blended to the light buffer.

\$\endgroup\$
  • \$\begingroup\$ Thank you for the answer, that's exactly what I was thinking I was doing wrong. I mean, right now I handle only one directional light and IBL, but I started to think that with more lights I would end up doing it the wrong way. Thank you for confirming my concerns! Also, I use the deferred rendering approach so I'll see if it's better to bake IBL evaluation inside the directional light pass or in another one (maybe the user would add more directional lights and this would break things up). \$\endgroup\$ – zeb Jul 2 '16 at 9:13

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.