mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-17 00:56:07 +09:00
4096 shader finally works... perhaps it needs bayer matrix?
This commit is contained in:
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user