Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

#ActualIceBreaker23

Posted 22 January 2012 - 02:45 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

#1IceBreaker23

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() ) );
}
}

PARTNERS