Unity Unity - GPU calculations (Noise)

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

Recommended Posts

In my game, I'm using BillowNoise to generate caves for my planets - it's also currently the most intensive part of the game. Th game isn't very graphically intensive, so I wanted to know if there are any good ways to move calculations to the GPU, fixing the CPU bottleneck.

Thanks! Again, just an idea.

Share on other sites
Do you need to generate all the caves at once or does generating a single cave still incur a lot of overhead?

Share on other sites
When getting values for noise in the caves, it slows down the generation by 20%. This random noise (BillowNoise) is necessary to get the correct look and structure of caves. If the value returned by the noise is over 0.5, the given block is set to be empty.

Share on other sites

Sample a 3D texture containing random values.  Depending on your use case this needn't be a huge texture, and if you don't need 3D noise you can get away with a 2D or even 1D texture.

If you also need to get the result back on the CPU things could get exciting (or interesting) though.

Share on other sites

You could generate only every second voxel with BillowNoise, and average the empty voxels inbetween afterwards with neighbours.. This will give you a good speed increase, and you'll probably not notice any big visual difference :)

Example:

1x 32x32x32 chunk = 32768 voxels

1x 16x16x16 chunk = 4096 voxels

= 8 times faster, if you only calculate every second voxel in a 32x32x32 chunk :)

Share on other sites

You could generate only every second voxel with BillowNoise, and average the empty voxels inbetween afterwards with neighbours.. This will give you a good speed increase, and you'll probably not notice any big visual difference :)

Example:

1x 32x32x32 chunk = 32768 voxels

1x 16x16x16 chunk = 4096 voxels

= 8 times faster, if you only calculate every second voxel in a 32x32x32 chunk :)

I will implement this idea - Still wondering, though, if it's possible to have the GPU do the math for the noise.

Share on other sites

You could try supplying your shader with a random seed through a constant buffer, then use this function to generate random numbers based on voxel XYZ (like XY, ZX, YZ etc. supplied as input to the function, with the random seed added/multiplied/whatever to the input):

float rand(float2 co)
{
return frac(sin(dot(co.xy ,float2(12.9898f, 78.233f))) * 43758.5453f);
}


1. 1
2. 2
Rutin
20
3. 3
khawk
18
4. 4
A4L
14
5. 5

• 12
• 16
• 26
• 10
• 44
• Forum Statistics

• Total Topics
633765
• Total Posts
3013730
×