-
Notifications
You must be signed in to change notification settings - Fork 38
Rendering
With rendering you can define how an object is culled, if it writes to the depth buffer, what color channels it can write to the color buffer and more Unity Manual.
Shader "ConfigurableShaders/Rendering"
{
Properties
{
...
[Header(Rendering)]
_Offset("Offset", float) = 0
[Enum(UnityEngine.Rendering.CullMode)] _Culling ("Cull Mode", Int) = 2
[Enum(Off,0,On,1)] _ZWrite("ZWrite", Int) = 1
[Enum(UnityEngine.Rendering.CompareFunction)] _ZTest ("ZTest", Int) = 4
[Enum(None,0,Alpha,1,Red,8,Green,4,Blue,2,RGB,14,RGBA,15)] _ColorMask("Color Mask", Int) = 15
}
SubShader
{
Pass
{
Tags { "RenderType"="Opaque" "Queue" = "Geometry" }
Cull [_Culling]
Offset [_Offset], [_Offset]
ZWrite [_ZWrite]
ZTest [_ZTest]
ColorMask [_ColorMask]
...
}
}
}
Changes the depth of a material relative to the camera. This way you can pull (negative) or push (positive) objects to the camera without changing their positions.
Manual
Decides which sides of a mesh a rendered.
Manual
Enum
public enum CullMode
{
Off = 0,
Front = 1,
Back = 2
}
Toggles if an object should write to the depth buffer.
Manual
private enum ZWrite
{
Off = 0,
On = 1
}
Defines what is being written in the color buffer. You can for example render nothing in the color buffer, but enable z-writing to just render the shadow of an object without rendering the object to the color buffer. Be aware, that optimizing shaders to write to RGB instead of RGBA can lead to performance degradation (also Unity Manual).
Manual
Enum
public enum ColorWriteMask
{
None = 0,
Alpha = 1,
Blue = 2,
Green = 4,
Red = 8,
All = 15
}
Defines the testing operation against the depth buffer to decide if an object should be rendered.
Manual
Enum
public enum CompareFunction
{
Disabled = 0,
Never = 1,
Less = 2,
Equal = 3,
LessEqual = 4,
Greater = 5,
NotEqual = 6,
GreaterEqual = 7,
Always = 8
}