-
-
Notifications
You must be signed in to change notification settings - Fork 398
Animate thruster flame #6204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
sturnclaw
merged 3 commits into
pioneerspacesim:master
from
fluffyfreak:animate-the-thrust-flame
Jan 3, 2026
+145
−15
Merged
Animate thruster flame #6204
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| // Copyright © 2008-2026 Pioneer Developers. See AUTHORS.txt for details | ||
| // Licensed under the terms of the GPL v3. See licenses/GPL-3.txt | ||
|
|
||
| #include "attributes.glsl" | ||
| #include "lib.glsl" | ||
|
|
||
| uniform sampler2D texture0; //diffuse | ||
|
|
||
| in vec2 texCoord0; | ||
| in vec4 flame_color; | ||
| in float ramp; | ||
|
|
||
| out vec4 frag_color; | ||
|
|
||
| void main(void) | ||
| { | ||
| vec4 color = texture(texture0, texCoord0); | ||
| vec3 old_color = color.rgb; | ||
| color *= flame_color; | ||
| // generate a light blue flickering glow around the flame | ||
| float ramp2 = ramp * ramp; | ||
| color.g += ramp2 * ramp2 * old_color.g; | ||
| color.r += ramp2 * ramp * old_color.r; | ||
| color.b += ramp2 * old_color.b; | ||
|
|
||
| frag_color = color; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| ## Copyright © 2008-2026 Pioneer Developers. See AUTHORS.txt for details | ||
| ## Licensed under the terms of the GPL v3. See licenses/GPL-3.txt | ||
|
|
||
| # Basic shader for drawing unlit, possibly textured models that are animated | ||
|
|
||
| Shader thruster | ||
|
|
||
| Texture sampler2D texture0 name=texture0 | ||
| Buffer DrawData binding=1 | ||
|
|
||
| Vertex "thruster.vert" | ||
| Fragment "thruster.frag" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| // Copyright © 2008-2026 Pioneer Developers. See AUTHORS.txt for details | ||
| // Licensed under the terms of the GPL v3. See licenses/GPL-3.txt | ||
|
|
||
| // #extension GL_ARB_gpu_shader5 : enable | ||
|
|
||
| #include "attributes.glsl" | ||
| #include "lib.glsl" | ||
|
|
||
| out vec2 texCoord0; | ||
| out vec4 flame_color; | ||
| out float ramp; | ||
|
|
||
| float map_percentage( float val, float base_percent) | ||
| { | ||
| return base_percent + val * (1.0 - base_percent); | ||
| } | ||
|
|
||
| void main(void) | ||
| { | ||
| // emission.r is the thruster power setting | ||
| float thruster_power = material.emission.r; | ||
| // emission.a is the random flicker value | ||
| float random = material.emission.a; | ||
|
|
||
| // power setting effects the brightness and opacity of the flame | ||
| float brightness = map_percentage(thruster_power, 0.25); | ||
| // flicker should only change the brightness a small amount each frame | ||
| float flicker = map_percentage(random, 0.95); | ||
|
|
||
| flame_color = material.diffuse * flicker * brightness; | ||
| // a very light blue flickering glow around flame | ||
| flame_color.rg *= vec2(flicker); | ||
|
|
||
| // the power setting also controls the length of the flame | ||
| // flame length can range from 50% to 100% | ||
| float flame_length = map_percentage(thruster_power, 0.5); | ||
| // modulate the flame shape using flicker | ||
| // flame_length only effects the z axis which is the thrust direction | ||
| vec4 scale = vec4(flicker, flicker, flicker * flame_length, 1.0); | ||
|
|
||
| gl_Position = uViewProjectionMatrix * (a_vertex * scale); | ||
|
|
||
| texCoord0 = a_uv0.xy; | ||
| // set the blend ramp | ||
| ramp = a_uv0.y * 0.5; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a huge fan of retaining the
displayedPowerstate variable, but if the smooth fade makes a perceptual difference then I will not protest it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it does, but feel free to hack at it and see if there's anything better!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do any further hacking-about in master, thanks!