56 lines
951 B
C#
56 lines
951 B
C#
using Godot;
|
|
using System.Reflection;
|
|
using System.Collections.Generic;
|
|
|
|
namespace Rokojori
|
|
{
|
|
public enum AlphaFadeMode
|
|
{
|
|
___,
|
|
Alpha,
|
|
NoiseDitherDiscard
|
|
}
|
|
|
|
|
|
public static class AlphaFade
|
|
{
|
|
public static List<ShaderCode> Includes( string variableName, AlphaFadeMode mode )
|
|
{
|
|
if ( AlphaFadeMode.NoiseDitherDiscard != mode )
|
|
{
|
|
return null;
|
|
}
|
|
|
|
return ShaderGenerationModule.IncludeNoiseLibrary();
|
|
}
|
|
|
|
|
|
|
|
public static string Fragment( string variableName, AlphaFadeMode mode )
|
|
{
|
|
if ( AlphaFadeMode.Alpha == mode )
|
|
{
|
|
return " ALPHA *= " + variableName + ";\n";
|
|
}
|
|
|
|
if ( AlphaFadeMode.NoiseDitherDiscard == mode )
|
|
{
|
|
|
|
var code =
|
|
$@"
|
|
if ( ditherDiscard( {variableName}, FRAGCOORD ) )
|
|
{{
|
|
discard;
|
|
}}
|
|
";
|
|
|
|
return code.Indent( " ");
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
}
|
|
}
|
|
|