Made accidental shader that looks like wat ppl with glasses see without glasses
This commit is contained in:
@@ -1,64 +1,124 @@
|
|||||||
#version 150
|
#version 150
|
||||||
|
|
||||||
|
// Minecrafts eingebaute Variablen für die Bildschirmgröße
|
||||||
|
uniform float viewWidth;
|
||||||
|
uniform float viewHeight;
|
||||||
|
|
||||||
uniform sampler2D colortex0;
|
uniform sampler2D colortex0;
|
||||||
in vec2 texCoord;
|
in vec2 texCoord;
|
||||||
out vec4 fragColor;
|
out vec4 fragColor;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
ivec2 pixelSizeInt = textureSize(colortex0, 0);
|
// Exakte Pixelgröße berechnen
|
||||||
vec2 pixelSizeFloat = vec2(pixelSizeInt);
|
vec2 texelSize = vec2(1.0 / viewWidth, 1.0 / viewHeight);
|
||||||
vec2 texelSize = vec2(1.0) / vec2(textureSize(colortex0, 0));
|
|
||||||
|
|
||||||
|
// =========================================================================
|
||||||
|
// QUADRANT 1: Oben-Rechts (Top-Right)
|
||||||
|
// =========================================================================
|
||||||
|
float lumaSum_tr = 0.0;
|
||||||
|
float lumaSquaredSum_tr = 0.0;
|
||||||
|
vec3 colorSum_tr = vec3(0.0);
|
||||||
|
|
||||||
|
for (int i = 0; i <= 4; i++) {
|
||||||
|
for (int j = 0; j <= 4; j++) {
|
||||||
|
vec2 offset = vec2(float(i), float(j)) * texelSize;
|
||||||
|
vec3 neighborColor = texture(colortex0, texCoord + offset).rgb;
|
||||||
|
float luma = dot(neighborColor, vec3(0.299, 0.587, 0.114));
|
||||||
|
|
||||||
|
colorSum_tr += neighborColor;
|
||||||
|
lumaSum_tr += luma;
|
||||||
|
lumaSquaredSum_tr += (luma * luma);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
vec3 mean_tr = colorSum_tr / 9.0;
|
||||||
|
float mean_luma_tr = lumaSum_tr / 9.0;
|
||||||
|
float variance_tr = (lumaSquaredSum_tr / 9.0) - (mean_luma_tr * mean_luma_tr);
|
||||||
|
|
||||||
// Following is made by Claude, that works (27.5.26)
|
// =========================================================================
|
||||||
/*
|
// QUADRANT 2: Oben-Links (Top-Left)
|
||||||
vec3 scene = texture(colortex0, texCoord).rgb;
|
// =========================================================================
|
||||||
float gray = dot(scene, vec3(2.5000, 0.5000, 0.5000)); // Farbkontrolle (Auch genannt, luma weiter oben)
|
float lumaSum_tl = 0.0;
|
||||||
fragColor = vec4(vec3(gray), 1.0);
|
float lumaSquaredSum_tl = 0.0;
|
||||||
*/
|
vec3 colorSum_tl = vec3(0.0);
|
||||||
}
|
|
||||||
|
|
||||||
squareBottomRight() {
|
for (int i = -4; i <= 0; i++) {
|
||||||
float lumaSum_br = 0.0;
|
for (int j = 0; j <= 4; j++) {
|
||||||
float lumaSquaredSum_br = 0.0;
|
vec2 offset = vec2(float(i), float(j)) * texelSize;
|
||||||
vec3 colorSum_br = vec3(0.0);
|
vec3 neighborColor = texture(colortex0, texCoord + offset).rgb;
|
||||||
vec3 mean_br = vec3(0.0);
|
float luma = dot(neighborColor, vec3(0.299, 0.587, 0.114));
|
||||||
vec3 mean_luma_br = vec3(0.0);
|
|
||||||
float variance_br = 0.0;
|
colorSum_tl += neighborColor;
|
||||||
for (int i = 0; i <= 2; i++) {
|
lumaSum_tl += luma;
|
||||||
for (int j = -2; j <= 0; j++) {
|
lumaSquaredSum_tl += (luma * luma);
|
||||||
vec2 offset_br = vec2(float(i), float(j)) * texelSize_br;
|
}
|
||||||
vec3 neighborColor_br = texture(colortex0, texCoord + offset_br).rgb;
|
}
|
||||||
float luma_br = dot(neighborColor_br, vec3(0.299, 0.587, 0.114)); // Basically dasselbe wie float gray weiter unten
|
vec3 mean_tl = colorSum_tl / 9.0;
|
||||||
colorSum_br += neighborColor_br;
|
float mean_luma_tl = lumaSum_tl / 9.0;
|
||||||
lumaSum_br += luma_br;
|
float variance_tl = (lumaSquaredSum_tl / 9.0) - (mean_luma_tl * mean_luma_tl);
|
||||||
lumaSquaredSum_br += (luma_br * luma_br);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
mean_br = (colorSum_br / 9.0);
|
|
||||||
mean_luma_br = (lumaSum_br / 9.0);
|
|
||||||
variance_br = (lumaSquaredSum_br / 9.0 - (mean_luma_br * mean_luma_br));
|
|
||||||
}
|
|
||||||
|
|
||||||
squareBottomLeft() {
|
// =========================================================================
|
||||||
float lumaSum_bl = 0.0;
|
// QUADRANT 3: Unten-Links (Bottom-Left)
|
||||||
float lumaSquaredSum_bl = 0.0;
|
// =========================================================================
|
||||||
vec3 colorSum_bl = vec3(0.0);
|
float lumaSum_bl = 0.0;
|
||||||
vec3 mean_bl = vec3(0.0);
|
float lumaSquaredSum_bl = 0.0;
|
||||||
vec3 mean_luma_bl = vec3(0.0);
|
vec3 colorSum_bl = vec3(0.0);
|
||||||
float variance_bl = 0.0;
|
|
||||||
for (int i = -2; i <= 0; i++) {
|
for (int i = -4; i <= 0; i++) {
|
||||||
for (int j = -2; j <= 0; j++) {
|
for (int j = -4; j <= 0; j++) {
|
||||||
vec2 offset_bl = vec2(float(i), float(j)) * texelSize_bl;
|
vec2 offset = vec2(float(i), float(j)) * texelSize;
|
||||||
vec3 neighborColor_bl = texture(colortex0, texCoord + offset_bl).rgb;
|
vec3 neighborColor = texture(colortex0, texCoord + offset).rgb;
|
||||||
float luma_bl = dot(neighborColor_bl, vec3(0.299, 0.587, 0.114)); // Basically dasselbe wie float gray weiter unten
|
float luma = dot(neighborColor, vec3(0.299, 0.587, 0.114));
|
||||||
colorSum_bl += neighborColor_bl;
|
|
||||||
lumaSum_bl += luma_bl;
|
colorSum_bl += neighborColor;
|
||||||
lumaSquaredSum_bl += (luma_bl * luma_bl);
|
lumaSum_bl += luma;
|
||||||
}
|
lumaSquaredSum_bl += (luma * luma);
|
||||||
}
|
}
|
||||||
mean_bl = (colorSum_bl / 9.0);
|
}
|
||||||
mean_luma_bl = (lumaSum_bl / 9.0);
|
vec3 mean_bl = colorSum_bl / 9.0;
|
||||||
variance_bl = (lumaSquaredSum_bl / 9.0 - (mean_luma_bl * mean_luma_bl));
|
float mean_luma_bl = lumaSum_bl / 9.0;
|
||||||
|
float variance_bl = (lumaSquaredSum_bl / 9.0) - (mean_luma_bl * mean_luma_bl);
|
||||||
|
|
||||||
|
// =========================================================================
|
||||||
|
// QUADRANT 4: Unten-Rechts (Bottom-Right)
|
||||||
|
// =========================================================================
|
||||||
|
float lumaSum_br = 0.0;
|
||||||
|
float lumaSquaredSum_br = 0.0;
|
||||||
|
vec3 colorSum_br = vec3(0.0);
|
||||||
|
|
||||||
|
for (int i = 0; i <= 4; i++) {
|
||||||
|
for (int j = -4; j <= 0; j++) {
|
||||||
|
vec2 offset = vec2(float(i), float(j)) * texelSize;
|
||||||
|
vec3 neighborColor = texture(colortex0, texCoord + offset).rgb;
|
||||||
|
float luma = dot(neighborColor, vec3(0.299, 0.587, 0.114));
|
||||||
|
|
||||||
|
colorSum_br += neighborColor;
|
||||||
|
lumaSum_br += luma;
|
||||||
|
lumaSquaredSum_br += (luma * luma);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
vec3 mean_br = colorSum_br / 9.0;
|
||||||
|
float mean_luma_br = lumaSum_br / 9.0;
|
||||||
|
float variance_br = (lumaSquaredSum_br / 9.0) - (mean_luma_br * mean_luma_br);
|
||||||
|
|
||||||
|
// =========================================================================
|
||||||
|
// FINALE AUSWAHL: Den Quadranten mit der NIEDRIGSTEN Varianz finden
|
||||||
|
// =========================================================================
|
||||||
|
float minVariance = variance_tr;
|
||||||
|
vec3 finalColor = mean_tr;
|
||||||
|
|
||||||
|
if (variance_tl < minVariance) {
|
||||||
|
minVariance = variance_tl;
|
||||||
|
finalColor = mean_tl;
|
||||||
|
}
|
||||||
|
if (variance_bl < minVariance) {
|
||||||
|
minVariance = variance_bl;
|
||||||
|
finalColor = mean_bl;
|
||||||
|
}
|
||||||
|
if (variance_br < minVariance) {
|
||||||
|
minVariance = variance_br;
|
||||||
|
finalColor = mean_br;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Farbe auf den Bildschirm bringen!
|
||||||
|
fragColor = vec4(finalColor, 1.0);
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user