Adding some glow effects

This commit is contained in:
Dan Baker 2024-06-01 17:35:21 +01:00
parent 05476a13fc
commit a91635a68c
6 changed files with 198 additions and 15 deletions

View file

@ -0,0 +1,11 @@
extends Node2D
class_name Glowling
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta):
pass

File diff suppressed because one or more lines are too long

View file

@ -15,10 +15,12 @@ run/main_scene="res://levels/test_level.tscn"
config/features=PackedStringArray("4.2", "Forward Plus")
config/icon="res://icon.svg"
[display]
window/stretch/mode="canvas_items"
window/stretch/scale=2.0
window/stretch/scale_mode="integer"
[editor_plugins]
enabled=PackedStringArray("res://addons/log/plugin.cfg")
[rendering]
renderer/rendering_method="mobile"

Binary file not shown.

After

Width:  |  Height:  |  Size: 812 B

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://b0v24ggq57237"
path="res://.godot/imported/smallcircle.png-8c648c542028291e1edb98fff4f52393.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://resources/particles/smallcircle.png"
dest_files=["res://.godot/imported/smallcircle.png-8c648c542028291e1edb98fff4f52393.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

71
shaders/fog.gdshader Normal file
View file

@ -0,0 +1,71 @@
shader_type canvas_item;
// Credit for the original shader goes to Gonkee: https://github.com/Gonkee/Gonkees-Shaders/blob/master/fog.shader
// Pixelate by Godot Shaders: https://godotshaders.com/shader/pixelate/
uniform vec4 color : source_color;
uniform int OCTAVES = 4;
uniform bool enable_pixelation = true;
uniform int pixelation_amount = 150;
uniform sampler2D fog_mask; // Texture mask for fog control
uniform vec2 fog_direction = vec2(1.0, 1.0); // Use -1 and 1 values to change direction. Increase the speed in that direction with values higher/lower than 1
uniform bool scroll_noise_tex = false;
uniform vec2 noise_scroll_direction = vec2(1.0, 0.0); // Direction to scroll the noise texture
float rand(vec2 coord){
return fract(sin(dot(coord, vec2(56, 78)) * 1000.0) * 1000.0);
}
float noise(vec2 coord){
vec2 i = floor(coord);
vec2 f = fract(coord);
float a = rand(i);
float b = rand(i + vec2(1.0, 0.0));
float c = rand(i + vec2(0.0, 1.0));
float d = rand(i + vec2(1.0, 1.0));
vec2 cubic = f * f * (3.0 - 2.0 * f);
return mix(a, b, cubic.x) + (c - a) * cubic.y * (1.0 - cubic.x) + (d - b) * cubic.x * cubic.y;
}
float fbm(vec2 coord){
float value = 0.0;
float scale = 0.5;
for(int i = 0; i < OCTAVES; i++){
value += noise(coord) * scale;
coord *= 2.0;
scale *= 0.5;
}
return value;
}
void fragment() {
vec2 grid_uv = UV;
if (enable_pixelation) {
grid_uv = round(UV * float(pixelation_amount)) / float(pixelation_amount);
}
// Compute noise based on pixelated or non-pixelated coordinates
vec2 coord = grid_uv * 20.0;
// Scroll the noise texture if enabled
if (scroll_noise_tex) {
coord += noise_scroll_direction * TIME;
}
vec2 motion = vec2(fbm(coord + fog_direction * TIME));
float final = fbm(coord + motion);
// Get the fog density from the texture mask
float mask_value = texture(fog_mask, UV).r; // Assuming the mask is grayscale
// Modulate the fog density by the mask value
final *= mask_value;
// Use the alpha value of the color to control the overall fog opacity
COLOR = vec4(color.rgb, final * color.a * 0.5);
}