normal mapping implementation

Started by
1 comment, last by 5ule1m4n 14 years, 5 months ago
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!
Advertisement
Hello,
I think you can easily Google "normal mapping" and find tutorial explaining how to implement that step by step
Some of my previous work on my personal webpage
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]

This topic is closed to new replies.

Advertisement