Jump to content
  • Advertisement
Sign in to follow this  
mind in a box

[DirectX10] Parallax mapping looks wrong

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

Hi there! I wont to put some parallax mapping into my engine, but something seems to be wrong: Image and video hosting by TinyPic The pixel shader is here:
float4 wtPixelShader(PixelShaderInput Input) : SV_Target
{
	
	float3 tCam = WorldToTangent_Inv(normalize(CamLoc-Input.VertexPos),Input.Norm,Input.Tangent,Input.Binormal);
	float Height = TexUV(Tex2,UV*5).r * 0.03;
	Height/=tCam.z;

	float2 ParallaxUV = (UV) + tCam.xy * Height;

	float4 Color = TexUV(Tex1,ParallaxUV);

	return Color;
	//return float4(ParallaxUV,0,1);
}

//... Include:

shared float3 WorldToTangent_Inv(float3 In,float3 Nrm,float3 Tan, float3 Bin)
{
    float3x3 mTangentFrame = {Tan, Bin, Nrm };
  
    return normalize(mul((float3x3)mTangentFrame, In));
    
}

Can you maybe give me some pseudo code? I ahve looked at the SDK sample already, but everything seems to be just like there...

Share this post


Link to post
Share on other sites
Advertisement
Yes, but the height is not the problem. When you take a closer look to the picture, you will notice that they bumps get shifted into the wrong direction...

Share this post


Link to post
Share on other sites
I had similar problem. The cause of my problem was wrong computation of mesh tangents. I used D3DXComputeTangentFrameEx() for tangent and binormal computation, and passing anything other than NULL for CONST DWORD * pdwAdjacency parameter caused this behavior in shader.

Share this post


Link to post
Share on other sites
I use a .x loader from the NVIDIA SDK10 for loading my meshes. So, I think they know what they are doing. Also normal mapping works just fine for me.

Share this post


Link to post
Share on other sites


it seems that it shifts correctly by y axis but opposite at x axis.
Try this then

Height/=tCam.z;

tCam.x=-tCam.x;

float2 ParallaxUV = (UV) + tCam.xy * Height;

float4 Color = TexUV(Tex1,ParallaxUV);

Share this post


Link to post
Share on other sites
Sorry, my internet was down for a while. But I found out that the Vertex-Position I used was in Object space. So it works now, but it looks strange. Also, if I rotate the model, the parallax mapping stays the same, just like I never rotated it. :(

Share this post


Link to post
Share on other sites
There are few things that are almost always responsible for various bump mapping problems. I suggest you try em all ad hoc and see if any work:

1) Swap the tangent and binormal params around
2) Tranpose the matrix before you multiply with it
3) When rotating normals, remember to cast a full matrix to a float3x3

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!