赞
踩
语法
Blend Off: 关闭混合(这是默认值)
Blend SrcFactor DstFactor: 配置并启用混合。生成的颜色将乘以 SrcFactor。屏幕上的已有颜色乘以 DstFactor,然后将这两个值相加。
Blend SrcFactor DstFactor, SrcFactorA DstFactorA: 同上,但使用不同系数来混合 Alpha 通道。
BlendOp OP:不将混合颜色相加,而是对它们执行不同的操作。
BlendOp OpColor, OpAlpha:同上,但是对颜色 (RGB) 通道和 Alpha (A) 通道使用不同的混合操作。
此外,您还可以设置上层渲染目标混合模式。当使用多渲染目标 (MRT) 渲染时,上面的常规语法 将为所有渲染目标设置相同的混合模式。以下语法可以为各个渲染目标设置不同的混合模式,其中 N
是渲染目标索引(0 到 7)。此功能适用于大多数现代 API/GPU(DX11/12、GLCore、Metal 和 PS4):
Blend N SrcFactor DstFactor
Blend N SrcFactor DstFactor, SrcFactorA DstFactorA
BlendOp N Op
BlendOp N OpColor, OpAlpha
Blend SrcAlpha OneMinusSrcAlpha | 传统透明度 |
Blend One OneMinusSrcAlpha | 预乘透明度 |
Blend One One | 加法 |
Blend OneMinusDstColor One | 软加法 |
Blend DstColor Zero | 乘法 |
Blend DstColor SrcColor | 2x 乘法 |
---|
Shader常用枚举类型
- Shader "MyShaders/EnumTest"
- {
- Properties
- {
- _MainTex ("Texture", 2D) = "white" {}
-
- [Header(Option)]
- [Space(5)]
- [Enum(UnityEngine.Rendering.BlendOp)] _BlendOp("BlendOp", Float) = 0
- [Enum(UnityEngine.Rendering.BlendMode)] _SrcMode("SrcMode", Float) = 1
- [Enum(UnityEngine.Rendering.BlendMode)] _DstMode("DstMode", Float) = 0
- [Enum(UnityEngine.Rendering.CullMode)] _CullMode("CullMode", Float) = 0
- [Enum(UnityEngine.Rendering.CompareFunction)] _ZTestMode("ZTestMode", Float) = 0
- [Enum(UnityEngine.Rendering.ColoWriteMask)] _ColorMask("ColorMask", Float) = 15
- //控制深度写入的比较特殊,可以用 Toggle 或者自定义的 Enum
- [Enum(off, 0, On, 1)] _ZWriteMode("ZWriteMode", Float) = 1
-
-
- [Header(Stencil)]
- [Enum(UnityEngine.Rendering.CompareFunction)] _StencilComp ("Stencil Comparison", Float) = 8
- [IntRange] _StencilWriteMask ("Stencil Write Mask", Range(0,255)) = 255
- [IntRange] _StencilReadMask ("Stencil Read Mask", Range(0,255)) = 255
- [IntRange] _Stencil ("Stencil ID", Range(0,255)) = 0
- [Enum(UnityEngine.Rendering.StencilOp)] _StencilPass ("Stencil Pass", Float) = 0
- [Enum(UnityEngine.Rendering.StencilOp)] _StencilFail ("Stencil Fail", Float) = 0
- [Enum(UnityEngine.Rendering.StencilOp)] _StencilZFail ("Stencil ZFail", Float) = 0
-
- }
-
- SubShader
- {
- Tags { "RenderType"="Opaque" }
- LOD 100
-
- Pass
- {
- BlendOp [_BlendOp]
- Blend [_SrcMode][_DstMode]
- ZTest [_ZTestMode]
- ZWrite [_ZWriteMode]
- Cull [_CullMode]
- ColorMask [_ColorMask]
-
- Ref [_Stencil]
- Comp [_StencilComp]
- ReadMask [_StencilReadMask]
- WriteMask [_StencilWriteMask]
- Pass [_StencilPass]
- Fail [_StencilFail]
- ZFail [_StencilZFail]
-
- ......
- }
- }
-
- Fallback Off
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。