Deferred shading and env mapping, albedo

Started by
1 comment, last by spek 14 years, 9 months ago
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?
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.

Game Programming Blog: www.mattnewport.com/blog

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

This topic is closed to new replies.

Advertisement