#### Archived

This topic is now archived and is closed to further replies.

# Problem With Creating Tiling Textures

This topic is 5609 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Dear All, I''ve got a 3D Noise texture that I''m using in DirectX 9. The problem is, that I''m using it tiled, and so there are discontinuities, where the sections meet. It''s already a big cpu drain to generate a 64x64x64 3d noise texture, and I''d rather not have to do anything else to it. Is there some DX function call I can use to interpolate the texture at it''s edges, or am I going to need to hack my texture? Thanks, Jesse

##### Share on other sites
You just have to change how you generate the texture slightly. It will take a lot longer to compute to get it to loop in all 3 dimensions though.
For 1D noise, instead of using noise(x), you use (1-x)*Noise(x)+x*Noise(x-1), where x ranges from 0 to 1. SO if x is 0, you get (1-0)*Noise(0)+0*Noise(-1), which is Noise(0). If x = 1, you get (1-1)*Noise(1)+1*Noise(1-1), which is also Noise(0), therefore it loops at x=1. For 2D, you just extend it a little, so it''s
(1-x)*(1-y)*Noise(x,y)+
(x)*(1-y)*Noise(x-1,y)+
(1-x)*(y)*Noise(x,y-1)+
(x)*(y)*Noise(x-1,y-1)
and then it loops in x and y. Going to 3D is about the same, and I don''t want to type it all out, so I hope you get the idea. But as you can see, you end up doing a lot of multiplies, and a lot of calls to Noise(). I haven''t played around with procedural textures much myself, and that''s the only way I know how to do it.

##### Share on other sites
Yes, I know that, I was just wondering if there was a way to do it without changing how you generate the texture(As that is going to take alot longer).

##### Share on other sites
A really simple way to do this would be to just generate a 32x32x32 texture, then "copy and paste" this texture in mirrored positions around the rest of the cube. Here''s a 2D example with a 3x3 texture:

123|321
632|236
048|840
_______
048|840
632|236
123|321

However the mirroring might be quite obvious depending on the use, it''s up to you to decide whether that''s a price you can pay for fast an easy tiling.

##### Share on other sites
The above mirror-tiling effect can be acheived in OpenGL 1.4 using the GL_MIRRORED_REPEAT texture wrap mode. In older versions of OpenGL, this mode is available through the ARB_texture_mirrored_repeat extension.

Michael K.,
Co-designer and Graphics Programmer of "The Keepers"

We come in peace... surrender or die!

##### Share on other sites
I do a slight modification inside the perlin noise function to make it tileable in all/any dimension. This avoids making four(eight) calls to a regular 2D(3D) perlin noise function to make it tileable. I make the integer lattice coordinates repeat before using them to lookup the gradient table. For power-of-two repetitions all that''s required is (x&(tile-1)) instead of x.

##### Share on other sites
I agree, Soiled.

It seems logical to sort the problem at the beginning than to duck and weave to effectively hide the problem later.

I bet we''ve all been told, at some time, "You should have thought of that before you started!"

Stevie

1. 1
2. 2
Rutin
19
3. 3
4. 4
khawk
15
5. 5
A4L
13

• 13
• 26
• 10
• 11
• 44
• ### Forum Statistics

• Total Topics
633743
• Total Posts
3013644
×