mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-10-30 10:50:28 +01:00
Let the smoke leave the exhaust as a widening jet that fades in
This commit is contained in:
@@ -19,10 +19,10 @@ struct smoke_source_s
|
||||
vec4 previous; // xyz: emitter at the update before, from the origin
|
||||
vec4 launch; // xy: inclination, radians, zw: speed, m/s
|
||||
vec4 initial; // xy: size, zw: opacity
|
||||
vec4 sizechange; // x: per second, y: min, z: max
|
||||
vec4 sizechange; // x: per second, y: min, z: max, w: per metre the particle goes through the air (spread:)
|
||||
vec4 opacitychange; // x: per second, y: min, z: max
|
||||
vec4 motion; // x: rise, y: damping (per second, of the vertical velocity), z: least vertical velocity
|
||||
vec4 settling; // x: velocity the particles settle at, m/s upwards, y: drag, per second, z: 1 when they settle (in place of motion)
|
||||
vec4 settling; // x: velocity the particles settle at, m/s upwards, y: drag, per second, z: 1 when they settle (in place of motion), w: seconds they take to show up (fade_in:)
|
||||
vec4 color; // rgb: colour of the smoke, lit by the lights of the pass
|
||||
vec4 oldcolor; // rgb: colour lit as the cpu does it, without the lights (gfx.smoke.lighting off)
|
||||
};
|
||||
|
||||
@@ -48,5 +48,9 @@ void main()
|
||||
vec3 color = source.oldcolor.rgb;
|
||||
if (options.x > 0.5)
|
||||
color = source.color.rgb * particle_light((view * vec4(world, 1.0)).xyz, world, options.y);
|
||||
particle_emit(world, size, vec3(particle.position.w, 0.0, 0.0), color, clamp(particle.state.x, 0.0, 1.0), uint(options.z));
|
||||
float opacity = clamp(particle.state.x, 0.0, 1.0);
|
||||
// showing up after the birth (smoke_source::fade_in())
|
||||
if (source.settling.w > 0.0)
|
||||
opacity *= smoothstep(0.0, source.settling.w, particle.state.y);
|
||||
particle_emit(world, size, vec3(particle.position.w, 0.0, 0.0), color, opacity, uint(options.z));
|
||||
}
|
||||
|
||||
@@ -37,6 +37,9 @@ bool advance(inout smoke_particle_s particle, smoke_source_s source, float secon
|
||||
if (particle.state.x <= 0.0)
|
||||
return false;
|
||||
particle.velocity.w = clamp(particle.velocity.w + source.sizechange.x * seconds, source.sizechange.y, source.sizechange.z);
|
||||
// the jet widens with the way it goes
|
||||
if (source.sizechange.w > 0.0)
|
||||
particle.velocity.w = min(particle.velocity.w + source.sizechange.w * length(particle.velocity.xyz) * seconds, source.sizechange.z);
|
||||
if (source.settling.z > 0.5)
|
||||
{
|
||||
// the drag of the air takes the particle towards the velocity it settles at
|
||||
|
||||
Reference in New Issue
Block a user