Initial commit
This commit is contained in:
64
shaders/final.fsh
Normal file
64
shaders/final.fsh
Normal file
@@ -0,0 +1,64 @@
|
||||
#version 150
|
||||
|
||||
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));
|
||||
|
||||
|
||||
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
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;
|
||||
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);
|
||||
}
|
||||
}
|
||||
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));
|
||||
}
|
||||
11
shaders/final.vsh
Normal file
11
shaders/final.vsh
Normal file
@@ -0,0 +1,11 @@
|
||||
#version 150
|
||||
|
||||
in vec3 vaPosition;
|
||||
in vec2 vaUV0;
|
||||
|
||||
out vec2 texCoord;
|
||||
|
||||
void main() {
|
||||
gl_Position = vec4(vaPosition.xy * 2.0 - 1.0, 0.0, 1.0);
|
||||
texCoord = vaUV0;
|
||||
}
|
||||
20
shaders/gbuffers_terrain.fsh
Normal file
20
shaders/gbuffers_terrain.fsh
Normal file
@@ -0,0 +1,20 @@
|
||||
#version 150
|
||||
|
||||
/* DRAWBUFFERS:0 */
|
||||
|
||||
uniform sampler2D gtexture;
|
||||
uniform sampler2D lightmap;
|
||||
|
||||
in vec2 texCoord;
|
||||
in vec4 tintColor;
|
||||
in vec2 lightCoord;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
void main() {
|
||||
vec4 color = texture(gtexture, texCoord);
|
||||
if (color.a < 0.1) discard;
|
||||
color *= tintColor;
|
||||
color.rgb *= texture(lightmap, lightCoord).rgb;
|
||||
fragColor = color;
|
||||
}
|
||||
21
shaders/gbuffers_terrain.vsh
Normal file
21
shaders/gbuffers_terrain.vsh
Normal file
@@ -0,0 +1,21 @@
|
||||
#version 150
|
||||
|
||||
uniform mat4 modelViewMatrix;
|
||||
uniform mat4 projectionMatrix;
|
||||
uniform vec3 chunkOffset;
|
||||
|
||||
in vec3 vaPosition;
|
||||
in vec4 vaColor;
|
||||
in vec2 vaUV0;
|
||||
in ivec2 vaUV2;
|
||||
|
||||
out vec2 texCoord;
|
||||
out vec4 tintColor;
|
||||
out vec2 lightCoord;
|
||||
|
||||
void main() {
|
||||
gl_Position = projectionMatrix * modelViewMatrix * vec4(vaPosition + chunkOffset, 1.0);
|
||||
texCoord = vaUV0;
|
||||
tintColor = vaColor;
|
||||
lightCoord = vaUV2 / 256.0;
|
||||
}
|
||||
Reference in New Issue
Block a user