Clamping UV texture co-ordinates

Started by
2 comments, last by David Clark 17 years, 3 months ago
I'm working on a 2d game and I've noticed that when the sprites increase in size the edges of the texture seem to wrap. The texture co-ordinates are simply 0,0,1,1. I know I could fix this by giving all my sprites a transparent border, but i'm sure there must be a solution as this kinda thing would surely affect 3d games! I remember back in the days i used to use blitzbasic and i had a texture which was a gradient. The ground was black, and the texture of the walls were a gradient of black to white, and the sky was white. I had a wrap problem back then as the top of the walls had some white appear on them, but there was an option to fix it called 'CLAMPUV'. So I'm wondering how do i go about this in direct x? is there a render state or something ? Thanks in advance :)
Advertisement
It's a samplerstate rather than a renderstate; You can call IDirect3DDevice9::SetSamplerState to set D3DSAMP_ADDRESSU and D3DSAMP_ADDRESSV to D3DTADDRESS_CLAMP.
Rim van Wersch [ MDXInfo ] [ XNAInfo ] [ YouTube ] - Do yourself a favor and bookmark this excellent free online D3D/shader book!
[edit : too slow]

Hello,

There is a (texture)sampler state for U,V and W texture coordinates which you can set to clamp, wrap or mirror. So you answered your own question already :)

Cheers !

oh such a simple solution! i feel like such a noob. Thanks heaps both of u!

This topic is closed to new replies.

Advertisement