Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions assets/textures/TrailParticle.png

This file was deleted.

36 changes: 0 additions & 36 deletions assets/textures/TrailParticle.png.import

This file was deleted.

21 changes: 14 additions & 7 deletions shaders/CurrentsParticles.gdshader
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
shader_type particles;
render_mode disable_velocity;

uniform vec3 emissionBoxExtents;
uniform vec4 colorValue : source_color;
Expand All @@ -20,6 +19,8 @@ uniform float brightness;
const float currentsTimescale = 0.25f;
const float positionScaling = 0.9f;

uniform float particleDepthVariation = 1.0f;

// Generates a random float and modifies the seed
float RandFromSeed(inout uint seed) {
int k;
Expand Down Expand Up @@ -55,11 +56,18 @@ void start() {
TRANSFORM[3].xyz = vec3(RandFromSeed(altSeed) * 2.0 - 1.0, RandFromSeed(altSeed) * 2.0 - 1.0,
RandFromSeed(altSeed) * 2.0 - 1.0) * emissionBoxExtents;
TRANSFORM = EMISSION_TRANSFORM * TRANSFORM;
float visibleScale = RandFromSeed(altSeed) * 0.75f + 0.625f;

float backgroundFactor = RandFromSeed(altSeed) * particleDepthVariation;
float adjustedBackgroundFactor = pow(backgroundFactor, 3.0f);
TRANSFORM[3].y -= adjustedBackgroundFactor * 80.0f;
float visibleScale = RandFromSeed(altSeed) * 0.75f + 0.625f
+ adjustedBackgroundFactor * 35.0f;

TRANSFORM[0].xyz *= visibleScale;
TRANSFORM[1].xyz *= visibleScale;
TRANSFORM[2].xyz *= visibleScale;
CUSTOM.w = RandFromSeed(altSeed) * 0.2f + 0.8f;

CUSTOM.w = 1.0f - backgroundFactor * 0.9f;
CUSTOM.z = gameTime + LIFETIME * 0.5f;
}

Expand Down Expand Up @@ -92,12 +100,11 @@ void process() {
current *= 10.0f * speed;
}

VELOCITY = mix(vec3(current.x, 0.0f, current.y), VELOCITY, 1.0f - DELTA * 5.0f);

TRANSFORM[3].xyz += VELOCITY * DELTA;
VELOCITY = mix(VELOCITY, vec3(current.x, 0.0f, current.y), DELTA * 5.0f);
VELOCITY *= CUSTOM.w * 0.05f + 0.95f;

vec4 finalColor = colorValue;
finalColor.rgb *= CUSTOM.w;
finalColor.rgba *= CUSTOM.w;
finalColor.a *= texture(alphaCurve, vec2(lifetimePercent)).r;
if (speed != 0.0)
{
Expand Down
3 changes: 1 addition & 2 deletions simulation_parameters/microbe_stage/backgrounds.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@
"res://assets/textures/background/Thrive_vent1.png",
"res://assets/textures/background/Thrive_vent2.png",
"res://assets/textures/background/Thrive_vent3.png"
],
"ParticleEffect": "res://src/microbe_stage/particles/background/Vent.tscn"
]
},
"banana": {
"Textures": [
Expand Down
8 changes: 7 additions & 1 deletion simulation_parameters/microbe_stage/biomes.json
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,13 @@
"Speed": 0.6,
"Chaoticness": 0.5,
"InverseScale": 1.0,
"ParticleCount": 900
"ParticleCount": 900,
"Colour": {
"r": 1.0,
"g": 0.49,
"b": 0.09,
"a": 1
}
},
"ActiveMusicContexts": [
"PatchVents"
Expand Down
15 changes: 4 additions & 11 deletions src/microbe_stage/Background.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@ public class Background : IRegistryType
[JsonRequired]
public List<string> Textures = null!;

[JsonRequired]
public string ParticleEffect = null!;
public string? ParticleEffect;

[JsonIgnore]
public PackedScene ParticleEffectScene = null!;
public PackedScene? ParticleEffectScene;

public string InternalName { get; set; } = null!;

Expand All @@ -26,12 +25,6 @@ public void Check(string name)
throw new InvalidRegistryDataException(name, GetType().Name,
"Background needs 4 layers");
}

if (string.IsNullOrEmpty(ParticleEffect))
{
throw new InvalidRegistryDataException(name, GetType().Name,
"ParticleEffect is missing");
}
}

/// <summary>
Expand All @@ -52,8 +45,8 @@ public void Resolve(SimulationParameters parameters)
}
}
#endif

ParticleEffectScene = GD.Load<PackedScene>(ParticleEffect);
if (ParticleEffect != null)
ParticleEffectScene = GD.Load<PackedScene>(ParticleEffect);
}

public void ApplyTranslations()
Expand Down
3 changes: 3 additions & 0 deletions src/microbe_stage/BackgroundPlane.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ public void SetBackground(Background background)

backgroundParticles?.DetachAndQueueFree();

if (background.ParticleEffectScene == null)
return;

backgroundParticles = background.ParticleEffectScene.Instantiate<GpuParticles3D>();
backgroundParticles.Rotation = Rotation;
backgroundParticles.LocalCoords = false;
Expand Down
4 changes: 4 additions & 0 deletions src/microbe_stage/FluidCurrentDisplay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public partial class FluidCurrentDisplay : GpuParticles3D
private readonly StringName inverseScaleParameterName = new("inverseScale");
private readonly StringName brightnessParameterName = new("brightness");
private readonly StringName colorParameterName = new("colorValue");
private readonly StringName particleDepthVariationParameterName = new("particleDepthVariation");

#pragma warning disable CA2213
[Export]
Expand Down Expand Up @@ -79,10 +80,12 @@ public void ApplyBiome(Biome biome)
if (biome.WaterCurrents.UseTrails)
{
DrawPass1 = trailedParticleMesh;
material.SetShaderParameter(particleDepthVariationParameterName, 0.0f);
}
else
{
DrawPass1 = normalParticleMesh;
material.SetShaderParameter(particleDepthVariationParameterName, 1.0f);
}

Amount = biome.WaterCurrents.ParticleCount;
Expand Down Expand Up @@ -113,6 +116,7 @@ protected override void Dispose(bool disposing)
inverseScaleParameterName.Dispose();
brightnessParameterName.Dispose();
colorParameterName.Dispose();
particleDepthVariationParameterName.Dispose();
}

base.Dispose(disposing);
Expand Down
1 change: 1 addition & 0 deletions src/microbe_stage/FluidCurrentDisplay.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ shader_parameter/speed = 1.0
shader_parameter/chaoticness = 0.0
shader_parameter/inverseScale = 1.0
shader_parameter/brightness = 1.0
shader_parameter/particleDepthVariation = 1.0

[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_mse0a"]
transparency = 1
Expand Down