Sign in to follow this  
SpikeViper

Unity Unity - GPU calculations (Noise)

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Announcements

  • Forum Statistics

    • Total Topics
      628301
    • Total Posts
      2981906
  • Similar Content

    • By CpawsMusic
      Hey there! My name is Cpaws and I compose music, sound effects and overall sound design for video games and film. I'm looking to work on a horror game mainly for fun and as an addition to my portfolio. I've used Unity & Wwise before for audio implementation.
      If you're interested in working together, don't hesitate to contact me at cpawsmusic@gmail.com
      Here's a few demo reels of my past projects: 
      Here's some snippets of some quick game music I've composed: https://soundcloud.com/cpawsmusic/sets/cpaws-video-game-film-music
      Here's my portfolio/website: https://CpawsMusic.com/
      E-mail: cpawsmusic@gmail.com
    • By muhamad rabee
      My first mobile game made by unity

      iphone: https://itunes.apple.com/us/app/aa-countdown/id1314223584?ls=1&mt=8

      android: https://play.google.com/store/apps/details?id=com.mr.AACountDown

      I appreciate every suggestion
    • By Simplepg
      https://play.google.com/store/apps/details?id=simple.gplay.GamesInABox
    • By Simplepg
      https://play.google.com/store/apps/details?id=simple.gplay.GamesInABox
    • By ForgedInteractive


      Who We Are
      We are Forged Interactive, a small team of like-minded game developers with the sole purpose of making games we love! We're a team of artists, animators, programmers, level designers, writers, composers, producers, and other creative minds. We want to make games that you, the modern gamer want to play! We hope to build a community that enjoys our games as much as we love creating them. With your feedback and support we will be able to achieve that.

      About the Game
      GAME NAME is a fun, action-packed army builder with unique characters, challenges and engaging levels. Set forth on an adventure to protect friends, family and countrymen from new adversaries. Once defeated your enemies turn coat and join you in your adventures. Players can enjoy a range of troops and abilities based on their gameplay style which become more important as maps introduce more challenging terrain, enemies and bosses. Strong orc knights, dangerous shamans, and even a dragon are out on the prowl. Knowing when to fight and when to run, and how to manage your army is essential. Your actions alone decide the fate of this world.

      Previous Work by Team
      Although we are working towards our first game as a team, our team members themselves have past experience in the industry.
      This includes members who have worked on titles including:
      Final Fantasy Kingsglaive, FIFA, Xcom 2 and Civilization.

      Who are we looking for? 3D Modellers Concept Artists Marketing Specialists Level Designer

      What do we expect? Reference work or portfolio. Examples what have you already done and what projects you have worked on academic or otherwise. The ability to commit to the project on a regular basis. If you are going on a two-week trip, we don't mind, but it would be good if you could commit 10+ hours to the project each week. Willingness to work with a royalty based compensation model, you will be paid when the game launches. Openness to learning new tools and techniques
      What can we offer? Continuous support and availability from our side. You have the ability to give design input, and creative say in the development of the game. Shown in credits on websites, in-game and more. Insight and contacts from within the Industry.
      Contact
      If you are interested in knowing more or joining. Please email or PM us on Skype. Myself or Colin will reply to you within 48 hours.

      E-mail: Recruitment@ForgedInteractive.com
      Skype: ForgedInteractive

      Regards,
      David and Colin

      Follow us on:

      Facebook: https://www.facebook.com/ForgedInteractive/
      Twitter: @ForgedInteract
      Youtube: https://www.youtube.com/channel/UCpK..._as=subscriber
      Reddit: https://www.reddit.com/user/Forged_Interactive/
  • Popular Now