Sign in to follow this  
jdavis

Parallax Mapping shader issue [video included]

Recommended Posts

I've been having trouble getting parallax mapping working in my engine. I coded my own version and looked up sample stuff and both gave me the same result. In the video, I have standard bump mapping and I activate parallax to show the difference. If anyone could spot what they think might be wrong, it would be greatly appreciated. It seems like it's something to do with the view vector but I don't see what it could be.

http://www.moonlightminions.com/parallax.avi

shader code via pastebin.com
http://pastebin.com/7xrvX3sP

Thanks,
Jon

Share this post


Link to post
Share on other sites
Couldn't see the video, probably I didn't have a proper codec. Anyway, your pixelshader code seems right. BUT, how is your viewvector made? Is it in tangent space? This is how I do it:

// View vector
half3 camVec = cameraPos.xyz - in.vertPos.xyz;

// For parallax, must be in tangent space
out.parViewVec.x = dot( camVec, in.Tangent );
out.parViewVec.y = dot( camVec, in.BiTang );
out.parViewVec.z = dot( camVec, in.Normal );

And maybe you'll have to invert the vector, in case you get exactly the opposite results.

Rick

Share this post


Link to post
Share on other sites
// Transform normal and tangent, and compute the binormal
i.Norm = normalize( mul(i.Norm, (float3x3)WorldMatrix ) );
i.Tan = normalize( mul(i.Tan, (float3x3)WorldMatrix ) );
float3 Binorm = cross( i.Norm, i.Tan);

PosWorld = mul(i.Pos, WorldMatrix);
View = CameraPos.xyz - PosWorld.xyz;

// Set the view
Out.View.x = dot( View,i.Tan );
Out.View.y = dot( View,Binorm );
Out.View.z = dot( View,i.Norm );

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