• Advertisement
Sign in to follow this  

Question on texture addressing

This topic is 3876 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'm a rookie on DX programming, so maybe my question is a little bit naive, but please help me with this one. In DX, the texture is accessed through texture coordinates, which is in the range of 0.0-1.0. Any coordinate out of the range of 1.0 will be set to one of the modes for special effects. My question is that, does DX have a mode to enable user to sample texture using coordinate out the range of 1.0? For example, if a texture has a width of 100 and height of 50, can I use texture coordinate (50.0, 25.0) to fetch the center pixel of the image, especially in shaders? If so, how should I change the context of DX settings, will there be any problems if I do so? Thank you very much for your all kinda help.

Share this post


Link to post
Share on other sites
Advertisement
Yes, but that depends on the texture addressing mode currently in use. Besides repeating the texture on every integer junction (identified by D3DTADDRESS_WRAP member of D3DTEXTUREADDRESS) there are other methods using which the textures can be tiled together. Search for "Texture Addressing Modes" in DirecX SDK documentations for more info.

Share this post


Link to post
Share on other sites
Using texture coordinates in normalized form is not really specific to D3D - it's more a general computer graphics thing.

Consider mip-mapping. Your pixel-oriented coordinates will only be valid for the top-most element in the chain, after that it's broken unless the GPU starts to re-map your coordinates each time. A normalized 0.0-1.0 coordinate is valid for all elements in the chain.

Using a shader you can do whatever you want, provided you pass the final values in a form that the API understands. It's not too uncommon to implement a VS/PS that maps from some app-specific data format to a GPU/D3D specific one...

hth
Jack

Share this post


Link to post
Share on other sites
Quote:
Original post by Ashkan
Yes, but that depends on the texture addressing mode currently in use. Besides repeating the texture on every integer junction (identified by D3DTADDRESS_WRAP member of D3DTEXTUREADDRESS) there are other methods using which the textures can be tiled together. Search for "Texture Addressing Modes" in DirecX SDK documentations for more info.


I know both of you guys' idea, and I know that if I have input over the range of 0.0-1.0, DX will do some fancy things like wrapping, clamping and stuff. But what I really wanna do is to addressing the texture using integer coordinate. For example, for a 2D texture of width 100 and height 50, I can address the texture pixel by pixel using texture coordinates: (0, 0), (0, 1), (0, 2), ....., (99, 49).

I know in OpenGL, we can use ARB extension to make this happen, I don't know if we have the same thing in DirectX.

Hope I understand what you mean correctly, if not, please inform me, I appreciate all the help!

Share this post


Link to post
Share on other sites
Quote:
Original post by jasonyang
I know in OpenGL, we can use ARB extension to make this happen, I don't know if we have the same thing in DirectX.
No, there is no equivalent in Direct3D. Emulate it using floating point maths and remap your integer coordinates to 0.0-1.0 values.

D3D9 shaders are FP throughout, so you can't safely send integer values to the shader - mostly it's okay, but you can potentially get rounding/precision issues. D3D10 is better as it has a full 32bit integer instruction set, but I don't think the load-from-buffer technique is quite what you're after, so you'd still be stuck there.

hth
Jack

Share this post


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

  • Advertisement