Everyday Unity – Telegram
Everyday Unity
1.1K 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
How can I achieve simulated fluid surface deformation in a bottle? Like in the Half-Life: Alyx

https://gamedev.stackexchange.com/questions/182989/how-can-i-achieve-simulated-fluid-surface-deformation-in-a-bottle

#liquid #breakdown
Introducing the Editor Iteration Profiler - Unity Forum

High-level features summary
Monitor and capture profiling data from assembly reload, assembly compilation, and enter playmode.

Export captured data or Profiler data to a number of formats such as HTML, JSON (for chrome://tracing, which is a fast flame-graph style data visualizer), CSV, and Plaintext.

Export to a special type of HTML (HTML Performance Report), which attempts to minimize the number of clicks needed to get to the important areas of the profiled data, as well as aggregate possible areas of interest which could be optimized (e.g. OnEnable calls)

https://forum.unity.com/threads/introducing-the-editor-iteration-profiler.908390/

#eip #editor #iteration #profiler
The danger of async/await and .Result in one picture – TooSlowException

https://tooslowexception.com/the-danger-of-asyncawait-and-result-in-one-picture/

#async #await #deadlock
After long adventures and frustrations with UGUI, I can say with confidence that reading the source code helps better than official documentation. There are many "not a Bug, but rather a feature by design" things, won't be fixed in current HorizontalOrVerticalLayoutGroup

To avoid using ForceRebuildLayoutImmediate or/and some manual update workarounds, the following approach works well:

Both "child controls size" checkboxes must be enabled and "child force expand" disabled for all ILayoutController (Horizontal, Vertical, also for nested ones), then to control the dimension of the objects you simply use the LayoutElement component (min, pref, flex sizes). As a result, any dynamic content is correctly aligned, regardless of the activation/deactivation/addition/removal of neighbors.

Note 1: There is no need for ContentSizeFitter component for GameObjects, that are first level children of any LayoutGroup. The main thing is to correctly set the checkboxes, as described above. However ContentSizeFitter may be useful for top level container, or children of children that are not directly controlled by any LayoutGroup.

Note 2: Minimize LayoutGroup nesting when possible. Layout rebuild is very expensive. More info on topic:
Unite Europe 2017 - Squeezing Unity: Tips for raising performance.

https://forum.unity.com/threads/force-immediate-layout-update.372630/#post-5604151

#ugui #ui #layout #optimization #performance #force #rebuild
float val = smoothstep(_Radius + _Blend, _Radius, UVDistance) * _CellBuffer[i].z;

Smoothstep работает следующим образом: если переменная «UVDistance» больше, чем "_Radius + _Blend", то она возвращает 0. Если переменная меньше, чем "_Radius", то она возвращает 1. Между ними значения плавно интерполируются от 0 до 1.

#shader #smoothstep
C# Delegates with IoC Containers and Dependency Injection

An interesting article on how to replace one method interfaces with delegates, how to use them inside DI containers and unit tests.

https://christianfindlay.com/2020/05/15/c-delegates-with-ioc-containers-and-dependency-injection/

Repo with examples: https://github.com/MelbourneDeveloper/Samples/tree/master/MockDelegates/MockDelegates

#delegate #ioc #di
Span

tl;dr Use Span to work with ANY kind of memory in a safe and very efficient way. Simplify your APIs and use the full power of unmanaged memory!

Important notice: async and await are awesome C# features. They make our life easier by solving a lot of problems and hiding a lot complexity from us.

But whenever async & await are used, an AsyncMethodBuilder is created. The builder creates an asynchronous state machine. Which at some point of time might put the parameters of the method on the heap. This is why Span must not be an argument for an async method.
https://adamsitnik.com/Span/

#csharp #span #performance #gc
Using Unity’s ShaderVariantCollection

Typical use of ShaderVariantCollection is to record the shader variants used during a play session from the editor (under Graphics Settings), save them out as an asset, and add to the list of preloaded shaders (again in Graphics Settings). Additionally, you could call WarmUp on a ShaderVariantCollection object manually.

https://asmaloney.com/2020/01/code/using-unitys-shadervariantcollection/

#shadercollection #shader #collection
World space UVs & Triplanar Mapping

This post includes an introduction to using the Position node to sample textures rather than using mesh UV channels, which is also the basis of Triplanar mapping. It won’t be super in-depth but will provide some example graphs to (hopefully) help beginners understand how this could be used!

https://cyangamedev.wordpress.com/2020/01/28/worldspace-uvs-triplanar-mapping/

#shader #graph #worldspace #uv #triplanar