This commit is contained in:
Josef 2026-01-27 07:57:54 +01:00
parent d996a9513c
commit 68917d081a
49 changed files with 2037 additions and 24 deletions

View File

@ -0,0 +1,67 @@
using Godot;
namespace Rokojori
{
[GlobalClass, Tool ]
public partial class SetVector3FromNodePosition : Action
{
[Export]
public Node3D source;
[Export]
public bool global = true;
[Export]
public bool convertToView = false;
[Export]
public Resource target;
[Export]
public string member;
[Export]
public Camera3D camera;
[Export]
public Vector3 scale = Vector3.One;
protected override void _OnTrigger()
{
if ( target == null || source == null )
{
return;
}
var value = source.GetPosition( global );
if ( convertToView )
{
if ( Engine.IsEditorHint() )
{
#if TOOLS
var editorCamera = EditorInterface.Singleton.GetEditorViewport3D().GetCamera3D();
value = editorCamera.ToLocal( value );
#endif
}
else
{
if ( camera != null )
{
value = camera.ToLocal( value );
}
}
}
value = value * scale;
// this.LogInfo( "Set", member, ">>", value );
ReflectionHelper.SetValue( target, member, value );
}
}
}

View File

@ -0,0 +1 @@
uid://bkkwusmw0yjam

View File

@ -114,6 +114,19 @@ namespace Rokojori
return degrees; return degrees;
} }
public static float Mix( float a, float b, float mix )
{
return a + mix * ( b - a );
}
public static float PowerValue( float polarValue, float positivePower = 10f, float negativePower = 3f )
{
float t = Smoothstep( -1.0f, 1.0f, polarValue );
float basis = Mix( negativePower, positivePower, t);
return Mathf.Pow( basis, polarValue );
}
public static float Smoothstep ( float edge0, float edge1, float x ) public static float Smoothstep ( float edge0, float edge1, float x )
{ {
x = MathX.Clamp01( ( x - edge0 ) / ( edge1 - edge0 ) ); x = MathX.Clamp01( ( x - edge0 ) / ( edge1 - edge0 ) );

View File

@ -839,14 +839,14 @@ namespace Rokojori
return mg; return mg;
} }
public static MeshGeometry BillboardQuad( float size = 1 ) public static MeshGeometry BillboardQuad( float size = 1, float z = 0 )
{ {
var hs = size / 2f; var hs = size / 2f;
var mg = new MeshGeometry(); var mg = new MeshGeometry();
mg.AddQuad( mg.AddQuad(
new Vector3( -hs, -hs, 0 ), new Vector3( hs, -hs, 0 ), new Vector3( -hs, -hs, z ), new Vector3( hs, -hs, z ),
new Vector3( hs, hs, 0 ), new Vector3( -hs, hs, 0 ), new Vector3( hs, hs, z ), new Vector3( -hs, hs, z ),
Vector3.Forward, Vector3.Forward, Vector3.Forward, Vector3.Forward, Vector3.Forward, Vector3.Forward, Vector3.Forward, Vector3.Forward,
@ -857,6 +857,22 @@ namespace Rokojori
return mg; return mg;
} }
public static MeshGeometry UnitBillboardQuads( int num, float zMin = 0, float zMax = 0 )
{
var mg = new MeshGeometry();
for ( int i = 0; i < num; i++ )
{
var t = num == 1 ? 0 : i / ( num - 1f );
var z = Mathf.Lerp( zMin, zMax, t );
var quad = BillboardQuad( 1f, z );
mg.Add( quad );
}
return mg;
}
public void Initialize( bool normals = true, bool uvs = true, bool colors = false, bool uvs2 = false ) public void Initialize( bool normals = true, bool uvs = true, bool colors = false, bool uvs2 = false )
{ {
this.normals = normals ? new List<Vector3>() : null; this.normals = normals ? new List<Vector3>() : null;

View File

@ -17,6 +17,9 @@ namespace Rokojori
[Export( PropertyHint.Range, "0,1") ] [Export( PropertyHint.Range, "0,1") ]
public float amount = 1f; public float amount = 1f;
[Export( PropertyHint.Range, "0,1") ]
public float skyAmount = 0f;
[Export] [Export]
public float zStart = 1f; public float zStart = 1f;
@ -26,8 +29,6 @@ namespace Rokojori
[Export( PropertyHint.Range, "-1,1") ] [Export( PropertyHint.Range, "-1,1") ]
public float zSpread = 0f; public float zSpread = 0f;
[Export] [Export]
public GradientTexture1D gradient = new GradientTexture1D(); public GradientTexture1D gradient = new GradientTexture1D();
@ -46,9 +47,41 @@ namespace Rokojori
[Export] [Export]
public TimeLine gradientUVScrollTimeline = null; public TimeLine gradientUVScrollTimeline = null;
public enum UVGradientSampleMode
{
Fract,
Clamp
}
[Export]
public UVGradientSampleMode gradientSampleMode = UVGradientSampleMode.Fract;
[Export] [Export]
public CurveTexture opacity = new CurveTexture().WithCurve( new Curve().WithValues( 1, 1 ) ); public CurveTexture opacity = new CurveTexture().WithCurve( new Curve().WithValues( 1, 1 ) );
[ExportToolButton("Z Distance Only")]
public Callable zWeightsButton => Callable.From( ()=> directionWeighting = new Vector3( 0, 0, -1 ) );
[ExportToolButton("XZ Distance")]
public Callable xzWeightsButton => Callable.From( ()=> directionWeighting = new Vector3( 1, 0, -1 ) );
[ExportToolButton("Distance to Camera")]
public Callable cameraWeightsButton => Callable.From( ()=> directionWeighting = new Vector3( 1, 1, -1 ) );
[Export]
public Vector3 directionWeighting = new Vector3( 1, 1, 1 );
[Export]
public float directionScalingX = 1f;
[Export]
public float directionScalingY = 1f;
[Export]
public Vector3 directionOffset = Vector3.Zero;
RG_ScreenColorTexure screenColorTexture; RG_ScreenColorTexure screenColorTexture;
RG_ScreenDepthTexture screenDepthTexture; RG_ScreenDepthTexture screenDepthTexture;
@ -116,14 +149,24 @@ namespace Rokojori
projection.W, projection.W,
amount, amount,
Mathf.Pow( 10f, zSpread ), MathX.PowerValue( zSpread ),
zStart, zStart,
zEnd, zEnd,
gradientUVScale, gradientUVScale,
gradientOffset, gradientOffset,
0f, directionWeighting.X,
0f directionWeighting.Y,
directionWeighting.Z,
(float) (int) gradientSampleMode,
skyAmount,
directionOffset.X,
directionOffset.Y,
directionOffset.Z,
directionScalingX,
directionScalingY
); );

View File

@ -275,16 +275,26 @@ uniform Parameters
float gradientUVScale; float gradientUVScale;
float gradientUVOffset; float gradientUVOffset;
float p0; float weightX;
float p1; float weightY;
float weightZ;
float uvMode;
float skyAmount;
float offsetX;
float offsetY;
float offsetZ;
float scaleX;
float scaleY;
} parameters; } parameters;
float getZ( vec2 uv, float depth, mat4 INV_PROJ ) vec3 getViewPosition( vec2 uv, float depth, mat4 INV_PROJ )
{ {
vec4 position = screenToView( uv, depth, INV_PROJ ); vec4 position = screenToView( uv, depth, INV_PROJ );
return max( 0.0, -position.z ); return position.xyz;
} }
void main() void main()
@ -301,18 +311,39 @@ void main()
mat4 INV_PROJ = mat4( parameters.m0, parameters.m1, parameters.m2, parameters.m3 ); mat4 INV_PROJ = mat4( parameters.m0, parameters.m1, parameters.m2, parameters.m3 );
float depth = texture( depthSampler, uv ).r; vec4 depthValue = texture( depthSampler, uv );
float z = getZ( uv, depth, INV_PROJ ); float depth = depthValue.r;
vec3 viewPosition = getViewPosition( uv, depth, INV_PROJ );
viewPosition *= vec3( parameters.scaleX, parameters.scaleY, 1.0 );
viewPosition += vec3( parameters.offsetX, parameters.offsetY, parameters.offsetZ );
vec3 weights = normalize( vec3( parameters.weightX, parameters.weightY, parameters.weightZ ) );
float z = length( weights * viewPosition );
float mappedZ = normalizeToRange01( z, parameters.zStart, parameters.zEnd ); float mappedZ = normalizeToRange01( z, parameters.zStart, parameters.zEnd );
mappedZ = pow( mappedZ, parameters.zSpread ); mappedZ = pow( mappedZ, parameters.zSpread );
vec2 gradientUV = vec2( mappedZ * parameters.gradientUVScale + parameters.gradientUVOffset, 0.0 ); vec2 gradientUV = vec2( mappedZ * parameters.gradientUVScale + parameters.gradientUVOffset, 0.0 );
gradientUV.x = fract( gradientUV.x );
int uvSampleMode = int( parameters.uvMode );
gradientUV.x = uvSampleMode == 0 ? fract( gradientUV.x ) :
clamp( gradientUV.x, 0.0, 1.0 );
vec4 gradientColor = SRGBtoLINEAR( textureLod( gradientSampler, gradientUV, 0 ) ); vec4 gradientColor = SRGBtoLINEAR( textureLod( gradientSampler, gradientUV, 0 ) );
vec4 opacity = textureLod( opacitySampler, vec2( mappedZ, 0.0 ), 0 ); vec4 opacity = textureLod( opacitySampler, vec2( mappedZ, 0.0 ), 0 );
if ( depth <= 0.0000001 )
{
gradientColor.a *= parameters.skyAmount;
}
else
{
gradientColor.a *= opacity.r; gradientColor.a *= opacity.r;
}
vec4 color = imageLoad( inputImage, xy ); vec4 color = imageLoad( inputImage, xy );

View File

