Watch the Video Tutorial
Hit Flash Effect Shader
This is a very simple shader and mostly used to make the player white indicating a hit or damage.
shader_type canvas_item;
uniform float quantity : hint_range(0.0, 1.0);
void fragment(){
vec4 base = texture(TEXTURE, UV);
vec4 new_color = vec4(1.0,1.0,1.0, base.a);
COLOR = mix(base,new_color,quantity);
}
Grayscale Shader
GrayScale can be useful in many cases,
like if you have a shop and some items are locked then You can turn them grayscale.
Or maybe use it to turn the entire scene grayscale when the player dies, similar to GTA V.
shader_type canvas_item;
uniform float quantity : hint_range(0.0, 1.0);
void fragment(){
vec4 original = texture(TEXTURE, UV);
float mean = (base.x + base.y + base.z) / 3.0;
vec4 gray = vec4(mean, mean ,mean, original.a);
COLOR = mix(original, gray, quantity);
}
Moving background Shader
A long time ago I made an endless runner game in which
I want to move the road vertically. But instead of actually moving the road
I used a shader to move it. Since Shaders work on GPU thus it reduce a little pressure on CPU
Similar to this you can also apply this shader to move it horizontally instead of actually moving the sprite.
shader_type canvas_item;
uniform float speed : hint_range(0.0, 5.0) ;
void fragment(){
vec2 uv = vec2(UV.x, UV.y - TIME * speed);
COLOR = texture(TEXTURE, uv);
}
Brightness Contrast Saturation Shaders
shader_type canvas_item;
uniform float brightness : hint_range(0.0,3.0) ;
uniform float contrast : hint_range(0.0,3.0) ;
uniform float saturation : hint_range(0.0,3.0);
void fragment(){
// Viewport texture
vec4 input_color = texture(SCREEN_TEXTURE, SCREEN_UV);
//Brightness adjustment
input_color.rgb = mix(vec3(0.0), input_color.rgb, brightness);
//Contrast adjustment
input_color.rgb = mix(vec3(0.5), input_color.rgb, contrast);
//Saturation adjustment
float gray = (input_color.r + input_color.g + input_color.b) / 3.0;
input_color.rgb = mix(vec3(gray), input_color.rgb, saturation);
//Final result
COLOR = input_color;
}
Blur
Creating the Blur effect is simplest among all. But you have to apply this Blur effect on ColorRect Node.
shader_type canvas_item;
uniform float blur : hint_range(0.0,5.0);
void fragment() {
COLOR = texture(SCREEN_TEXTURE, SCREEN_UV, blur);
}
Comments
Post a Comment