Jump to content
  • Advertisement
Sign in to follow this  
SpikeViper

Unity Unity - GPU calculations (Noise)

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

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


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


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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);
}

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!