Jump to content
  • Advertisement
Sign in to follow this  
Florian22222

Problem with texturing a heightmap

This topic is 2513 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!

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

Share this post


Link to post
Share on other sites
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.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!