2025-05-13 19:22:01 +08:00

40 lines
1.4 KiB
Plaintext

/*
Earthbound battle backgrounds shader with scrolling effect and palette cycling like in the original game.
@retr0_dev
Apply the shader to a TextureRect or a Sprite. Use a texture with some shapes in a transparent background for best results.
You can then use a ColorRect or another method to paint the background.
You can use the shader on multiple TextureRects and obtain a double-buffer effect tweaking the values for each one, remember to Make Unique the shader material.
*/
shader_type canvas_item;
uniform float screen_height = 640.0;
uniform float amplitude = 0.075;
uniform float frequency = 10.0;
uniform float speed = 2.0;
uniform float amplitude_vertical = 0.0;
uniform float frequency_vertical = 0.0;
uniform float speed_vertical = 0.0;
uniform vec2 scroll_direction = vec2(0.0, 0.0);
uniform float scrolling_speed = 0.08;
uniform float alpha = 1.0;
//uniform sampler2D SCREEN_TEXTURE : hint_screen_texture;
varying vec4 c;
void vertex(){
c = COLOR;
}
void fragment()
{
float diff_x = amplitude * sin((frequency * UV.y) + (speed * TIME));
float diff_y = amplitude_vertical * sin((frequency_vertical * UV.y) + (speed_vertical * TIME));
vec2 scroll = scroll_direction * TIME * scrolling_speed;
vec4 tex = texture(TEXTURE, vec2(UV.x + diff_x, UV.y + diff_y) + scroll);
COLOR = c * vec4(tex.rgb, tex.a);
//COLOR = mix(vec4(0.0), COLOR, float(int(UV.y * screen_height) % 2));
}