Jump to content
  • Advertisement
Sign in to follow this  
solinent

Deferred shading and env mapping, albedo

This topic is 3350 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'm implementing a deferred renderer. So far, my g-buffer looks like this:
All targets are GL_RGBA16F_ARB
    |R         |G          |B         |A
RT0:|Normal.x  |Normal.y   |Normal.z  |Depth
RT1:|Lighting accumulation            |Unused
As you can see, I'm not that far into development. However, I seem to have reached a stopping point. I've implemented lighting accumulation as first storing ambient, then adding lightDiffuseColor*NdotL*shadow, to it, which seems correct. However, I'm confused on how to add diffuse color (albedo) to the objects, and how to implement environment mapping. For albedo, does the renderer in the geometry pass render textures and diffuse colors to a separate render target, and then when doing the lighting calculation, add lightDiffuseColor*materialDiffuseColor*NdotL*shadow to the lighting accumulation buffer? It seems that killzone 2 doesn't do this, in their lighting accumulation shot they don't have any textures involved in it. This would make more sense to me, and would correctly re-arrange the lighting equation. Also, how should I attempt environment mapping? In a forward renderer one mixes the final color with the color of the environment map, but now that I think about this, this doesn't seem as correct. Is there any reference (you or otherwise) that gives the lighting equation nicely? Like how diffuse, specular, ambient, reflection, refraction etc. play into determining the final color. Does the amount of reflection change based on how lit the surface is?

Share this post


Link to post
Share on other sites
Advertisement
There are a few different ways to set up a deferred renderer. Using a lighting accumulation buffer is actually not a pure deferred renderer, it's usually called deferred lighting rather than deferred rendering. Check out Deferred Lighting Approaches for a description of the different techniques.

Share this post


Link to post
Share on other sites
Reflections are ussually added on top. So what you could do is storing a specular color or factor into your render targets. Later on you render the whole thing with x lights. And then on top render a screen quad again with additive rendering. This quad colors would be calculated like this:


normal.rgb = texProj( normalTex, texcoords );
specular.rgb = texProj( specularTex, texcoords ); // rgb or single factor
< get cubeMap color >
reflectColor.rgb = texCUBE( ..., normal ).rgb;

output.rgb = reflectColor * specular;

More difficult might be choosing which cubeMap to use for each pixel, in case you have multiple cubeMaps. You could use pixel depth or xyz coordinates to find your cubeMap. However, I found out that using a single cubeMap that moves along with the camera can deliver quite proper reflections as well. Not that accurate, but who will notice (unless using it for water or mirrors)?

Greetings,
Rick

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!