77 lines
1.8 KiB
C#
77 lines
1.8 KiB
C#
using Godot;
|
|
using System.Reflection;
|
|
using System.Collections.Generic;
|
|
|
|
namespace Rokojori
|
|
{
|
|
[Tool]
|
|
[GlobalClass]
|
|
public partial class VertexWind:VertexModifier
|
|
{
|
|
[Export]
|
|
public bool enabled = true;
|
|
|
|
[Export]
|
|
public bool sampleAngleFromNoise = true;
|
|
|
|
[Export]
|
|
public bool heightCompensation = true;
|
|
|
|
|
|
public override List<ShaderCode> GetCode( ShaderGenerationContext context )
|
|
{
|
|
if ( ShaderPhase.Includes == context.phase )
|
|
{
|
|
return ToCode( "#include \"res://addons/rokojori_action_library/Runtime/Shading/Library/Wind.gdshaderinc\"" );
|
|
}
|
|
|
|
if ( ShaderPhase.Variables == context.phase )
|
|
{
|
|
return AsUniformGroup( "Wind",
|
|
|
|
@"
|
|
uniform float windStrength = 0;
|
|
uniform vec2 windSpeed = vec2(1,1);
|
|
uniform float windScale = 1;
|
|
uniform sampler2D windNoise;
|
|
uniform vec2 windNoiseAngleOffset;
|
|
uniform vec2 windNoiseStrengthOffset = vec2( 0.1234, 0.56789 );
|
|
uniform float windStart = 0;
|
|
uniform float windEnd = 1;
|
|
uniform float windWeightCurve:hint_range(0,1) = 0.5f;
|
|
uniform float windHeightCompensation :hint_range(0,1) = 0.5f;
|
|
"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
if ( ShaderPhase.Vertex == context.phase )
|
|
{
|
|
|
|
return ToInnerBlock( "Wind",
|
|
|
|
@"
|
|
applyWind(
|
|
TIME, MODEL_MATRIX, VERTEX,
|
|
|
|
windStrength,
|
|
windSpeed,
|
|
windScale,
|
|
windNoise,
|
|
windNoiseAngleOffset,
|
|
windNoiseStrengthOffset,
|
|
windStart,
|
|
windEnd,
|
|
windWeightCurve,
|
|
windHeightCompensation
|
|
);
|
|
"
|
|
|
|
);
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|
|
} |