# 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.

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

http://pastebin.com/7xrvX3sP

Thanks,
Jon

##### 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 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 );

1. 1
2. 2
3. 3
Rutin
21
4. 4
5. 5

• 14
• 30
• 13
• 11
• 11
• ### Forum Statistics

• Total Topics
631778
• Total Posts
3002308
×