Sign in to follow this  
Disfunctional

normal mapping implementation

Recommended Posts

Hello, I've a rather noob question again: how can I implement normal mapping / bump mapping. I've got this tangent space file that I would like to map to some point I with it's normal N. What do I have to do? And how do I do that? Thanks for everything!

Share this post


Link to post
Share on other sites
I would recommend you to do something like this in your pixel shader:

The In.normal, In.tangent, and In.binormal are in world space (just multiply them with your WorldInverseTranspose Matrix in your vertex shader).

float2 bump = bumpStrength * (tex2D(YourNormalMapSampler, IN.uv).rg - 0.5);
float3 normal = IN.normal + bump.x * IN.tangent + bump.y * IN.binormal;

Use the light source from worldspace and calculate the light components.

Of course you could do all the calculations in tangent space, which is faster but not as well suited for deffered rendering.

[Edited by - 5ule1m4n on November 6, 2009 12:59:01 PM]

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