浏览代码

Add Transparent (premultiply alpha) blend mode

/main
Matt Dean 7 年前
当前提交
b73b2432
共有 4 个文件被更改,包括 16 次插入0 次删除
  1. 3
      com.unity.shadergraph/Editor/Data/LightweightPipeline/LightWeightPBRSubShader.cs
  2. 3
      com.unity.shadergraph/Editor/Data/LightweightPipeline/LightWeightUnlitSubShader.cs
  3. 1
      com.unity.shadergraph/Editor/Data/MasterNodes/AlphaMode.cs
  4. 9
      com.unity.shadergraph/Editor/Data/Util/ShaderGenerator.cs

3
com.unity.shadergraph/Editor/Data/LightweightPipeline/LightWeightPBRSubShader.cs


if (masterNode.IsSlotConnected(PBRMasterNode.AlphaThresholdSlotId))
defines.AddShaderChunk("#define _AlphaClip 1", true);
if(masterNode.alphaMode == AlphaMode.Transparent)
defines.AddShaderChunk("#define _ALPHAPREMULTIPLY_ON 1", true);
var templateLocation = ShaderGenerator.GetTemplatePath(template);
foreach (var slot in usedSlots)

3
com.unity.shadergraph/Editor/Data/LightweightPipeline/LightWeightUnlitSubShader.cs


if (masterNode.IsSlotConnected(UnlitMasterNode.AlphaThresholdSlotId))
defines.AddShaderChunk("#define _AlphaClip 1", true);
if(masterNode.alphaMode == AlphaMode.Transparent)
defines.AddShaderChunk("#define _ALPHAPREMULTIPLY_ON 1", true);
var templateLocation = ShaderGenerator.GetTemplatePath(template);
foreach (var slot in usedSlots)

1
com.unity.shadergraph/Editor/Data/MasterNodes/AlphaMode.cs


{
Opaque,
Fade,
Transparent,
Additive,
Multiply
}

9
com.unity.shadergraph/Editor/Data/Util/ShaderGenerator.cs


materialOptions.renderQueue = SurfaceMaterialOptions.RenderQueue.Transparent;
materialOptions.renderType = SurfaceMaterialOptions.RenderType.Transparent;
break;
case AlphaMode.Transparent:
materialOptions.srcBlend = SurfaceMaterialOptions.BlendMode.One;
materialOptions.dstBlend = SurfaceMaterialOptions.BlendMode.OneMinusSrcAlpha;
materialOptions.cullMode = twoSided ? SurfaceMaterialOptions.CullMode.Off : SurfaceMaterialOptions.CullMode.Back;
materialOptions.zTest = SurfaceMaterialOptions.ZTest.LEqual;
materialOptions.zWrite = SurfaceMaterialOptions.ZWrite.Off;
materialOptions.renderQueue = SurfaceMaterialOptions.RenderQueue.Transparent;
materialOptions.renderType = SurfaceMaterialOptions.RenderType.Transparent;
break;
case AlphaMode.Additive:
materialOptions.srcBlend = SurfaceMaterialOptions.BlendMode.One;
materialOptions.dstBlend = SurfaceMaterialOptions.BlendMode.One;

正在加载...
取消
保存