Jump to content
  • Advertisement
Sign in to follow this  
Reb1rth

Tileable Perlin Noise textures for a cube map

This topic is 2586 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

Hi guys, first post from me which is a problem I have been working on for a couple of days with little joy.

I need to generate a cubemap texture out of six large individual textures that have been generated using a Perlin noise function. I have tried many methods to get the result I want, including taking images from inside of a sphere using one giant mapped texture. Although this kinda worked, the actual texture would need to be seamless (which is wasn't) and it is low quality and distorted (especially at the singular poles).

I am now going back to the idea of generating 6 seperate heightmaps and attemping to join them to form a cubemap (sideways cross). I can shift the X and Y start points and make the image appear to be joined, but obviously, not all sides meet up and would become obvious once it was mapped onto a cube.

I'm just wondering if someone could help me to address this problem in simple laymans terms. I am using the improved perlin 2D noise function. I do have a 3D noise function, but do not know how to implement the algorithm for the actual heightmap generation using 3d noise, and I don't just want to rip off somebody elses code without properly understanding it. Plus, I am so lost with this i'm not even sure 3D noise is heading towards the solution.

Thanks.

Share this post


Link to post
Share on other sites
Advertisement
you should probably use your 3D noise.

however, if your cubemap is meant to be a spherical texture, sampling the noise with the 3D positions of the cube face's texels will yield distortion artifacts : the cubemap face corners will appear having denser detail than the face centers.
one way to fix this would be to just normalize the 3D texel coordinates before passing them to the noise sampling function, therefore sampling a unit sphere instead of a unit cube within the 3D noise.

for example, to sample the first texel of the +X face of an 8*8 cubemap :

float cubemapSize = 8;
float halfPixelOffset = 0.5f / cubemapSize;

noise.Sample(noiseScale * normalize(float3(1.0f, 1.0f - halfPixelOffset, -1.0f + halfPixelOffset)));

(the halfPixelOffset is here just to sample at the pixel centers, to avoid artifacts at the face borders)

Share this post


Link to post
Share on other sites
Thanks for responding.

I used 3d noise and simply took all the noise from the faces of the noise cube and mapped the data onto six textures. I'm only applying noise to the sides of the 3d noise cube, which keeps it nice and fast. Seems to have worked, but have yet to implement filters.

Thanks for sharing your pseudocode. I'm not sure if it applies to what I am doing, but will definately keep a note of it.

Share this post


Link to post
Share on other sites
I don't think you should have any trouble tiling 2d perlin noise so long as the values in your gradient field match up along the edges. I know I've created infinitely tileable noise by just ensuring that the gradients wrap around the edges and corners.

Share this post


Link to post
Share on other sites
From what i've noticed with Perlin noise is that it stretches into infinity, so all you need to do is to displace the coordinates to get tiling. What I required was some sort of circular system so everything meets up without any sort of repetitive pattern. Using 3D noise to do it turned out to be a very simple task, because it generates a cube of noise by default.

Share this post


Link to post
Share on other sites
I don't think you should sample the 3D noise at the cube. If you do that, the frequency characteristics of the noise near the center of the faces will be different than near the corners. Instead, you can normalize each vector before you sample the 3D noise, so you are effectively sampling at a sphere.

Share this post


Link to post
Share on other sites

I don't think you should sample the 3D noise at the cube. If you do that, the frequency characteristics of the noise near the center of the faces will be different than near the corners. Instead, you can normalize each vector before you sample the 3D noise, so you are effectively sampling at a sphere.


The UVW coords are being normalized when passing to the noise function, and the result is then stored in a 3d array. I then pull the sides from the array.

Is what you mean?

This is a 'scaled down' result of the six textures. It goes, left, front, right, back. Top and bottom is lined up with front.

cubemap.jpg

Share this post


Link to post
Share on other sites

[quote name='alvaro' timestamp='1321385986' post='4884272']
I don't think you should sample the 3D noise at the cube. If you do that, the frequency characteristics of the noise near the center of the faces will be different than near the corners. Instead, you can normalize each vector before you sample the 3D noise, so you are effectively sampling at a sphere.


The UVW coords are being normalized when passing to the noise function, and the result is then stored in a 3d array. I then pull the sides from the array.

Is what you mean?[/quote]

Yes, that's what I mean. I didn't get the impression that you were doing the normalization, from the previous posts.

Share this post


Link to post
Share on other sites
Yes, that's what I mean. I didn't get the impression that you were doing the normalization, from the previous posts.


I was tired and thought you was talking about the final array. I was imagining it as a hollow cube. :)

Thanks for the help though guys.

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!