Skip to content

Blending

Johannes Deml edited this page Apr 18, 2020 · 8 revisions

Blending defines how the source (color input) and the destination (the current value in the color buffer) should be combined. Think of it as photoshop layers, but with less/strange blend modes. You can find a breakdown of different modes on the wiki page Blend Modes
UI Blending shader inspector with dropdown enums
UI Shader File

Usage

Shader "ConfigurableShaders/UI Blending"
{
	Properties
	{
		...

		[Enum(UnityEngine.Rendering.BlendMode)] _BlendSrc ("Blend mode Source", Int) = 5
		[Enum(UnityEngine.Rendering.BlendMode)] _BlendDst ("Blend mode Destination", Int) = 10
	}

	SubShader
	{
		Pass
		{
			Tags
			{ "Queue"="Transparent" "RenderType"="Transparent"}
			Blend [_BlendSrc] [_BlendDst]

			...
		}
	}
}

References

Blend Mode

Manual
Enum

public enum BlendMode
{
	Zero = 0,
	One = 1,
	DstColor = 2,
	SrcColor = 3,
	OneMinusDstColor = 4,
	SrcAlpha = 5,
	OneMinusSrcColor = 6,
	DstAlpha = 7,
	OneMinusDstAlpha = 8,
	SrcAlphaSaturate = 9,
	OneMinusSrcAlpha = 10
}

Blend Operation

(Mostly DX11.1 only)
Right now this is just as a reference in here and not used, since it seems to be quite graphics driver specific.
Manual
Enum

public enum BlendOp
{
	Add = 0,
	Subtract = 1,
	ReverseSubtract = 2,
	Min = 3,
	Max = 4,
	LogicalClear = 5,
	LogicalSet = 6,
	LogicalCopy = 7,
	LogicalCopyInverted = 8,
	LogicalNoop = 9,
	LogicalInvert = 10,
	LogicalAnd = 11,
	LogicalNand = 12,
	LogicalOr = 13,
	LogicalNor = 14,
	LogicalXor = 15,
	LogicalEquivalence = 16,
	LogicalAndReverse = 17,
	LogicalAndInverted = 18,
	LogicalOrReverse = 19,
	LogicalOrInverted = 20,
	Multiply = 21,
	Screen = 22,
	Overlay = 23,
	Darken = 24,
	Lighten = 25,
	ColorDodge = 26,
	ColorBurn = 27,
	HardLight = 28,
	SoftLight = 29,
	Difference = 30,
	Exclusion = 31,
	HSLHue = 32,
	HSLSaturation = 33,
	HSLColor = 34,
	HSLLuminosity = 35
}