Everyday Unity – Telegram
Everyday Unity
1.11K subscribers
157 photos
59 videos
42 files
2.36K links
A game developer and tech lead in a top grossing company posting Unity, programming, and gamedev related stuff that I find interesting
Website: https://gamedev.center

Most used tags are:
#performance
#shader
#interview

Author: @alexmtr
Download Telegram
List Add is way slower (almost 3 times) in net9.0 preview 3 than with net8.0
dotnet/runtime

This is an interesting discussion and investigation into why performance significantly drops on one of the platforms after optimization in net9.0. I always love reading how engineers solve complex problems. It's fascinating to see what changes under the hood can cause such big differences in performance and how they track down the issue.

https://github.com/dotnet/runtime/issues/101437

#performance
👍6🔥2
10 Unity Audio Optimisation Tips

There are a few posts covering audio optimization available. While it's true that this topic is usually overlooked since assets, noscripts, and rendering optimizations yield more significant performance gains, it's great to have such posts bookmarked, as they list a lot of high-quality tips. Moreover, now you know that sounds might also cripple performance.

https://gamedevbeginner.com/unity-audio-optimisation-tips/

#audio #optimization
👍4🔥2
Unity Shader Variants Optimisation and Troubleshooting

When using shaders from the asset store it might become challenging to control shader variants leading to increased build size and time to prewarm it. It's a good post to bookmark and get back to it during your project check ups.

https://dev.to/attiliohimeki/unity-shader-variants-optimisation-and-troubleshooting-28ci

#optimization #shader #shadervariants
👍5🔥5
CPU performance optimization guide - part 1 - CPU performance optimization guide

A great example of how to profile CPU performance at the lowest level. From my experience, you very rarely need to dive this deep in your daily work. However, if a method is on the hot path and invoked many times per frame, and all low-hanging fruit optimizations are done, then you definitely need this post bookmarked for future reference

https://gpuopen.com/learn/cpu-performance-guide/cpu-performance-guide-part1/

#profiling #cpu
🔥4👍2
Introducing our new e-book: Unity’s Data-Oriented Technology Stack (DOTS) for advanced developers

Here's an overview of DOTS. Many people think DOTS is just ECS, but there are multiple packages and tools under this umbrella.

Of course, ECS is a big part of DOTS, which is why half of the book is about it, but you might be using DOTS without even knowing it, as some packages are jobified, and use burst/native collections under the hood.

https://blog.unity.com/engine-platform/new-ebook-understanding-unity-dots

#dots #book
👍6🔥2
ECS Programming Patterns from Official Packages

A list of advice how to perform common operations in unity.entities with examples from the entities package internals.
I also have personal notes with tips from the Hot Path Show that I found interesting, and they are pretty similar to what is shared in that post, e.g. tricks how to create new entities with the set of components without allocating a managed array of types and without adding components one by one which is very inefficient in the archetypes ECS implementation. This show is usually around 2 hours so it takes time to gather all these tips and sit through the whole video, so not everyone watches it completely. Put a 💯 reaction if you'd like me to publish it in a similar form to the post with top tips from Unite.

https://gametorrahod.com/ecs-patterns/

#dots #ecs
👍6💯5🔥1
.NET 9: Array vs Dictionary lookup performance in C#

I wanted to revisit my old post about the performance of lookup operations in dictionaries and arrays to see how all the performance improvements in newer .NET versions affect old benchmarks. TL;DR: The benchmark shows that dictionary lookups are around 2 times faster in .NET 9 compared to Framework 4.8. This means there is now less sense to use arrays to speed up lookups in small collections.

This does not apply to Unity yet, though they promise CoreCLR integration, so it might become useful someday

https://gamedev.center/net-9-array-vs-dictionary-lookup-performance-in-c/

#performance #lookup
👍6🔥1
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
👍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
🔥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:
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
A genshin-like post processing render feature, based on URP.

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
🔥4👍3
Which collection interface to use?

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
🔥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
🔥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
🔥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.
🔥12👍1
🔥13
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.
🔥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
👍7🔥1