Skip to content
This repository has been archived by the owner on Apr 20, 2022. It is now read-only.

Commit

Permalink
added support for discarding fragments
Browse files Browse the repository at this point in the history
  • Loading branch information
WolfgangSt committed Oct 6, 2011
1 parent 14b5bab commit 1413072
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions IIS.SLSharp/IIS.SLSharp.csproj
Expand Up @@ -80,6 +80,7 @@
<Compile Include="Shaders\ShaderDefinition.MatrixFunctions.cs" />
<Compile Include="Shaders\ShaderDefinition.Noise.cs" />
<Compile Include="Shaders\ShaderDefinition.Sampler.cs" />
<Compile Include="Shaders\ShaderDefinition.Special.cs" />
<Compile Include="Shaders\ShaderDefinition.Texture.cs" />
<Compile Include="Shaders\ShaderDefinition.Trigonometry.cs" />
<Compile Include="Shaders\ShaderDefinition.UInt32Vector.cs" />
Expand Down
15 changes: 15 additions & 0 deletions IIS.SLSharp/Shaders/ShaderDefinition.Special.cs
@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace IIS.SLSharp.Shaders
{
public abstract partial class ShaderDefinition
{
/// <summary>
/// Discards the current fragment.
/// </summary>
protected internal static void Discard() { throw _invalidAccess; }
}
}
7 changes: 7 additions & 0 deletions IIS.SLSharp/Translation/GLSL/GlslVisitor.ShaderDef.cs
Expand Up @@ -14,6 +14,8 @@ public GlslVisitor()
{
Handlers = new Dictionary<Expression<Action>, Func<MethodDefinition, InvocationExpression, StringBuilder>>(new HandlerComparer())
{
{ () => ShaderDefinition.Discard(), KeywordDiscard },

#region Trigonometry

{ () => ShaderDefinition.Radians(_float), ToLower },
Expand Down Expand Up @@ -518,5 +520,10 @@ public GlslVisitor()
#endregion
};
}

private StringBuilder KeywordDiscard(MethodDefinition unused1, InvocationExpression unused2)
{
return new StringBuilder("discard");
}
}
}

0 comments on commit 1413072

Please sign in to comment.