mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-11 06:11:50 +09:00
better shadow for wall-stickers
This commit is contained in:
30
src/shaders/gaussian3x3.frag
Normal file
30
src/shaders/gaussian3x3.frag
Normal file
@@ -0,0 +1,30 @@
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
#endif
|
||||
|
||||
in vec4 v_color;
|
||||
in vec2 v_texCoords;
|
||||
uniform sampler2D u_texture;
|
||||
|
||||
// recommended value: n / vec2(fbo_width, fbo_height) where n is something like {0.5, 1, 2, 4, ... }
|
||||
// that, or simply 0.5, depending on how your uv coord works
|
||||
uniform vec2 halfpixel = vec2(0.0, 0.0);
|
||||
|
||||
const vec2 twister = vec2(1.0, -1.0);
|
||||
const vec2 boolean = vec2(1.0, 0.0);
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
void main() {
|
||||
vec4 sum = texture(u_texture, v_texCoords) * 4.0 + // C
|
||||
texture(u_texture, v_texCoords + halfpixel) + // SE
|
||||
texture(u_texture, v_texCoords - halfpixel) + // NW
|
||||
texture(u_texture, v_texCoords + halfpixel * twister) + // NE
|
||||
texture(u_texture, v_texCoords - halfpixel * twister) + // SW
|
||||
texture(u_texture, v_texCoords + halfpixel * boolean.xy) * 2.0 + // E
|
||||
texture(u_texture, v_texCoords - halfpixel * boolean.xy) * 2.0 + // W
|
||||
texture(u_texture, v_texCoords + halfpixel * boolean.yx) * 2.0 + // S
|
||||
texture(u_texture, v_texCoords - halfpixel * boolean.yx) * 2.0 ; // N
|
||||
|
||||
fragColor = sum / 16.0;
|
||||
}
|
||||
@@ -10,11 +10,11 @@ uniform sampler2D u_texture;
|
||||
uniform sampler2D u_wall;
|
||||
out vec4 fragColor;
|
||||
|
||||
vec4 mult = vec4(0.0, 0.0, 0.0, 1.5);
|
||||
vec4 mult = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
|
||||
void main() {
|
||||
vec4 backcol = texture(u_wall, v_texCoords);
|
||||
vec4 incol = texture(u_texture, v_texCoords);
|
||||
vec4 outcol = vec4(incol.rgb, backcol.a * pow(incol.a, 2.0));
|
||||
vec4 outcol = vec4(incol.rgb, backcol.a * incol.a);
|
||||
fragColor = mult * outcol;
|
||||
}
|
||||
Reference in New Issue
Block a user