Jump to content
  • Advertisement
Sign in to follow this  
MZP

Parallax Mapping Error

This topic is 3172 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello guys, I have some problems with implementing standard parallax mapping. The error is hard to explain, please take a look at this image: http://i36.tinypic.com/2u8aqv4.jpg Notice how the capped cone is facing away in the wrong direction. In the vertex shader I transform the toEye vector to tangent space...
float3 Pos = mul ( float4 ( input.Pos, 1 ), World );
float3 Nor = mul ( float4 ( input.Nor, 0 ), World );
float3 Tan = mul ( float4 ( input.Tan, 0 ), World );

float3 N = Nor;
float3 T = normalize ( Tan -N *dot ( Tan, N ) );
float3 B = cross ( N, T );
float3x3 TBN = float3x3 ( T, B, N );

output.toEye = mul ( TBN, CameraPosition -Pos );

... and in the pixel shader I use this vector to offset my texture coordinates.
const float BIAS  = +0.04f;
const float SCALE = +0.08f;

float height = texture2.Sample ( linearSampler, input.Tex ).r *SCALE -BIAS;
input.Tex += height *normalize ( input.toEye ).xy;

// use input.Tex to sample diffuse and normal map, etc etc...

Thanks in advance!

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!