Jump to content
  • Advertisement
Sign in to follow this  
racarate

Simple IBL question

This topic is 1199 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've been doing a lot of reading on IBL this week, and am about ready to start implementing... but I seem to be missing one big piece.  How is the resulting indirect/ambient diffuse irradiance cubemap lookup value and the indirec/ambient specular irradiance cubemap lookup value combined with the values returned from your analytic lights?

 

Do they all just simple sum?  Or do they all attenuate each other in some wacky way?  It's weird, I've read like thirty articles about IBL and none of them answer this question.

 

Is this like the old way of "let the artist pick the weighting of ambient/diffuse/specular" in the fixed-function world?

 

For that matter, how to screen-space reflections get summed in as well?  So many contributions!

Share this post


Link to post
Share on other sites
Advertisement

Ahhh, interesting.  So I see that Fresnel is used to weight the final diffuse and final specular.

 

But say I have an analytic point light (with specular and diffuse) a specular cubemap and a diffuse cubemap.  Would that simply be:

 

finalDiffuse = analyticDiffuse + cubemapDiffuse

finalSpecular = analyticSpecular + cubemapSpecular

Share this post


Link to post
Share on other sites

I think so, yeah.  It's all about energy (flux), right?  So ultimately the energy in has to equal the energy out (disregarding dissipation).  If you have an analytic light source and a specular/diffuse cubemap, then you're doubling the potential output irradiance.  So you then need an exposure function which takes into account that larger total.

Share this post


Link to post
Share on other sites
Yeah you're dealing with radiometry (or photometry, which is radiometry weighted against the human vision system). Your radiometric "lighting" units are basically energy, or energy per angle, or energy per angle per area, etc...

Typically we completely ignore interference... So the correct way to combine two beams of energy is just to add those together.

IBL is just another light, so add it to all the other lights.

If beam A has 10 photons per second and beam B has 40 photons per second travelling through it, then if you overlap them, you'll have 50 photons per second travelling through that overlapped region.

Physically speaking:
Overlapping lights = just add them.
Translucency / opacity / absorbtion = multiply (modulate) with a number from 0 to 1.

Going off topic slightly to translucency -- A filter might absorb half the photons that travel through it. This would act as a 0.5 multiplier for all light that travels through the filter. Or a 0.5 alpha value used with "premultiplied alpha blending" (fixed function: op=add, srcFactor=one, dstFactor=invSrcAlpha).

The reason you want to use "premultiplied alpha blending" instead of "traditional alpha blending" (fixed function: op=add, srcFactor=srcAlpha, dstFactor=invSrcAlpha) is that the traditional method completely fades out the foreground layer when the alpha value approaches zero.
However, we only want this to happen to our diffuse lighting (which comes from within the surface).
Specular lighting is reflected off the surface and never actually enters the material, so it is completely unaffected by alpha/translucency!
E.g. Think of a nearly completely tanslucent pane of glass - there's no diffuse lighting, but the specular reflections are obvious.

The end of a translucent lighting shader (which shoupd be used with the fixed function blend state configured to "premultiplied alpha blending") should look something like:
float3 diffuse = blah;
float3 specular = blah;
return float4( specular + diffuse * alpha, alpha );// translucent
This will cause diffuse to be modulated / traditionally-alpha-blended with the background, but specular will be plain old additive.

For non-translucent lighting shaders, you would use fixed-function additive blending instead OR ouput zero alpha with premul blending:
return float4( specular + diffuse, 0 );//opaque

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!