mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-10 13:51:53 +09:00
4096 shader finally works... perhaps it needs bayer matrix?
This commit is contained in:
@@ -1,16 +0,0 @@
|
||||
vec4 blur13(sampler2D image, vec2 uv, vec2 resolution, vec2 direction) {
|
||||
vec4 color = vec4(0.0);
|
||||
vec2 off1 = vec2(1.411764705882353) * direction;
|
||||
vec2 off2 = vec2(3.2941176470588234) * direction;
|
||||
vec2 off3 = vec2(5.176470588235294) * direction;
|
||||
color += texture2D(image, uv) * 0.1964825501511404;
|
||||
color += texture2D(image, uv + (off1 / resolution)) * 0.2969069646728344;
|
||||
color += texture2D(image, uv - (off1 / resolution)) * 0.2969069646728344;
|
||||
color += texture2D(image, uv + (off2 / resolution)) * 0.09447039785044732;
|
||||
color += texture2D(image, uv - (off2 / resolution)) * 0.09447039785044732;
|
||||
color += texture2D(image, uv + (off3 / resolution)) * 0.010381362401148057;
|
||||
color += texture2D(image, uv - (off3 / resolution)) * 0.010381362401148057;
|
||||
return color;
|
||||
}
|
||||
|
||||
#pragma glslify: export(blur13)
|
||||
@@ -1,37 +1,11 @@
|
||||
varying vec2 texcoord;
|
||||
varying vec4 v_color;
|
||||
varying vec2 v_texCoords;
|
||||
uniform sampler2D u_texture;
|
||||
|
||||
uniform sampler2D renderTexture;
|
||||
uniform mat4 Bayer;
|
||||
uniform int pixelSize;
|
||||
|
||||
void main(void) {
|
||||
// create texture coordinates based on pixelSize //
|
||||
|
||||
// vec2 discrete = (gl_FragCoord.xy + 0.001) / texcoord / pixelSize; //
|
||||
vec4 color = texture2D(u_texture, v_texCoords);
|
||||
color = floor(15.0 * color + 0.5) / 15.0;
|
||||
|
||||
vec2 pixelSizeVec = vec2(float(pixelSize), float(pixelSize));
|
||||
|
||||
vec2 discrete = (gl_FragCoord.xy + 0.001) / texcoord / pixelSizeVec;
|
||||
|
||||
discrete = floor(discrete * texcoord) / discrete;
|
||||
|
||||
vec3 color = texture2D(renderTexture, discrete).rgb;
|
||||
|
||||
// increase contrast (Bayer matrix operation reduces it) //
|
||||
float contrast = 1.65;
|
||||
color = mix(vec3(0.5), color, contrast);
|
||||
|
||||
// add Bayer matrix entry to current pixel //
|
||||
// vec2 entry = mod(gl_FragCoord.xy / pixelSizeVec, vec2(4, 4));
|
||||
|
||||
// color.r = color.r + Bayer[int(entry.x)][int(entry.y)] / 17.0 - 0.5;
|
||||
// color.g = color.g + Bayer[int(entry.x)][int(entry.y)] / 17.0 - 0.5;
|
||||
// color.b = color.b + Bayer[int(entry.x)][int(entry.y)] / 17.0 - 0.5;
|
||||
|
||||
// find nearest 8-bit color //
|
||||
color.r = floor(8.0 * color.r + 0.5) / 8.0;
|
||||
color.g = floor(8.0 * color.g + 0.5) / 8.0;
|
||||
color.b = floor(4.0 * color.b + 0.5) / 4.0;
|
||||
|
||||
gl_FragColor = vec4(color, 1.0);
|
||||
gl_FragColor = color;
|
||||
}
|
||||
@@ -1,7 +1,14 @@
|
||||
varying vec2 texcoord;
|
||||
attribute vec4 a_position;
|
||||
attribute vec4 a_color;
|
||||
attribute vec2 a_texCoord0;
|
||||
|
||||
void main(void) { // fairly usual fullscreen quad setup //
|
||||
vec2 corners = sign(gl_Vertex.xy);
|
||||
texcoord = 0.5 * corners + vec2(0.5);
|
||||
gl_Position = vec4(corners, 0.0, 1.0);
|
||||
uniform mat4 u_projTrans;
|
||||
|
||||
varying vec4 v_color;
|
||||
varying vec2 v_texCoords;
|
||||
|
||||
void main() {
|
||||
v_color = a_color;
|
||||
v_texCoords = a_texCoord0;
|
||||
gl_Position = u_projTrans * a_position;
|
||||
}
|
||||
Reference in New Issue
Block a user