|
|
|
|
|
|
return resultPass; |
|
|
|
} |
|
|
|
|
|
|
|
public static SurfaceMaterialOptions GetMaterialOptionsFromAlphaMode(AlphaMode alphaMode) |
|
|
|
{ |
|
|
|
var materialOptions = new SurfaceMaterialOptions(); |
|
|
|
switch (alphaMode) |
|
|
|
{ |
|
|
|
case AlphaMode.Opaque: |
|
|
|
materialOptions.srcBlend = SurfaceMaterialOptions.BlendMode.One; |
|
|
|
materialOptions.dstBlend = SurfaceMaterialOptions.BlendMode.Zero; |
|
|
|
materialOptions.cullMode = SurfaceMaterialOptions.CullMode.Back; |
|
|
|
materialOptions.zTest = SurfaceMaterialOptions.ZTest.LEqual; |
|
|
|
materialOptions.zWrite = SurfaceMaterialOptions.ZWrite.On; |
|
|
|
materialOptions.renderQueue = SurfaceMaterialOptions.RenderQueue.Geometry; |
|
|
|
materialOptions.renderType = SurfaceMaterialOptions.RenderType.Opaque; |
|
|
|
break; |
|
|
|
case AlphaMode.AlphaBlend: |
|
|
|
materialOptions.srcBlend = SurfaceMaterialOptions.BlendMode.SrcAlpha; |
|
|
|
materialOptions.dstBlend = SurfaceMaterialOptions.BlendMode.OneMinusSrcAlpha; |
|
|
|
materialOptions.cullMode = 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.AdditiveBlend: |
|
|
|
materialOptions.srcBlend = SurfaceMaterialOptions.BlendMode.One; |
|
|
|
materialOptions.dstBlend = SurfaceMaterialOptions.BlendMode.One; |
|
|
|
materialOptions.cullMode = SurfaceMaterialOptions.CullMode.Back; |
|
|
|
materialOptions.zTest = SurfaceMaterialOptions.ZTest.LEqual; |
|
|
|
materialOptions.zWrite = SurfaceMaterialOptions.ZWrite.Off; |
|
|
|
materialOptions.renderQueue = SurfaceMaterialOptions.RenderQueue.Transparent; |
|
|
|
materialOptions.renderType = SurfaceMaterialOptions.RenderType.Transparent; |
|
|
|
break; |
|
|
|
} |
|
|
|
return materialOptions; |
|
|
|
} |
|
|
|
|
|
|
|
public IEnumerable<string> GetSubshader(PBRMasterNode masterNode, GenerationMode mode) |
|
|
|
{ |
|
|
|
var subShader = new ShaderGenerator(); |
|
|
|
|
|
|
subShader.AddShaderChunk("Tags{ \"RenderPipeline\" = \"LightweightPipeline\"}", true); |
|
|
|
|
|
|
|
var materialOptions = GetMaterialOptionsFromAlphaMode(masterNode.alphaMode); |
|
|
|
var materialOptions = MasterNode.GetMaterialOptionsFromAlphaMode(masterNode.alphaMode); |
|
|
|
var tagsVisitor = new ShaderGenerator(); |
|
|
|
materialOptions.GetTags(tagsVisitor); |
|
|
|
subShader.AddShaderChunk(tagsVisitor.GetShaderString(0), true); |
|
|
|