Made accidental shader that looks like wat ppl with glasses see without glasses

This commit is contained in:
Cametendo
2026-06-01 09:36:15 +02:00
parent c68a109c97
commit 2ce7ca661b

View File

@@ -1,64 +1,124 @@
#version 150
// Minecrafts eingebaute Variablen für die Bildschirmgröße
uniform float viewWidth;
uniform float viewHeight;
uniform sampler2D colortex0;
in vec2 texCoord;
out vec4 fragColor;
void main() {
ivec2 pixelSizeInt = textureSize(colortex0, 0);
vec2 pixelSizeFloat = vec2(pixelSizeInt);
vec2 texelSize = vec2(1.0) / vec2(textureSize(colortex0, 0));
// Exakte Pixelgröße berechnen
vec2 texelSize = vec2(1.0 / viewWidth, 1.0 / viewHeight);
// =========================================================================
// 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));
// Following is made by Claude, that works (27.5.26)
/*
vec3 scene = texture(colortex0, texCoord).rgb;
float gray = dot(scene, vec3(2.5000, 0.5000, 0.5000)); // Farbkontrolle (Auch genannt, luma weiter oben)
fragColor = vec4(vec3(gray), 1.0);
*/
}
squareBottomRight() {
float lumaSum_br = 0.0;
float lumaSquaredSum_br = 0.0;
vec3 colorSum_br = vec3(0.0);
vec3 mean_br = vec3(0.0);
vec3 mean_luma_br = vec3(0.0);
float variance_br = 0.0;
for (int i = 0; i <= 2; i++) {
for (int j = -2; j <= 0; j++) {
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
colorSum_br += neighborColor_br;
lumaSum_br += luma_br;
lumaSquaredSum_br += (luma_br * luma_br);
colorSum_tr += neighborColor;
lumaSum_tr += luma;
lumaSquaredSum_tr += (luma * luma);
}
}
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));
}
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);
squareBottomLeft() {
// =========================================================================
// QUADRANT 2: Oben-Links (Top-Left)
// =========================================================================
float lumaSum_tl = 0.0;
float lumaSquaredSum_tl = 0.0;
vec3 colorSum_tl = vec3(0.0);
for (int i = -4; i <= 0; 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_tl += neighborColor;
lumaSum_tl += luma;
lumaSquaredSum_tl += (luma * luma);
}
}
vec3 mean_tl = colorSum_tl / 9.0;
float mean_luma_tl = lumaSum_tl / 9.0;
float variance_tl = (lumaSquaredSum_tl / 9.0) - (mean_luma_tl * mean_luma_tl);
// =========================================================================
// QUADRANT 3: Unten-Links (Bottom-Left)
// =========================================================================
float lumaSum_bl = 0.0;
float lumaSquaredSum_bl = 0.0;
vec3 colorSum_bl = vec3(0.0);
vec3 mean_bl = vec3(0.0);
vec3 mean_luma_bl = vec3(0.0);
float variance_bl = 0.0;
for (int i = -2; i <= 0; i++) {
for (int j = -2; j <= 0; j++) {
vec2 offset_bl = vec2(float(i), float(j)) * texelSize_bl;
vec3 neighborColor_bl = texture(colortex0, texCoord + offset_bl).rgb;
float luma_bl = dot(neighborColor_bl, vec3(0.299, 0.587, 0.114)); // Basically dasselbe wie float gray weiter unten
colorSum_bl += neighborColor_bl;
lumaSum_bl += luma_bl;
lumaSquaredSum_bl += (luma_bl * luma_bl);
for (int i = -4; i <= 0; 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_bl += neighborColor;
lumaSum_bl += luma;
lumaSquaredSum_bl += (luma * luma);
}
}
mean_bl = (colorSum_bl / 9.0);
mean_luma_bl = (lumaSum_bl / 9.0);
variance_bl = (lumaSquaredSum_bl / 9.0 - (mean_luma_bl * mean_luma_bl));
vec3 mean_bl = colorSum_bl / 9.0;
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);
}