Archived

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

laeuchli

Problem With Creating Tiling Textures

Recommended Posts

laeuchli    338
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 this post


Link to post
Share on other sites
DekuTree64    1168
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 this post


Link to post
Share on other sites
laeuchli    338
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 this post


Link to post
Share on other sites
bazee    122
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 this post


Link to post
Share on other sites
technobot    238
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 this post


Link to post
Share on other sites
Soiled    286
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 this post


Link to post
Share on other sites
stevie56    145
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

Don''t follow me, I''m lost.

Share this post


Link to post
Share on other sites