diff --git a/Runtime/Actions/Node3D/SetVector3FromNodePosition.cs b/Runtime/Actions/Node3D/SetVector3FromNodePosition.cs new file mode 100644 index 0000000..6d1aad7 --- /dev/null +++ b/Runtime/Actions/Node3D/SetVector3FromNodePosition.cs @@ -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 ); + + } + } +} \ No newline at end of file diff --git a/Runtime/Actions/Node3D/SetVector3FromNodePosition.cs.uid b/Runtime/Actions/Node3D/SetVector3FromNodePosition.cs.uid new file mode 100644 index 0000000..df89fad --- /dev/null +++ b/Runtime/Actions/Node3D/SetVector3FromNodePosition.cs.uid @@ -0,0 +1 @@ +uid://bkkwusmw0yjam diff --git a/Runtime/Math/MathX.cs b/Runtime/Math/MathX.cs index 81499c7..2f51c30 100644 --- a/Runtime/Math/MathX.cs +++ b/Runtime/Math/MathX.cs @@ -114,6 +114,19 @@ namespace Rokojori 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 ) { x = MathX.Clamp01( ( x - edge0 ) / ( edge1 - edge0 ) ); diff --git a/Runtime/Procedural/Mesh/MeshGeometry.cs b/Runtime/Procedural/Mesh/MeshGeometry.cs index 1cdaa92..7b3d629 100644 --- a/Runtime/Procedural/Mesh/MeshGeometry.cs +++ b/Runtime/Procedural/Mesh/MeshGeometry.cs @@ -839,14 +839,14 @@ namespace Rokojori return mg; } - public static MeshGeometry BillboardQuad( float size = 1 ) + public static MeshGeometry BillboardQuad( float size = 1, float z = 0 ) { var hs = size / 2f; var mg = new MeshGeometry(); mg.AddQuad( - new Vector3( -hs, -hs, 0 ), new Vector3( hs, -hs, 0 ), - new Vector3( hs, hs, 0 ), new Vector3( -hs, hs, 0 ), + new Vector3( -hs, -hs, z ), new Vector3( hs, -hs, z ), + new Vector3( hs, hs, z ), new Vector3( -hs, hs, z ), Vector3.Forward, Vector3.Forward, Vector3.Forward, Vector3.Forward, @@ -857,6 +857,22 @@ namespace Rokojori 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 ) { this.normals = normals ? new List() : null; diff --git a/Runtime/Rendering/Compositor/CompositorEffects/Fog/GradientFog/GradientFogEffect.cs b/Runtime/Rendering/Compositor/CompositorEffects/Fog/GradientFog/GradientFogEffect.cs index 92d41f4..cae3f87 100644 --- a/Runtime/Rendering/Compositor/CompositorEffects/Fog/GradientFog/GradientFogEffect.cs +++ b/Runtime/Rendering/Compositor/CompositorEffects/Fog/GradientFog/GradientFogEffect.cs @@ -17,6 +17,9 @@ namespace Rokojori [Export( PropertyHint.Range, "0,1") ] public float amount = 1f; + [Export( PropertyHint.Range, "0,1") ] + public float skyAmount = 0f; + [Export] public float zStart = 1f; @@ -26,8 +29,6 @@ namespace Rokojori [Export( PropertyHint.Range, "-1,1") ] public float zSpread = 0f; - - [Export] public GradientTexture1D gradient = new GradientTexture1D(); @@ -46,9 +47,41 @@ namespace Rokojori [Export] public TimeLine gradientUVScrollTimeline = null; + public enum UVGradientSampleMode + { + Fract, + Clamp + } + + [Export] + public UVGradientSampleMode gradientSampleMode = UVGradientSampleMode.Fract; + + + [Export] 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_ScreenDepthTexture screenDepthTexture; @@ -116,15 +149,25 @@ namespace Rokojori projection.W, amount, - Mathf.Pow( 10f, zSpread ), + MathX.PowerValue( zSpread ), zStart, zEnd, gradientUVScale, gradientOffset, - 0f, - 0f - + directionWeighting.X, + directionWeighting.Y, + + directionWeighting.Z, + (float) (int) gradientSampleMode, + skyAmount, + directionOffset.X, + + directionOffset.Y, + directionOffset.Z, + directionScalingX, + directionScalingY + ); } diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Fog/GradientFog/GradientFog.glsl b/Runtime/Rendering/RenderGraph/Nodes/Processors/Fog/GradientFog/GradientFog.glsl index 83ade3e..f4d402c 100644 --- a/Runtime/Rendering/RenderGraph/Nodes/Processors/Fog/GradientFog/GradientFog.glsl +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Fog/GradientFog/GradientFog.glsl @@ -275,16 +275,26 @@ uniform Parameters float gradientUVScale; float gradientUVOffset; - float p0; - float p1; - + float weightX; + float weightY; + + float weightZ; + float uvMode; + float skyAmount; + float offsetX; + + float offsetY; + float offsetZ; + float scaleX; + float scaleY; + } 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 ); - return max( 0.0, -position.z ); + return position.xyz; } void main() @@ -301,18 +311,39 @@ void main() mat4 INV_PROJ = mat4( parameters.m0, parameters.m1, parameters.m2, parameters.m3 ); - float depth = texture( depthSampler, uv ).r; - float z = getZ( uv, depth, INV_PROJ ); + vec4 depthValue = texture( depthSampler, uv ); + 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 ); mappedZ = pow( mappedZ, parameters.zSpread ); 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 opacity = textureLod( opacitySampler, vec2( mappedZ, 0.0 ), 0 ); - gradientColor.a *= opacity.r; + if ( depth <= 0.0000001 ) + { + gradientColor.a *= parameters.skyAmount; + } + else + { + gradientColor.a *= opacity.r; + } + + + vec4 color = imageLoad( inputImage, xy ); diff --git a/Runtime/Shading/Library/Colors.gdshaderinc b/Runtime/Shading/Library/Colors.gdshaderinc index e7f9a42..53248e6 100644 --- a/Runtime/Shading/Library/Colors.gdshaderinc +++ b/Runtime/Shading/Library/Colors.gdshaderinc @@ -300,6 +300,8 @@ vec3 shiftHSL( vec3 hsl, vec3 offset, float blendRadius ) vec3 shiftRGBwithHSL( vec3 rgb, vec3 offset, float blendRadius ) { + // float scale = getRGBScale( rbg ); + // rgb /= scale; vec3 hsl = RGBtoHSL( rgb ); hsl = shiftHSL( hsl, offset, blendRadius ); return HSLtoRGB( hsl ); diff --git a/Runtime/Shading/Library/SDF.gdshaderinc b/Runtime/Shading/Library/SDF.gdshaderinc index 86536de..f3708c5 100644 --- a/Runtime/Shading/Library/SDF.gdshaderinc +++ b/Runtime/Shading/Library/SDF.gdshaderinc @@ -164,6 +164,138 @@ float sdEllipse( in vec2 p, in vec2 ab ) 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=v[i].y,p.ye.y*w.x); +// if( all(c) || all(not(c)) ) s*=-1.0; +// } + +// return s*sqrt(d); +// } /* TAKEN FROM diff --git a/Runtime/Shading/Library/Transform.gdshaderinc b/Runtime/Shading/Library/Transform.gdshaderinc index ba1e7de..8998f0b 100644 --- a/Runtime/Shading/Library/Transform.gdshaderinc +++ b/Runtime/Shading/Library/Transform.gdshaderinc @@ -246,6 +246,30 @@ vec2 tilingOffsetRepeat( vec2 uv, vec4 tilingOffset ) 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 ) { vec2 mappedUV = mix( vec2(-1,1), vec2( 1, -1 ), _UV ); @@ -416,7 +440,7 @@ vec2 applyMatrix_m3v2( mat3 matrix, vec2 point ) float y = point.y; // float ox = matrix[ 0 ] * x + matrix[ 3 ] * y + matrix[ 6 ]; - // float oy = matrix[ 1 ] * x + matrix[ 4 ] * y + matrix[ 7 ]; + // float oy = matrix[ 1 ] * x + matrix[ 4 ] * y + matrix[ 7 ]; // 0 1 2 0 3 6 // 3 4 5 1 4 7 @@ -426,7 +450,7 @@ vec2 applyMatrix_m3v2( mat3 matrix, vec2 point ) vec3 my = matrix[ 1 ]; float ox = mx.x * x + mx.y * y + mx.z; - float oy = my.x * x + my.y * y + my.z; + float oy = my.x * x + my.y * y + my.z; return vec2( ox, oy ); } @@ -445,7 +469,7 @@ vec2 applyMatrixBase_m3v2( mat3 matrix, vec2 point ) vec3 my = matrix[ 1 ]; float ox = mx.x * x + mx.y * y; - float oy = my.x * x + my.y * y; + float oy = my.x * x + my.y * y; return vec2( ox, oy ); } @@ -546,7 +570,7 @@ mat3 quaternionToRotationMatrix( vec4 q ) float w = q.w; float x2 = x + x; - float y2 = y + y; + float y2 = y + y; float z2 = z + z; float xx = x * x2; diff --git a/Runtime/Shading/Shaders/Flares/EllipseFlare/EllipseFlareAddMaterial.cs b/Runtime/Shading/Shaders/Flares/EllipseFlare/EllipseFlareAddMaterial.cs new file mode 100644 index 0000000..184540c --- /dev/null +++ b/Runtime/Shading/Shaders/Flares/EllipseFlare/EllipseFlareAddMaterial.cs @@ -0,0 +1,120 @@ +using Godot; + +namespace Rokojori +{ + // Generated by ShaderClassGenerator + + public class EllipseFlareAddShader + { + public static readonly CachedResource shader = new CachedResource( + "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; + public readonly CustomMaterialProperty alphaScale; + public readonly CustomMaterialProperty circleAmount; + public readonly CustomMaterialProperty circleDistortion; + public readonly CustomMaterialProperty ellipseAmount; + public readonly CustomMaterialProperty ellipseDistortion; + public readonly CustomMaterialProperty ellipseScale; + public readonly CustomMaterialProperty addVsMax; + public readonly CustomMaterialProperty centerHsl; + public readonly CustomMaterialProperty outsideHsl; + public readonly CustomMaterialProperty sizeX; + public readonly CustomMaterialProperty sizeY; + public readonly CustomMaterialProperty scaleAll; + public readonly CustomMaterialProperty worldSizeVsScreenSize; + public readonly CustomMaterialProperty usSpectralsNoise; + public readonly CustomMaterialProperty spectralsAmount; + public readonly CustomMaterialProperty nonSpectralAmount; + public readonly CustomMaterialProperty spectralsSize; + public readonly CustomMaterialProperty spectralsSharpness; + public readonly CustomMaterialProperty spectralsFrequency; + public readonly CustomMaterialProperty spectralsSpeed; + public readonly CustomMaterialProperty fading; + public readonly CustomMaterialProperty sizeXfading; + public readonly CustomMaterialProperty sizeYfading; + public readonly CustomMaterialProperty useQuickOcclusionTest; + public readonly CustomMaterialProperty occlusionZOffset; + public readonly CustomMaterialProperty occlusionTestMaxSteps; + public readonly CustomMaterialProperty occlusionTestStepStride; + public readonly CustomMaterialProperty occlusionTestViewDependingScaleAmount; + public readonly CustomMaterialProperty occlusionTestViewDependingDistance; + + public EllipseFlareAddMaterial() + { + Shader = EllipseFlareAddShader.shader.Get(); + + color = new CustomMaterialProperty( this, EllipseFlareAddShader.color ); + alphaScale = new CustomMaterialProperty( this, EllipseFlareAddShader.alphaScale ); + circleAmount = new CustomMaterialProperty( this, EllipseFlareAddShader.circleAmount ); + circleDistortion = new CustomMaterialProperty( this, EllipseFlareAddShader.circleDistortion ); + ellipseAmount = new CustomMaterialProperty( this, EllipseFlareAddShader.ellipseAmount ); + ellipseDistortion = new CustomMaterialProperty( this, EllipseFlareAddShader.ellipseDistortion ); + ellipseScale = new CustomMaterialProperty( this, EllipseFlareAddShader.ellipseScale ); + addVsMax = new CustomMaterialProperty( this, EllipseFlareAddShader.addVsMax ); + centerHsl = new CustomMaterialProperty( this, EllipseFlareAddShader.centerHsl ); + outsideHsl = new CustomMaterialProperty( this, EllipseFlareAddShader.outsideHsl ); + sizeX = new CustomMaterialProperty( this, EllipseFlareAddShader.sizeX ); + sizeY = new CustomMaterialProperty( this, EllipseFlareAddShader.sizeY ); + scaleAll = new CustomMaterialProperty( this, EllipseFlareAddShader.scaleAll ); + worldSizeVsScreenSize = new CustomMaterialProperty( this, EllipseFlareAddShader.worldSizeVsScreenSize ); + usSpectralsNoise = new CustomMaterialProperty( this, EllipseFlareAddShader.usSpectralsNoise ); + spectralsAmount = new CustomMaterialProperty( this, EllipseFlareAddShader.spectralsAmount ); + nonSpectralAmount = new CustomMaterialProperty( this, EllipseFlareAddShader.nonSpectralAmount ); + spectralsSize = new CustomMaterialProperty( this, EllipseFlareAddShader.spectralsSize ); + spectralsSharpness = new CustomMaterialProperty( this, EllipseFlareAddShader.spectralsSharpness ); + spectralsFrequency = new CustomMaterialProperty( this, EllipseFlareAddShader.spectralsFrequency ); + spectralsSpeed = new CustomMaterialProperty( this, EllipseFlareAddShader.spectralsSpeed ); + fading = new CustomMaterialProperty( this, EllipseFlareAddShader.fading ); + sizeXfading = new CustomMaterialProperty( this, EllipseFlareAddShader.sizeXfading ); + sizeYfading = new CustomMaterialProperty( this, EllipseFlareAddShader.sizeYfading ); + useQuickOcclusionTest = new CustomMaterialProperty( this, EllipseFlareAddShader.useQuickOcclusionTest ); + occlusionZOffset = new CustomMaterialProperty( this, EllipseFlareAddShader.occlusionZOffset ); + occlusionTestMaxSteps = new CustomMaterialProperty( this, EllipseFlareAddShader.occlusionTestMaxSteps ); + occlusionTestStepStride = new CustomMaterialProperty( this, EllipseFlareAddShader.occlusionTestStepStride ); + occlusionTestViewDependingScaleAmount = new CustomMaterialProperty( this, EllipseFlareAddShader.occlusionTestViewDependingScaleAmount ); + occlusionTestViewDependingDistance = new CustomMaterialProperty( this, EllipseFlareAddShader.occlusionTestViewDependingDistance ); + } + + } + +} \ No newline at end of file diff --git a/Runtime/Shading/Shaders/Flares/EllipseFlare/EllipseFlareAddMaterial.cs.uid b/Runtime/Shading/Shaders/Flares/EllipseFlare/EllipseFlareAddMaterial.cs.uid new file mode 100644 index 0000000..7626981 --- /dev/null +++ b/Runtime/Shading/Shaders/Flares/EllipseFlare/EllipseFlareAddMaterial.cs.uid @@ -0,0 +1 @@ +uid://c21rt2tkpb7v6 diff --git a/Runtime/Shading/Shaders/Flares/EllipseFlare/EllipseFlareMixMaterial.cs b/Runtime/Shading/Shaders/Flares/EllipseFlare/EllipseFlareMixMaterial.cs new file mode 100644 index 0000000..b22de4f --- /dev/null +++ b/Runtime/Shading/Shaders/Flares/EllipseFlare/EllipseFlareMixMaterial.cs @@ -0,0 +1,120 @@ +using Godot; + +namespace Rokojori +{ + // Generated by ShaderClassGenerator + + public class EllipseFlareMixShader + { + public static readonly CachedResource shader = new CachedResource( + "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; + public readonly CustomMaterialProperty alphaScale; + public readonly CustomMaterialProperty circleAmount; + public readonly CustomMaterialProperty circleDistortion; + public readonly CustomMaterialProperty ellipseAmount; + public readonly CustomMaterialProperty ellipseDistortion; + public readonly CustomMaterialProperty ellipseScale; + public readonly CustomMaterialProperty addVsMax; + public readonly CustomMaterialProperty centerHsl; + public readonly CustomMaterialProperty outsideHsl; + public readonly CustomMaterialProperty sizeX; + public readonly CustomMaterialProperty sizeY; + public readonly CustomMaterialProperty scaleAll; + public readonly CustomMaterialProperty worldSizeVsScreenSize; + public readonly CustomMaterialProperty usSpectralsNoise; + public readonly CustomMaterialProperty spectralsAmount; + public readonly CustomMaterialProperty nonSpectralAmount; + public readonly CustomMaterialProperty spectralsSize; + public readonly CustomMaterialProperty spectralsSharpness; + public readonly CustomMaterialProperty spectralsFrequency; + public readonly CustomMaterialProperty spectralsSpeed; + public readonly CustomMaterialProperty fading; + public readonly CustomMaterialProperty sizeXfading; + public readonly CustomMaterialProperty sizeYfading; + public readonly CustomMaterialProperty useQuickOcclusionTest; + public readonly CustomMaterialProperty occlusionZOffset; + public readonly CustomMaterialProperty occlusionTestMaxSteps; + public readonly CustomMaterialProperty occlusionTestStepStride; + public readonly CustomMaterialProperty occlusionTestViewDependingScaleAmount; + public readonly CustomMaterialProperty occlusionTestViewDependingDistance; + + public EllipseFlareMixMaterial() + { + Shader = EllipseFlareMixShader.shader.Get(); + + color = new CustomMaterialProperty( this, EllipseFlareMixShader.color ); + alphaScale = new CustomMaterialProperty( this, EllipseFlareMixShader.alphaScale ); + circleAmount = new CustomMaterialProperty( this, EllipseFlareMixShader.circleAmount ); + circleDistortion = new CustomMaterialProperty( this, EllipseFlareMixShader.circleDistortion ); + ellipseAmount = new CustomMaterialProperty( this, EllipseFlareMixShader.ellipseAmount ); + ellipseDistortion = new CustomMaterialProperty( this, EllipseFlareMixShader.ellipseDistortion ); + ellipseScale = new CustomMaterialProperty( this, EllipseFlareMixShader.ellipseScale ); + addVsMax = new CustomMaterialProperty( this, EllipseFlareMixShader.addVsMax ); + centerHsl = new CustomMaterialProperty( this, EllipseFlareMixShader.centerHsl ); + outsideHsl = new CustomMaterialProperty( this, EllipseFlareMixShader.outsideHsl ); + sizeX = new CustomMaterialProperty( this, EllipseFlareMixShader.sizeX ); + sizeY = new CustomMaterialProperty( this, EllipseFlareMixShader.sizeY ); + scaleAll = new CustomMaterialProperty( this, EllipseFlareMixShader.scaleAll ); + worldSizeVsScreenSize = new CustomMaterialProperty( this, EllipseFlareMixShader.worldSizeVsScreenSize ); + usSpectralsNoise = new CustomMaterialProperty( this, EllipseFlareMixShader.usSpectralsNoise ); + spectralsAmount = new CustomMaterialProperty( this, EllipseFlareMixShader.spectralsAmount ); + nonSpectralAmount = new CustomMaterialProperty( this, EllipseFlareMixShader.nonSpectralAmount ); + spectralsSize = new CustomMaterialProperty( this, EllipseFlareMixShader.spectralsSize ); + spectralsSharpness = new CustomMaterialProperty( this, EllipseFlareMixShader.spectralsSharpness ); + spectralsFrequency = new CustomMaterialProperty( this, EllipseFlareMixShader.spectralsFrequency ); + spectralsSpeed = new CustomMaterialProperty( this, EllipseFlareMixShader.spectralsSpeed ); + fading = new CustomMaterialProperty( this, EllipseFlareMixShader.fading ); + sizeXfading = new CustomMaterialProperty( this, EllipseFlareMixShader.sizeXfading ); + sizeYfading = new CustomMaterialProperty( this, EllipseFlareMixShader.sizeYfading ); + useQuickOcclusionTest = new CustomMaterialProperty( this, EllipseFlareMixShader.useQuickOcclusionTest ); + occlusionZOffset = new CustomMaterialProperty( this, EllipseFlareMixShader.occlusionZOffset ); + occlusionTestMaxSteps = new CustomMaterialProperty( this, EllipseFlareMixShader.occlusionTestMaxSteps ); + occlusionTestStepStride = new CustomMaterialProperty( this, EllipseFlareMixShader.occlusionTestStepStride ); + occlusionTestViewDependingScaleAmount = new CustomMaterialProperty( this, EllipseFlareMixShader.occlusionTestViewDependingScaleAmount ); + occlusionTestViewDependingDistance = new CustomMaterialProperty( this, EllipseFlareMixShader.occlusionTestViewDependingDistance ); + } + + } + +} \ No newline at end of file diff --git a/Runtime/Shading/Shaders/Flares/EllipseFlare/EllipseFlareMixMaterial.cs.uid b/Runtime/Shading/Shaders/Flares/EllipseFlare/EllipseFlareMixMaterial.cs.uid new file mode 100644 index 0000000..7d85d2b --- /dev/null +++ b/Runtime/Shading/Shaders/Flares/EllipseFlare/EllipseFlareMixMaterial.cs.uid @@ -0,0 +1 @@ +uid://bmf3lrrftcy8s diff --git a/Runtime/Shading/Shaders/Flares/Flares.gdshaderinc b/Runtime/Shading/Shaders/Flares/Flares.gdshaderinc new file mode 100644 index 0000000..6f230d0 --- /dev/null +++ b/Runtime/Shading/Shaders/Flares/Flares.gdshaderinc @@ -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); +} \ No newline at end of file diff --git a/Runtime/Shading/Shaders/Flares/Flares.gdshaderinc.uid b/Runtime/Shading/Shaders/Flares/Flares.gdshaderinc.uid new file mode 100644 index 0000000..e1649e8 --- /dev/null +++ b/Runtime/Shading/Shaders/Flares/Flares.gdshaderinc.uid @@ -0,0 +1 @@ +uid://fokkb8onnm7p diff --git a/Runtime/Shading/Shaders/Flares/GlowFlare/GlowFlareAdd.gdshader b/Runtime/Shading/Shaders/Flares/GlowFlare/GlowFlareAdd.gdshader new file mode 100644 index 0000000..d0335d0 --- /dev/null +++ b/Runtime/Shading/Shaders/Flares/GlowFlare/GlowFlareAdd.gdshader @@ -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" \ No newline at end of file diff --git a/Runtime/Shading/Shaders/Flares/GlowFlare/GlowFlareAdd.gdshader.uid b/Runtime/Shading/Shaders/Flares/GlowFlare/GlowFlareAdd.gdshader.uid new file mode 100644 index 0000000..da5aa9d --- /dev/null +++ b/Runtime/Shading/Shaders/Flares/GlowFlare/GlowFlareAdd.gdshader.uid @@ -0,0 +1 @@ +uid://cqyc7q1cj6yso diff --git a/Runtime/Shading/Shaders/Flares/GlowFlare/GlowFlareAddMaterial.cs b/Runtime/Shading/Shaders/Flares/GlowFlare/GlowFlareAddMaterial.cs new file mode 100644 index 0000000..2a2a6db --- /dev/null +++ b/Runtime/Shading/Shaders/Flares/GlowFlare/GlowFlareAddMaterial.cs @@ -0,0 +1,102 @@ +using Godot; + +namespace Rokojori +{ + // Generated by ShaderClassGenerator + + public class GlowFlareAddShader + { + public static readonly CachedResource shader = new CachedResource( + "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; + public readonly CustomMaterialProperty opacity; + public readonly CustomMaterialProperty opacityCurve; + public readonly CustomMaterialProperty colorDistortion; + public readonly CustomMaterialProperty alphaDistortion; + public readonly CustomMaterialProperty centerHsl; + public readonly CustomMaterialProperty outsideHsl; + public readonly CustomMaterialProperty sizeX; + public readonly CustomMaterialProperty sizeY; + public readonly CustomMaterialProperty worldSizeScale; + public readonly CustomMaterialProperty screenSizeScale; + public readonly CustomMaterialProperty worldSizeVsScreenSize; + public readonly CustomMaterialProperty screenOffsetScale; + public readonly CustomMaterialProperty screenOffsetLayerSpread; + public readonly CustomMaterialProperty fading; + public readonly CustomMaterialProperty opacityFading; + public readonly CustomMaterialProperty sizeXfading; + public readonly CustomMaterialProperty sizeYfading; + public readonly CustomMaterialProperty useQuickOcclusionTest; + public readonly CustomMaterialProperty occlusionZOffset; + public readonly CustomMaterialProperty occlusionTestMaxSteps; + public readonly CustomMaterialProperty occlusionTestStepStride; + public readonly CustomMaterialProperty occlusionTestViewDependingScaleAmount; + public readonly CustomMaterialProperty occlusionTestViewDependingDistance; + + public GlowFlareAddMaterial() + { + Shader = GlowFlareAddShader.shader.Get(); + + color = new CustomMaterialProperty( this, GlowFlareAddShader.color ); + opacity = new CustomMaterialProperty( this, GlowFlareAddShader.opacity ); + opacityCurve = new CustomMaterialProperty( this, GlowFlareAddShader.opacityCurve ); + colorDistortion = new CustomMaterialProperty( this, GlowFlareAddShader.colorDistortion ); + alphaDistortion = new CustomMaterialProperty( this, GlowFlareAddShader.alphaDistortion ); + centerHsl = new CustomMaterialProperty( this, GlowFlareAddShader.centerHsl ); + outsideHsl = new CustomMaterialProperty( this, GlowFlareAddShader.outsideHsl ); + sizeX = new CustomMaterialProperty( this, GlowFlareAddShader.sizeX ); + sizeY = new CustomMaterialProperty( this, GlowFlareAddShader.sizeY ); + worldSizeScale = new CustomMaterialProperty( this, GlowFlareAddShader.worldSizeScale ); + screenSizeScale = new CustomMaterialProperty( this, GlowFlareAddShader.screenSizeScale ); + worldSizeVsScreenSize = new CustomMaterialProperty( this, GlowFlareAddShader.worldSizeVsScreenSize ); + screenOffsetScale = new CustomMaterialProperty( this, GlowFlareAddShader.screenOffsetScale ); + screenOffsetLayerSpread = new CustomMaterialProperty( this, GlowFlareAddShader.screenOffsetLayerSpread ); + fading = new CustomMaterialProperty( this, GlowFlareAddShader.fading ); + opacityFading = new CustomMaterialProperty( this, GlowFlareAddShader.opacityFading ); + sizeXfading = new CustomMaterialProperty( this, GlowFlareAddShader.sizeXfading ); + sizeYfading = new CustomMaterialProperty( this, GlowFlareAddShader.sizeYfading ); + useQuickOcclusionTest = new CustomMaterialProperty( this, GlowFlareAddShader.useQuickOcclusionTest ); + occlusionZOffset = new CustomMaterialProperty( this, GlowFlareAddShader.occlusionZOffset ); + occlusionTestMaxSteps = new CustomMaterialProperty( this, GlowFlareAddShader.occlusionTestMaxSteps ); + occlusionTestStepStride = new CustomMaterialProperty( this, GlowFlareAddShader.occlusionTestStepStride ); + occlusionTestViewDependingScaleAmount = new CustomMaterialProperty( this, GlowFlareAddShader.occlusionTestViewDependingScaleAmount ); + occlusionTestViewDependingDistance = new CustomMaterialProperty( this, GlowFlareAddShader.occlusionTestViewDependingDistance ); + } + + } + +} \ No newline at end of file diff --git a/Runtime/Shading/Shaders/Flares/GlowFlare/GlowFlareAddMaterial.cs.uid b/Runtime/Shading/Shaders/Flares/GlowFlare/GlowFlareAddMaterial.cs.uid new file mode 100644 index 0000000..4edf20f --- /dev/null +++ b/Runtime/Shading/Shaders/Flares/GlowFlare/GlowFlareAddMaterial.cs.uid @@ -0,0 +1 @@ +uid://b751ojo6ggfls diff --git a/Runtime/Shading/Shaders/Flares/GlowFlare/GlowFlareBase.gdshaderinc b/Runtime/Shading/Shaders/Flares/GlowFlare/GlowFlareBase.gdshaderinc new file mode 100644 index 0000000..4da79f5 --- /dev/null +++ b/Runtime/Shading/Shaders/Flares/GlowFlare/GlowFlareBase.gdshaderinc @@ -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; + +} diff --git a/Runtime/Shading/Shaders/Flares/GlowFlare/GlowFlareBase.gdshaderinc.uid b/Runtime/Shading/Shaders/Flares/GlowFlare/GlowFlareBase.gdshaderinc.uid new file mode 100644 index 0000000..4d5f28d --- /dev/null +++ b/Runtime/Shading/Shaders/Flares/GlowFlare/GlowFlareBase.gdshaderinc.uid @@ -0,0 +1 @@ +uid://dv4j06odwqjvu diff --git a/Runtime/Shading/Shaders/Flares/GlowFlare/GlowFlareMix.gdshader b/Runtime/Shading/Shaders/Flares/GlowFlare/GlowFlareMix.gdshader new file mode 100644 index 0000000..c914f16 --- /dev/null +++ b/Runtime/Shading/Shaders/Flares/GlowFlare/GlowFlareMix.gdshader @@ -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" \ No newline at end of file diff --git a/Runtime/Shading/Shaders/Flares/GlowFlare/GlowFlareMix.gdshader.uid b/Runtime/Shading/Shaders/Flares/GlowFlare/GlowFlareMix.gdshader.uid new file mode 100644 index 0000000..aaac975 --- /dev/null +++ b/Runtime/Shading/Shaders/Flares/GlowFlare/GlowFlareMix.gdshader.uid @@ -0,0 +1 @@ +uid://bvjxbgnsu8pcj diff --git a/Runtime/Shading/Shaders/Flares/GlowFlare/GlowFlareMixMaterial.cs b/Runtime/Shading/Shaders/Flares/GlowFlare/GlowFlareMixMaterial.cs new file mode 100644 index 0000000..37fe8ec --- /dev/null +++ b/Runtime/Shading/Shaders/Flares/GlowFlare/GlowFlareMixMaterial.cs @@ -0,0 +1,102 @@ +using Godot; + +namespace Rokojori +{ + // Generated by ShaderClassGenerator + + public class GlowFlareMixShader + { + public static readonly CachedResource shader = new CachedResource( + "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; + public readonly CustomMaterialProperty opacity; + public readonly CustomMaterialProperty opacityCurve; + public readonly CustomMaterialProperty colorDistortion; + public readonly CustomMaterialProperty alphaDistortion; + public readonly CustomMaterialProperty centerHsl; + public readonly CustomMaterialProperty outsideHsl; + public readonly CustomMaterialProperty sizeX; + public readonly CustomMaterialProperty sizeY; + public readonly CustomMaterialProperty worldSizeScale; + public readonly CustomMaterialProperty screenSizeScale; + public readonly CustomMaterialProperty worldSizeVsScreenSize; + public readonly CustomMaterialProperty screenOffsetScale; + public readonly CustomMaterialProperty screenOffsetLayerSpread; + public readonly CustomMaterialProperty fading; + public readonly CustomMaterialProperty opacityFading; + public readonly CustomMaterialProperty sizeXfading; + public readonly CustomMaterialProperty sizeYfading; + public readonly CustomMaterialProperty useQuickOcclusionTest; + public readonly CustomMaterialProperty occlusionZOffset; + public readonly CustomMaterialProperty occlusionTestMaxSteps; + public readonly CustomMaterialProperty occlusionTestStepStride; + public readonly CustomMaterialProperty occlusionTestViewDependingScaleAmount; + public readonly CustomMaterialProperty occlusionTestViewDependingDistance; + + public GlowFlareMixMaterial() + { + Shader = GlowFlareMixShader.shader.Get(); + + color = new CustomMaterialProperty( this, GlowFlareMixShader.color ); + opacity = new CustomMaterialProperty( this, GlowFlareMixShader.opacity ); + opacityCurve = new CustomMaterialProperty( this, GlowFlareMixShader.opacityCurve ); + colorDistortion = new CustomMaterialProperty( this, GlowFlareMixShader.colorDistortion ); + alphaDistortion = new CustomMaterialProperty( this, GlowFlareMixShader.alphaDistortion ); + centerHsl = new CustomMaterialProperty( this, GlowFlareMixShader.centerHsl ); + outsideHsl = new CustomMaterialProperty( this, GlowFlareMixShader.outsideHsl ); + sizeX = new CustomMaterialProperty( this, GlowFlareMixShader.sizeX ); + sizeY = new CustomMaterialProperty( this, GlowFlareMixShader.sizeY ); + worldSizeScale = new CustomMaterialProperty( this, GlowFlareMixShader.worldSizeScale ); + screenSizeScale = new CustomMaterialProperty( this, GlowFlareMixShader.screenSizeScale ); + worldSizeVsScreenSize = new CustomMaterialProperty( this, GlowFlareMixShader.worldSizeVsScreenSize ); + screenOffsetScale = new CustomMaterialProperty( this, GlowFlareMixShader.screenOffsetScale ); + screenOffsetLayerSpread = new CustomMaterialProperty( this, GlowFlareMixShader.screenOffsetLayerSpread ); + fading = new CustomMaterialProperty( this, GlowFlareMixShader.fading ); + opacityFading = new CustomMaterialProperty( this, GlowFlareMixShader.opacityFading ); + sizeXfading = new CustomMaterialProperty( this, GlowFlareMixShader.sizeXfading ); + sizeYfading = new CustomMaterialProperty( this, GlowFlareMixShader.sizeYfading ); + useQuickOcclusionTest = new CustomMaterialProperty( this, GlowFlareMixShader.useQuickOcclusionTest ); + occlusionZOffset = new CustomMaterialProperty( this, GlowFlareMixShader.occlusionZOffset ); + occlusionTestMaxSteps = new CustomMaterialProperty( this, GlowFlareMixShader.occlusionTestMaxSteps ); + occlusionTestStepStride = new CustomMaterialProperty( this, GlowFlareMixShader.occlusionTestStepStride ); + occlusionTestViewDependingScaleAmount = new CustomMaterialProperty( this, GlowFlareMixShader.occlusionTestViewDependingScaleAmount ); + occlusionTestViewDependingDistance = new CustomMaterialProperty( this, GlowFlareMixShader.occlusionTestViewDependingDistance ); + } + + } + +} \ No newline at end of file diff --git a/Runtime/Shading/Shaders/Flares/GlowFlare/GlowFlareMixMaterial.cs.uid b/Runtime/Shading/Shaders/Flares/GlowFlare/GlowFlareMixMaterial.cs.uid new file mode 100644 index 0000000..6937a69 --- /dev/null +++ b/Runtime/Shading/Shaders/Flares/GlowFlare/GlowFlareMixMaterial.cs.uid @@ -0,0 +1 @@ +uid://cusgp711ny0pc diff --git a/Runtime/Shading/Shaders/Flares/ShapeFlare/ShapeFlareAdd.gdshader b/Runtime/Shading/Shaders/Flares/ShapeFlare/ShapeFlareAdd.gdshader new file mode 100644 index 0000000..89fbc03 --- /dev/null +++ b/Runtime/Shading/Shaders/Flares/ShapeFlare/ShapeFlareAdd.gdshader @@ -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" \ No newline at end of file diff --git a/Runtime/Shading/Shaders/Flares/ShapeFlare/ShapeFlareAdd.gdshader.uid b/Runtime/Shading/Shaders/Flares/ShapeFlare/ShapeFlareAdd.gdshader.uid new file mode 100644 index 0000000..07b5484 --- /dev/null +++ b/Runtime/Shading/Shaders/Flares/ShapeFlare/ShapeFlareAdd.gdshader.uid @@ -0,0 +1 @@ +uid://ibo7qa8hf6he diff --git a/Runtime/Shading/Shaders/Flares/ShapeFlare/ShapeFlareAddMaterial.cs b/Runtime/Shading/Shaders/Flares/ShapeFlare/ShapeFlareAddMaterial.cs new file mode 100644 index 0000000..398e057 --- /dev/null +++ b/Runtime/Shading/Shaders/Flares/ShapeFlare/ShapeFlareAddMaterial.cs @@ -0,0 +1,135 @@ +using Godot; + +namespace Rokojori +{ + // Generated by ShaderClassGenerator + + public class ShapeFlareAddShader + { + public static readonly CachedResource shader = new CachedResource( + "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 shapeType; + public readonly CustomMaterialProperty shapeScale; + public readonly CustomMaterialProperty shapeRotation; + public readonly CustomMaterialProperty minShapeDistance; + public readonly CustomMaterialProperty maxShapeDistance; + public readonly CustomMaterialProperty color; + public readonly CustomMaterialProperty opacity; + public readonly CustomMaterialProperty opacityCurve; + public readonly CustomMaterialProperty colorDistortion; + public readonly CustomMaterialProperty alphaDistortion; + public readonly CustomMaterialProperty centerHsl; + public readonly CustomMaterialProperty outsideHsl; + public readonly CustomMaterialProperty minHueRandom; + public readonly CustomMaterialProperty maxHueRandom; + public readonly CustomMaterialProperty minShapeDistanceColor; + public readonly CustomMaterialProperty maxShapeDistanceColor; + public readonly CustomMaterialProperty sizeX; + public readonly CustomMaterialProperty sizeY; + public readonly CustomMaterialProperty worldSizeScale; + public readonly CustomMaterialProperty screenSizeScale; + public readonly CustomMaterialProperty worldSizeVsScreenSize; + public readonly CustomMaterialProperty randomScaleMin; + public readonly CustomMaterialProperty randomScaleMax; + public readonly CustomMaterialProperty screenOffsetScale; + public readonly CustomMaterialProperty screenOffsetLayerSpread; + public readonly CustomMaterialProperty fading; + public readonly CustomMaterialProperty opacityFading; + public readonly CustomMaterialProperty sizeXfading; + public readonly CustomMaterialProperty sizeYfading; + public readonly CustomMaterialProperty useQuickOcclusionTest; + public readonly CustomMaterialProperty occlusionZOffset; + public readonly CustomMaterialProperty occlusionTestMaxSteps; + public readonly CustomMaterialProperty occlusionTestStepStride; + public readonly CustomMaterialProperty occlusionTestViewDependingScaleAmount; + public readonly CustomMaterialProperty occlusionTestViewDependingDistance; + + public ShapeFlareAddMaterial() + { + Shader = ShapeFlareAddShader.shader.Get(); + + shapeType = new CustomMaterialProperty( this, ShapeFlareAddShader.shapeType ); + shapeScale = new CustomMaterialProperty( this, ShapeFlareAddShader.shapeScale ); + shapeRotation = new CustomMaterialProperty( this, ShapeFlareAddShader.shapeRotation ); + minShapeDistance = new CustomMaterialProperty( this, ShapeFlareAddShader.minShapeDistance ); + maxShapeDistance = new CustomMaterialProperty( this, ShapeFlareAddShader.maxShapeDistance ); + color = new CustomMaterialProperty( this, ShapeFlareAddShader.color ); + opacity = new CustomMaterialProperty( this, ShapeFlareAddShader.opacity ); + opacityCurve = new CustomMaterialProperty( this, ShapeFlareAddShader.opacityCurve ); + colorDistortion = new CustomMaterialProperty( this, ShapeFlareAddShader.colorDistortion ); + alphaDistortion = new CustomMaterialProperty( this, ShapeFlareAddShader.alphaDistortion ); + centerHsl = new CustomMaterialProperty( this, ShapeFlareAddShader.centerHsl ); + outsideHsl = new CustomMaterialProperty( this, ShapeFlareAddShader.outsideHsl ); + minHueRandom = new CustomMaterialProperty( this, ShapeFlareAddShader.minHueRandom ); + maxHueRandom = new CustomMaterialProperty( this, ShapeFlareAddShader.maxHueRandom ); + minShapeDistanceColor = new CustomMaterialProperty( this, ShapeFlareAddShader.minShapeDistanceColor ); + maxShapeDistanceColor = new CustomMaterialProperty( this, ShapeFlareAddShader.maxShapeDistanceColor ); + sizeX = new CustomMaterialProperty( this, ShapeFlareAddShader.sizeX ); + sizeY = new CustomMaterialProperty( this, ShapeFlareAddShader.sizeY ); + worldSizeScale = new CustomMaterialProperty( this, ShapeFlareAddShader.worldSizeScale ); + screenSizeScale = new CustomMaterialProperty( this, ShapeFlareAddShader.screenSizeScale ); + worldSizeVsScreenSize = new CustomMaterialProperty( this, ShapeFlareAddShader.worldSizeVsScreenSize ); + randomScaleMin = new CustomMaterialProperty( this, ShapeFlareAddShader.randomScaleMin ); + randomScaleMax = new CustomMaterialProperty( this, ShapeFlareAddShader.randomScaleMax ); + screenOffsetScale = new CustomMaterialProperty( this, ShapeFlareAddShader.screenOffsetScale ); + screenOffsetLayerSpread = new CustomMaterialProperty( this, ShapeFlareAddShader.screenOffsetLayerSpread ); + fading = new CustomMaterialProperty( this, ShapeFlareAddShader.fading ); + opacityFading = new CustomMaterialProperty( this, ShapeFlareAddShader.opacityFading ); + sizeXfading = new CustomMaterialProperty( this, ShapeFlareAddShader.sizeXfading ); + sizeYfading = new CustomMaterialProperty( this, ShapeFlareAddShader.sizeYfading ); + useQuickOcclusionTest = new CustomMaterialProperty( this, ShapeFlareAddShader.useQuickOcclusionTest ); + occlusionZOffset = new CustomMaterialProperty( this, ShapeFlareAddShader.occlusionZOffset ); + occlusionTestMaxSteps = new CustomMaterialProperty( this, ShapeFlareAddShader.occlusionTestMaxSteps ); + occlusionTestStepStride = new CustomMaterialProperty( this, ShapeFlareAddShader.occlusionTestStepStride ); + occlusionTestViewDependingScaleAmount = new CustomMaterialProperty( this, ShapeFlareAddShader.occlusionTestViewDependingScaleAmount ); + occlusionTestViewDependingDistance = new CustomMaterialProperty( this, ShapeFlareAddShader.occlusionTestViewDependingDistance ); + } + + } + +} \ No newline at end of file diff --git a/Runtime/Shading/Shaders/Flares/ShapeFlare/ShapeFlareAddMaterial.cs.uid b/Runtime/Shading/Shaders/Flares/ShapeFlare/ShapeFlareAddMaterial.cs.uid new file mode 100644 index 0000000..534b447 --- /dev/null +++ b/Runtime/Shading/Shaders/Flares/ShapeFlare/ShapeFlareAddMaterial.cs.uid @@ -0,0 +1 @@ +uid://btnca61nvu55p diff --git a/Runtime/Shading/Shaders/Flares/ShapeFlare/ShapeFlareBase.gdshaderinc b/Runtime/Shading/Shaders/Flares/ShapeFlare/ShapeFlareBase.gdshaderinc new file mode 100644 index 0000000..bdc0c25 --- /dev/null +++ b/Runtime/Shading/Shaders/Flares/ShapeFlare/ShapeFlareBase.gdshaderinc @@ -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; + +} diff --git a/Runtime/Shading/Shaders/Flares/ShapeFlare/ShapeFlareBase.gdshaderinc.uid b/Runtime/Shading/Shaders/Flares/ShapeFlare/ShapeFlareBase.gdshaderinc.uid new file mode 100644 index 0000000..59b8fc4 --- /dev/null +++ b/Runtime/Shading/Shaders/Flares/ShapeFlare/ShapeFlareBase.gdshaderinc.uid @@ -0,0 +1 @@ +uid://vfabwu76j40f diff --git a/Runtime/Shading/Shaders/Flares/ShapeFlare/ShapeFlareMix.gdshader b/Runtime/Shading/Shaders/Flares/ShapeFlare/ShapeFlareMix.gdshader new file mode 100644 index 0000000..b762a30 --- /dev/null +++ b/Runtime/Shading/Shaders/Flares/ShapeFlare/ShapeFlareMix.gdshader @@ -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" \ No newline at end of file diff --git a/Runtime/Shading/Shaders/Flares/ShapeFlare/ShapeFlareMix.gdshader.uid b/Runtime/Shading/Shaders/Flares/ShapeFlare/ShapeFlareMix.gdshader.uid new file mode 100644 index 0000000..10b2f86 --- /dev/null +++ b/Runtime/Shading/Shaders/Flares/ShapeFlare/ShapeFlareMix.gdshader.uid @@ -0,0 +1 @@ +uid://yy2pi2u1bg4n diff --git a/Runtime/Shading/Shaders/Flares/ShapeFlare/ShapeFlareMixMaterial.cs b/Runtime/Shading/Shaders/Flares/ShapeFlare/ShapeFlareMixMaterial.cs new file mode 100644 index 0000000..f05adcc --- /dev/null +++ b/Runtime/Shading/Shaders/Flares/ShapeFlare/ShapeFlareMixMaterial.cs @@ -0,0 +1,135 @@ +using Godot; + +namespace Rokojori +{ + // Generated by ShaderClassGenerator + + public class ShapeFlareMixShader + { + public static readonly CachedResource shader = new CachedResource( + "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 shapeType; + public readonly CustomMaterialProperty shapeScale; + public readonly CustomMaterialProperty shapeRotation; + public readonly CustomMaterialProperty minShapeDistance; + public readonly CustomMaterialProperty maxShapeDistance; + public readonly CustomMaterialProperty color; + public readonly CustomMaterialProperty opacity; + public readonly CustomMaterialProperty opacityCurve; + public readonly CustomMaterialProperty colorDistortion; + public readonly CustomMaterialProperty alphaDistortion; + public readonly CustomMaterialProperty centerHsl; + public readonly CustomMaterialProperty outsideHsl; + public readonly CustomMaterialProperty minHueRandom; + public readonly CustomMaterialProperty maxHueRandom; + public readonly CustomMaterialProperty minShapeDistanceColor; + public readonly CustomMaterialProperty maxShapeDistanceColor; + public readonly CustomMaterialProperty sizeX; + public readonly CustomMaterialProperty sizeY; + public readonly CustomMaterialProperty worldSizeScale; + public readonly CustomMaterialProperty screenSizeScale; + public readonly CustomMaterialProperty worldSizeVsScreenSize; + public readonly CustomMaterialProperty randomScaleMin; + public readonly CustomMaterialProperty randomScaleMax; + public readonly CustomMaterialProperty screenOffsetScale; + public readonly CustomMaterialProperty screenOffsetLayerSpread; + public readonly CustomMaterialProperty fading; + public readonly CustomMaterialProperty opacityFading; + public readonly CustomMaterialProperty sizeXfading; + public readonly CustomMaterialProperty sizeYfading; + public readonly CustomMaterialProperty useQuickOcclusionTest; + public readonly CustomMaterialProperty occlusionZOffset; + public readonly CustomMaterialProperty occlusionTestMaxSteps; + public readonly CustomMaterialProperty occlusionTestStepStride; + public readonly CustomMaterialProperty occlusionTestViewDependingScaleAmount; + public readonly CustomMaterialProperty occlusionTestViewDependingDistance; + + public ShapeFlareMixMaterial() + { + Shader = ShapeFlareMixShader.shader.Get(); + + shapeType = new CustomMaterialProperty( this, ShapeFlareMixShader.shapeType ); + shapeScale = new CustomMaterialProperty( this, ShapeFlareMixShader.shapeScale ); + shapeRotation = new CustomMaterialProperty( this, ShapeFlareMixShader.shapeRotation ); + minShapeDistance = new CustomMaterialProperty( this, ShapeFlareMixShader.minShapeDistance ); + maxShapeDistance = new CustomMaterialProperty( this, ShapeFlareMixShader.maxShapeDistance ); + color = new CustomMaterialProperty( this, ShapeFlareMixShader.color ); + opacity = new CustomMaterialProperty( this, ShapeFlareMixShader.opacity ); + opacityCurve = new CustomMaterialProperty( this, ShapeFlareMixShader.opacityCurve ); + colorDistortion = new CustomMaterialProperty( this, ShapeFlareMixShader.colorDistortion ); + alphaDistortion = new CustomMaterialProperty( this, ShapeFlareMixShader.alphaDistortion ); + centerHsl = new CustomMaterialProperty( this, ShapeFlareMixShader.centerHsl ); + outsideHsl = new CustomMaterialProperty( this, ShapeFlareMixShader.outsideHsl ); + minHueRandom = new CustomMaterialProperty( this, ShapeFlareMixShader.minHueRandom ); + maxHueRandom = new CustomMaterialProperty( this, ShapeFlareMixShader.maxHueRandom ); + minShapeDistanceColor = new CustomMaterialProperty( this, ShapeFlareMixShader.minShapeDistanceColor ); + maxShapeDistanceColor = new CustomMaterialProperty( this, ShapeFlareMixShader.maxShapeDistanceColor ); + sizeX = new CustomMaterialProperty( this, ShapeFlareMixShader.sizeX ); + sizeY = new CustomMaterialProperty( this, ShapeFlareMixShader.sizeY ); + worldSizeScale = new CustomMaterialProperty( this, ShapeFlareMixShader.worldSizeScale ); + screenSizeScale = new CustomMaterialProperty( this, ShapeFlareMixShader.screenSizeScale ); + worldSizeVsScreenSize = new CustomMaterialProperty( this, ShapeFlareMixShader.worldSizeVsScreenSize ); + randomScaleMin = new CustomMaterialProperty( this, ShapeFlareMixShader.randomScaleMin ); + randomScaleMax = new CustomMaterialProperty( this, ShapeFlareMixShader.randomScaleMax ); + screenOffsetScale = new CustomMaterialProperty( this, ShapeFlareMixShader.screenOffsetScale ); + screenOffsetLayerSpread = new CustomMaterialProperty( this, ShapeFlareMixShader.screenOffsetLayerSpread ); + fading = new CustomMaterialProperty( this, ShapeFlareMixShader.fading ); + opacityFading = new CustomMaterialProperty( this, ShapeFlareMixShader.opacityFading ); + sizeXfading = new CustomMaterialProperty( this, ShapeFlareMixShader.sizeXfading ); + sizeYfading = new CustomMaterialProperty( this, ShapeFlareMixShader.sizeYfading ); + useQuickOcclusionTest = new CustomMaterialProperty( this, ShapeFlareMixShader.useQuickOcclusionTest ); + occlusionZOffset = new CustomMaterialProperty( this, ShapeFlareMixShader.occlusionZOffset ); + occlusionTestMaxSteps = new CustomMaterialProperty( this, ShapeFlareMixShader.occlusionTestMaxSteps ); + occlusionTestStepStride = new CustomMaterialProperty( this, ShapeFlareMixShader.occlusionTestStepStride ); + occlusionTestViewDependingScaleAmount = new CustomMaterialProperty( this, ShapeFlareMixShader.occlusionTestViewDependingScaleAmount ); + occlusionTestViewDependingDistance = new CustomMaterialProperty( this, ShapeFlareMixShader.occlusionTestViewDependingDistance ); + } + + } + +} \ No newline at end of file diff --git a/Runtime/Shading/Shaders/Flares/ShapeFlare/ShapeFlareMixMaterial.cs.uid b/Runtime/Shading/Shaders/Flares/ShapeFlare/ShapeFlareMixMaterial.cs.uid new file mode 100644 index 0000000..e27a24f --- /dev/null +++ b/Runtime/Shading/Shaders/Flares/ShapeFlare/ShapeFlareMixMaterial.cs.uid @@ -0,0 +1 @@ +uid://chr1ackucqmih diff --git a/Runtime/Tools/Boxed/BoxedColorValue.cs b/Runtime/Tools/Boxed/BoxedColorValue.cs new file mode 100644 index 0000000..eaa4219 --- /dev/null +++ b/Runtime/Tools/Boxed/BoxedColorValue.cs @@ -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 ) ); + } + } +} \ No newline at end of file diff --git a/Runtime/Tools/Boxed/BoxedColorValue.cs.uid b/Runtime/Tools/Boxed/BoxedColorValue.cs.uid new file mode 100644 index 0000000..4cdeff9 --- /dev/null +++ b/Runtime/Tools/Boxed/BoxedColorValue.cs.uid @@ -0,0 +1 @@ +uid://dnlkoewly1o25 diff --git a/Runtime/Tools/Boxed/BoxedFloatValue.cs b/Runtime/Tools/Boxed/BoxedFloatValue.cs index a546916..02e4f7f 100644 --- a/Runtime/Tools/Boxed/BoxedFloatValue.cs +++ b/Runtime/Tools/Boxed/BoxedFloatValue.cs @@ -8,7 +8,7 @@ namespace Rokojori { [Tool] [GlobalClass] - public partial class BoxedFloatValue:Resource + public abstract partial class BoxedFloatValue:Resource { public virtual float GetFloatValue() diff --git a/Runtime/Tools/Boxed/ColorValue.cs b/Runtime/Tools/Boxed/ColorValue.cs index cd0bc23..e24fd59 100644 --- a/Runtime/Tools/Boxed/ColorValue.cs +++ b/Runtime/Tools/Boxed/ColorValue.cs @@ -8,7 +8,7 @@ namespace Rokojori { [Tool] [GlobalClass] - public partial class ColorValue:Resource + public partial class ColorValue:BoxedColorValue { [Export] public Color value; @@ -18,6 +18,18 @@ namespace Rokojori return "ColorValue( " + value + " )"; } + public override Color GetColorValue() + { + return value; + } + + public override void SetColorValue( Color color ) + { + value = color; + } + + + public static ColorValue Create( Color value ) { var cv = new ColorValue(); diff --git a/Runtime/VFX/FlareVFX/FlareVFX.cs b/Runtime/VFX/FlareVFX/FlareVFX.cs new file mode 100644 index 0000000..078530f --- /dev/null +++ b/Runtime/VFX/FlareVFX/FlareVFX.cs @@ -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 _layers = new List(); + + [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 + } +} \ No newline at end of file diff --git a/Runtime/VFX/FlareVFX/FlareVFX.cs.uid b/Runtime/VFX/FlareVFX/FlareVFX.cs.uid new file mode 100644 index 0000000..71bcfc6 --- /dev/null +++ b/Runtime/VFX/FlareVFX/FlareVFX.cs.uid @@ -0,0 +1 @@ +uid://wo6881tihorq diff --git a/Runtime/VFX/FlareVFX/FlareVFXPreset.cs b/Runtime/VFX/FlareVFX/FlareVFXPreset.cs new file mode 100644 index 0000000..cf8e373 --- /dev/null +++ b/Runtime/VFX/FlareVFX/FlareVFXPreset.cs @@ -0,0 +1,17 @@ +using Godot; + + +namespace Rokojori +{ + [Tool] + [GlobalClass] + public partial class FlareVFXPreset:Resource + { + [Export] + public Color mainColor; + + [Export] + public FlareVFXLayer[] flareLayers = []; + + } +} \ No newline at end of file diff --git a/Runtime/VFX/FlareVFX/FlareVFXPreset.cs.uid b/Runtime/VFX/FlareVFX/FlareVFXPreset.cs.uid new file mode 100644 index 0000000..97e96fd --- /dev/null +++ b/Runtime/VFX/FlareVFX/FlareVFXPreset.cs.uid @@ -0,0 +1 @@ +uid://dciilhb7dhar1 diff --git a/Runtime/VFX/FlareVFX/Layers/FlareVFXLayer.cs b/Runtime/VFX/FlareVFX/Layers/FlareVFXLayer.cs new file mode 100644 index 0000000..c617594 --- /dev/null +++ b/Runtime/VFX/FlareVFX/Layers/FlareVFXLayer.cs @@ -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 ); + + } +} \ No newline at end of file diff --git a/Runtime/VFX/FlareVFX/Layers/FlareVFXLayer.cs.uid b/Runtime/VFX/FlareVFX/Layers/FlareVFXLayer.cs.uid new file mode 100644 index 0000000..cb656a7 --- /dev/null +++ b/Runtime/VFX/FlareVFX/Layers/FlareVFXLayer.cs.uid @@ -0,0 +1 @@ +uid://b8kyy3yeh0bpt diff --git a/Runtime/VFX/FlareVFX/Layers/GlowFlareVFXLayer.cs b/Runtime/VFX/FlareVFX/Layers/GlowFlareVFXLayer.cs new file mode 100644 index 0000000..19286bf --- /dev/null +++ b/Runtime/VFX/FlareVFX/Layers/GlowFlareVFXLayer.cs @@ -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(); + 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 ); + + + + + + } + } +} \ No newline at end of file diff --git a/Runtime/VFX/FlareVFX/Layers/GlowFlareVFXLayer.cs.uid b/Runtime/VFX/FlareVFX/Layers/GlowFlareVFXLayer.cs.uid new file mode 100644 index 0000000..a758400 --- /dev/null +++ b/Runtime/VFX/FlareVFX/Layers/GlowFlareVFXLayer.cs.uid @@ -0,0 +1 @@ +uid://cs35ft8hb0dqy diff --git a/Runtime/VFX/FlareVFX/Layers/ShapeFlareVFXLayer.cs b/Runtime/VFX/FlareVFX/Layers/ShapeFlareVFXLayer.cs new file mode 100644 index 0000000..fd6c906 --- /dev/null +++ b/Runtime/VFX/FlareVFX/Layers/ShapeFlareVFXLayer.cs @@ -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(); + 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 ); + + } + } +} \ No newline at end of file diff --git a/Runtime/VFX/FlareVFX/Layers/ShapeFlareVFXLayer.cs.uid b/Runtime/VFX/FlareVFX/Layers/ShapeFlareVFXLayer.cs.uid new file mode 100644 index 0000000..8dcdc95 --- /dev/null +++ b/Runtime/VFX/FlareVFX/Layers/ShapeFlareVFXLayer.cs.uid @@ -0,0 +1 @@ +uid://cdg307hboj17p