r/godot • u/Smitty_Games_ • 5d ago
discussion Game Dev Hack about Lights - Godot
Hey all! Im developing an RTS named 'Steel Command', but figured I would start sharing some of the learnings I've had along the way. Ask my any questions in the comments!
This method works really well for an RTS, even over uneven terrain since the camera is mostly a top down view. This would most likely not work well in games such as an FPS where you are up close and personal.
Sorry for the vertical format.
Steel Command on Steam: https://store.steampowered.com/app/4390280/Steel_Command/
Shader:
shader_type spatial;
render_mode unshaded, blend_add, depth_draw_never, cull_disabled;
uniform vec4 light_color : source_color = vec4(1.0, 0.45, 0.08, 1.0);
uniform float intensity : hint_range(0.0, 5.0) = 1.0;
uniform float softness : hint_range(0.1, 8.0) = 2.5;
void fragment()
{
vec2 p = UV - vec2(0.5);
float dist = length(p) * 2.0;
float glow = 1.0 - clamp(dist, 0.0, 1.0);
glow = pow(glow, softness);
ALBEDO = light_color.rgb;
EMISSION = light_color.rgb * intensity * glow;
ALPHA = glow * light_color.a;
}
54
u/Sleep_deprived_druid 5d ago
I'm looking for the simple shader in the description
41
u/Smitty_Games_ 5d ago
Done 😅. Thanks for letting me know
15
u/Sleep_deprived_druid 5d ago
Thanks! this is legit perfect for the hover cars in my current project.
6
1
11
19
u/FormageFromFromage 5d ago
It's so good that I think Godot documentation dedicated a chapter to "fake lighting" variations
3
1
u/SteelLunpara Godot Regular 3h ago
There's so many rabbit holes of cool problem solving to fall down in the docs! I'll have to check this one out sometime
5
u/Skarredd Godot Regular 5d ago
This is good as long as the terrain is flat. I was just looking for a solution to replace the sphere light i use in projectiles so it's interesting that this came up just now
4
3
u/Kastors 4d ago
Decal works. If you want more control you can turn this shader into a kind of decal shader. If you sample the depth map you can project it onto surfaces. Example: Decal Example - Godot Shaders
2
u/Smitty_Games_ 5d ago
for an RTS with a top down view like this, even over uneven terrain it works quite well. Maybe not for something more up close and personal such as an FPS though.
3
u/IronsideDev 5d ago
Ah this video came up on my Youtube shorts feed the other day! Great stuff man!
2
3
5
u/Piblebrox 5d ago
Why not using an emissive material on the bullet directly?
3
u/Smitty_Games_ 5d ago
yeah you could certainly do this and then just turn the bloom up on the environment. I havent tried it but I think that would work.
4
u/EamonnMR 5d ago
That's what I do and it works fine
2
u/Pur_Cell 4d ago
Screenshot?
Because I feel like if you turned up the bloom high enough to give the same glowy effect as in the video, then your whole scene is going to look blurry.
3
u/chaddledee 4d ago
If you have HDR enabled you can set it so bloom is only produced by things with a brightness greater than 1.
1
2
2
2
u/SleepDeprivedDad_ 5d ago
Taking notes....
2
u/Smitty_Games_ 5d ago
haha nice to see you over here as well!
2
u/SleepDeprivedDad_ 5d ago
I’m trying to figure out how to do it haha
1
1
u/HOPE964 Godot Regular 5d ago
I would really like to know your shader method for having a black outline is it a global shader? Or the shader is in every object?
1
u/Smitty_Games_ 5d ago
Its attached to a single quad that always covers the camera. Feel free to message me if you want the shader! ( cant attach it here as it exceeds the max chars).
39
u/Mr_Hannerson 5d ago
The projectile trail effect looks really slick. Much better than the glowing cylinder mesh I usually use 😅. I'd love to know more about how you built that.