Created
July 19, 2024 21:27
-
-
Save bearlikelion/b7735a8fb99db444766cefeb61b3726a to your computer and use it in GitHub Desktop.
This file contains 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
shader_type canvas_item; | |
uniform sampler2D noise_texture: repeat_enable, filter_nearest; | |
uniform sampler2D screen_texture: hint_screen_texture, repeat_disable, filter_nearest; | |
uniform vec2 position = vec2(0,0); | |
uniform float move_x = 1.0; | |
uniform float move_y = 1.0; | |
void vertex() { | |
// Called for every vertex the material is visible on. | |
} | |
void fragment() { | |
// Called for every pixel the material is visible on. | |
vec4 red_color = vec4(1.,0.2,0.,1.); | |
vec4 yellow_color = vec4(1.,0.4,0.,1.); | |
float effect_strength = 1.; | |
vec2 offset = position; | |
offset.x *= move_x; | |
offset.y *= move_y; | |
vec2 uv = UV + (offset * 0.0025) * 0.5; | |
float noise_texture_val = texture(noise_texture,uv + vec2(0.,1.)*TIME/20.).r; | |
float sample_distance = 8.; | |
bool foundSample = false; | |
float sampleNum = 0.0; | |
while(sampleNum < sample_distance && !foundSample){ | |
if(texture(screen_texture,SCREEN_UV + vec2(0.,0.007)*sampleNum).r > 0.55){ | |
foundSample = true; | |
} | |
sampleNum = sampleNum + sample_distance/10.; | |
} | |
vec4 color = texture(screen_texture,SCREEN_UV); | |
if(foundSample){ | |
effect_strength -= smoothstep(0.9,1.,SCREEN_UV.y); | |
effect_strength = clamp(effect_strength,0.,10); | |
color += noise_texture_val*red_color*((sample_distance-sampleNum)/sample_distance)*effect_strength; | |
color += noise_texture_val*yellow_color*((sample_distance/2.-clamp(sampleNum,0.,5.))/sample_distance/2.)*effect_strength; | |
} | |
if(texture(screen_texture,vec2(SCREEN_UV)).r > 0.55){ | |
float noise_texture_val_2 = texture(noise_texture,uv + vec2(0.5,0.5)*TIME/20.).r; | |
color += smoothstep(0.6,1.,noise_texture_val_2/2. + noise_texture_val/2.)*1.2; | |
} | |
color.a = 0.45; | |
COLOR = color; | |
} | |
//void light() { | |
// Called for every pixel for every light affecting the CanvasItem. | |
// Uncomment to replace the default light processing function with this one. | |
//} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment