John2156

I have a large, nearly flat cube which represents the ground in my 3d world. I'm trying to apply a grass texture to this cube. Because of the size of the cube any applied texture stretches. Is there an easy way to repeat the texture being applied to eliminate the stretching problem I have it looking really nice in Maya, but when I export it to .x it continues to stretch a single copy of the texture across the surface. Does an operation like this require the use of HLSL I could just create a bunch of smaller cubes that are closer to the texture size and piece the ground together, but that seems like a messy way to go about it.

I'm new to this, so anything to point me in the right direction would be helpful.



Re: XNA Framework Wrapping a model with a repeated texture

neogir

The simpliest way is to scale the UV coordinates for all six faces, f.e instead of 0,0 .... 1,1 apply the 0.,0 .... 1000.0f,1000.0f. It depends on the size of your textures and may be implemented in the realtime, including shader techique as well.



Re: XNA Framework Wrapping a model with a repeated texture

Jon Watte

You can either stretch the texture map, or stretch the texture coordinates. If you stretch the texture coordinates, it should work when you export. (I e, map the faces to a range greater than 0-1)

Another option is to multiply the texture coordinates in your pixel shader:

float4 color = tex2D(PixelInput.Texture0 * 10, MyTextureSampler);







Re: XNA Framework Wrapping a model with a repeated texture

John2156

Thanks. Stretching the texture coordinates worked perfectly.