Deferred Rendering and Normal Mapping

To do normal mapping in Deferred Rendering is little dificult because you need to store in G-buffer tangent and binormal if you want, but it is easy to calculate. Or you can calculate TBN matrix per pixel with your 2D normal map stored in G-buffer. So I can’t do that because have high GPU consumption.

Other thing that you can to do is store in 8bit the result of “light power” calc in Geometry stage and then, use that in Lighting Stage. But “normal mapping” will be based in 1 light.

Anyway, we can do an approximation using a bling phong lighting and fast normal mapping calc:

// Calculate half vector
vec3 H = normalize( normalize(lightDirection) + normalize(eyePosition.xyz - pixelPosition.xyz)); 
 
// Calculate phong shading
float shininess = 100.0;
vec3 phong = pow(max(dot(H, normal.xyz), 0.0), shininess) * specular.rgb; 
 
// Calculate normal mapping effect
float lightAmount = max(dot(normal.xyz, normalize(lightDirection)), 0.0);
This entry was posted in Graphics, Programming and tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">