Sign in to follow this  
solinent

Deferred shading and env mapping, albedo

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this