• Advertisement
Sign in to follow this  

problem with repeat U/v

This topic is 4229 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 have a plane polygon (4.5 x 8.5 (with 1x1 faces, and some 1x0.5)) in Maya with a DirectX shader that has a texture (256x256). In Maya I set [repeat U=4.5] and [repeat V=8.5]. This way each face of the polygon will have that texture right? Well, first of all, I can't see the texture redered in Maya; the polygon becomes black when I turn on 'Hardware Textures'. Second, and much more important, In my DirectX application the (one) texture is stretched out over the whole polygon. I use the plugin for exporting to an X file. Can someone please tell me what I'm doing wrong here? Thanks, Dennis

Share this post


Link to post
Share on other sites
Advertisement
You have to set address modes if you want your texture to be 'repeated' ( when your u/v coordinates are larger than 1 ).

Here is a nice resource on how to use them.

Let me quote the relevant bit from that site:

Quote:

Textures are mapped onto geometry using U and V values. UV value of 1,1 is the bottom right of the texture while 0,0 is the top left. If looking at a texture U values increase to the right and V values increase downward. If we go beyond 1 we can repeat (tile) the texture. How these situations are handled can be define via these states.

* D3DSAMP_ADDRESSU - texture address mode for the u co-ordinate. This can be D3DTADDRESS_WRAP which means the texture is repeated if values are beyond 1. So if we set a U value to 10 the texture would repeat 10 times in the U direction. D3DTADDRESS_MIRROR is like wrap but each tile is mirrored from the previous one. D3DTADDRESS_CLAMP restricts texture look up to the range 0 to 1. E.g. if the value goes beyond 1 the colour will be what is at 1. Look in the DirectX help for a full list of value options.
* D3DSAMP_ADDRESSV - as above but for the V co-ordinate.
* D3DSAMP_ADDRESSW - as above for the W co-ordinate

All the above default to D3DTADDRESS_WRAP.


Basically, you have to use the SetSamplerState method of your device to get it done. In your case I think you would have to use:


Device->SetSamplerState ( 0, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP );
Device->SetSamplerState ( 0, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP );


I didn't test it so please let me know if this solved it :)

Share this post


Link to post
Share on other sites
I called the functions just before setting the textures. I also tried to call them after setting all render states after initialisation.
That didn't help.
Matbe it's important to know that I'm using DX meshes?

Share this post


Link to post
Share on other sites
Hehe, I'm not at all sure about how to do it with meshes. I would think you'd have to set the address mode per subset you're drawing.
So you'd associate a texture with a subset, then set those sampler states etc. and draw the subsets. That's how I think it works anyway, but someone correct me if I'm wrong :)

Share this post


Link to post
Share on other sites
Well, it turned out to be a problem in Maya or the DirectX plugin, because the .x file didn't have repeated U and V coordinates. Now I have to edit the x-file manualy, unless anybody has a solution within maya for me.

Thanks

Share this post


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

  • Advertisement