@ -300,6 +300,8 @@ vec3 shiftHSL( vec3 hsl, vec3 offset, float blendRadius )
vec3 shiftRGBwithHSL( vec3 rgb, vec3 offset, float blendRadius ) vec3 shiftRGBwithHSL( vec3 rgb, vec3 offset, float blendRadius )
{ {
// float scale = getRGBScale( rbg );
// rgb /= scale;
vec3 hsl = RGBtoHSL( rgb ); vec3 hsl = RGBtoHSL( rgb );
hsl = shiftHSL( hsl, offset, blendRadius ); hsl = shiftHSL( hsl, offset, blendRadius );
return HSLtoRGB( hsl ); return HSLtoRGB( hsl );

View File

@ -164,6 +164,138 @@ float sdEllipse( in vec2 p, in vec2 ab )
return length(r-p) * sign(p.y-r.y); return length(r-p) * sign(p.y-r.y);
} }
float sdEquilateralTriangle( in vec2 p, in float r )
{
const float k = sqrt(3.0);
p.x = abs(p.x) - r;
p.y = p.y + r/k;
if( p.x+k*p.y>0.0 ) p = vec2(p.x-k*p.y,-k*p.x-p.y)/2.0;
p.x -= clamp( p.x, -2.0*r, 0.0 );
return -length(p)*sign(p.y);
}
float sdPentagon( in vec2 p, in float r )
{
const vec3 k = vec3(0.809016994,0.587785252,0.726542528);
p.x = abs(p.x);
p -= 2.0*min(dot(vec2(-k.x,k.y),p),0.0)*vec2(-k.x,k.y);
p -= 2.0*min(dot(vec2( k.x,k.y),p),0.0)*vec2( k.x,k.y);
p -= vec2(clamp(p.x,-r*k.z,r*k.z),r);
return length(p)*sign(p.y);
}
float sdHexagon( in vec2 p, in float r )
{
const vec3 k = vec3(-0.866025404,0.5,0.577350269);
p = abs(p);
p -= 2.0*min(dot(k.xy,p),0.0)*k.xy;
p -= vec2(clamp(p.x, -k.z*r, k.z*r), r);
return length(p)*sign(p.y);
}
float sdOctogon( in vec2 p, in float r )
{
const vec3 k = vec3(-0.9238795325, 0.3826834323, 0.4142135623 );
p = abs(p);
p -= 2.0*min(dot(vec2( k.x,k.y),p),0.0)*vec2( k.x,k.y);
p -= 2.0*min(dot(vec2(-k.x,k.y),p),0.0)*vec2(-k.x,k.y);
p -= vec2(clamp(p.x, -k.z*r, k.z*r), r);
return length(p)*sign(p.y);
}
float sdHexagram( in vec2 p, in float r )
{
const vec4 k = vec4(-0.5,0.8660254038,0.5773502692,1.7320508076);
p = abs(p);
p -= 2.0*min(dot(k.xy,p),0.0)*k.xy;
p -= 2.0*min(dot(k.yx,p),0.0)*k.yx;
p -= vec2(clamp(p.x,r*k.z,r*k.w),r);
return length(p)*sign(p.y);
}
float sdPentagram(in vec2 p, in float r )
{
const float k1x = 0.809016994; // cos(π/ 5) = ¼(√5+1)
const float k2x = 0.309016994; // sin(π/10) = ¼(√5-1)
const float k1y = 0.587785252; // sin(π/ 5) = ¼√(10-2√5)
const float k2y = 0.951056516; // cos(π/10) = ¼√(10+2√5)
const float k1z = 0.726542528; // tan(π/ 5) = √(5-2√5)
const vec2 v1 = vec2( k1x,-k1y);
const vec2 v2 = vec2(-k1x,-k1y);
const vec2 v3 = vec2( k2x,-k2y);
p.x = abs(p.x);
p -= 2.0*max(dot(v1,p),0.0)*v1;
p -= 2.0*max(dot(v2,p),0.0)*v2;
p.x = abs(p.x);
p.y -= r;
return length(p-v3*clamp(dot(p,v3),0.0,k1z*r))
* sign(p.y*v3.x-p.x*v3.y);
}
float sdStar( in vec2 p, in float r, in int n, in float m)
{
// next 4 lines can be precomputed for a given shape
float an = 3.141593/float(n);
float en = 3.141593/m; // m is between 2 and n
vec2 acs = vec2(cos(an),sin(an));
vec2 ecs = vec2(cos(en),sin(en)); // ecs=vec2(0,1) for regular polygon
float bn = mod(atan(p.x,p.y),2.0*an) - an;
p = length(p)*vec2(cos(bn),abs(sin(bn)));
p -= r*acs;
p += ecs*clamp( -dot(p,ecs), 0.0, r*acs.y/ecs.y);
return length(p)*sign(p.x);
}
float sdMoon(vec2 p, float d, float ra, float rb )
{
p.y = abs(p.y);
float a = (ra*ra - rb*rb + d*d)/(2.0*d);
float b = sqrt(max(ra*ra-a*a,0.0));
if( d*(p.x*b-p.y*a) > d*d*max(b-p.y,0.0) )
return length(p-vec2(a,b));
return max( (length(p )-ra),
-(length(p-vec2(d,0))-rb));
}
float sdHeart( in vec2 p )
{
p += vec2( 0, 0.6 );
p.x = abs(p.x);
if( p.y+p.x>1.0 )
return sqrt(dot2(p-vec2(0.25,0.75))) - sqrt(2.0)/4.0;
return sqrt(min(dot2(p-vec2(0.00,1.00)),
dot2(p-0.5*max(p.x+p.y,0.0)))) * sign(p.x-p.y);
}
float sdRoundedX( in vec2 p, in float w, in float r )
{
p = abs(p);
return length(p-min(p.x+p.y,w)*0.5) - r;
}
// float sdPolygon( in vec2[N] v, in vec2 p )
// {
// float d = dot(p-v[0],p-v[0]);
// float s = 1.0;
// for( int i=0, j=N-1; i<N; j=i, i++ )
// {
// vec2 e = v[j] - v[i];
// vec2 w = p - v[i];
// vec2 b = w - e*clamp( dot(w,e)/dot(e,e), 0.0, 1.0 );
// d = min( d, dot(b,b) );
// bvec3 c = bvec3(p.y>=v[i].y,p.y<v[j].y,e.x*w.y>e.y*w.x);
// if( all(c) || all(not(c)) ) s*=-1.0;
// }
// return s*sqrt(d);
// }
/* /*
TAKEN FROM TAKEN FROM

View File

@ -246,6 +246,30 @@ vec2 tilingOffsetRepeat( vec2 uv, vec4 tilingOffset )
return mod( uv, vec2(1,1) ); return mod( uv, vec2(1,1) );
} }
// void setBillboardMode( inout mat4 _MODELVIEW_MATRIX, inout mat4 _MODELVIEW_NORMAL_MATRIX, mat4 _VIEW_MATRIX, mat4 _MAIN_CAM_INV_VIEW_MATRIX, mat4 _MODEL_MATRIX )
// {
// _MODELVIEW_MATRIX = _VIEW_MATRIX * mat4(
// _MAIN_CAM_INV_VIEW_MATRIX[ 0 ],
// _MAIN_CAM_INV_VIEW_MATRIX[ 1 ],
// _MAIN_CAM_INV_VIEW_MATRIX[ 2 ],
// _MODEL_MATRIX[ 3 ]
// );
// float scaleX = length( _MODEL_MATRIX[ 0 ].xyz );
// float scaleY = length( _MODEL_MATRIX[ 1 ].xyz );
// float scaleZ = length( _MODEL_MATRIX[ 2 ].xyz );
// _MODELVIEW_MATRIX = _MODELVIEW_MATRIX * mat4(
// vec4( scaleX, 0.0, 0.0, 0.0 ),
// vec4( 0.0, scaleY, 0.0, 0.0 ),
// vec4( 0.0, 0.0, scaleZ, 0.0 ),
// vec4( 0.0, 0.0, 0.0, 1.0 )
// );
// _MODELVIEW_NORMAL_MATRIX = mat3( _MODELVIEW_MATRIX);
// }
vec3 billboardWorldOffset( vec2 _UV, mat4 _INV_VIEW_MATRIX, mat4 _MODEL_MATRIX ) vec3 billboardWorldOffset( vec2 _UV, mat4 _INV_VIEW_MATRIX, mat4 _MODEL_MATRIX )
{ {
vec2 mappedUV = mix( vec2(-1,1), vec2( 1, -1 ), _UV ); vec2 mappedUV = mix( vec2(-1,1), vec2( 1, -1 ), _UV );

View File

@ -0,0 +1,120 @@
using Godot;
namespace Rokojori
{
// Generated by ShaderClassGenerator
public class EllipseFlareAddShader
{
public static readonly CachedResource<Shader> shader = new CachedResource<Shader>(
"res://addons/rokojori_action_library/Runtime/Shading/Shaders/Flares/EllipseFlare/EllipseFlareAdd.gdshader"
);
public static readonly ColorPropertyName color = ColorPropertyName.Create( "color" );
public static readonly FloatPropertyName alphaScale = FloatPropertyName.Create( "alphaScale" );
public static readonly FloatPropertyName circleAmount = FloatPropertyName.Create( "circleAmount" );
public static readonly FloatPropertyName circleDistortion = FloatPropertyName.Create( "circleDistortion" );
public static readonly FloatPropertyName ellipseAmount = FloatPropertyName.Create( "ellipseAmount" );
public static readonly FloatPropertyName ellipseDistortion = FloatPropertyName.Create( "ellipseDistortion" );
public static readonly Vector2PropertyName ellipseScale = Vector2PropertyName.Create( "ellipseScale" );
public static readonly FloatPropertyName addVsMax = FloatPropertyName.Create( "add_vs_max" );
public static readonly Vector4PropertyName centerHsl = Vector4PropertyName.Create( "centerHSL" );
public static readonly Vector4PropertyName outsideHsl = Vector4PropertyName.Create( "outsideHSL" );
public static readonly FloatPropertyName sizeX = FloatPropertyName.Create( "sizeX" );
public static readonly FloatPropertyName sizeY = FloatPropertyName.Create( "sizeY" );
public static readonly FloatPropertyName scaleAll = FloatPropertyName.Create( "scaleAll" );
public static readonly FloatPropertyName worldSizeVsScreenSize = FloatPropertyName.Create( "worldSize_vs_screenSize" );
public static readonly BoolPropertyName usSpectralsNoise = BoolPropertyName.Create( "usSpectralsNoise" );
public static readonly Vector3PropertyName spectralsAmount = Vector3PropertyName.Create( "spectralsAmount" );
public static readonly FloatPropertyName nonSpectralAmount = FloatPropertyName.Create( "nonSpectralAmount" );
public static readonly Vector3PropertyName spectralsSize = Vector3PropertyName.Create( "spectralsSize" );
public static readonly Vector3PropertyName spectralsSharpness = Vector3PropertyName.Create( "spectralsSharpness" );
public static readonly Vector3PropertyName spectralsFrequency = Vector3PropertyName.Create( "spectralsFrequency" );
public static readonly Vector3PropertyName spectralsSpeed = Vector3PropertyName.Create( "spectralsSpeed" );
public static readonly Sampler2DPropertyName fading = Sampler2DPropertyName.Create( "fading" );
public static readonly Sampler2DPropertyName sizeXfading = Sampler2DPropertyName.Create( "sizeXfading" );
public static readonly Sampler2DPropertyName sizeYfading = Sampler2DPropertyName.Create( "sizeYfading" );
public static readonly BoolPropertyName useQuickOcclusionTest = BoolPropertyName.Create( "useQuickOcclusionTest" );
public static readonly FloatPropertyName occlusionZOffset = FloatPropertyName.Create( "occlusionZOffset" );
public static readonly IntPropertyName occlusionTestMaxSteps = IntPropertyName.Create( "occlusionTestMaxSteps" );
public static readonly FloatPropertyName occlusionTestStepStride = FloatPropertyName.Create( "occlusionTestStepStride" );
public static readonly FloatPropertyName occlusionTestViewDependingScaleAmount = FloatPropertyName.Create( "occlusionTest_ViewDependingScaleAmount" );
public static readonly FloatPropertyName occlusionTestViewDependingDistance = FloatPropertyName.Create( "occlusionTest_ViewDependingDistance" );
}
[Tool]
public partial class EllipseFlareAddMaterial:CustomMaterial
{
public readonly CustomMaterialProperty<Color> color;
public readonly CustomMaterialProperty<float> alphaScale;
public readonly CustomMaterialProperty<float> circleAmount;
public readonly CustomMaterialProperty<float> circleDistortion;
public readonly CustomMaterialProperty<float> ellipseAmount;
public readonly CustomMaterialProperty<float> ellipseDistortion;
public readonly CustomMaterialProperty<Vector2> ellipseScale;
public readonly CustomMaterialProperty<float> addVsMax;
public readonly CustomMaterialProperty<Vector4> centerHsl;
public readonly CustomMaterialProperty<Vector4> outsideHsl;
public readonly CustomMaterialProperty<float> sizeX;
public readonly CustomMaterialProperty<float> sizeY;
public readonly CustomMaterialProperty<float> scaleAll;
public readonly CustomMaterialProperty<float> worldSizeVsScreenSize;
public readonly CustomMaterialProperty<bool> usSpectralsNoise;
public readonly CustomMaterialProperty<Vector3> spectralsAmount;
public readonly CustomMaterialProperty<float> nonSpectralAmount;
public readonly CustomMaterialProperty<Vector3> spectralsSize;
public readonly CustomMaterialProperty<Vector3> spectralsSharpness;
public readonly CustomMaterialProperty<Vector3> spectralsFrequency;
public readonly CustomMaterialProperty<Vector3> spectralsSpeed;
public readonly CustomMaterialProperty<Texture2D> fading;
public readonly CustomMaterialProperty<Texture2D> sizeXfading;
public readonly CustomMaterialProperty<Texture2D> sizeYfading;
public readonly CustomMaterialProperty<bool> useQuickOcclusionTest;
public readonly CustomMaterialProperty<float> occlusionZOffset;
public readonly CustomMaterialProperty<int> occlusionTestMaxSteps;
public readonly CustomMaterialProperty<float> occlusionTestStepStride;
public readonly CustomMaterialProperty<float> occlusionTestViewDependingScaleAmount;
public readonly CustomMaterialProperty<float> occlusionTestViewDependingDistance;
public EllipseFlareAddMaterial()
{
Shader = EllipseFlareAddShader.shader.Get();
color = new CustomMaterialProperty<Color>( this, EllipseFlareAddShader.color );
alphaScale = new CustomMaterialProperty<float>( this, EllipseFlareAddShader.alphaScale );
circleAmount = new CustomMaterialProperty<float>( this, EllipseFlareAddShader.circleAmount );
circleDistortion = new CustomMaterialProperty<float>( this, EllipseFlareAddShader.circleDistortion );
ellipseAmount = new CustomMaterialProperty<float>( this, EllipseFlareAddShader.ellipseAmount );
ellipseDistortion = new CustomMaterialProperty<float>( this, EllipseFlareAddShader.ellipseDistortion );
ellipseScale = new CustomMaterialProperty<Vector2>( this, EllipseFlareAddShader.ellipseScale );
addVsMax = new CustomMaterialProperty<float>( this, EllipseFlareAddShader.addVsMax );
centerHsl = new CustomMaterialProperty<Vector4>( this, EllipseFlareAddShader.centerHsl );
outsideHsl = new CustomMaterialProperty<Vector4>( this, EllipseFlareAddShader.outsideHsl );
sizeX = new CustomMaterialProperty<float>( this, EllipseFlareAddShader.sizeX );
sizeY = new CustomMaterialProperty<float>( this, EllipseFlareAddShader.sizeY );
scaleAll = new CustomMaterialProperty<float>( this, EllipseFlareAddShader.scaleAll );
worldSizeVsScreenSize = new CustomMaterialProperty<float>( this, EllipseFlareAddShader.worldSizeVsScreenSize );
usSpectralsNoise = new CustomMaterialProperty<bool>( this, EllipseFlareAddShader.usSpectralsNoise );
spectralsAmount = new CustomMaterialProperty<Vector3>( this, EllipseFlareAddShader.spectralsAmount );
nonSpectralAmount = new CustomMaterialProperty<float>( this, EllipseFlareAddShader.nonSpectralAmount );
spectralsSize = new CustomMaterialProperty<Vector3>( this, EllipseFlareAddShader.spectralsSize );
spectralsSharpness = new CustomMaterialProperty<Vector3>( this, EllipseFlareAddShader.spectralsSharpness );
spectralsFrequency = new CustomMaterialProperty<Vector3>( this, EllipseFlareAddShader.spectralsFrequency );
spectralsSpeed = new CustomMaterialProperty<Vector3>( this, EllipseFlareAddShader.spectralsSpeed );
fading = new CustomMaterialProperty<Texture2D>( this, EllipseFlareAddShader.fading );
sizeXfading = new CustomMaterialProperty<Texture2D>( this, EllipseFlareAddShader.sizeXfading );
sizeYfading = new CustomMaterialProperty<Texture2D>( this, EllipseFlareAddShader.sizeYfading );
useQuickOcclusionTest = new CustomMaterialProperty<bool>( this, EllipseFlareAddShader.useQuickOcclusionTest );
occlusionZOffset = new CustomMaterialProperty<float>( this, EllipseFlareAddShader.occlusionZOffset );
occlusionTestMaxSteps = new CustomMaterialProperty<int>( this, EllipseFlareAddShader.occlusionTestMaxSteps );
occlusionTestStepStride = new CustomMaterialProperty<float>( this, EllipseFlareAddShader.occlusionTestStepStride );
occlusionTestViewDependingScaleAmount = new CustomMaterialProperty<float>( this, EllipseFlareAddShader.occlusionTestViewDependingScaleAmount );
occlusionTestViewDependingDistance = new CustomMaterialProperty<float>( this, EllipseFlareAddShader.occlusionTestViewDependingDistance );
}
}
}

View File

@ -0,0 +1 @@
uid://c21rt2tkpb7v6

View File

@ -0,0 +1,120 @@
using Godot;
namespace Rokojori
{
// Generated by ShaderClassGenerator
public class EllipseFlareMixShader
{
public static readonly CachedResource<Shader> shader = new CachedResource<Shader>(
"res://addons/rokojori_action_library/Runtime/Shading/Shaders/Flares/EllipseFlare/EllipseFlareMix.gdshader"
);
public static readonly ColorPropertyName color = ColorPropertyName.Create( "color" );
public static readonly FloatPropertyName alphaScale = FloatPropertyName.Create( "alphaScale" );
public static readonly FloatPropertyName circleAmount = FloatPropertyName.Create( "circleAmount" );
public static readonly FloatPropertyName circleDistortion = FloatPropertyName.Create( "circleDistortion" );
public static readonly FloatPropertyName ellipseAmount = FloatPropertyName.Create( "ellipseAmount" );
public static readonly FloatPropertyName ellipseDistortion = FloatPropertyName.Create( "ellipseDistortion" );
public static readonly Vector2PropertyName ellipseScale = Vector2PropertyName.Create( "ellipseScale" );
public static readonly FloatPropertyName addVsMax = FloatPropertyName.Create( "add_vs_max" );
public static readonly Vector4PropertyName centerHsl = Vector4PropertyName.Create( "centerHSL" );
public static readonly Vector4PropertyName outsideHsl = Vector4PropertyName.Create( "outsideHSL" );
public static readonly FloatPropertyName sizeX = FloatPropertyName.Create( "sizeX" );
public static readonly FloatPropertyName sizeY = FloatPropertyName.Create( "sizeY" );
public static readonly FloatPropertyName scaleAll = FloatPropertyName.Create( "scaleAll" );
public static readonly FloatPropertyName worldSizeVsScreenSize = FloatPropertyName.Create( "worldSize_vs_screenSize" );
public static readonly BoolPropertyName usSpectralsNoise = BoolPropertyName.Create( "usSpectralsNoise" );
public static readonly Vector3PropertyName spectralsAmount = Vector3PropertyName.Create( "spectralsAmount" );
public static readonly FloatPropertyName nonSpectralAmount = FloatPropertyName.Create( "nonSpectralAmount" );
public static readonly Vector3PropertyName spectralsSize = Vector3PropertyName.Create( "spectralsSize" );
public static readonly Vector3PropertyName spectralsSharpness = Vector3PropertyName.Create( "spectralsSharpness" );
public static readonly Vector3PropertyName spectralsFrequency = Vector3PropertyName.Create( "spectralsFrequency" );
public static readonly Vector3PropertyName spectralsSpeed = Vector3PropertyName.Create( "spectralsSpeed" );
public static readonly Sampler2DPropertyName fading = Sampler2DPropertyName.Create( "fading" );
public static readonly Sampler2DPropertyName sizeXfading = Sampler2DPropertyName.Create( "sizeXfading" );
public static readonly Sampler2DPropertyName sizeYfading = Sampler2DPropertyName.Create( "sizeYfading" );
public static readonly BoolPropertyName useQuickOcclusionTest = BoolPropertyName.Create( "useQuickOcclusionTest" );
public static readonly FloatPropertyName occlusionZOffset = FloatPropertyName.Create( "occlusionZOffset" );
public static readonly IntPropertyName occlusionTestMaxSteps = IntPropertyName.Create( "occlusionTestMaxSteps" );
public static readonly FloatPropertyName occlusionTestStepStride = FloatPropertyName.Create( "occlusionTestStepStride" );
public static readonly FloatPropertyName occlusionTestViewDependingScaleAmount = FloatPropertyName.Create( "occlusionTest_ViewDependingScaleAmount" );
public static readonly FloatPropertyName occlusionTestViewDependingDistance = FloatPropertyName.Create( "occlusionTest_ViewDependingDistance" );
}
[Tool]
public partial class EllipseFlareMixMaterial:CustomMaterial
{
public readonly CustomMaterialProperty<Color> color;
public readonly CustomMaterialProperty<float> alphaScale;
public readonly CustomMaterialProperty<float> circleAmount;
public readonly CustomMaterialProperty<float> circleDistortion;
public readonly CustomMaterialProperty<float> ellipseAmount;
public readonly CustomMaterialProperty<float> ellipseDistortion;
public readonly CustomMaterialProperty<Vector2> ellipseScale;
public readonly CustomMaterialProperty<float> addVsMax;
public readonly CustomMaterialProperty<Vector4> centerHsl;
public readonly CustomMaterialProperty<Vector4> outsideHsl;
public readonly CustomMaterialProperty<float> sizeX;
public readonly CustomMaterialProperty<float> sizeY;
public readonly CustomMaterialProperty<float> scaleAll;
public readonly CustomMaterialProperty<float> worldSizeVsScreenSize;
public readonly CustomMaterialProperty<bool> usSpectralsNoise;
public readonly CustomMaterialProperty<Vector3> spectralsAmount;
public readonly CustomMaterialProperty<float> nonSpectralAmount;
public readonly CustomMaterialProperty<Vector3> spectralsSize;
public readonly CustomMaterialProperty<Vector3> spectralsSharpness;
public readonly CustomMaterialProperty<Vector3> spectralsFrequency;
public readonly CustomMaterialProperty<Vector3> spectralsSpeed;
public readonly CustomMaterialProperty<Texture2D> fading;
public readonly CustomMaterialProperty<Texture2D> sizeXfading;
public readonly CustomMaterialProperty<Texture2D> sizeYfading;
public readonly CustomMaterialProperty<bool> useQuickOcclusionTest;
public readonly CustomMaterialProperty<float> occlusionZOffset;
public readonly CustomMaterialProperty<int> occlusionTestMaxSteps;
public readonly CustomMaterialProperty<float> occlusionTestStepStride;
public readonly CustomMaterialProperty<float> occlusionTestViewDependingScaleAmount;
public readonly CustomMaterialProperty<float> occlusionTestViewDependingDistance;
public EllipseFlareMixMaterial()
{
Shader = EllipseFlareMixShader.shader.Get();
color = new CustomMaterialProperty<Color>( this, EllipseFlareMixShader.color );
alphaScale = new CustomMaterialProperty<float>( this, EllipseFlareMixShader.alphaScale );
circleAmount = new CustomMaterialProperty<float>( this, EllipseFlareMixShader.circleAmount );
circleDistortion = new CustomMaterialProperty<float>( this, EllipseFlareMixShader.circleDistortion );
ellipseAmount = new CustomMaterialProperty<float>( this, EllipseFlareMixShader.ellipseAmount );
ellipseDistortion = new CustomMaterialProperty<float>( this, EllipseFlareMixShader.ellipseDistortion );
ellipseScale = new CustomMaterialProperty<Vector2>( this, EllipseFlareMixShader.ellipseScale );
addVsMax = new CustomMaterialProperty<float>( this, EllipseFlareMixShader.addVsMax );
centerHsl = new CustomMaterialProperty<Vector4>( this, EllipseFlareMixShader.centerHsl );
outsideHsl = new CustomMaterialProperty<Vector4>( this, EllipseFlareMixShader.outsideHsl );
sizeX = new CustomMaterialProperty<float>( this, EllipseFlareMixShader.sizeX );
sizeY = new CustomMaterialProperty<float>( this, EllipseFlareMixShader.sizeY );
scaleAll = new CustomMaterialProperty<float>( this, EllipseFlareMixShader.scaleAll );
worldSizeVsScreenSize = new CustomMaterialProperty<float>( this, EllipseFlareMixShader.worldSizeVsScreenSize );
usSpectralsNoise = new CustomMaterialProperty<bool>( this, EllipseFlareMixShader.usSpectralsNoise );
spectralsAmount = new CustomMaterialProperty<Vector3>( this, EllipseFlareMixShader.spectralsAmount );
nonSpectralAmount = new CustomMaterialProperty<float>( this, EllipseFlareMixShader.nonSpectralAmount );
spectralsSize = new CustomMaterialProperty<Vector3>( this, EllipseFlareMixShader.spectralsSize );
spectralsSharpness = new CustomMaterialProperty<Vector3>( this, EllipseFlareMixShader.spectralsSharpness );
spectralsFrequency = new CustomMaterialProperty<Vector3>( this, EllipseFlareMixShader.spectralsFrequency );
spectralsSpeed = new CustomMaterialProperty<Vector3>( this, EllipseFlareMixShader.spectralsSpeed );
fading = new CustomMaterialProperty<Texture2D>( this, EllipseFlareMixShader.fading );
sizeXfading = new CustomMaterialProperty<Texture2D>( this, EllipseFlareMixShader.sizeXfading );
sizeYfading = new CustomMaterialProperty<Texture2D>( this, EllipseFlareMixShader.sizeYfading );
useQuickOcclusionTest = new CustomMaterialProperty<bool>( this, EllipseFlareMixShader.useQuickOcclusionTest );
occlusionZOffset = new CustomMaterialProperty<float>( this, EllipseFlareMixShader.occlusionZOffset );
occlusionTestMaxSteps = new CustomMaterialProperty<int>( this, EllipseFlareMixShader.occlusionTestMaxSteps );
occlusionTestStepStride = new CustomMaterialProperty<float>( this, EllipseFlareMixShader.occlusionTestStepStride );
occlusionTestViewDependingScaleAmount = new CustomMaterialProperty<float>( this, EllipseFlareMixShader.occlusionTestViewDependingScaleAmount );
occlusionTestViewDependingDistance = new CustomMaterialProperty<float>( this, EllipseFlareMixShader.occlusionTestViewDependingDistance );
}
}
}

View File

@ -0,0 +1 @@
uid://bmf3lrrftcy8s

View File

@ -0,0 +1,32 @@
void setFlareBillboard(
inout mat4 _MODELVIEW_MATRIX, inout mat3 _MODELVIEW_NORMAL_MATRIX,
mat4 _VIEW_MATRIX, mat4 _MAIN_CAM_INV_VIEW_MATRIX, mat4 _MODEL_MATRIX,
vec3 scale, vec2 _screenOffsetScale
)
{
_MODELVIEW_MATRIX = _VIEW_MATRIX * mat4(
_MAIN_CAM_INV_VIEW_MATRIX[ 0 ],
_MAIN_CAM_INV_VIEW_MATRIX[ 1 ],
_MAIN_CAM_INV_VIEW_MATRIX[ 2 ],
_MODEL_MATRIX[ 3 ]
);
vec3 viewPosition = _MODELVIEW_MATRIX[ 3 ].xyz;
viewPosition.xy += viewPosition.xy * _screenOffsetScale;
_MODELVIEW_MATRIX[ 3 ].xyz = viewPosition;
float scaleX = length( _MODEL_MATRIX[ 0 ].xyz ) * scale.x;
float scaleY = length( _MODEL_MATRIX[ 1 ].xyz ) * scale.y;
float scaleZ = length( _MODEL_MATRIX[ 2 ].xyz ) * scale.z;
_MODELVIEW_MATRIX = _MODELVIEW_MATRIX * mat4(
vec4( scaleX, 0.0, 0.0, 0.0 ),
vec4( 0.0, scaleY, 0.0, 0.0 ),
vec4( 0.0, 0.0, scaleZ, 0.0 ),
vec4( 0.0, 0.0, 0.0, 1.0 )
);
_MODELVIEW_NORMAL_MATRIX = mat3( _MODELVIEW_MATRIX);
}

View File

@ -0,0 +1 @@
uid://fokkb8onnm7p

View File

@ -0,0 +1,4 @@
shader_type spatial;
render_mode blend_add, depth_test_disabled, cull_disabled, unshaded, fog_disabled;
#include "res://addons/rokojori_action_library/Runtime/Shading/Shaders/Flares/GlowFlare/GlowFlareBase.gdshaderinc"

View File

@ -0,0 +1 @@
uid://cqyc7q1cj6yso

View File

@ -0,0 +1,102 @@
using Godot;
namespace Rokojori
{
// Generated by ShaderClassGenerator
public class GlowFlareAddShader
{
public static readonly CachedResource<Shader> shader = new CachedResource<Shader>(
"res://addons/rokojori_action_library/Runtime/Shading/Shaders/Flares/GlowFlare/GlowFlareAdd.gdshader"
);
public static readonly ColorPropertyName color = ColorPropertyName.Create( "color" );
public static readonly FloatPropertyName opacity = FloatPropertyName.Create( "opacity" );
public static readonly Sampler2DPropertyName opacityCurve = Sampler2DPropertyName.Create( "opacityCurve" );
public static readonly FloatPropertyName colorDistortion = FloatPropertyName.Create( "colorDistortion" );
public static readonly FloatPropertyName alphaDistortion = FloatPropertyName.Create( "alphaDistortion" );
public static readonly Vector4PropertyName centerHsl = Vector4PropertyName.Create( "centerHSL" );
public static readonly Vector4PropertyName outsideHsl = Vector4PropertyName.Create( "outsideHSL" );
public static readonly FloatPropertyName sizeX = FloatPropertyName.Create( "sizeX" );
public static readonly FloatPropertyName sizeY = FloatPropertyName.Create( "sizeY" );
public static readonly FloatPropertyName worldSizeScale = FloatPropertyName.Create( "worldSizeScale" );
public static readonly FloatPropertyName screenSizeScale = FloatPropertyName.Create( "screenSizeScale" );
public static readonly FloatPropertyName worldSizeVsScreenSize = FloatPropertyName.Create( "worldSize_vs_screenSize" );
public static readonly Vector2PropertyName screenOffsetScale = Vector2PropertyName.Create( "screenOffsetScale" );
public static readonly Vector2PropertyName screenOffsetLayerSpread = Vector2PropertyName.Create( "screenOffsetLayerSpread" );
public static readonly Sampler2DPropertyName fading = Sampler2DPropertyName.Create( "fading" );
public static readonly Sampler2DPropertyName opacityFading = Sampler2DPropertyName.Create( "opacityFading" );
public static readonly Sampler2DPropertyName sizeXfading = Sampler2DPropertyName.Create( "sizeXfading" );
public static readonly Sampler2DPropertyName sizeYfading = Sampler2DPropertyName.Create( "sizeYfading" );
public static readonly BoolPropertyName useQuickOcclusionTest = BoolPropertyName.Create( "useQuickOcclusionTest" );
public static readonly FloatPropertyName occlusionZOffset = FloatPropertyName.Create( "occlusionZOffset" );
public static readonly IntPropertyName occlusionTestMaxSteps = IntPropertyName.Create( "occlusionTestMaxSteps" );
public static readonly FloatPropertyName occlusionTestStepStride = FloatPropertyName.Create( "occlusionTestStepStride" );
public static readonly FloatPropertyName occlusionTestViewDependingScaleAmount = FloatPropertyName.Create( "occlusionTest_ViewDependingScaleAmount" );
public static readonly FloatPropertyName occlusionTestViewDependingDistance = FloatPropertyName.Create( "occlusionTest_ViewDependingDistance" );
}
[Tool]
public partial class GlowFlareAddMaterial:CustomMaterial
{
public readonly CustomMaterialProperty<Color> color;
public readonly CustomMaterialProperty<float> opacity;
public readonly CustomMaterialProperty<Texture2D> opacityCurve;
public readonly CustomMaterialProperty<float> colorDistortion;
public readonly CustomMaterialProperty<float> alphaDistortion;
public readonly CustomMaterialProperty<Vector4> centerHsl;
public readonly CustomMaterialProperty<Vector4> outsideHsl;
public readonly CustomMaterialProperty<float> sizeX;
public readonly CustomMaterialProperty<float> sizeY;
public readonly CustomMaterialProperty<float> worldSizeScale;
public readonly CustomMaterialProperty<float> screenSizeScale;
public readonly CustomMaterialProperty<float> worldSizeVsScreenSize;
public readonly CustomMaterialProperty<Vector2> screenOffsetScale;
public readonly CustomMaterialProperty<Vector2> screenOffsetLayerSpread;
public readonly CustomMaterialProperty<Texture2D> fading;
public readonly CustomMaterialProperty<Texture2D> opacityFading;
public readonly CustomMaterialProperty<Texture2D> sizeXfading;
public readonly CustomMaterialProperty<Texture2D> sizeYfading;
public readonly CustomMaterialProperty<bool> useQuickOcclusionTest;
public readonly CustomMaterialProperty<float> occlusionZOffset;
public readonly CustomMaterialProperty<int> occlusionTestMaxSteps;
public readonly CustomMaterialProperty<float> occlusionTestStepStride;
public readonly CustomMaterialProperty<float> occlusionTestViewDependingScaleAmount;
public readonly CustomMaterialProperty<float> occlusionTestViewDependingDistance;
public GlowFlareAddMaterial()
{
Shader = GlowFlareAddShader.shader.Get();
color = new CustomMaterialProperty<Color>( this, GlowFlareAddShader.color );
opacity = new CustomMaterialProperty<float>( this, GlowFlareAddShader.opacity );
opacityCurve = new CustomMaterialProperty<Texture2D>( this, GlowFlareAddShader.opacityCurve );
colorDistortion = new CustomMaterialProperty<float>( this, GlowFlareAddShader.colorDistortion );
alphaDistortion = new CustomMaterialProperty<float>( this, GlowFlareAddShader.alphaDistortion );
centerHsl = new CustomMaterialProperty<Vector4>( this, GlowFlareAddShader.centerHsl );
outsideHsl = new CustomMaterialProperty<Vector4>( this, GlowFlareAddShader.outsideHsl );
sizeX = new CustomMaterialProperty<float>( this, GlowFlareAddShader.sizeX );
sizeY = new CustomMaterialProperty<float>( this, GlowFlareAddShader.sizeY );
worldSizeScale = new CustomMaterialProperty<float>( this, GlowFlareAddShader.worldSizeScale );
screenSizeScale = new CustomMaterialProperty<float>( this, GlowFlareAddShader.screenSizeScale );
worldSizeVsScreenSize = new CustomMaterialProperty<float>( this, GlowFlareAddShader.worldSizeVsScreenSize );
screenOffsetScale = new CustomMaterialProperty<Vector2>( this, GlowFlareAddShader.screenOffsetScale );
screenOffsetLayerSpread = new CustomMaterialProperty<Vector2>( this, GlowFlareAddShader.screenOffsetLayerSpread );
fading = new CustomMaterialProperty<Texture2D>( this, GlowFlareAddShader.fading );
opacityFading = new CustomMaterialProperty<Texture2D>( this, GlowFlareAddShader.opacityFading );
sizeXfading = new CustomMaterialProperty<Texture2D>( this, GlowFlareAddShader.sizeXfading );
sizeYfading = new CustomMaterialProperty<Texture2D>( this, GlowFlareAddShader.sizeYfading );
useQuickOcclusionTest = new CustomMaterialProperty<bool>( this, GlowFlareAddShader.useQuickOcclusionTest );
occlusionZOffset = new CustomMaterialProperty<float>( this, GlowFlareAddShader.occlusionZOffset );
occlusionTestMaxSteps = new CustomMaterialProperty<int>( this, GlowFlareAddShader.occlusionTestMaxSteps );
occlusionTestStepStride = new CustomMaterialProperty<float>( this, GlowFlareAddShader.occlusionTestStepStride );
occlusionTestViewDependingScaleAmount = new CustomMaterialProperty<float>( this, GlowFlareAddShader.occlusionTestViewDependingScaleAmount );
occlusionTestViewDependingDistance = new CustomMaterialProperty<float>( this, GlowFlareAddShader.occlusionTestViewDependingDistance );
}
}
}

View File

@ -0,0 +1 @@
uid://b751ojo6ggfls

View File

@ -0,0 +1,178 @@
#include "res://addons/rokojori_action_library/Runtime/Shading/Library/Colors.gdshaderinc"
#include "res://addons/rokojori_action_library/Runtime/Shading/Library/Math.gdshaderinc"
#include "res://addons/rokojori_action_library/Runtime/Shading/Library/Transform.gdshaderinc"
#include "res://addons/rokojori_action_library/Runtime/Shading/Library/Depth.gdshaderinc"
#include "res://addons/rokojori_action_library/Runtime/Shading/Shaders/Flares/Flares.gdshaderinc"
// COLOR
group_uniforms Color;
uniform sampler2D depthTexture:hint_depth_texture;
uniform vec4 color : source_color = vec4( 0.887, 0.434, 0.233, 1.0 );
uniform float opacity = 1;
uniform sampler2D opacityCurve:source_color;
uniform float colorDistortion:hint_range(0.2,20) = 2;
uniform float alphaDistortion:hint_range(0.2,20) = 2;
uniform vec4 centerHSL = vec4( 0.08, 0.0, 0.18, 1.0 );
varying vec4 centerColor;
uniform vec4 outsideHSL = vec4( -0.05, 1.65, 0.02, 0.0 );
varying vec4 outsideColor;
group_uniforms;
// SIZE
group_uniforms Size;
uniform float sizeX:hint_range(1,100) = 1;
uniform float sizeY:hint_range(1,100) = 1;
uniform float worldSizeScale = 1;
uniform float screenSizeScale = 1;
uniform float worldSize_vs_screenSize:hint_range(0,1) = 0.5;
group_uniforms;
// SCREEN OFFSET
group_uniforms ScreenOffset;
uniform vec2 screenOffsetScale = vec2( 0, 0 );
uniform vec2 screenOffsetLayerSpread = vec2( 0, 0 );
group_uniforms;
// Fading
group_uniforms Fading;
uniform sampler2D fading:source_color, repeat_disable, filter_linear;
uniform sampler2D opacityFading:source_color, repeat_disable, filter_linear;
uniform sampler2D sizeXfading:source_color, repeat_disable, filter_linear;
uniform sampler2D sizeYfading:source_color, repeat_disable, filter_linear;
varying float opacityFadeValue;
group_uniforms;
// OCCLUSION
group_uniforms Occlusion;
uniform bool useQuickOcclusionTest = false;
uniform float occlusionZOffset:hint_range(-30,30) = 0;
uniform int occlusionTestMaxSteps = 10;
uniform float occlusionTestStepStride = 1;
uniform float occlusionTest_ViewDependingScaleAmount:hint_range(0,1) = 0.5;
uniform float occlusionTest_ViewDependingDistance = 100;
varying float occlusionAlpha;
group_uniforms;
// void setFlareBillboard(
// inout mat4 _MODELVIEW_MATRIX, inout mat3 _MODELVIEW_NORMAL_MATRIX,
// mat4 _VIEW_MATRIX, mat4 _MAIN_CAM_INV_VIEW_MATRIX, mat4 _MODEL_MATRIX,
// vec3 scale, vec2 _screenOffsetScale
// )
// {
// _MODELVIEW_MATRIX = _VIEW_MATRIX * mat4(
// _MAIN_CAM_INV_VIEW_MATRIX[ 0 ],
// _MAIN_CAM_INV_VIEW_MATRIX[ 1 ],
// _MAIN_CAM_INV_VIEW_MATRIX[ 2 ],
// _MODEL_MATRIX[ 3 ]
// );
// vec3 viewPosition = _MODELVIEW_MATRIX[ 3 ].xyz;
// viewPosition.xy += viewPosition.xy * _screenOffsetScale;
// _MODELVIEW_MATRIX[ 3 ].xyz = viewPosition;
// float scaleX = length( _MODEL_MATRIX[ 0 ].xyz ) * scale.x;
// float scaleY = length( _MODEL_MATRIX[ 1 ].xyz ) * scale.y;
// float scaleZ = length( _MODEL_MATRIX[ 2 ].xyz ) * scale.z;
// _MODELVIEW_MATRIX = _MODELVIEW_MATRIX * mat4(
// vec4( scaleX, 0.0, 0.0, 0.0 ),
// vec4( 0.0, scaleY, 0.0, 0.0 ),
// vec4( 0.0, 0.0, scaleZ, 0.0 ),
// vec4( 0.0, 0.0, 0.0, 1.0 )
// );
// _MODELVIEW_NORMAL_MATRIX = mat3( _MODELVIEW_MATRIX);
// }
void vertex()
{
float normalizedIndex = VERTEX.z;
VERTEX.z = 0.0;
vec3 viewOffset = viewToWorldDirection( vec3( 0, 0, occlusionZOffset ), INV_VIEW_MATRIX );
vec3 nodePositionView = worldToView( NODE_POSITION_WORLD + viewOffset, VIEW_MATRIX );
vec2 screenPosition = viewToScreen( nodePositionView, PROJECTION_MATRIX );
float fadeValue = textureLod( fading, screenPosition, 0.0 ).r;
float opacityValue = textureLod( opacityFading, screenPosition, 0.0 ).r;
float sizeXFade = textureLod( sizeXfading, screenPosition, 0.0 ).r;
float sizeYFade = textureLod( sizeYfading, screenPosition, 0.0 ).r;
float nodeScale = length( extractScale( MODEL_MATRIX ) );
float sX = sizeX * sizeXFade;
float sY = sizeY * sizeYFade;
vec2 uvPixelSize = vec2( 1.0, 1.0 ) / VIEWPORT_SIZE ;
vec2 scaledUVPixelSize = uvPixelSize * max( 1.0, nodePositionView.z / occlusionTest_ViewDependingDistance );
uvPixelSize = mix( uvPixelSize, scaledUVPixelSize, occlusionTest_ViewDependingScaleAmount );
float occlusionValue = useQuickOcclusionTest ?
getQuickOcclusionAt( depthTexture, nodePositionView, uvPixelSize,
occlusionTestMaxSteps, occlusionTestStepStride,
PROJECTION_MATRIX, INV_PROJECTION_MATRIX ) :
getOcclusionAt( depthTexture, nodePositionView, uvPixelSize,
occlusionTestMaxSteps, occlusionTestStepStride,
PROJECTION_MATRIX, INV_PROJECTION_MATRIX );
occlusionAlpha = occlusionValue * fadeValue;
float camDist = length( NODE_POSITION_WORLD - CAMERA_POSITION_WORLD );
vec2 sizeScaled = vec2( sX, sY ) * occlusionAlpha * nodeScale;
vec2 size = mix( sizeScaled * worldSizeScale, sizeScaled * camDist * 0.1 * screenSizeScale, worldSize_vs_screenSize );
setFlareBillboard(
MODELVIEW_MATRIX, MODELVIEW_NORMAL_MATRIX,
VIEW_MATRIX, MAIN_CAM_INV_VIEW_MATRIX, MODEL_MATRIX,
vec3( size.x, size.y, 1.0 ), screenOffsetScale + screenOffsetLayerSpread * ( normalizedIndex * 2.0 - 1.0 )
);
vec3 hsl = RGBtoHSL( color.rgb );
vec3 shiftedHSL = shiftHSL( hsl, centerHSL.rgb, 60.0 );
vec3 shiftedRGB = HSLtoRGB( shiftedHSL );
centerColor = vec4( shiftRGBwithHSL( color.rgb, centerHSL.rgb, 60.0 ), centerHSL.a * color.a );
outsideColor = vec4( shiftRGBwithHSL( color.rgb, outsideHSL.rgb, 60.0 ), outsideHSL.a * color.a );
opacityFadeValue = fadeValue * opacityValue;
float opacityMapValue = textureLod( opacityCurve, vec2( normalizedIndex, 0.0 ), 0.0 ).r;
opacityFadeValue *= opacityMapValue;
}
void fragment()
{
float distanceToCircle = 1.0 - min( 1, length( UV - vec2( 0.5, 0.5 ) ) / 0.5 );
float alpha = pow( distanceToCircle, alphaDistortion );
alpha = min( 1, alpha );
distanceToCircle = pow( distanceToCircle, colorDistortion );
float t = min( 1, distanceToCircle );
vec4 mixedColor = mixThreeColors( outsideColor, color, centerColor, t );
mixedColor.a *= alpha;
ALBEDO = mixedColor.rgb;
ALPHA = mixedColor.a * occlusionAlpha * opacity * opacityFadeValue;
}

View File

@ -0,0 +1 @@
uid://dv4j06odwqjvu

View File

@ -0,0 +1,4 @@
shader_type spatial;
render_mode blend_mix, depth_test_disabled, cull_disabled, unshaded, fog_disabled;
#include "res://addons/rokojori_action_library/Runtime/Shading/Shaders/Flares/GlowFlare/GlowFlareBase.gdshaderinc"

View File

@ -0,0 +1 @@
uid://bvjxbgnsu8pcj

View File

@ -0,0 +1,102 @@
using Godot;
namespace Rokojori
{
// Generated by ShaderClassGenerator
public class GlowFlareMixShader
{
public static readonly CachedResource<Shader> shader = new CachedResource<Shader>(
"res://addons/rokojori_action_library/Runtime/Shading/Shaders/Flares/GlowFlare/GlowFlareMix.gdshader"
);
public static readonly ColorPropertyName color = ColorPropertyName.Create( "color" );
public static readonly FloatPropertyName opacity = FloatPropertyName.Create( "opacity" );
public static readonly Sampler2DPropertyName opacityCurve = Sampler2DPropertyName.Create( "opacityCurve" );
public static readonly FloatPropertyName colorDistortion = FloatPropertyName.Create( "colorDistortion" );
public static readonly FloatPropertyName alphaDistortion = FloatPropertyName.Create( "alphaDistortion" );
public static readonly Vector4PropertyName centerHsl = Vector4PropertyName.Create( "centerHSL" );
public static readonly Vector4PropertyName outsideHsl = Vector4PropertyName.Create( "outsideHSL" );
public static readonly FloatPropertyName sizeX = FloatPropertyName.Create( "sizeX" );
public static readonly FloatPropertyName sizeY = FloatPropertyName.Create( "sizeY" );
public static readonly FloatPropertyName worldSizeScale = FloatPropertyName.Create( "worldSizeScale" );
public static readonly FloatPropertyName screenSizeScale = FloatPropertyName.Create( "screenSizeScale" );
public static readonly FloatPropertyName worldSizeVsScreenSize = FloatPropertyName.Create( "worldSize_vs_screenSize" );
public static readonly Vector2PropertyName screenOffsetScale = Vector2PropertyName.Create( "screenOffsetScale" );
public static readonly Vector2PropertyName screenOffsetLayerSpread = Vector2PropertyName.Create( "screenOffsetLayerSpread" );
public static readonly Sampler2DPropertyName fading = Sampler2DPropertyName.Create( "fading" );
public static readonly Sampler2DPropertyName opacityFading = Sampler2DPropertyName.Create( "opacityFading" );
public static readonly Sampler2DPropertyName sizeXfading = Sampler2DPropertyName.Create( "sizeXfading" );
public static readonly Sampler2DPropertyName sizeYfading = Sampler2DPropertyName.Create( "sizeYfading" );
public static readonly BoolPropertyName useQuickOcclusionTest = BoolPropertyName.Create( "useQuickOcclusionTest" );
public static readonly FloatPropertyName occlusionZOffset = FloatPropertyName.Create( "occlusionZOffset" );
public static readonly IntPropertyName occlusionTestMaxSteps = IntPropertyName.Create( "occlusionTestMaxSteps" );
public static readonly FloatPropertyName occlusionTestStepStride = FloatPropertyName.Create( "occlusionTestStepStride" );
public static readonly FloatPropertyName occlusionTestViewDependingScaleAmount = FloatPropertyName.Create( "occlusionTest_ViewDependingScaleAmount" );
public static readonly FloatPropertyName occlusionTestViewDependingDistance = FloatPropertyName.Create( "occlusionTest_ViewDependingDistance" );
}
[Tool]
public partial class GlowFlareMixMaterial:CustomMaterial
{
public readonly CustomMaterialProperty<Color> color;
public readonly CustomMaterialProperty<float> opacity;
public readonly CustomMaterialProperty<Texture2D> opacityCurve;
public readonly CustomMaterialProperty<float> colorDistortion;
public readonly CustomMaterialProperty<float> alphaDistortion;
public readonly CustomMaterialProperty<Vector4> centerHsl;
public readonly CustomMaterialProperty<Vector4> outsideHsl;
public readonly CustomMaterialProperty<float> sizeX;
public readonly CustomMaterialProperty<float> sizeY;
public readonly CustomMaterialProperty<float> worldSizeScale;
public readonly CustomMaterialProperty<float> screenSizeScale;
public readonly CustomMaterialProperty<float> worldSizeVsScreenSize;
public readonly CustomMaterialProperty<Vector2> screenOffsetScale;
public readonly CustomMaterialProperty<Vector2> screenOffsetLayerSpread;
public readonly CustomMaterialProperty<Texture2D> fading;
public readonly CustomMaterialProperty<Texture2D> opacityFading;
public readonly CustomMaterialProperty<Texture2D> sizeXfading;
public readonly CustomMaterialProperty<Texture2D> sizeYfading;
public readonly CustomMaterialProperty<bool> useQuickOcclusionTest;
public readonly CustomMaterialProperty<float> occlusionZOffset;
public readonly CustomMaterialProperty<int> occlusionTestMaxSteps;
public readonly CustomMaterialProperty<float> occlusionTestStepStride;
public readonly CustomMaterialProperty<float> occlusionTestViewDependingScaleAmount;
public readonly CustomMaterialProperty<float> occlusionTestViewDependingDistance;
public GlowFlareMixMaterial()
{
Shader = GlowFlareMixShader.shader.Get();
color = new CustomMaterialProperty<Color>( this, GlowFlareMixShader.color );
opacity = new CustomMaterialProperty<float>( this, GlowFlareMixShader.opacity );
opacityCurve = new CustomMaterialProperty<Texture2D>( this, GlowFlareMixShader.opacityCurve );
colorDistortion = new CustomMaterialProperty<float>( this, GlowFlareMixShader.colorDistortion );
alphaDistortion = new CustomMaterialProperty<float>( this, GlowFlareMixShader.alphaDistortion );
centerHsl = new CustomMaterialProperty<Vector4>( this, GlowFlareMixShader.centerHsl );
outsideHsl = new CustomMaterialProperty<Vector4>( this, GlowFlareMixShader.outsideHsl );
sizeX = new CustomMaterialProperty<float>( this, GlowFlareMixShader.sizeX );
sizeY = new CustomMaterialProperty<float>( this, GlowFlareMixShader.sizeY );
worldSizeScale = new CustomMaterialProperty<float>( this, GlowFlareMixShader.worldSizeScale );
screenSizeScale = new CustomMaterialProperty<float>( this, GlowFlareMixShader.screenSizeScale );
worldSizeVsScreenSize = new CustomMaterialProperty<float>( this, GlowFlareMixShader.worldSizeVsScreenSize );
screenOffsetScale = new CustomMaterialProperty<Vector2>( this, GlowFlareMixShader.screenOffsetScale );
screenOffsetLayerSpread = new CustomMaterialProperty<Vector2>( this, GlowFlareMixShader.screenOffsetLayerSpread );
fading = new CustomMaterialProperty<Texture2D>( this, GlowFlareMixShader.fading );
opacityFading = new CustomMaterialProperty<Texture2D>( this, GlowFlareMixShader.opacityFading );
sizeXfading = new CustomMaterialProperty<Texture2D>( this, GlowFlareMixShader.sizeXfading );
sizeYfading = new CustomMaterialProperty<Texture2D>( this, GlowFlareMixShader.sizeYfading );
useQuickOcclusionTest = new CustomMaterialProperty<bool>( this, GlowFlareMixShader.useQuickOcclusionTest );
occlusionZOffset = new CustomMaterialProperty<float>( this, GlowFlareMixShader.occlusionZOffset );
occlusionTestMaxSteps = new CustomMaterialProperty<int>( this, GlowFlareMixShader.occlusionTestMaxSteps );
occlusionTestStepStride = new CustomMaterialProperty<float>( this, GlowFlareMixShader.occlusionTestStepStride );
occlusionTestViewDependingScaleAmount = new CustomMaterialProperty<float>( this, GlowFlareMixShader.occlusionTestViewDependingScaleAmount );
occlusionTestViewDependingDistance = new CustomMaterialProperty<float>( this, GlowFlareMixShader.occlusionTestViewDependingDistance );
}
}
}

View File

@ -0,0 +1 @@
uid://cusgp711ny0pc

View File

@ -0,0 +1,4 @@
shader_type spatial;
render_mode blend_add, depth_test_disabled, cull_disabled, unshaded, fog_disabled;
#include "res://addons/rokojori_action_library/Runtime/Shading/Shaders/Flares/ShapeFlare/ShapeFlareBase.gdshaderinc"

View File

@ -0,0 +1 @@
uid://ibo7qa8hf6he

View File

@ -0,0 +1,135 @@
using Godot;
namespace Rokojori
{
// Generated by ShaderClassGenerator
public class ShapeFlareAddShader
{
public static readonly CachedResource<Shader> shader = new CachedResource<Shader>(
"res://addons/rokojori_action_library/Runtime/Shading/Shaders/Flares/ShapeFlare/ShapeFlareAdd.gdshader"
);
public static readonly IntPropertyName shapeType = IntPropertyName.Create( "shapeType" );
public static readonly FloatPropertyName shapeScale = FloatPropertyName.Create( "shapeScale" );
public static readonly FloatPropertyName shapeRotation = FloatPropertyName.Create( "shapeRotation" );
public static readonly FloatPropertyName minShapeDistance = FloatPropertyName.Create( "minShapeDistance" );
public static readonly FloatPropertyName maxShapeDistance = FloatPropertyName.Create( "maxShapeDistance" );
public static readonly ColorPropertyName color = ColorPropertyName.Create( "color" );
public static readonly FloatPropertyName opacity = FloatPropertyName.Create( "opacity" );
public static readonly Sampler2DPropertyName opacityCurve = Sampler2DPropertyName.Create( "opacityCurve" );
public static readonly FloatPropertyName colorDistortion = FloatPropertyName.Create( "colorDistortion" );
public static readonly FloatPropertyName alphaDistortion = FloatPropertyName.Create( "alphaDistortion" );
public static readonly Vector4PropertyName centerHsl = Vector4PropertyName.Create( "centerHSL" );
public static readonly Vector4PropertyName outsideHsl = Vector4PropertyName.Create( "outsideHSL" );
public static readonly FloatPropertyName minHueRandom = FloatPropertyName.Create( "minHueRandom" );
public static readonly FloatPropertyName maxHueRandom = FloatPropertyName.Create( "maxHueRandom" );
public static readonly FloatPropertyName minShapeDistanceColor = FloatPropertyName.Create( "minShapeDistanceColor" );
public static readonly FloatPropertyName maxShapeDistanceColor = FloatPropertyName.Create( "maxShapeDistanceColor" );
public static readonly FloatPropertyName sizeX = FloatPropertyName.Create( "sizeX" );
public static readonly FloatPropertyName sizeY = FloatPropertyName.Create( "sizeY" );
public static readonly FloatPropertyName worldSizeScale = FloatPropertyName.Create( "worldSizeScale" );
public static readonly FloatPropertyName screenSizeScale = FloatPropertyName.Create( "screenSizeScale" );
public static readonly FloatPropertyName worldSizeVsScreenSize = FloatPropertyName.Create( "worldSize_vs_screenSize" );
public static readonly FloatPropertyName randomScaleMin = FloatPropertyName.Create( "randomScaleMin" );
public static readonly FloatPropertyName randomScaleMax = FloatPropertyName.Create( "randomScaleMax" );
public static readonly Vector2PropertyName screenOffsetScale = Vector2PropertyName.Create( "screenOffsetScale" );
public static readonly Vector2PropertyName screenOffsetLayerSpread = Vector2PropertyName.Create( "screenOffsetLayerSpread" );
public static readonly Sampler2DPropertyName fading = Sampler2DPropertyName.Create( "fading" );
public static readonly Sampler2DPropertyName opacityFading = Sampler2DPropertyName.Create( "opacityFading" );
public static readonly Sampler2DPropertyName sizeXfading = Sampler2DPropertyName.Create( "sizeXfading" );
public static readonly Sampler2DPropertyName sizeYfading = Sampler2DPropertyName.Create( "sizeYfading" );
public static readonly BoolPropertyName useQuickOcclusionTest = BoolPropertyName.Create( "useQuickOcclusionTest" );
public static readonly FloatPropertyName occlusionZOffset = FloatPropertyName.Create( "occlusionZOffset" );
public static readonly IntPropertyName occlusionTestMaxSteps = IntPropertyName.Create( "occlusionTestMaxSteps" );
public static readonly FloatPropertyName occlusionTestStepStride = FloatPropertyName.Create( "occlusionTestStepStride" );
public static readonly FloatPropertyName occlusionTestViewDependingScaleAmount = FloatPropertyName.Create( "occlusionTest_ViewDependingScaleAmount" );
public static readonly FloatPropertyName occlusionTestViewDependingDistance = FloatPropertyName.Create( "occlusionTest_ViewDependingDistance" );
}
[Tool]
public partial class ShapeFlareAddMaterial:CustomMaterial
{
public readonly CustomMaterialProperty<int> shapeType;
public readonly CustomMaterialProperty<float> shapeScale;
public readonly CustomMaterialProperty<float> shapeRotation;
public readonly CustomMaterialProperty<float> minShapeDistance;
public readonly CustomMaterialProperty<float> maxShapeDistance;
public readonly CustomMaterialProperty<Color> color;
public readonly CustomMaterialProperty<float> opacity;
public readonly CustomMaterialProperty<Texture2D> opacityCurve;
public readonly CustomMaterialProperty<float> colorDistortion;
public readonly CustomMaterialProperty<float> alphaDistortion;
public readonly CustomMaterialProperty<Vector4> centerHsl;
public readonly CustomMaterialProperty<Vector4> outsideHsl;
public readonly CustomMaterialProperty<float> minHueRandom;
public readonly CustomMaterialProperty<float> maxHueRandom;
public readonly CustomMaterialProperty<float> minShapeDistanceColor;
public readonly CustomMaterialProperty<float> maxShapeDistanceColor;
public readonly CustomMaterialProperty<float> sizeX;
public readonly CustomMaterialProperty<float> sizeY;
public readonly CustomMaterialProperty<float> worldSizeScale;
public readonly CustomMaterialProperty<float> screenSizeScale;
public readonly CustomMaterialProperty<float> worldSizeVsScreenSize;
public readonly CustomMaterialProperty<float> randomScaleMin;
public readonly CustomMaterialProperty<float> randomScaleMax;
public readonly CustomMaterialProperty<Vector2> screenOffsetScale;
public readonly CustomMaterialProperty<Vector2> screenOffsetLayerSpread;
public readonly CustomMaterialProperty<Texture2D> fading;
public readonly CustomMaterialProperty<Texture2D> opacityFading;
public readonly CustomMaterialProperty<Texture2D> sizeXfading;
public readonly CustomMaterialProperty<Texture2D> sizeYfading;
public readonly CustomMaterialProperty<bool> useQuickOcclusionTest;
public readonly CustomMaterialProperty<float> occlusionZOffset;
public readonly CustomMaterialProperty<int> occlusionTestMaxSteps;
public readonly CustomMaterialProperty<float> occlusionTestStepStride;
public readonly CustomMaterialProperty<float> occlusionTestViewDependingScaleAmount;
public readonly CustomMaterialProperty<float> occlusionTestViewDependingDistance;
public ShapeFlareAddMaterial()
{
Shader = ShapeFlareAddShader.shader.Get();
shapeType = new CustomMaterialProperty<int>( this, ShapeFlareAddShader.shapeType );
shapeScale = new CustomMaterialProperty<float>( this, ShapeFlareAddShader.shapeScale );
shapeRotation = new CustomMaterialProperty<float>( this, ShapeFlareAddShader.shapeRotation );
minShapeDistance = new CustomMaterialProperty<float>( this, ShapeFlareAddShader.minShapeDistance );
maxShapeDistance = new CustomMaterialProperty<float>( this, ShapeFlareAddShader.maxShapeDistance );
color = new CustomMaterialProperty<Color>( this, ShapeFlareAddShader.color );
opacity = new CustomMaterialProperty<float>( this, ShapeFlareAddShader.opacity );
opacityCurve = new CustomMaterialProperty<Texture2D>( this, ShapeFlareAddShader.opacityCurve );
colorDistortion = new CustomMaterialProperty<float>( this, ShapeFlareAddShader.colorDistortion );
alphaDistortion = new CustomMaterialProperty<float>( this, ShapeFlareAddShader.alphaDistortion );
centerHsl = new CustomMaterialProperty<Vector4>( this, ShapeFlareAddShader.centerHsl );
outsideHsl = new CustomMaterialProperty<Vector4>( this, ShapeFlareAddShader.outsideHsl );
minHueRandom = new CustomMaterialProperty<float>( this, ShapeFlareAddShader.minHueRandom );
maxHueRandom = new CustomMaterialProperty<float>( this, ShapeFlareAddShader.maxHueRandom );
minShapeDistanceColor = new CustomMaterialProperty<float>( this, ShapeFlareAddShader.minShapeDistanceColor );
maxShapeDistanceColor = new CustomMaterialProperty<float>( this, ShapeFlareAddShader.maxShapeDistanceColor );
sizeX = new CustomMaterialProperty<float>( this, ShapeFlareAddShader.sizeX );
sizeY = new CustomMaterialProperty<float>( this, ShapeFlareAddShader.sizeY );
worldSizeScale = new CustomMaterialProperty<float>( this, ShapeFlareAddShader.worldSizeScale );
screenSizeScale = new CustomMaterialProperty<float>( this, ShapeFlareAddShader.screenSizeScale );
worldSizeVsScreenSize = new CustomMaterialProperty<float>( this, ShapeFlareAddShader.worldSizeVsScreenSize );
randomScaleMin = new CustomMaterialProperty<float>( this, ShapeFlareAddShader.randomScaleMin );
randomScaleMax = new CustomMaterialProperty<float>( this, ShapeFlareAddShader.randomScaleMax );
screenOffsetScale = new CustomMaterialProperty<Vector2>( this, ShapeFlareAddShader.screenOffsetScale );
screenOffsetLayerSpread = new CustomMaterialProperty<Vector2>( this, ShapeFlareAddShader.screenOffsetLayerSpread );
fading = new CustomMaterialProperty<Texture2D>( this, ShapeFlareAddShader.fading );
opacityFading = new CustomMaterialProperty<Texture2D>( this, ShapeFlareAddShader.opacityFading );
sizeXfading = new CustomMaterialProperty<Texture2D>( this, ShapeFlareAddShader.sizeXfading );
sizeYfading = new CustomMaterialProperty<Texture2D>( this, ShapeFlareAddShader.sizeYfading );
useQuickOcclusionTest = new CustomMaterialProperty<bool>( this, ShapeFlareAddShader.useQuickOcclusionTest );
occlusionZOffset = new CustomMaterialProperty<float>( this, ShapeFlareAddShader.occlusionZOffset );
occlusionTestMaxSteps = new CustomMaterialProperty<int>( this, ShapeFlareAddShader.occlusionTestMaxSteps );
occlusionTestStepStride = new CustomMaterialProperty<float>( this, ShapeFlareAddShader.occlusionTestStepStride );
occlusionTestViewDependingScaleAmount = new CustomMaterialProperty<float>( this, ShapeFlareAddShader.occlusionTestViewDependingScaleAmount );
occlusionTestViewDependingDistance = new CustomMaterialProperty<float>( this, ShapeFlareAddShader.occlusionTestViewDependingDistance );
}
}
}

View File

@ -0,0 +1 @@
uid://btnca61nvu55p

View File

@ -0,0 +1,241 @@
#include "res://addons/rokojori_action_library/Runtime/Shading/Library/Colors.gdshaderinc"
#include "res://addons/rokojori_action_library/Runtime/Shading/Library/Math.gdshaderinc"
#include "res://addons/rokojori_action_library/Runtime/Shading/Library/Transform.gdshaderinc"
#include "res://addons/rokojori_action_library/Runtime/Shading/Library/Depth.gdshaderinc"
#include "res://addons/rokojori_action_library/Runtime/Shading/Library/SDF.gdshaderinc"
#include "res://addons/rokojori_action_library/Runtime/Shading/Library/Noise.gdshaderinc"
#include "res://addons/rokojori_action_library/Runtime/Shading/Shaders/Flares/Flares.gdshaderinc"
// SHAPE
group_uniforms Shape;
uniform int shapeType:hint_range(0,12);
uniform float shapeScale:hint_range(0,1) = 0.5;
uniform float shapeRotation:hint_range(-180,180) = 0;
uniform float minShapeDistance = 0;
uniform float maxShapeDistance = 0.05;
group_uniforms;
// COLOR
group_uniforms Color;
uniform sampler2D depthTexture:hint_depth_texture;
uniform vec4 color : source_color = vec4( 0.887, 0.434, 0.233, 1.0 );
uniform float opacity = 1;
uniform sampler2D opacityCurve:source_color;
uniform float colorDistortion:hint_range(0.2,20) = 2;
uniform float alphaDistortion:hint_range(0.2,20) = 2;
uniform vec4 centerHSL = vec4( 0.08, 0.0, 0.18, 1.0 );
varying vec4 centerColor;
uniform vec4 outsideHSL = vec4( -0.05, 1.65, 0.02, 0.0 );
varying vec4 outsideColor;
uniform float minHueRandom = 0;
uniform float maxHueRandom = 0;
uniform float minShapeDistanceColor = 0;
uniform float maxShapeDistanceColor = 0.05;
group_uniforms;
// SIZE
group_uniforms Size;
uniform float sizeX:hint_range(1,100) = 1;
uniform float sizeY:hint_range(1,100) = 1;
uniform float worldSizeScale = 1;
uniform float screenSizeScale = 1;
uniform float worldSize_vs_screenSize:hint_range(0,1) = 0.5;
uniform float randomScaleMin = 1.0;
uniform float randomScaleMax = 1.0;
group_uniforms;
// SCREEN OFFSET
group_uniforms ScreenOffset;
uniform vec2 screenOffsetScale = vec2( 0, 0 );
uniform vec2 screenOffsetLayerSpread = vec2( 0, 0 );
group_uniforms;
// Fading
group_uniforms Fading;
// uniform sampler2D fading:source_color, repeat_disable, filter_linear;
// uniform sampler2D opacityFading:source_color, repeat_disable, filter_linear;
// uniform sampler2D sizeXfading:source_color, repeat_disable, filter_linear;
// uniform sampler2D sizeYfading:source_color, repeat_disable, filter_linear;
uniform float fadingPower = 1.0;
uniform float opacityFadingPower = 1.0;
uniform float sizeXfadingPower = 1.0;
uniform float sizeYfadingPower = 1.0;
varying float opacityFadeValue;
group_uniforms;
// OCCLUSION
group_uniforms Occlusion;
uniform bool useQuickOcclusionTest = false;
uniform float occlusionZOffset:hint_range(-30,30) = 0;
uniform int occlusionTestMaxSteps = 10;
uniform float occlusionTestStepStride = 1;
uniform float occlusionTest_ViewDependingScaleAmount:hint_range(0,1) = 0.5;
uniform float occlusionTest_ViewDependingDistance = 100;
varying float occlusionAlpha;
group_uniforms;
float getShapeDistance(
int _shapeType, float _shapeScale, float _shapeRotation, vec2 _uv, float _minShapeDistance, float _maxShapeDistance )
{
float distance = 0.0;
_shapeRotation += 180.0;
_uv -= vec2( 0.5 );
_uv = rotate_v2( _uv, _shapeRotation / 180.0 * 3.141592653 );
_uv /= _shapeScale;
if ( _shapeType == 0 ) { distance = sdCircle( _uv, 0.5 ); }
else if ( _shapeType == 1 ) { distance = sdRoundedX( _uv, 0.5, 0.2 ); }
else if ( _shapeType == 2 ) { distance = sdEquilateralTriangle( _uv, 0.666 ); }
else if ( _shapeType == 3 ) { distance = sdBox( _uv, vec2( 0.5 ) ); }
else if ( _shapeType == 4 ) { distance = sdPentagon( _uv, 0.5 ); }
else if ( _shapeType == 5 ) { distance = sdHexagon( _uv, 0.5 ); }
else if ( _shapeType == 6 ) { distance = sdOctogon( _uv, 0.5 ); }
else if ( _shapeType == 7 ) { distance = sdHexagram( _uv, 0.333); }
else if ( _shapeType == 8 ) { distance = sdPentagram( _uv, 0.6666 ); }
else if ( _shapeType == 9 ) { distance = sdMoon( _uv, 0.0, 0.5, 0.4 ); }
else if ( _shapeType == 10 ) { distance = sdMoon( _uv, 0.5, 0.5, 0.4 ); }
else if ( _shapeType == 11 ) { distance = sdMoon( _uv, 0.1, 0.5, 0.3 ); }
else if ( _shapeType == 12 ) { distance = sdHeart( _uv ); }
return distance;
// float normalizedDistance = normalizeToRange01( distance, _minShapeDistance, _maxShapeDistance );
// return 1.0 - normalizedDistance;
}
varying vec4 combinedColor;
void vertex()
{
float normalizedIndex = VERTEX.z;
VERTEX.z = 0.0;
vec3 viewOffset = viewToWorldDirection( vec3( 0, 0, occlusionZOffset ), INV_VIEW_MATRIX );
vec3 nodePositionView = worldToView( NODE_POSITION_WORLD + viewOffset, VIEW_MATRIX );
vec2 screenPosition = viewToScreen( nodePositionView, PROJECTION_MATRIX );
float edgeDistance = max( 0.0, -sdBox( screenPosition - vec2( 0.5 ), vec2( 0.5 ) ) ) * 2.0;
// float fadeValue = textureLod( fading, screenPosition, 0.0 ).r;
// float opacityValue = textureLod( opacityFading, screenPosition, 0.0 ).r;
// float sizeXFade = textureLod( sizeXfading, screenPosition, 0.0 ).r;
// float sizeYFade = textureLod( sizeYfading, screenPosition, 0.0 ).r;
float fadeValue = pow( edgeDistance, fadingPower );
float opacityValue = pow( edgeDistance, opacityFadingPower );
float sizeXFade = pow( edgeDistance, sizeXfadingPower );
float sizeYFade = pow( edgeDistance, sizeYfadingPower );
float nodeScale = length( extractScale( MODEL_MATRIX ) );
float sX = sizeX * sizeXFade;
float sY = sizeY * sizeYFade;
vec2 uvPixelSize = vec2( 1.0, 1.0 ) / VIEWPORT_SIZE ;
vec2 scaledUVPixelSize = uvPixelSize * max( 1.0, nodePositionView.z / occlusionTest_ViewDependingDistance );
uvPixelSize = mix( uvPixelSize, scaledUVPixelSize, occlusionTest_ViewDependingScaleAmount );
float occlusionValue = useQuickOcclusionTest ?
getQuickOcclusionAt( depthTexture, nodePositionView, uvPixelSize,
occlusionTestMaxSteps, occlusionTestStepStride,
PROJECTION_MATRIX, INV_PROJECTION_MATRIX ) :
getOcclusionAt( depthTexture, nodePositionView, uvPixelSize,
occlusionTestMaxSteps, occlusionTestStepStride,
PROJECTION_MATRIX, INV_PROJECTION_MATRIX );
occlusionAlpha = occlusionValue * fadeValue;
float camDist = length( NODE_POSITION_WORLD - CAMERA_POSITION_WORLD );
vec2 sizeScaled = vec2( sX, sY ) * occlusionAlpha * nodeScale;
vec2 size = mix( sizeScaled * worldSizeScale, sizeScaled * camDist * 0.1 * screenSizeScale, worldSize_vs_screenSize );
float randomScale = mix( randomScaleMin, randomScaleMax, random( vec2( normalizedIndex ) ) );
size *= randomScale;
setFlareBillboard(
MODELVIEW_MATRIX, MODELVIEW_NORMAL_MATRIX,
VIEW_MATRIX, MAIN_CAM_INV_VIEW_MATRIX, MODEL_MATRIX,
vec3( size.x, size.y, 1.0 ), screenOffsetScale + screenOffsetLayerSpread * ( normalizedIndex * 2.0 - 1.0 )
);
vec3 hsl = RGBtoHSL( color.rgb );
vec3 shiftedHSL = shiftHSL( hsl, centerHSL.rgb, 60.0 );
vec3 shiftedRGB = HSLtoRGB( shiftedHSL );
combinedColor = color;
float rgbScale = getRGBScale( combinedColor.rgb );
float randomHueOffset = mix( minHueRandom, maxHueRandom, random( vec2( normalizedIndex ) + vec2( 0.23, 0.13 ) ) );
combinedColor.rgb = changeHueOfRGB( combinedColor.rgb / rgbScale, randomHueOffset ) * rgbScale;
rgbScale = getRGBScale( combinedColor.rgb );
centerColor = vec4( shiftRGBwithHSL( combinedColor.rgb / rgbScale, centerHSL.rgb, 60.0 ) * rgbScale, centerHSL.a * color.a );
outsideColor = vec4( shiftRGBwithHSL( combinedColor.rgb / rgbScale, outsideHSL.rgb, 60.0 ) * rgbScale, outsideHSL.a * color.a );
opacityFadeValue = fadeValue * opacityValue;
float opacityMapValue = textureLod( opacityCurve, vec2( normalizedIndex, 0.0 ), 0.0 ).r;
opacityFadeValue *= opacityMapValue;
}
void fragment()
{
// float distanceToCircle = 1.0 - min( 1, length( UV - vec2( 0.5, 0.5 ) ) / 0.5 );
// float normalizedDistance = normalizeToRange01( distance, _minShapeDistance, _maxShapeDistance );
// return 1.0 - normalizedDistance;
float distance = getShapeDistance( shapeType, shapeScale, -shapeRotation, UV, minShapeDistance, maxShapeDistance );
float normalizedAlphaDistance = normalizeToRange01( distance, minShapeDistance, maxShapeDistance );
float alphaT = 1.0 - normalizedAlphaDistance;
float normalizedColorDistance = normalizeToRange01( distance, minShapeDistanceColor, maxShapeDistanceColor );
float colorT = 1.0 - normalizedColorDistance;
colorT = pow( colorT, colorDistortion );
alphaT = pow( alphaT, alphaDistortion );
float t = min( 1, colorT );
vec4 mixedColor = mixThreeColors( outsideColor, combinedColor, centerColor, t );
// mixedColor = outsideColor;
mixedColor.a *= alphaT;
ALBEDO = mixedColor.rgb;
ALPHA = mixedColor.a * occlusionAlpha * opacity * opacityFadeValue;
}

View File

@ -0,0 +1 @@
uid://vfabwu76j40f

View File

@ -0,0 +1,4 @@
shader_type spatial;
render_mode blend_mix, depth_test_disabled, cull_disabled, unshaded, fog_disabled;
#include "res://addons/rokojori_action_library/Runtime/Shading/Shaders/Flares/ShapeFlare/ShapeFlareBase.gdshaderinc"

View File

@ -0,0 +1 @@
uid://yy2pi2u1bg4n

View File

@ -0,0 +1,135 @@
using Godot;
namespace Rokojori
{
// Generated by ShaderClassGenerator
public class ShapeFlareMixShader
{
public static readonly CachedResource<Shader> shader = new CachedResource<Shader>(
"res://addons/rokojori_action_library/Runtime/Shading/Shaders/Flares/ShapeFlare/ShapeFlareMix.gdshader"
);
public static readonly IntPropertyName shapeType = IntPropertyName.Create( "shapeType" );
public static readonly FloatPropertyName shapeScale = FloatPropertyName.Create( "shapeScale" );
public static readonly FloatPropertyName shapeRotation = FloatPropertyName.Create( "shapeRotation" );
public static readonly FloatPropertyName minShapeDistance = FloatPropertyName.Create( "minShapeDistance" );
public static readonly FloatPropertyName maxShapeDistance = FloatPropertyName.Create( "maxShapeDistance" );
public static readonly ColorPropertyName color = ColorPropertyName.Create( "color" );
public static readonly FloatPropertyName opacity = FloatPropertyName.Create( "opacity" );
public static readonly Sampler2DPropertyName opacityCurve = Sampler2DPropertyName.Create( "opacityCurve" );
public static readonly FloatPropertyName colorDistortion = FloatPropertyName.Create( "colorDistortion" );
public static readonly FloatPropertyName alphaDistortion = FloatPropertyName.Create( "alphaDistortion" );
public static readonly Vector4PropertyName centerHsl = Vector4PropertyName.Create( "centerHSL" );
public static readonly Vector4PropertyName outsideHsl = Vector4PropertyName.Create( "outsideHSL" );
public static readonly FloatPropertyName minHueRandom = FloatPropertyName.Create( "minHueRandom" );
public static readonly FloatPropertyName maxHueRandom = FloatPropertyName.Create( "maxHueRandom" );
public static readonly FloatPropertyName minShapeDistanceColor = FloatPropertyName.Create( "minShapeDistanceColor" );
public static readonly FloatPropertyName maxShapeDistanceColor = FloatPropertyName.Create( "maxShapeDistanceColor" );
public static readonly FloatPropertyName sizeX = FloatPropertyName.Create( "sizeX" );
public static readonly FloatPropertyName sizeY = FloatPropertyName.Create( "sizeY" );
public static readonly FloatPropertyName worldSizeScale = FloatPropertyName.Create( "worldSizeScale" );
public static readonly FloatPropertyName screenSizeScale = FloatPropertyName.Create( "screenSizeScale" );
public static readonly FloatPropertyName worldSizeVsScreenSize = FloatPropertyName.Create( "worldSize_vs_screenSize" );
public static readonly FloatPropertyName randomScaleMin = FloatPropertyName.Create( "randomScaleMin" );
public static readonly FloatPropertyName randomScaleMax = FloatPropertyName.Create( "randomScaleMax" );
public static readonly Vector2PropertyName screenOffsetScale = Vector2PropertyName.Create( "screenOffsetScale" );
public static readonly Vector2PropertyName screenOffsetLayerSpread = Vector2PropertyName.Create( "screenOffsetLayerSpread" );
public static readonly Sampler2DPropertyName fading = Sampler2DPropertyName.Create( "fading" );
public static readonly Sampler2DPropertyName opacityFading = Sampler2DPropertyName.Create( "opacityFading" );
public static readonly Sampler2DPropertyName sizeXfading = Sampler2DPropertyName.Create( "sizeXfading" );
public static readonly Sampler2DPropertyName sizeYfading = Sampler2DPropertyName.Create( "sizeYfading" );
public static readonly BoolPropertyName useQuickOcclusionTest = BoolPropertyName.Create( "useQuickOcclusionTest" );
public static readonly FloatPropertyName occlusionZOffset = FloatPropertyName.Create( "occlusionZOffset" );
public static readonly IntPropertyName occlusionTestMaxSteps = IntPropertyName.Create( "occlusionTestMaxSteps" );
public static readonly FloatPropertyName occlusionTestStepStride = FloatPropertyName.Create( "occlusionTestStepStride" );
public static readonly FloatPropertyName occlusionTestViewDependingScaleAmount = FloatPropertyName.Create( "occlusionTest_ViewDependingScaleAmount" );
public static readonly FloatPropertyName occlusionTestViewDependingDistance = FloatPropertyName.Create( "occlusionTest_ViewDependingDistance" );
}
[Tool]
public partial class ShapeFlareMixMaterial:CustomMaterial
{
public readonly CustomMaterialProperty<int> shapeType;
public readonly CustomMaterialProperty<float> shapeScale;
public readonly CustomMaterialProperty<float> shapeRotation;
public readonly CustomMaterialProperty<float> minShapeDistance;
public readonly CustomMaterialProperty<float> maxShapeDistance;
public readonly CustomMaterialProperty<Color> color;
public readonly CustomMaterialProperty<float> opacity;
public readonly CustomMaterialProperty<Texture2D> opacityCurve;
public readonly CustomMaterialProperty<float> colorDistortion;
public readonly CustomMaterialProperty<float> alphaDistortion;
public readonly CustomMaterialProperty<Vector4> centerHsl;
public readonly CustomMaterialProperty<Vector4> outsideHsl;
public readonly CustomMaterialProperty<float> minHueRandom;
public readonly CustomMaterialProperty<float> maxHueRandom;
public readonly CustomMaterialProperty<float> minShapeDistanceColor;
public readonly CustomMaterialProperty<float> maxShapeDistanceColor;
public readonly CustomMaterialProperty<float> sizeX;
public readonly CustomMaterialProperty<float> sizeY;
public readonly CustomMaterialProperty<float> worldSizeScale;
public readonly CustomMaterialProperty<float> screenSizeScale;
public readonly CustomMaterialProperty<float> worldSizeVsScreenSize;
public readonly CustomMaterialProperty<float> randomScaleMin;
public readonly CustomMaterialProperty<float> randomScaleMax;
public readonly CustomMaterialProperty<Vector2> screenOffsetScale;
public readonly CustomMaterialProperty<Vector2> screenOffsetLayerSpread;
public readonly CustomMaterialProperty<Texture2D> fading;
public readonly CustomMaterialProperty<Texture2D> opacityFading;
public readonly CustomMaterialProperty<Texture2D> sizeXfading;
public readonly CustomMaterialProperty<Texture2D> sizeYfading;
public readonly CustomMaterialProperty<bool> useQuickOcclusionTest;
public readonly CustomMaterialProperty<float> occlusionZOffset;
public readonly CustomMaterialProperty<int> occlusionTestMaxSteps;
public readonly CustomMaterialProperty<float> occlusionTestStepStride;
public readonly CustomMaterialProperty<float> occlusionTestViewDependingScaleAmount;
public readonly CustomMaterialProperty<float> occlusionTestViewDependingDistance;
public ShapeFlareMixMaterial()
{
Shader = ShapeFlareMixShader.shader.Get();
shapeType = new CustomMaterialProperty<int>( this, ShapeFlareMixShader.shapeType );
shapeScale = new CustomMaterialProperty<float>( this, ShapeFlareMixShader.shapeScale );
shapeRotation = new CustomMaterialProperty<float>( this, ShapeFlareMixShader.shapeRotation );
minShapeDistance = new CustomMaterialProperty<float>( this, ShapeFlareMixShader.minShapeDistance );
maxShapeDistance = new CustomMaterialProperty<float>( this, ShapeFlareMixShader.maxShapeDistance );
color = new CustomMaterialProperty<Color>( this, ShapeFlareMixShader.color );
opacity = new CustomMaterialProperty<float>( this, ShapeFlareMixShader.opacity );
opacityCurve = new CustomMaterialProperty<Texture2D>( this, ShapeFlareMixShader.opacityCurve );
colorDistortion = new CustomMaterialProperty<float>( this, ShapeFlareMixShader.colorDistortion );
alphaDistortion = new CustomMaterialProperty<float>( this, ShapeFlareMixShader.alphaDistortion );
centerHsl = new CustomMaterialProperty<Vector4>( this, ShapeFlareMixShader.centerHsl );
outsideHsl = new CustomMaterialProperty<Vector4>( this, ShapeFlareMixShader.outsideHsl );
minHueRandom = new CustomMaterialProperty<float>( this, ShapeFlareMixShader.minHueRandom );
maxHueRandom = new CustomMaterialProperty<float>( this, ShapeFlareMixShader.maxHueRandom );
minShapeDistanceColor = new CustomMaterialProperty<float>( this, ShapeFlareMixShader.minShapeDistanceColor );
maxShapeDistanceColor = new CustomMaterialProperty<float>( this, ShapeFlareMixShader.maxShapeDistanceColor );
sizeX = new CustomMaterialProperty<float>( this, ShapeFlareMixShader.sizeX );
sizeY = new CustomMaterialProperty<float>( this, ShapeFlareMixShader.sizeY );
worldSizeScale = new CustomMaterialProperty<float>( this, ShapeFlareMixShader.worldSizeScale );
screenSizeScale = new CustomMaterialProperty<float>( this, ShapeFlareMixShader.screenSizeScale );
worldSizeVsScreenSize = new CustomMaterialProperty<float>( this, ShapeFlareMixShader.worldSizeVsScreenSize );
randomScaleMin = new CustomMaterialProperty<float>( this, ShapeFlareMixShader.randomScaleMin );
randomScaleMax = new CustomMaterialProperty<float>( this, ShapeFlareMixShader.randomScaleMax );
screenOffsetScale = new CustomMaterialProperty<Vector2>( this, ShapeFlareMixShader.screenOffsetScale );
screenOffsetLayerSpread = new CustomMaterialProperty<Vector2>( this, ShapeFlareMixShader.screenOffsetLayerSpread );
fading = new CustomMaterialProperty<Texture2D>( this, ShapeFlareMixShader.fading );
opacityFading = new CustomMaterialProperty<Texture2D>( this, ShapeFlareMixShader.opacityFading );
sizeXfading = new CustomMaterialProperty<Texture2D>( this, ShapeFlareMixShader.sizeXfading );
sizeYfading = new CustomMaterialProperty<Texture2D>( this, ShapeFlareMixShader.sizeYfading );
useQuickOcclusionTest = new CustomMaterialProperty<bool>( this, ShapeFlareMixShader.useQuickOcclusionTest );
occlusionZOffset = new CustomMaterialProperty<float>( this, ShapeFlareMixShader.occlusionZOffset );
occlusionTestMaxSteps = new CustomMaterialProperty<int>( this, ShapeFlareMixShader.occlusionTestMaxSteps );
occlusionTestStepStride = new CustomMaterialProperty<float>( this, ShapeFlareMixShader.occlusionTestStepStride );
occlusionTestViewDependingScaleAmount = new CustomMaterialProperty<float>( this, ShapeFlareMixShader.occlusionTestViewDependingScaleAmount );
occlusionTestViewDependingDistance = new CustomMaterialProperty<float>( this, ShapeFlareMixShader.occlusionTestViewDependingDistance );
}
}
}

View File

@ -0,0 +1 @@
uid://chr1ackucqmih

View File

@ -0,0 +1,46 @@
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System;
using Godot;
namespace Rokojori
{
[Tool]
[GlobalClass]
public abstract partial class BoxedColorValue:Resource
{
public virtual Color GetColorValue()
{
return Colors.White;
}
public virtual void SetColorValue( Color color )
{
}
public override string ToString()
{
var color = GetColorValue();
var r = RegexUtility.NumberToString( color.R ) ;
var g = RegexUtility.NumberToString( color.G ) ;
var b = RegexUtility.NumberToString( color.B ) ;
var a = RegexUtility.NumberToString( color.A ) ;
return this.GetType().Name + "( " + r + ", " + g + ", " + b + ", " + a + " )";
}
public static void Lerp( BoxedColorValue a, BoxedColorValue b, float amount, BoxedColorValue output )
{
if ( a == null || b == null || output == null )
{
return;
}
output.SetColorValue( ColorX.Lerp( a.GetColorValue(), b.GetColorValue(), amount ) );
}
}
}

View File

@ -0,0 +1 @@
uid://dnlkoewly1o25

View File

@ -8,7 +8,7 @@ namespace Rokojori
{ {
[Tool] [Tool]
[GlobalClass] [GlobalClass]
public partial class BoxedFloatValue:Resource public abstract partial class BoxedFloatValue:Resource
{ {
public virtual float GetFloatValue() public virtual float GetFloatValue()

View File

@ -8,7 +8,7 @@ namespace Rokojori
{ {
[Tool] [Tool]
[GlobalClass] [GlobalClass]
public partial class ColorValue:Resource public partial class ColorValue:BoxedColorValue
{ {
[Export] [Export]
public Color value; public Color value;
@ -18,6 +18,18 @@ namespace Rokojori
return "ColorValue( " + value + " )"; return "ColorValue( " + value + " )";
} }
public override Color GetColorValue()
{
return value;
}
public override void SetColorValue( Color color )
{
value = color;
}
public static ColorValue Create( Color value ) public static ColorValue Create( Color value )
{ {
var cv = new ColorValue(); var cv = new ColorValue();

View File

@ -0,0 +1,79 @@
using Godot;
using System.Collections.Generic;
namespace Rokojori
{
[Tool]
[GlobalClass]
public partial class FlareVFX:Node3D
{
[Export]
public FlareVFXPreset preset;
[Export]
public Node3D container;
[Export]
public bool debug = false;
public Node3D GetContainer()
{
return container == null ? this : container;
}
List<FlareVFXLayer> _layers = new List<FlareVFXLayer>();
[ExportToolButton( "Update Flare" )]
public Callable updateFlareButton => Callable.From( ()=> UpdateFlare() );
void UpdateFlare()
{
if ( debug )
{
numLayers = _layers.Count;
}
_layers.ForEach( l => l.Update( this ) );
}
[ExportToolButton( "Create Flare" )]
public Callable createFlareButton => Callable.From( ()=> CreateFlare() );
void CreateFlare()
{
GetContainer().DestroyChildren();
_layers = [];
preset.flareLayers.ForEach(
( l )=>
{
if ( l == null )
{
return;
}
_layers.Add( l.Create( this ) );
}
);
UpdateFlare();
}
#if TOOLS
[Export]
public bool editMode = false;
[Export]
public int numLayers = 0;
public override void _Process( double delta )
{
// this.LogInfo( "Hello" );
if ( editMode )
{
UpdateFlare();
}
}
#endif
}
}

View File

@ -0,0 +1 @@
uid://wo6881tihorq

View File

@ -0,0 +1,17 @@
using Godot;
namespace Rokojori
{
[Tool]
[GlobalClass]
public partial class FlareVFXPreset:Resource
{
[Export]
public Color mainColor;
[Export]
public FlareVFXLayer[] flareLayers = [];
}
}

View File

@ -0,0 +1 @@
uid://dciilhb7dhar1

View File

@ -0,0 +1,25 @@
using Godot;
namespace Rokojori
{
[Tool]
[GlobalClass]
public abstract partial class FlareVFXLayer:Resource
{
public virtual int GetNumInstances()
{
return 1;
}
public virtual void SetInstanceIndex( int index, float normalized )
{
}
public abstract FlareVFXLayer Create( FlareVFX flareVFX );
public abstract void Update( FlareVFX flareVFX );
}
}

View File

@ -0,0 +1 @@
uid://b8kyy3yeh0bpt

View File

@ -0,0 +1,98 @@
using Godot;
namespace Rokojori
{
[Tool]
[GlobalClass]
public partial class GlowFlareVFXLayer:FlareVFXLayer
{
[Export( PropertyHint.Range, "1, 1000" )]
public int numInstances = 1;
[ExportGroup("Color")]
[Export]
public BoxedColorValue colorOverwrite;
[Export]
public float opacity = 1f;
[Export]
public CurveTexture opacityCurve = new CurveTexture().WithCurve( new Curve().WithValues( 1f, 1f ).WithLinearTangents() );
[ExportGroup("Size")]
[Export]
public Vector2 size = Vector2.One;
[Export]
public float sizeXY = 1f;
[Export]
public float worldSizeScale = 1f;
[Export]
public float screenSizeScale = 1f;
[Export( PropertyHint.Range, "0,1" )]
public float worldSize_vs_screenSize = 1f;
[ExportGroup("Screen Offset")]
[Export]
public Vector2 screenOffset = Vector2.Zero;
[Export]
public Vector2 screenOffsetSpreadPerLayer = Vector2.Zero;
MeshInstance3D mesh;
GlowFlareVFXLayer parent;
GlowFlareAddMaterial glowMaterial;
int _numInstances = 0;
public override FlareVFXLayer Create( FlareVFX flareVFX )
{
var clone = Duplicate() as GlowFlareVFXLayer;
clone.mesh = flareVFX.GetContainer().CreateChild<MeshInstance3D>();
clone._numInstances = numInstances;
clone.mesh.Mesh = MeshGeometry.UnitBillboardQuads( numInstances, 0f, 1f ).GenerateMesh();
clone.glowMaterial = new GlowFlareAddMaterial();
clone.mesh.SetSurfaceOverrideMaterial( 0, clone.glowMaterial );
clone.parent = this;
return clone;
}
public override void Update( FlareVFX flareVFX )
{
if ( _numInstances != parent.numInstances )
{
_numInstances = parent.numInstances;
mesh.Mesh = MeshGeometry.UnitBillboardQuads( _numInstances, 0f, 1f ).GenerateMesh();
}
glowMaterial.color.Set( parent.colorOverwrite !=null ? parent.colorOverwrite.GetColorValue() : flareVFX.preset.mainColor );
glowMaterial.opacity.Set( parent.opacity );
glowMaterial.opacityCurve.Set( parent.opacityCurve );
var size = parent.size * parent.sizeXY;
glowMaterial.sizeX.Set( size.X );
glowMaterial.sizeY.Set( size.Y );
glowMaterial.worldSizeScale.Set( parent.worldSizeScale );
glowMaterial.screenSizeScale.Set( parent.screenSizeScale );
glowMaterial.worldSizeVsScreenSize.Set( parent.worldSize_vs_screenSize );
glowMaterial.screenOffsetScale.Set( parent.screenOffset );
glowMaterial.screenOffsetLayerSpread.Set( parent.screenOffsetSpreadPerLayer );
}
}
}

View File

@ -0,0 +1 @@
uid://cs35ft8hb0dqy

View File

@ -0,0 +1,207 @@
using Godot;
namespace Rokojori
{
[Tool]
[GlobalClass]
public partial class ShapeFlareVFXLayer:FlareVFXLayer
{
[Export( PropertyHint.Range, "1, 1000" )]
public int numInstances = 1;
[ExportGroup("Color")]
[Export]
public BoxedColorValue colorOverwrite;
[Export( PropertyHint.Range, "0.2,20")]
public float colorDistortion = 2f;
[Export( PropertyHint.Range, "0.2,20")]
public float alphaDistortion= 2f;
[Export]
public Vector4 centerHSLA = Vector4.Zero;
[Export]
public Vector4 outsideHSLA = Vector4.Zero;
[Export]
public float minShapeDistanceColor = 0f;
[Export]
public float maxShapeDistanceColor = 0.05f;
[Export]
public float shapeDistanceOffsetColor = 0f;
[Export]
public float shapeDistanceSpreadColor = 0.05f;
[Export]
public float minHueRandom = 0f;
[Export]
public float maxHueRandom = 0f;
[Export]
public float hueOffset = 0f;
[Export]
public float hueSpread = 0f;
[Export]
public float opacity = 1f;
[Export]
public CurveTexture opacityCurve = new CurveTexture().WithCurve( new Curve().WithValues( 1f, 1f ).WithLinearTangents() );
public enum ShapeType
{
Circle,
Cross,
Triangle,
Rectangle,
Pentagon,
Hexagon,
Octogon,
Hexagram,
Pentagram,
Ring,
Cutout1,
Cutout2,
Heart
}
[ExportGroup("Shape", "shape")]
[Export]
public ShapeType shapeType = ShapeType.Pentagon;
[Export( PropertyHint.Range, "-180,180" ) ]
public float shapeRotation = 0;
[Export( PropertyHint.Range, "0,1" ) ]
public float shapeScale = 0f;
[Export]
public float shapeMinDistance = 0;
[Export]
public float shapeMaxDistance = 0.05f;
[Export]
public float shapeDistanceOffset = 0f;
[Export]
public float shapeDistanceSpread = 0f;
[ExportGroup("Size")]
[Export]
public Vector2 size = Vector2.One;
[Export]
public float sizeXY = 1f;
[Export]
public float worldSizeScale = 1f;
[Export]
public float screenSizeScale = 1f;
[Export]
public float minRandomScale = 1f;
[Export]
public float maxRandomScale = 1f;
[Export]
public float polarRandomScale = 0f;
[Export( PropertyHint.Range, "0,1" )]
public float worldSize_vs_screenSize = 1f;
[ExportGroup("Screen Offset")]
[Export]
public Vector2 screenOffset = Vector2.Zero;
[Export]
public Vector2 screenOffsetSpreadPerLayer = Vector2.Zero;
MeshInstance3D mesh;
ShapeFlareVFXLayer parent;
ShapeFlareAddMaterial glowMaterial;
int _numInstances = 0;
public override FlareVFXLayer Create( FlareVFX flareVFX )
{
var clone = Duplicate() as ShapeFlareVFXLayer;
clone.mesh = flareVFX.GetContainer().CreateChild<MeshInstance3D>();
clone._numInstances = numInstances;
clone.mesh.Mesh = MeshGeometry.UnitBillboardQuads( numInstances, 0f, 1f ).GenerateMesh();
clone.glowMaterial = new ShapeFlareAddMaterial();
clone.mesh.SetSurfaceOverrideMaterial( 0, clone.glowMaterial );
clone.parent = this;
return clone;
}
public override void Update( FlareVFX flareVFX )
{
if ( _numInstances != parent.numInstances )
{
_numInstances = parent.numInstances;
mesh.Mesh = MeshGeometry.UnitBillboardQuads( _numInstances, 0f, 1f ).GenerateMesh();
}
glowMaterial.color.Set( parent.colorOverwrite !=null ? parent.colorOverwrite.GetColorValue() : flareVFX.preset.mainColor );
glowMaterial.colorDistortion.Set( parent.colorDistortion );
glowMaterial.alphaDistortion.Set( parent.alphaDistortion );
glowMaterial.centerHsl.Set( parent.centerHSLA );
glowMaterial.outsideHsl.Set( parent.outsideHSLA );
glowMaterial.minHueRandom.Set( parent.minHueRandom + parent.hueOffset - parent.hueSpread );
glowMaterial.maxHueRandom.Set( parent.maxHueRandom + parent.hueOffset + parent.hueSpread );
glowMaterial.opacity.Set( parent.opacity );
glowMaterial.opacityCurve.Set( parent.opacityCurve );
var size = parent.size * parent.sizeXY;
glowMaterial.sizeX.Set( size.X );
glowMaterial.sizeY.Set( size.Y );
glowMaterial.worldSizeScale.Set( parent.worldSizeScale );
glowMaterial.screenSizeScale.Set( parent.screenSizeScale );
glowMaterial.worldSizeVsScreenSize.Set( parent.worldSize_vs_screenSize );
glowMaterial.screenOffsetScale.Set( parent.screenOffset );
glowMaterial.screenOffsetLayerSpread.Set( parent.screenOffsetSpreadPerLayer );
glowMaterial.shapeType.Set( (int) parent.shapeType );
glowMaterial.shapeType.Set( (int) parent.shapeType );
glowMaterial.shapeRotation.Set( parent.shapeRotation );
glowMaterial.shapeScale.Set( parent.shapeScale );
glowMaterial.minShapeDistance.Set( parent.shapeMinDistance + parent.shapeDistanceOffset - parent.shapeDistanceSpread );
glowMaterial.maxShapeDistance.Set( parent.shapeMaxDistance + parent.shapeDistanceOffset + parent.shapeDistanceSpread );
glowMaterial.minShapeDistanceColor.Set( parent.minShapeDistanceColor + parent.shapeDistanceOffsetColor - parent.shapeDistanceSpreadColor );
glowMaterial.maxShapeDistanceColor.Set( parent.maxShapeDistanceColor + parent.shapeDistanceOffsetColor + parent.shapeDistanceSpreadColor );
glowMaterial.randomScaleMin.Set( parent.minRandomScale - parent.polarRandomScale );
glowMaterial.randomScaleMax.Set( parent.maxRandomScale + parent.polarRandomScale );
}
}
}

View File

@ -0,0 +1 @@
uid://cdg307hboj17p