Controlling Unity's Rendering Order - Why and How
A detailed post packed with references to other posts, documentation, and even source code. Digging into source code is a crucial skill for software engineers.
I especially love the conclusion—something I’ve discussed extensively in my posts from Unite:
#rendering #sorting
A detailed post packed with references to other posts, documentation, and even source code. Digging into source code is a crucial skill for software engineers.
I especially love the conclusion—something I’ve discussed extensively in my posts from Unite:
In closing, I’ll repeat that if your interest in this topic is to improve performance, make sure to profile before you decide that changing the rendering order is the right optimization to implement!https://medium.com/toca-boca-tech-blog/controlling-unitys-rendering-order-why-and-how-3c2bb1da8e78
#rendering #sorting
Medium
Controlling Unity’s rendering order — why and how
Deep dive into Unity’s rendering order of objects with a focus on URP in Unity 2022.3 and Unity 6.
🔥6👍2
This media is not supported in your browser
VIEW IN TELEGRAM
Chromatic-Distortion-Sphere: A chromatic distortion sphere shader.
https://github.com/MirzaBeig/Chromatic-Distortion-Sphere
#urp #orb #shader
https://github.com/MirzaBeig/Chromatic-Distortion-Sphere
#urp #orb #shader
🔥14👍4
Optimizing Texture Memory (VRAM) & Size
https://www.poiyomi.com/blog/2022-10-17-texture-optimization
#optimization #vram
TL;DR
MEASURE TEXTURE VRAM USAGE AND DOWNLOAD SIZE using lox9973's Assetbundle Stat tool and Thry's VRAM estimator.
Reduce Resolution in the texture import settings! Not every texture needs to be 2k or 4k.
Don't disable mipmaps - Your materials will look and run better with them on!
Crunch doesn't change VRAM usage but can reduce download size. Not a magic bullet!
For Normal Maps, Use RG Compressed BC5 (From Platform overrides menu1). Normal Quality (DXT5nm) and High Quality (BC7) use the same VRAM but look worse.
For textures with Alpha, Use High Quality (BC7). Normal Quality (DXT5) uses the same VRAM but looks worse.
Don't use JPG (or other lossy formats) to store your source textures! Lower quality, with no benefit to VRAM/Download Size
https://www.poiyomi.com/blog/2022-10-17-texture-optimization
#optimization #vram
Poiyomi
Optimizing Texture Memory (VRAM) & Size | Poiyomi Shaders
Tips and guidelines for optimizing texture memory (VRAM) and filesize for VRChat creation.
🔥7👍2
Everyday Unity
The final talk of the conference, and the one I was most excited about: "Performance Tips & Tricks from a Unity Consultant." I wanted to attend this session because one of my favorite talks ever at Unite was on the same topic by Ian Dundore. I learned a lot…
Performance tips and tricks from a Unity consultant
Amazing how fast recordings from Unite are available. Here is one of my favorite talks. Others I covered above and many more worth watching are all available now too.
https://youtu.be/CmD8MVGkDxQ?si=8JUVHTwHTqiRIT3l
#performance #optimization
Amazing how fast recordings from Unite are available. Here is one of my favorite talks. Others I covered above and many more worth watching are all available now too.
https://youtu.be/CmD8MVGkDxQ?si=8JUVHTwHTqiRIT3l
#performance #optimization
YouTube
Performance tips & tricks from a Unity consultant | Unite 2024
In this video, you'll learn proven best practices from Nicolas Borromeo, a highly experienced consultant and author of the Hands-On Unity book. He’ll cover some of the most consequential performance issues he sees regularly and tell you how to avoid or resolve…
👍7🔥2
Connecting the DOTS: Let’s make a game with Entities | Unite 2024
If you still haven't tried Entities, this talk gives you a good overview of what it is, how to work with it, and what drawbacks it has.
https://www.youtube.com/watch?v=gqJlQJn0N2g
Repo: https://github.com/Unity-Technologies/Unite24ConnectingTheDOTS
The speaker, Daniel, is also a regular guest on the Hot Path Show, which I recommend watching if you already have any experience with Entities and would like to dive into the details.
#dots #entities
If you still haven't tried Entities, this talk gives you a good overview of what it is, how to work with it, and what drawbacks it has.
https://www.youtube.com/watch?v=gqJlQJn0N2g
Repo: https://github.com/Unity-Technologies/Unite24ConnectingTheDOTS
The speaker, Daniel, is also a regular guest on the Hot Path Show, which I recommend watching if you already have any experience with Entities and would like to dive into the details.
#dots #entities
YouTube
Connecting the DOTS: Let’s make a game with Entities | Unite 2024
From ECS fundamentals to Entities 1.3, we give you a bird’s-eye view of the API landscape today in this tutorial on Unity’s Entity Component System (ECS). This video will empower you to explore the API and build the confidence to continue your ECS development…
👍8🔥3
Everyday Unity
An unusual post for this channel and a note on why I haven't posted in a while. I had the pleasure of giving a talk at Digital Dragons about "The Controllers Tree," the architectural framework developed by some of the top-tier engineers at our company. I…
Architecture Behind Our Most Popular Games
The recording of my talk from May is finally available. It focuses on how multiple successful large-scale mobile games are developed and supported over an extended lifespan. I have already received feedback, and I realize I should have provided more detail on specific areas, such as the role of each component. If you'd like a post with a deeper dive into this architecture, drop a 🔥 reaction. Feel free to ask questions so I can cover them in that post.
https://www.youtube.com/watch?v=-TlQAm8IZp4
#architecture #mvc #hmvc
The recording of my talk from May is finally available. It focuses on how multiple successful large-scale mobile games are developed and supported over an extended lifespan. I have already received feedback, and I realize I should have provided more detail on specific areas, such as the role of each component. If you'd like a post with a deeper dive into this architecture, drop a 🔥 reaction. Feel free to ask questions so I can cover them in that post.
https://www.youtube.com/watch?v=-TlQAm8IZp4
#architecture #mvc #hmvc
YouTube
Alexey Merzlikin - Architecture Behind Our Most Popular Unity Games
Are you curious about how some of the most successful Unity games are built? Do you want to learn the best practices and tips for designing scalable and maintainable game architectures? We are going to talk about the Controllers Tree architecture that is…
🔥30👍2
Classic 3D videogame shadow techniques
https://30fps.net/pages/videogame-shadows/
I found this denoscription of shadow techniques very interesting. It's a good starting point for learning shadowing by trying to implement some of these techniques. For example, I learned a lot about shadow cascades by implementing it while following an excellent tutorial on a noscriptable render pipeline: https://news.1rj.ru/str/everydayUnity/2276.
Cascades are briefly mentioned in this post as a technique used in modern games. However, it does not cover the radiance cascade technique, which you can read more about here: https://news.1rj.ru/str/everydayUnity/2423.
#rendering #shadow
https://30fps.net/pages/videogame-shadows/
I found this denoscription of shadow techniques very interesting. It's a good starting point for learning shadowing by trying to implement some of these techniques. For example, I learned a lot about shadow cascades by implementing it while following an excellent tutorial on a noscriptable render pipeline: https://news.1rj.ru/str/everydayUnity/2276.
Cascades are briefly mentioned in this post as a technique used in modern games. However, it does not cover the radiance cascade technique, which you can read more about here: https://news.1rj.ru/str/everydayUnity/2423.
#rendering #shadow
Telegram
Everyday Unity
Custom SRP 1.0.0
How to upgrade the old SRP tutorial to Unity 2022. Some of these fixes I had to do myself when I followed this series a long time ago but using Unity 2021. It's great that Jasper supports the series and shared the update.
I personally recommend…
How to upgrade the old SRP tutorial to Unity 2022. Some of these fixes I had to do myself when I followed this series a long time ago but using Unity 2021. It's great that Jasper supports the series and shared the update.
I personally recommend…
👍8🔥2
Unity 6 "empty" web build file sizes
How to reduce the size of web builds:
https://gist.github.com/aras-p/740c2d4f9977ce92b7de72b1394dd365
It’s worth noting that many of these recommendations are included in the updated Unity 6 documentation. However, it’s convenient to bookmark this post to have all the advice on one page.
https://docs.unity3d.com/Manual/web-optimization.html
https://docs.unity3d.com/Manual/web-optimization-mobile.html
#web #buildsize
How to reduce the size of web builds:
https://gist.github.com/aras-p/740c2d4f9977ce92b7de72b1394dd365
It’s worth noting that many of these recommendations are included in the updated Unity 6 documentation. However, it’s convenient to bookmark this post to have all the advice on one page.
https://docs.unity3d.com/Manual/web-optimization.html
https://docs.unity3d.com/Manual/web-optimization-mobile.html
#web #buildsize
Gist
Unity 6 "empty" web build file sizes
Unity 6 "empty" web build file sizes. GitHub Gist: instantly share code, notes, and snippets.
🔥14👍2
Memory Mastery: Comparing Unity and .NET Garbage Collection
Another frequently raised question in interviews involves the differences between Unity and .NET garbage collection, and this post provides a clear answer without diving way too deep into the topic. Additionally, it offers general advice on avoiding excessive garbage generation, which can help reduce potential spikes caused by garbage collection.
https://medium.com/my-games-company/memory-mastery-comparing-unity-and-net-garbage-collection-4c23e693d3a5
#gc #interview
Another frequently raised question in interviews involves the differences between Unity and .NET garbage collection, and this post provides a clear answer without diving way too deep into the topic. Additionally, it offers general advice on avoiding excessive garbage generation, which can help reduce potential spikes caused by garbage collection.
https://medium.com/my-games-company/memory-mastery-comparing-unity-and-net-garbage-collection-4c23e693d3a5
#gc #interview
Medium
Memory Mastery: Comparing Unity and .NET Garbage Collection
Learn the differences between garbage collection in Unity and .NET, then go deep into the specifics of memory management in Unity.
👍9🔥4
Optimize your game performance for mobile, XR, and the web in Unity (Unity 6 edition)
https://unity.com/resources/mobile-xr-web-game-performance-optimization-unity-6
A solid book with many performance tips — some are well-known, while others are new, especially those shared at the latest Unite conference regarding Unity 6. I'd like to point out the absence of the well-known tip about avoiding the animator's usage on the UI. It is claimed to have been fixed for quite some time already, even though it still has some performance implications (smaller tho): https://discussions.unity.com/t/animators-and-dirtying-ui/769821/16
#optimization #tips
https://unity.com/resources/mobile-xr-web-game-performance-optimization-unity-6
A solid book with many performance tips — some are well-known, while others are new, especially those shared at the latest Unite conference regarding Unity 6. I'd like to point out the absence of the well-known tip about avoiding the animator's usage on the UI. It is claimed to have been fixed for quite some time already, even though it still has some performance implications (smaller tho): https://discussions.unity.com/t/animators-and-dirtying-ui/769821/16
#optimization #tips
Unity
Optimize performance for mobile, XR & web games (Unity 6 edition) | Unity
This guide brings together all the best and latest mobile, XR, and Unity Web performance optimization tips for Unity 6.
👍6🔥5
Fake it ‘til You Make It: Faking Extended Draw Distance in Mobile Games
Developers of Block City Wars demonstrate a clever use of shaders and fog effects to fake distant objects, optimizing draw distance for better performance. In this game, players must be able to see the entire map from any position to avoid being at a disadvantage. Simply increasing the far clip plane isn’t feasible, as it raises the number of triangles passing through all culling stages. This means more objects undergo bounding box checks on the CPU and more fragments are processed on the GPU.
I encountered a similar issue while developing a car simulator set in an open city. We struggled because of the need to support multiple monitors, requiring separate cameras for forward, left, and right views, along with additional cameras for rearview mirrors.
Why not use a single camera with an ultra-wide FOV for forward, left, and right views? The answer is straightforward: to render 180 degrees, the FOV must be extremely high, resulting in unacceptable image quality due to severe distortions. This approach looked particularly bad on multiple monitors.
Instead, we opted for a combination of LODs, impostors, fog, and shorter draw distances for the left, right, and back cameras. Since players primarily focus on the forward view, this compromise worked well. And what was easier was that we didn’t need to render important objects all the time, as it was not needed for players to orient themselves using them.
https://www.gamedeveloper.com/production/fake-it-til-you-make-it-faking-extended-draw-distance-in-mobile-games
However, it’s unclear whether the solution includes LOD support for scaled-down meshes. If the distance is faked by scaling objects, then the high-poly version should be rendered, leading to high vertex density. This introduces performance challenges, as detailed in previous posts:
Vertex density
https://news.1rj.ru/str/everydayUnity/1634
Tips from the latest Unite https://news.1rj.ru/str/everydayUnity/2441
#rendering #culling
Developers of Block City Wars demonstrate a clever use of shaders and fog effects to fake distant objects, optimizing draw distance for better performance. In this game, players must be able to see the entire map from any position to avoid being at a disadvantage. Simply increasing the far clip plane isn’t feasible, as it raises the number of triangles passing through all culling stages. This means more objects undergo bounding box checks on the CPU and more fragments are processed on the GPU.
I encountered a similar issue while developing a car simulator set in an open city. We struggled because of the need to support multiple monitors, requiring separate cameras for forward, left, and right views, along with additional cameras for rearview mirrors.
Why not use a single camera with an ultra-wide FOV for forward, left, and right views? The answer is straightforward: to render 180 degrees, the FOV must be extremely high, resulting in unacceptable image quality due to severe distortions. This approach looked particularly bad on multiple monitors.
Instead, we opted for a combination of LODs, impostors, fog, and shorter draw distances for the left, right, and back cameras. Since players primarily focus on the forward view, this compromise worked well. And what was easier was that we didn’t need to render important objects all the time, as it was not needed for players to orient themselves using them.
https://www.gamedeveloper.com/production/fake-it-til-you-make-it-faking-extended-draw-distance-in-mobile-games
However, it’s unclear whether the solution includes LOD support for scaled-down meshes. If the distance is faked by scaling objects, then the high-poly version should be rendered, leading to high vertex density. This introduces performance challenges, as detailed in previous posts:
Vertex density
https://news.1rj.ru/str/everydayUnity/1634
Tips from the latest Unite https://news.1rj.ru/str/everydayUnity/2441
#rendering #culling
Game Developer
Fake it til’ you make it - faking extended draw distance in mobile games
How Block City Wars developers use shaders and fog effects to fake distant objects, optimizing draw distance for better performance.
👍7🔥4
Unity’s TransformAccessArray — Internals and Best Practices
The TransformAccessArray in Unity is a specialized structure used for efficiently managing and accessing multiple Transform components, particularly in the context of jobs. It is designed to work with the Job System to allow parallel processing of Transform operations while minimizing overhead.
I tested this in my pet project a long time ago, and the difference was very noticeable, almost eliminating the cost of moving a large number of transforms every frame. While the API is pretty clean, working with jobs still adds cognitive load, so my advice is to always profile your code. Only if you see that transforms are the bottleneck should you switch from simple transform manipulations to using TransformAccessArray.
Tips from the Article:
- Use Burst.
- When a job only needs to read transforms (i.e., not write), use
- Break deep transform hierarchies into multiple transform roots whenever possible. This tip was also mentioned at Unite 2018 and in my post summarizing all performance tips from Unite.
- Review the
- Prefer local space transform data like
- Reuse TransformAccessArray instances between frames; avoid recreating them unnecessarily.
- To remove a transform from the array, use
- Avoid using transforms in a TransformAccessArray to store intermediary data between jobs. Transform access in jobs is slower compared to other alternatives.
https://medium.com/toca-boca-tech-blog/unitys-transformaccessarray-internals-and-best-practices-2923546e0b41
#optimization #performance #transform
The TransformAccessArray in Unity is a specialized structure used for efficiently managing and accessing multiple Transform components, particularly in the context of jobs. It is designed to work with the Job System to allow parallel processing of Transform operations while minimizing overhead.
I tested this in my pet project a long time ago, and the difference was very noticeable, almost eliminating the cost of moving a large number of transforms every frame. While the API is pretty clean, working with jobs still adds cognitive load, so my advice is to always profile your code. Only if you see that transforms are the bottleneck should you switch from simple transform manipulations to using TransformAccessArray.
Tips from the Article:
- Use Burst.
- When a job only needs to read transforms (i.e., not write), use
IJobParallelForTransform.ScheduleReadOnly.- Break deep transform hierarchies into multiple transform roots whenever possible. This tip was also mentioned at Unite 2018 and in my post summarizing all performance tips from Unite.
- Review the
desiredJobCount and innerloopBatchCount parameters. Aim for small enough values to keep all workers busy, but large enough to minimize the overhead of workers grabbing or stealing tasks too frequently.- Prefer local space transform data like
localPosition and GetLocalPositionAndRotation over world space data like position and localToWorldMatrix when possible.- Reuse TransformAccessArray instances between frames; avoid recreating them unnecessarily.
- To remove a transform from the array, use
TransformAccessArray.RemoveAtSwapBack instead of recreating the array. This is a general best practice for removing elements in hot paths.- Avoid using transforms in a TransformAccessArray to store intermediary data between jobs. Transform access in jobs is slower compared to other alternatives.
https://medium.com/toca-boca-tech-blog/unitys-transformaccessarray-internals-and-best-practices-2923546e0b41
#optimization #performance #transform
Medium
Unity’s TransformAccessArray — internals and best practices
Understand Unity’s TransformAccessArray in depth with examples, and learn performance best practices for transforms and the job system.
🔥10👍2
UI Toolkit with Unity ECS - The Hot Path Show Ep. 3
In a free time I develop a pet project using Entities and
I've already mentioned The Hot Path Show here a few times promising to share my notes with insights from it. Even thought the videos are pretty long I find them very valuable as it always features the developer of Entities or the developer of a game made with DOTS and they share a lot of tips that might not be so obvious from the docs.
Here are my notes from the episode 3:
- ECB is slow, replaying the commands has a performance hit
- Dont use ECB all the time, default to use the main thread.
- If you see that parallelization is needed, then try to use native collections to gather entities and then perform the modification after the job
- Only if all the above is not working then use ECB
- Enableable components do not cause a not structural change
- EntityManager + EntityQuery is fast
- This is an example of fast entities destroying, since all of them in a one chunk
- Dont use EntityQueryBuilder as its not burstable
I'd recommend you to check the show yourself, Since I am somewhat familiar with DOTS and Entities already, I might have missed some more basic advice. Would be great if anyone watching that shares the missed tips in the comments.
Drop a 🔥if you want more of similar recaps of videos and conference talks.
https://www.youtube.com/watch?v=bXR7EYacusI
#ecs #dots
In a free time I develop a pet project using Entities and
I've already mentioned The Hot Path Show here a few times promising to share my notes with insights from it. Even thought the videos are pretty long I find them very valuable as it always features the developer of Entities or the developer of a game made with DOTS and they share a lot of tips that might not be so obvious from the docs.
Here are my notes from the episode 3:
- ECB is slow, replaying the commands has a performance hit
- Dont use ECB all the time, default to use the main thread.
- If you see that parallelization is needed, then try to use native collections to gather entities and then perform the modification after the job
- Only if all the above is not working then use ECB
- Enableable components do not cause a not structural change
- EntityManager + EntityQuery is fast
- This is an example of fast entities destroying, since all of them in a one chunk
state.EntityManager.DestroyEntity(SystemAPI.QueryBuilder().WithAll<T>().Build());
- Dont use EntityQueryBuilder as its not burstable
I'd recommend you to check the show yourself, Since I am somewhat familiar with DOTS and Entities already, I might have missed some more basic advice. Would be great if anyone watching that shares the missed tips in the comments.
Drop a 🔥if you want more of similar recaps of videos and conference talks.
https://www.youtube.com/watch?v=bXR7EYacusI
#ecs #dots
YouTube
UI Toolkit with Unity ECS - The Hot Path Show Ep. 3
The Hot Path Show is a weekly livestream focused on showcasing different ways to solve problems in game development through data-oriented design.
Support The Hot Path Show and get extra bonuses: https://patreon.com/TurboMakesGames
Episode Sample Project…
Support The Hot Path Show and get extra bonuses: https://patreon.com/TurboMakesGames
Episode Sample Project…
🔥7👍4
Twenty Five Slicer
A Unity package designed for more advanced sprite slicing, enabling a "25-slice" approach. It divides a sprite into a 5x5 grid, allowing precise scaling and manipulation of individual regions while preserving key areas.
9 slices: Non-stretchable areas.
6 slices: Stretch horizontally only.
6 slices: Stretch vertically only.
4 slices: Stretch in both directions.
This allows for far more detailed slicing. Where traditional 9-slice images often require stacking multiple image layers to achieve complex UI shapes (e.g., speech bubbles, boxes with icons or separators at the center), a 25-slice configuration can often handle these scenarios with just a single image.
https://github.com/kwan3854/TwentyFiveSlicer
#sprite #slicer
A Unity package designed for more advanced sprite slicing, enabling a "25-slice" approach. It divides a sprite into a 5x5 grid, allowing precise scaling and manipulation of individual regions while preserving key areas.
9 slices: Non-stretchable areas.
6 slices: Stretch horizontally only.
6 slices: Stretch vertically only.
4 slices: Stretch in both directions.
This allows for far more detailed slicing. Where traditional 9-slice images often require stacking multiple image layers to achieve complex UI shapes (e.g., speech bubbles, boxes with icons or separators at the center), a 25-slice configuration can often handle these scenarios with just a single image.
https://github.com/kwan3854/TwentyFiveSlicer
#sprite #slicer
GitHub
GitHub - kwan3854/TwentyFiveSlicer: A Unity package for handling advanced 25-slice sprites.
A Unity package for handling advanced 25-slice sprites. - kwan3854/TwentyFiveSlicer
🔥13👍6
ArtificeToolkit: A Unity toolkit that allows easy editor customization with simple C# attributes.
A pretty new open-source package that can help replace Odin Inspector. Normally, extending Unity's editor requires specialized knowledge of IMGUI or UI Toolkit libraries and maintaining separate files for each extension. ArtificeToolkit simplifies this by letting you use custom attributes directly in the source code to alter property appearances in the editor.
It might not cover all of Odin's functionality, but based on the denoscription, it includes everything I used in my project, so it looks good to me. I haven't tested it personally, though.
It's implemented using Unity's new VisualElements framework.
Also not mentioned in the documentation, but you can create Editor Windows as if they were simple components by inheriting the ArtificeEditorWindow class and calling through a menu item the GetWindow
https://github.com/AbZorbaGames/artificetoolkit
#editor #inspector
A pretty new open-source package that can help replace Odin Inspector. Normally, extending Unity's editor requires specialized knowledge of IMGUI or UI Toolkit libraries and maintaining separate files for each extension. ArtificeToolkit simplifies this by letting you use custom attributes directly in the source code to alter property appearances in the editor.
It might not cover all of Odin's functionality, but based on the denoscription, it includes everything I used in my project, so it looks good to me. I haven't tested it personally, though.
It's implemented using Unity's new VisualElements framework.
Also not mentioned in the documentation, but you can create Editor Windows as if they were simple components by inheriting the ArtificeEditorWindow class and calling through a menu item the GetWindow
https://github.com/AbZorbaGames/artificetoolkit
#editor #inspector
👍13🔥6💩1