Advanced Configuration and Key Rendering Concepts
Last updated
Last updated
If you are more of a visual learner there’s also a video tutorial:
This is the advanced configuration window:
Let’s go over each option to see what they do and how they can be used.
Alpha Blending Modes: Sets the blending of the shader output and will determine how the shader result is blended into the final frame. Since the Material will most likely be transparent we need to decide how the transparent parts will be blended with the rest of the frame. You can read more about it here:
https://docs.unity3d.com/Manual/SL-Blend.html
Additive Configuration: Tells the shader this is an additive configuration. This will make the global result of the shader grayscale be considered as alpha. This only makes sense when the Blending Mode is set to an Additive configuration.
Premultiply Alpha: This will multiply the shape result alpha into the color, effectively darkening the parts where the alpha is lower than 1.
Premultiply Color: This will multiply the shape result greyscale into the alpha, effectively making the result invisible where the color is black. The darker the result is the more invisible it will become.
Enable Z Write: When enabled the mesh we are rendering the material onto will write to the Z Buffer, meaning that other objects sorting will be affected by this mesh. This option is useful for meshes that aren’t very transparent and to make sure that all faces on meshes that overlap with itself get drawn in the correct order. For example we’ll want to use this on a Sphere so that the back faces are rendered after the front faces. You can read more about it here: https://docs.unity3d.com/Manual/SL-ZWrite.html
ZTest Mode: This will dictate how the material interacts with the values of the ZBuffer. We can choose when we want to render this material. By default the Test Mode is LEqual which means that we’ll render this material when the current depth value is less or equal to the one in the ZBuffer. This will guarantee the object is occluded by other materials that are closer to the camera. Materials that are in front and write to the ZBuffer.
We can change the ZTest to Always if we want this material to always be visible. You can read more about this here: https://docs.unity3d.com/Manual/SL-ZTest.html
Culling Mode: In graphics culling means discard and avoid rendering something. In this case culling refers to what faces are discarded based on its orientation. By default it is set to Off, which means that we don’t discard any faces, all faces will always be drawn. We can switch to Front or Back and discard the faces that are facing towards or away from the camera. This is great to avoid rendering part of a mesh, for example on a transparent sphere we may want to discard Back faces for a cleaner look. You can read more about it here: https://docs.unity3d.com/es/2018.4/Manual/SL-CullAndDepth.html
Color Write Mask: Allows you to choose what channels the Material will write on. It decides the shader output channels. You’ll probably never use this.
Random Seed: A number that will create variations on all texture scrolling, rotations and distortions. This is used to create variations for material instances you are reusing. You can break the repeating visual pattern with this. You can change this via script or through particle system custom data (read the Random Seed section of the documentation to learn how to do so).
Use Unity Fog: Makes the material be affected by Unity’s fog of the render pipeline you are using. Note that in HDRP fog is a post processing effect, so this toggle will have no effect.
Use Custom Time: Explained in the Custom Scaled Time section.
Enable GPU Instancing: Makes the Material be GPU instanced to save draw calls. For this to work the meshes must be the same in all instances too. You can read more about it here:
https://docs.unity3d.com/Manual/GPUInstancing.html
Render Queue: This will set the order in which materials are rendered. The higher the number the later it will render. This can be very important to guarantee that your materials get rendered in the order that works for your setup. You can choose how transparent objects are sorted in Project Settings, Graphics, Transparency Sort Mode and Axis, but in some cases we need to tweak this Render Queue value too to make sure we always get the render order we need.