When Your Game Is Bad But Your Optimisation Is Genius
3 simple optimisations that you can use to make your game run up to 10 times quicker.
Not a Unity video, but still can be easily applied to a Unity game. I have done similar optimizations to the terrain a long time ago in my own mobile game and got a significant boost.
https://www.youtube.com/watch?v=5zlfJW2VGLM
Repo: https://github.com/vercidium-patreon/glvertexid
#optimisation #terrain
3 simple optimisations that you can use to make your game run up to 10 times quicker.
Not a Unity video, but still can be easily applied to a Unity game. I have done similar optimizations to the terrain a long time ago in my own mobile game and got a significant boost.
https://www.youtube.com/watch?v=5zlfJW2VGLM
Repo: https://github.com/vercidium-patreon/glvertexid
#optimisation #terrain
YouTube
When Your Game Is Bad But Your Optimisation Is Genius
The source code and demos are available here: https://patreon.com/vercidium
An extra heightmap renderer is available here: https://github.com/vercidium-patreon/glvertexid
I spent the past 6 years creating a game engine, and I've been shocked at the things…
An extra heightmap renderer is available here: https://github.com/vercidium-patreon/glvertexid
I spent the past 6 years creating a game engine, and I've been shocked at the things…
👍12🔥2
Unity 2D Radiance Cascade Demo
This repository provides a basic implementation of a global illumination technique based on the concept of Radiance Cascades, as described in the paper Radiance Cascades: A Novel Approach to Calculating Global Illumination.
The illumination algorithm is applied as a post-processing effect on the main camera.
The repository includes two versions of the algorithm:
3D Texture Implementation: For easy understanding of the technique.
2D Texture Implementation: For greater portability across different platforms.
I have tested it with different resolutions, and the highest one has put my high-end GPU to work taking 22 ms per frame. Would be interesting to check it in a real project and play around with values to find an optimal compromise.
https://github.com/ZY4N/Unity-2D-Radiance-Cascade-Demo
#computeshader #raytracing #lighting
This repository provides a basic implementation of a global illumination technique based on the concept of Radiance Cascades, as described in the paper Radiance Cascades: A Novel Approach to Calculating Global Illumination.
The illumination algorithm is applied as a post-processing effect on the main camera.
The repository includes two versions of the algorithm:
3D Texture Implementation: For easy understanding of the technique.
2D Texture Implementation: For greater portability across different platforms.
I have tested it with different resolutions, and the highest one has put my high-end GPU to work taking 22 ms per frame. Would be interesting to check it in a real project and play around with values to find an optimal compromise.
https://github.com/ZY4N/Unity-2D-Radiance-Cascade-Demo
#computeshader #raytracing #lighting
🔥5👍1
Parsing JSON Really Quickly: Lessons Learned
1. No branching
2. Don't process byte by byte, use SIMD
3. Avoid memory allocations
4. Measure the performance (CI performance tests)
How simdjson is made that parses gigabytes of JSON per second. There are also a few performance tricks related to parsing.
And there is a very interesting comment under the video:
Which is even more true nowadays with a wider adoption of e-cores and p-cores in modern CPUs.
https://www.youtube.com/watch?v=wlvKAT7SZIQ
#performance
1. No branching
2. Don't process byte by byte, use SIMD
3. Avoid memory allocations
4. Measure the performance (CI performance tests)
How simdjson is made that parses gigabytes of JSON per second. There are also a few performance tricks related to parsing.
And there is a very interesting comment under the video:
43:37 "cause you're assuming that the person running your program is not switching the CPU under you". The audience might be laughing, but this actually is sometimes a case, even in consumer hardware. Non-US Samsung Galaxy S9 has a heterogenous CPU, with some cores supporting the atomic increment instruction LDADDAL and others not, and with Linux kernel modified by Samsung to report that all cores support that instruction. Your program would crash after being rescheduled to another core.
Which is even more true nowadays with a wider adoption of e-cores and p-cores in modern CPUs.
https://www.youtube.com/watch?v=wlvKAT7SZIQ
#performance
👍10🔥1
Everyday Unity
Unity 2D Radiance Cascade Demo This repository provides a basic implementation of a global illumination technique based on the concept of Radiance Cascades, as described in the paper Radiance Cascades: A Novel Approach to Calculating Global Illumination.…
Exploring a New Approach to Realistic Lighting: Radiance Cascades
The video explaining the theory behind a novel lighting approach. I also shared an open source implementation in Unity a while ago.
https://www.youtube.com/watch?v=3so7xdZHKxw
#lighting #radiancecascades
The video explaining the theory behind a novel lighting approach. I also shared an open source implementation in Unity a while ago.
https://www.youtube.com/watch?v=3so7xdZHKxw
#lighting #radiancecascades
YouTube
Exploring a New Approach to Realistic Lighting: Radiance Cascades
Radiance Cascades are an innovative solution to global illumination from the devs of Path of Exile 2. Let's explore and implement their approach.
Gamedev Courses: https://simondev.io
Support me on Patreon: https://www.patreon.com/simondevyt
Follow me on:…
Gamedev Courses: https://simondev.io
Support me on Patreon: https://www.patreon.com/simondevyt
Follow me on:…
🔥3👍1
A genshin-like post processing render feature, based on URP.
https://github.com/kaze-mio/UnityGenshinPostProcessing
#renderfeature #urp #postproccess
https://github.com/kaze-mio/UnityGenshinPostProcessing
#renderfeature #urp #postproccess
👍6🔥3
SanderMertens/ecs-faq: Frequently asked questions about Entity Component Systems
A good starting point to dive into ECS. There is a strong emphasis on the performance of ECS, and while it is mentioned, it is not stated clearly that ECS is not always about performance. Primarily, it is an architectural approach. With the right design — both in terms of framework and game design — it can significantly benefit performance, but this is not guaranteed by default.
https://github.com/SanderMertens/ecs-faq
#ecs
A good starting point to dive into ECS. There is a strong emphasis on the performance of ECS, and while it is mentioned, it is not stated clearly that ECS is not always about performance. Primarily, it is an architectural approach. With the right design — both in terms of framework and game design — it can significantly benefit performance, but this is not guaranteed by default.
https://github.com/SanderMertens/ecs-faq
#ecs
GitHub
GitHub - SanderMertens/ecs-faq: Frequently asked questions about Entity Component Systems
Frequently asked questions about Entity Component Systems - SanderMertens/ecs-faq
🔥4👍3
Which collection interface to use?
Tl;dr:
https://enterprisecraftsmanship.com/posts/which-collection-interface-to-use/
#design #api
Tl;dr:
Use the most generic types possible for arguments,
Use the most specific types possible for return values
Adhere to the following guideline.
Use IEnumerable for arguments as the most generic type possible.
Use IReadOnlyList for return values as the most specific type possible.
IQueryable is a leaky abstraction because it requires you to know which LINQ expressions the ORM can understand.
IList and Array aren’t suitable because they are mutable.
Keep in mind that some implementations of IEnumerable are also leaky abstractions
https://enterprisecraftsmanship.com/posts/which-collection-interface-to-use/
#design #api
Enterprise Craftsmanship
Which collection interface to use?
Let’s talk about when to use which collection type and why.
🔥3👍2👎1
Choosing the right network model for your multiplayer game
A good starting point, with references for in-depth investigation, to help you choose the right network model for your game by going over the list of questions the author provides and high level denoscriptions
https://mas-bandwidth.com/choosing-the-right-network-model-for-your-multiplayer-game/
#netcode
A good starting point, with references for in-depth investigation, to help you choose the right network model for your game by going over the list of questions the author provides and high level denoscriptions
https://mas-bandwidth.com/choosing-the-right-network-model-for-your-multiplayer-game/
#netcode
Más Bandwidth
Choosing the right network model for your multiplayer game
Don't fuck it up. Pick the correct one for your game.
🔥5
Unity Asset Bundles tips and pitfalls
A helpful list of tips for working with asset bundles. It provides just enough detail to explain why each tip is useful, while keeping the post concise.
https://unity.com/blog/engine-platform/unity-asset-bundles-tips-pitfalls
#assetbundle #tips
A helpful list of tips for working with asset bundles. It provides just enough detail to explain why each tip is useful, while keeping the post concise.
https://unity.com/blog/engine-platform/unity-asset-bundles-tips-pitfalls
#assetbundle #tips
Unity
Unity Asset Bundles tips and pitfalls
Learn about lesser-known aspects of Asset Bundles, with a focus on game performance, memory runtime usage, and general compatibility.
🔥5
I'm visiting Unite 2024 and wanted to share a high-level overview of the talks I attended and found interesting.
The first one was Making Prince of Persia: The Lost Crown.
The speakers presented several key ideas, including the importance of automated testing. They specifically mentioned automated performance testing using custom tools built on top of Unity’s provided systems. My favorite was a custom tool called the "performance map reporter," which shows frame times for each location. This tool helps quickly analyze how new content and code changes impact different areas of the game.
Here’s an overview of the key technologies and tools they use:
Unity 2021
A forked URP (Universal Render Pipeline)
Houdini for content design
Extensive use of addressables for streaming
Scriptable Build Pipeline
Bake visible vertices and cull invisible ones to save 40-60% in build size
Custom post-processing stack
Combine procedural geometry into 64k vertices chunks for optimized static batching, reducing draw calls from 2k to 500
For animations, they use Jobs Skinning on the CPU, which provides better performance for them compared to GPU compute skinning
Background animation is baked into textures and animated in the shader
Use of constant buffers instead of uniform constants
Ubershader instead of Shader Graph
Object pooling, avoiding the use of strings
If you're here at Unite too, I'd be happy to meet up. Hit me up in direct messages; my contact is in the channel denoscription.
The first one was Making Prince of Persia: The Lost Crown.
The speakers presented several key ideas, including the importance of automated testing. They specifically mentioned automated performance testing using custom tools built on top of Unity’s provided systems. My favorite was a custom tool called the "performance map reporter," which shows frame times for each location. This tool helps quickly analyze how new content and code changes impact different areas of the game.
Here’s an overview of the key technologies and tools they use:
Unity 2021
A forked URP (Universal Render Pipeline)
Houdini for content design
Extensive use of addressables for streaming
Scriptable Build Pipeline
Bake visible vertices and cull invisible ones to save 40-60% in build size
Custom post-processing stack
Combine procedural geometry into 64k vertices chunks for optimized static batching, reducing draw calls from 2k to 500
For animations, they use Jobs Skinning on the CPU, which provides better performance for them compared to GPU compute skinning
Background animation is baked into textures and animated in the shader
Use of constant buffers instead of uniform constants
Ubershader instead of Shader Graph
Object pooling, avoiding the use of strings
If you're here at Unite too, I'd be happy to meet up. Hit me up in direct messages; my contact is in the channel denoscription.
🔥12👍1
Another talk I attended yesterday was Accelerating the Creation of Your Competitive Multiplayer Game. It was a brief demonstration on how to set up rotating cubes in multiplayer using Unity services, so nothing particularly special.
The second part of the day consisted of private meetings with Unity about Vivox, Muse, and Asset Manager, discussing how these tools could solve our challenges.
Vivox has been around for many years, so nothing new there.
Muse: There are plans for integrating an AI agent into the editor, which could help with simple, repetitive, and tedious tasks.
Asset Manager: This tool bridges the gap in the production pipeline between artists and developers, providing a way to review and deliver new assets into Unity projects.
What is more there is already a video available about upcoming changes: https://www.youtube.com/watch?v=80Jw4orjvuk.
There are a lot of interesting changes ahead and some insights: DOTS is alive, rendering pipelines are being unified, UI Toolkit is expected to be greatly improved to be on par with uGUI in Unity 7, and if it goes well, then the old gui will be deprecated in 8. Overall, with the new CEO, I like the direction the company is taking and its interest in addressing the pain points of studios that use Unity. Of course, they do this as part of the services they're heavily promoting, but I still noticed a strong interest in our feedback.
The second part of the day consisted of private meetings with Unity about Vivox, Muse, and Asset Manager, discussing how these tools could solve our challenges.
Vivox has been around for many years, so nothing new there.
Muse: There are plans for integrating an AI agent into the editor, which could help with simple, repetitive, and tedious tasks.
Asset Manager: This tool bridges the gap in the production pipeline between artists and developers, providing a way to review and deliver new assets into Unity projects.
What is more there is already a video available about upcoming changes: https://www.youtube.com/watch?v=80Jw4orjvuk.
There are a lot of interesting changes ahead and some insights: DOTS is alive, rendering pipelines are being unified, UI Toolkit is expected to be greatly improved to be on par with uGUI in Unity 7, and if it goes well, then the old gui will be deprecated in 8. Overall, with the new CEO, I like the direction the company is taking and its interest in addressing the pain points of studios that use Unity. Of course, they do this as part of the services they're heavily promoting, but I still noticed a strong interest in our feedback.
🔥3👍1
The next talk was Boosting Your Game Performance with Profilers in Unity 6
This is a basic overview of how to use a profiler in Unity 6. There are some quality-of-life improvements, such as target frame rate settings and a simplified view to easily identify if the bottleneck is in CPU or GPU. However, if you're already familiar with the profiler, this talk can be skipped.
Takeaways:
It's important to know your performance budget before starting the game so you can identify when optimization is needed.
Additionally, manual profiling can be time-consuming, so automated profiling and data analysis can yield great results, especially if your game has strict performance limitations.
In the project I'm working on, we’ve already implemented automation for performance metrics. The next step is to extend the system to gather and analyze more detailed data, allowing us to more quickly identify where performance degradation happened
This is a basic overview of how to use a profiler in Unity 6. There are some quality-of-life improvements, such as target frame rate settings and a simplified view to easily identify if the bottleneck is in CPU or GPU. However, if you're already familiar with the profiler, this talk can be skipped.
Takeaways:
It's important to know your performance budget before starting the game so you can identify when optimization is needed.
Additionally, manual profiling can be time-consuming, so automated profiling and data analysis can yield great results, especially if your game has strict performance limitations.
In the project I'm working on, we’ve already implemented automation for performance metrics. The next step is to extend the system to gather and analyze more detailed data, allowing us to more quickly identify where performance degradation happened
👍7🔥1
Everyday Unity
Another talk I attended yesterday was Accelerating the Creation of Your Competitive Multiplayer Game. It was a brief demonstration on how to set up rotating cubes in multiplayer using Unity services, so nothing particularly special. The second part of the…
The Unity Engine Roadmap
The recording from Unite—great that they shared it so quickly.
Watch it here: https://m.youtube.com/watch?v=pq3QokizOTQ
Discussions: https://discussions.unity.com/t/unite-2024-roadmap/1519260
I'm particularly interested in the CoreCLR migration and the benefits it brings: https://discussions.unity.com/t/coreclr-and-net-modernization-unite-2024/1519272
I'm also hoping to see further improvements to ECS to reduce the steep learning curve and finally have built-in animation support.
#roadmap
The recording from Unite—great that they shared it so quickly.
Watch it here: https://m.youtube.com/watch?v=pq3QokizOTQ
Discussions: https://discussions.unity.com/t/unite-2024-roadmap/1519260
I'm particularly interested in the CoreCLR migration and the benefits it brings: https://discussions.unity.com/t/coreclr-and-net-modernization-unite-2024/1519272
I'm also hoping to see further improvements to ECS to reduce the steep learning curve and finally have built-in animation support.
#roadmap
YouTube
The Unity Engine Roadmap
Eager to learn more about upcoming Unity tech and features? In this video, Andrew Bowell and Will Goldstone will guide you through all the exciting updates coming to the Unity Editor and Engine. They'll also share valuable insights on where we’re headed beyond…
👍4🔥1
The second day started with Deep Impact: Optimizing Outer Wilds for a New Platform
The Unity team talked about how they helped port the game to Switch. The structure of the talk was less than ideal as they hardly shared any before-and-after comparisons using profilers, but it still contained a lot of useful tips. Since the game is now released on Switch, let’s assume everything worked well.
Main takeaways:
- Updated Unity to a newer version (questionable, but it helped them)
- Implemented a custom occlusion culling system tailored to their specific use case (this is a big takeaway, as Unity’s default systems are usually made to fit general needs, while a custom system can be designed to do exactly what's required, saving resources; of course, you have to profile and weigh the development and support costs against the potential benefits—no need to do it for things that aren't causing issues)
- Collider optimization: simpler mesh colliders and primitive colliders
- Combined small geometry in chunks of 64k vertices using jobs, and split large ones
- Swapped meshes for simpler ones when it wasn’t noticeable to the player
- Used LOD + HLOD
- Reduced vertex count without compromising quality
- Used fewer unique materials
- Enabled dynamic resolution
- Switched to Addressables instead of Resources
- Set asset loading priorities to load the most important assets first
- Replaced the standard shader
- Streamed textures and mipmaps
- Used burstable code
I’m also adding a picture with their takeaways. However, I slightly disagree: you should never optimize just because "it's almost always a good idea." Always profile first to ensure optimization is necessary, and then verify with the profiler after that the optimization was successful. Also, parallelization can bring great benefits, but not in all cases—synchronization can sometimes be even slower than the initial computation. That's why I love so much talks by Ian Dundore at Unite, because he also pushed that great idea.
So my conclusion would be:
Always profile, only you know your game and your particular case. Do optimizations according to that and verify every change.
The Unity team talked about how they helped port the game to Switch. The structure of the talk was less than ideal as they hardly shared any before-and-after comparisons using profilers, but it still contained a lot of useful tips. Since the game is now released on Switch, let’s assume everything worked well.
Main takeaways:
- Updated Unity to a newer version (questionable, but it helped them)
- Implemented a custom occlusion culling system tailored to their specific use case (this is a big takeaway, as Unity’s default systems are usually made to fit general needs, while a custom system can be designed to do exactly what's required, saving resources; of course, you have to profile and weigh the development and support costs against the potential benefits—no need to do it for things that aren't causing issues)
- Collider optimization: simpler mesh colliders and primitive colliders
- Combined small geometry in chunks of 64k vertices using jobs, and split large ones
- Swapped meshes for simpler ones when it wasn’t noticeable to the player
- Used LOD + HLOD
- Reduced vertex count without compromising quality
- Used fewer unique materials
- Enabled dynamic resolution
- Switched to Addressables instead of Resources
- Set asset loading priorities to load the most important assets first
- Replaced the standard shader
- Streamed textures and mipmaps
- Used burstable code
I’m also adding a picture with their takeaways. However, I slightly disagree: you should never optimize just because "it's almost always a good idea." Always profile first to ensure optimization is necessary, and then verify with the profiler after that the optimization was successful. Also, parallelization can bring great benefits, but not in all cases—synchronization can sometimes be even slower than the initial computation. That's why I love so much talks by Ian Dundore at Unite, because he also pushed that great idea.
So my conclusion would be:
Always profile, only you know your game and your particular case. Do optimizations according to that and verify every change.
👍9🔥2
The next talk at Unite 2024 worth mentioning was "Best Practices for Reducing ANRs on Android"
Highlights:
- The ANR timer may vary from vendor to vendor. The default is 5 seconds, while some Samsung devices have 10 seconds.
- ANR rate affects app discoverability.
- The main thread and Unity thread are two separate threads. Thread.Sleep() blocks the main thread, but not the Unity one, so animations can still run in the background.
- Unity published a test game to the store to track ANRs. An update to the 2021 version had the biggest impact, reducing the ANR rate from 3.5% to 0.4%. If you're still experiencing issues on older versions, consider updating. We saw a similar effect with a significant reduction after updating for our game, though our old rate wasn't that bad.
- They also broke down top ANRs. TL;DR:
- NativePollOnce: Can be ignored.
- PerformPause: Unity Android player syncs with the engine for more than 4 seconds.
- NativeUnitySendMessage: Too much workload on resume triggered from native callbacks.
- For debugging, use Android Strict Mode to identify performance issues and long I/O on the main thread.
- Check the ANR playbook on the Android Developers Portal.
- Update to Unity 6 or 2022.3.10 to reduce the ANR rate even further by 20-40%.
- Unity 6 can embed debug symbols into the app bundle to simplify the uploading process.
- Unity 6 has GameActivity, which supports better threading.
I am also adding a few slides from that talk that I find interesting and that speak for themselves
Highlights:
- The ANR timer may vary from vendor to vendor. The default is 5 seconds, while some Samsung devices have 10 seconds.
- ANR rate affects app discoverability.
- The main thread and Unity thread are two separate threads. Thread.Sleep() blocks the main thread, but not the Unity one, so animations can still run in the background.
- Unity published a test game to the store to track ANRs. An update to the 2021 version had the biggest impact, reducing the ANR rate from 3.5% to 0.4%. If you're still experiencing issues on older versions, consider updating. We saw a similar effect with a significant reduction after updating for our game, though our old rate wasn't that bad.
- They also broke down top ANRs. TL;DR:
- NativePollOnce: Can be ignored.
- PerformPause: Unity Android player syncs with the engine for more than 4 seconds.
- NativeUnitySendMessage: Too much workload on resume triggered from native callbacks.
- For debugging, use Android Strict Mode to identify performance issues and long I/O on the main thread.
- Check the ANR playbook on the Android Developers Portal.
- Update to Unity 6 or 2022.3.10 to reduce the ANR rate even further by 20-40%.
- Unity 6 can embed debug symbols into the app bundle to simplify the uploading process.
- Unity 6 has GameActivity, which supports better threading.
I am also adding a few slides from that talk that I find interesting and that speak for themselves
🔥10👍3