Unity - GPU calculations (Noise)

Started by
5 comments, last by vinterberg 8 years ago

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.

I'm making an open source voxel space game called V0xel_Sp4ce! Help me out with the repository here: https://github.com/SpikeViper/V0xel_Sp4ce

Advertisement
Do you need to generate all the caves at once or does generating a single cave still incur a lot of overhead?
My current game project Platform RPG
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.

I'm making an open source voxel space game called V0xel_Sp4ce! Help me out with the repository here: https://github.com/SpikeViper/V0xel_Sp4ce

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.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

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 :)

.:vinterberg:.

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.

I'm making an open source voxel space game called V0xel_Sp4ce! Help me out with the repository here: https://github.com/SpikeViper/V0xel_Sp4ce

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);
}

.:vinterberg:.

This topic is closed to new replies.

Advertisement