public ShaderBuilder(string name, ShapesBlendMode blendMode, RenderPipeline rp) { this.blendMode = blendMode; this.shaderName = name; using (Scope($"Shader \"Shapes/{name} {blendMode.ToString()}\"")) { using (Scope("Properties")) { AppendLine("[Enum(UnityEngine.Rendering.CompareFunction)] _ZTest (\"Z Test\", int) = 4"); AppendLine("_ZOffsetFactor (\"Z Offset Factor\", Float ) = 0"); AppendLine("_ZOffsetUnits (\"Z Offset Units\", int ) = 0"); AppendLine("[Enum(UnityEngine.Rendering.CompareFunction)] _StencilComp (\"Stencil Comparison\", int) = 8"); AppendLine("[Enum(UnityEngine.Rendering.StencilOp)] _StencilOpPass (\"Stencil Operation Pass\", int) = 0"); AppendLine("_StencilID (\"Stencil ID\", int) = 0"); AppendLine("_StencilReadMask (\"Stencil Read Mask\", int) = 255"); AppendLine("_StencilWriteMask (\"Stencil Write Mask\", int) = 255"); } using (Scope("SubShader")) { using (Scope("Tags")) { // subshader tags AppendLines(rp.GetSubshaderTags()); AppendLines(blendMode.GetSubshaderTags()); } AppendPass(ShaderPassType.Render, rp); if (rp != RenderPipeline.Legacy) { AppendPass(ShaderPassType.DepthOnly, rp); } AppendPass(ShaderPassType.Picking, rp); AppendPass(ShaderPassType.Selection, rp); } } }
public ShaderBuilder(string name, ShapesBlendMode blendMode) { this.blendMode = blendMode; this.shaderName = name; using (Scope($"Shader \"Shapes/{name} {blendMode.ToString()}\"")) { using (Scope("SubShader")) { using (Scope("Tags")) // sub shader tags AppendLines(blendMode.GetSubshaderTags()); using (Scope("Pass")) { // render pass AppendLines(blendMode.GetPassRenderStates()); AppendCGPROGRAM(ShaderPassType.Render); } using (Scope("Pass")) { // picking pass AppendLine("Name \"Picking\""); AppendLine("Tags { \"LightMode\" = \"Picking\" }"); AppendLine("Cull Off"); AppendCGPROGRAM(ShaderPassType.Picking); } using (Scope("Pass")) { // selection pass AppendLine("Name \"Selection\""); AppendLine("Tags { \"LightMode\" = \"SceneSelectionPass\" }"); AppendLine("Cull Off"); AppendCGPROGRAM(ShaderPassType.Selection); } } } }