Compute Shaders = Insane performances !
Hello friendly gamer.
This is the second devlog for Aekan : Call of Ruligon
Has you may already know, Aekan : Call of Ruligon is an information game. It mean that your goal as a player is to understand what’s going on in this world. It’s about seeking truth, and hopefully, have an impact on the story. And the way you do is to use information you’ve already gained, by applying it, combining it, deducing things from it, stuff like that.
Today I’m going to talk about Compute Shaders and how I used to them get better performances.
In my previous devlog, I already had a procedurally generated infinite map. And this large map was divided into small chunks of 20x20 square meter. Each time a chunk is about to enter the frustrum, I generate it mesh by using a combination of Perlin noise and other mathematical tools. But theses operation was performed on the CPU side and I got a noticeable frame drop each time it happens.
So I started to move the whole algorithm to the GPU using Compute shaders. The first challenge I had to overcome was to found a good alternative to the Unity Perlin noise. I wanted to have the same results than in CPU, and I struggle a moment testing many Perlin and Simplex implementation. Until I realized most of them are returning values between -1 to 1, where Unity Perlin noise return values from 0 to 1. After I fixed this, it was just a matter of time before I finished the implementation.
And guys, it’s now insanely fast to execute theses operations. Each chunk is generated in less than 1ms, when it took more than 120ms previously on the CPU. But even at this speed, I was having some framedrop, so I suspect there was a bottleneck somewhere. To fix this, I end up using the AsyncGPUReadbackRequest that allow to retrieve the result of a Compute Shader asynchronously. Now, the game is incredibly fast and I can at walk at the improbable speed of 300 m/s at 160fps.
This was the second devlog for Aekan : Call of Ruligon. More will follow and if you want to hear more about it, just follow me.
Leave a comment
Log in with itch.io to leave a comment.