Merge pull request #504 from MihailRis/post-effects
Post-processing effects
This commit is contained in:
+3
-1
@@ -5,10 +5,12 @@
|
||||
"main",
|
||||
"lines",
|
||||
"entity",
|
||||
"screen",
|
||||
"background",
|
||||
"skybox_gen"
|
||||
],
|
||||
"post-effects": [
|
||||
"default"
|
||||
],
|
||||
"textures": [
|
||||
"gui/menubg",
|
||||
"gui/delete_icon",
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
in vec2 v_uv;
|
||||
out vec4 f_color;
|
||||
|
||||
uniform sampler2D u_screen;
|
||||
uniform ivec2 u_screenSize;
|
||||
uniform float u_intensity;
|
||||
|
||||
#include <__effect__>
|
||||
|
||||
void main() {
|
||||
f_color = effect();
|
||||
}
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
layout (location = 0) in vec2 v_position;
|
||||
|
||||
out vec2 v_coord;
|
||||
out vec2 v_uv;
|
||||
|
||||
uniform ivec2 u_screenSize;
|
||||
uniform float u_timer;
|
||||
uniform float u_dayTime;
|
||||
|
||||
void main(){
|
||||
v_coord = v_position * 0.5 + 0.5;
|
||||
v_uv = v_position * 0.5 + 0.5;
|
||||
gl_Position = vec4(v_position, 0.0, 1.0);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
vec4 effect() {
|
||||
return texture(u_screen, v_uv);
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
vec4 effect() {
|
||||
vec3 color = texture(u_screen, v_uv).rgb;
|
||||
float m = (color.r + color.g + color.b) / 3.0;
|
||||
return vec4(mix(color, vec3(m), u_intensity), 1.0);
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
vec4 effect() {
|
||||
vec4 color = texture(u_screen, v_uv);
|
||||
color = mix(color, 1.0 - color, u_intensity);
|
||||
color.a = 1.0;
|
||||
return color;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
#include <commons>
|
||||
|
||||
#param float p_radius = 1.1
|
||||
#param float p_softness = 0.7
|
||||
|
||||
vec4 apply_vignette(vec4 color) {
|
||||
vec2 position = v_uv - vec2(0.5);
|
||||
float dist = length(position);
|
||||
float vignette = smoothstep(p_radius, p_radius - p_softness, dist);
|
||||
return vec4(color.rgb * vignette, 1.0);
|
||||
}
|
||||
|
||||
vec4 effect() {
|
||||
return apply_vignette(texture(u_screen, v_uv));
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
in vec2 v_coord;
|
||||
out vec4 f_color;
|
||||
|
||||
uniform sampler2D u_texture0;
|
||||
uniform ivec2 u_screenSize;
|
||||
|
||||
// Vignette
|
||||
vec4 apply_vignette(vec4 color) {
|
||||
vec2 position = (gl_FragCoord.xy / u_screenSize) - vec2(0.5);
|
||||
float dist = length(position);
|
||||
|
||||
float radius = 1.3;
|
||||
float softness = 1.0;
|
||||
float vignette = smoothstep(radius, radius - softness, dist);
|
||||
|
||||
color.rgb = color.rgb * vignette;
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
void main() {
|
||||
f_color = texture(u_texture0, v_coord);
|
||||
f_color = apply_vignette(f_color);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user