Jump to content
  • Advertisement
Sign in to follow this  

Parallax Mapping shader issue [video included]

This topic is 2854 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

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.


shader code via pastebin.com


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.


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
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!