mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-09 10:04:05 +09:00
kawase blur is working i think
This commit is contained in:
23
assets/shaders/kawasedown.frag
Normal file
23
assets/shaders/kawasedown.frag
Normal file
@@ -0,0 +1,23 @@
|
||||
#version 120
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
#endif
|
||||
|
||||
varying vec4 v_color;
|
||||
varying vec2 v_texCoords;
|
||||
uniform sampler2D u_texture;
|
||||
|
||||
uniform vec2 halfpixel = vec2(0.0, 0.0);
|
||||
|
||||
vec2 twister = vec2(1.0, -1.0);
|
||||
|
||||
void main() {
|
||||
vec4 sum = texture2D(u_texture, v_texCoords) * 4.0;
|
||||
sum += texture2D(u_texture, v_texCoords - halfpixel);
|
||||
sum += texture2D(u_texture, v_texCoords + halfpixel);
|
||||
sum += texture2D(u_texture, v_texCoords - halfpixel * twister);
|
||||
sum += texture2D(u_texture, v_texCoords + halfpixel * twister);
|
||||
gl_FragColor = sum / 8.0;
|
||||
|
||||
// gl_FragColor = texture2D(u_texture, v_texCoords);
|
||||
}
|
||||
28
assets/shaders/kawaseup.frag
Normal file
28
assets/shaders/kawaseup.frag
Normal file
@@ -0,0 +1,28 @@
|
||||
#version 120
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
#endif
|
||||
|
||||
varying vec4 v_color;
|
||||
varying vec2 v_texCoords;
|
||||
uniform sampler2D u_texture;
|
||||
|
||||
uniform vec2 halfpixel = vec2(0.0, 0.0);
|
||||
|
||||
vec2 doublex = vec2(2.0, 0.0);
|
||||
vec2 doubley = vec2(0.0, 2.0);
|
||||
vec2 twister = vec2(1.0, -1.0);
|
||||
|
||||
void main() {
|
||||
vec4 sum = texture2D(u_texture, v_texCoords - halfpixel * doublex);
|
||||
sum += texture2D(u_texture, v_texCoords - halfpixel * twister) * 2.0;
|
||||
sum += texture2D(u_texture, v_texCoords + halfpixel * doubley);
|
||||
sum += texture2D(u_texture, v_texCoords + halfpixel) * 2.0;
|
||||
sum += texture2D(u_texture, v_texCoords + halfpixel * doublex);
|
||||
sum += texture2D(u_texture, v_texCoords + halfpixel * twister) * 2.0;
|
||||
sum += texture2D(u_texture, v_texCoords - halfpixel * doubley);
|
||||
sum += texture2D(u_texture, v_texCoords - halfpixel) * 2.0;
|
||||
gl_FragColor = sum / 12.0;
|
||||
|
||||
// gl_FragColor = texture2D(u_texture, v_texCoords);
|
||||
}
|
||||
Reference in New Issue
Block a user