• Advertisement
Sign in to follow this  

Texture UV Coordinates

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

I am trying to render a texture across 4 flat quads. I want the texture to strech across all of them only once exactly (i.e. it shouldn't repeat). The texture is 8x8 pixels and has a blue, red, yellow and green pixel in each corner. Here is a screen shot of what it currently looks like: http://home.ripway.com/2005-2/258982/screen.jpg As you can see, the texture is not completely clamped to the edges, there is a bit of repeating going on. This is how I set up the uv coordinates:
int Width = 5;
int Height = 5;
for(int Y=0;Y<Height;++Y)
{
  for(int X=0;X<Width;++X)
  {
    verts[(Y*Height)+X].U = (FLOAT)X/(Width-1);
    verts[(Y*Height)+X].V = (FLOAT)Y/(Height-1);
  }
}
Should I be doing this differently or is there a rendering setting that clamps the texture to the edges?

Share this post


Link to post
Share on other sites
Advertisement
Yeh:

gD3dDevice->SetSamplerState( 0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP );
gD3dDevice->SetSamplerState( 0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP );

alternative (and default) is D3DTADDRESS_WRAP

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement