Jump to content

  • Log In with Google      Sign In   
  • Create Account

Problem with texturing a heightmap


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 IceBreaker23   Members   -  Reputation: 618

Like
0Likes
Like

Posted 22 January 2012 - 02:41 PM

Hi!

I have a problem with texturing a heightmap with a simple dirt-tile. On every position when the y-coord doesnt change for a few vertices, the texture is getting stretched. Look at the attached pictures. You´ll find a screenshot and the dirttile itself(sometimes it looks confusing)

I´ve used the same code in d3d9 to creating a heightfield and its coordinates, so it cant be that the texture coordinates are the error. I think there´s something in my shadercode that causes this issue.

My effect file:
uniform extern matrix gWVP;
uniform extern Texture2D gTileTex;
SamplerState TextureSampler
{
	Filter = MIN_MAG_MIP_LINEAR;
AddressU = WRAP;
AddressV = WRAP;
};
//shader i/o structs
struct VS_OUTPUT
{
	float4 Position	 : SV_POSITION; // vertex position
	float2 TexCoord2	: TEXCOORD0;   // vertex texture coords
};
VS_OUTPUT RenderSceneVS( float3 Position : POSITION, float2 TexCoord2 : TEXCOORD0 )
{
	VS_OUTPUT Output = (VS_OUTPUT) 0;

Output.Position = mul(float4(Position,1.0f),gWVP);
Output.TexCoord2 = TexCoord2;

return Output;
}
float4 RenderScenePS(VS_OUTPUT Input) : SV_TARGET
{
return gTileTex.Sample(TextureSampler,Input.TexCoord2);
}
technique10 T1
{
pass P1
{
  SetVertexShader( CompileShader( vs_4_0, RenderSceneVS() ) );
  SetGeometryShader( NULL );
  SetPixelShader( CompileShader( ps_4_0, RenderScenePS() ) );
}
}

EDIT: I am using sm5(fx_5_0) for the shader

Attached Thumbnails

  • heightmap_dirt.png
  • dirt.jpg


Sponsor:

#2 Tarika   Members   -  Reputation: 481

Like
0Likes
Like

Posted 26 January 2012 - 10:32 PM

The shader code looks fine, have you checked the UV coords being passed in? I've seen wrap have some unexpected results in dx9 when the UV's are off.

We are now on Tumblr, so please come and check out our site! 

 

http://xpod-games.com


#3 IceBreaker23   Members   -  Reputation: 618

Like
0Likes
Like

Posted 27 January 2012 - 04:08 AM

Sorry, I forgot about writing this.
I solved the problem a week ago.
The input layout wasn´t specified right.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS