Problem with texturing a heightmap

Started by
1 comment, last by Florian22222 12 years, 2 months ago
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
Advertisement
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

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

This topic is closed to new replies.

Advertisement