• Advertisement
Sign in to follow this  

Parallax Mapping Error

This topic is 3051 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
Sign in to follow this  

  • Advertisement