summaryrefslogtreecommitdiffstats
path: root/cwd/assets/altcraft/shaders
diff options
context:
space:
mode:
authorLaG1924 <12997935+LaG1924@users.noreply.github.com>2021-12-25 07:50:14 +0100
committerGitHub <noreply@github.com>2021-12-25 07:50:14 +0100
commit7ebc8e1bd33b6658b50153a26945814a87fba5f4 (patch)
tree51d377a4560a7e12b3b404b0b043d9f64981caf3 /cwd/assets/altcraft/shaders
parentMerge pull request #77 from LaG1924/ftr/graphics-abstraction-layer (diff)
parentAdded smooth lighting settings parameter (diff)
downloadAltCraft-7ebc8e1bd33b6658b50153a26945814a87fba5f4.tar
AltCraft-7ebc8e1bd33b6658b50153a26945814a87fba5f4.tar.gz
AltCraft-7ebc8e1bd33b6658b50153a26945814a87fba5f4.tar.bz2
AltCraft-7ebc8e1bd33b6658b50153a26945814a87fba5f4.tar.lz
AltCraft-7ebc8e1bd33b6658b50153a26945814a87fba5f4.tar.xz
AltCraft-7ebc8e1bd33b6658b50153a26945814a87fba5f4.tar.zst
AltCraft-7ebc8e1bd33b6658b50153a26945814a87fba5f4.zip
Diffstat (limited to 'cwd/assets/altcraft/shaders')
-rw-r--r--cwd/assets/altcraft/shaders/frag/blur.fs22
-rw-r--r--cwd/assets/altcraft/shaders/frag/copy.fs11
-rw-r--r--cwd/assets/altcraft/shaders/frag/entity.fs10
-rw-r--r--cwd/assets/altcraft/shaders/frag/face.fs21
-rw-r--r--cwd/assets/altcraft/shaders/frag/fbo.fs11
-rw-r--r--cwd/assets/altcraft/shaders/frag/fwd_entity.fs11
-rw-r--r--cwd/assets/altcraft/shaders/frag/fwd_face.fs39
-rw-r--r--cwd/assets/altcraft/shaders/frag/fwd_sky.fs66
-rw-r--r--cwd/assets/altcraft/shaders/frag/light.fs83
-rw-r--r--cwd/assets/altcraft/shaders/frag/rml.fs8
-rw-r--r--cwd/assets/altcraft/shaders/frag/rmltex.fs12
-rw-r--r--cwd/assets/altcraft/shaders/frag/sky.fs37
-rw-r--r--cwd/assets/altcraft/shaders/frag/ssao.fs68
-rw-r--r--cwd/assets/altcraft/shaders/vert/entity.vs17
-rw-r--r--cwd/assets/altcraft/shaders/vert/face.vs49
-rw-r--r--cwd/assets/altcraft/shaders/vert/fbo.vs11
-rw-r--r--cwd/assets/altcraft/shaders/vert/quad.vs23
-rw-r--r--cwd/assets/altcraft/shaders/vert/rml.vs32
-rw-r--r--cwd/assets/altcraft/shaders/vert/sky.vs21
19 files changed, 458 insertions, 94 deletions
diff --git a/cwd/assets/altcraft/shaders/frag/blur.fs b/cwd/assets/altcraft/shaders/frag/blur.fs
new file mode 100644
index 0000000..89d4498
--- /dev/null
+++ b/cwd/assets/altcraft/shaders/frag/blur.fs
@@ -0,0 +1,22 @@
+#version 330 core
+
+out vec4 fragColor;
+
+in vec2 uv;
+
+uniform sampler2D blurInput;
+uniform int blurScale;
+
+void main() {
+ vec2 texelSize = 1.0f / vec2(textureSize(blurInput, 0));
+ vec4 result = vec4(0.0f);
+ for (int x = -blurScale; x < blurScale; x++)
+ {
+ for (int y = -blurScale; y < blurScale; y++)
+ {
+ vec2 offset = vec2(float(x), float(y)) * texelSize;
+ result += texture(blurInput, uv + offset);
+ }
+ }
+ fragColor = result / pow(blurScale * 2.0f, 2);
+}
diff --git a/cwd/assets/altcraft/shaders/frag/copy.fs b/cwd/assets/altcraft/shaders/frag/copy.fs
new file mode 100644
index 0000000..a5a7a2b
--- /dev/null
+++ b/cwd/assets/altcraft/shaders/frag/copy.fs
@@ -0,0 +1,11 @@
+#version 330 core
+
+in vec2 uv;
+
+out vec4 fragColor;
+
+uniform sampler2D inputTexture;
+
+void main() {
+ fragColor = texture(inputTexture, uv);
+}
diff --git a/cwd/assets/altcraft/shaders/frag/entity.fs b/cwd/assets/altcraft/shaders/frag/entity.fs
index 06d5759..a857da1 100644
--- a/cwd/assets/altcraft/shaders/frag/entity.fs
+++ b/cwd/assets/altcraft/shaders/frag/entity.fs
@@ -1,9 +1,13 @@
#version 330 core
-out vec4 fragColor;
+layout (location = 0) out vec4 color;
+layout (location = 1) out vec4 normal;
+layout (location = 2) out vec4 light;
-uniform vec3 color;
+uniform vec3 entityColor;
void main() {
- fragColor = vec4(color, 1);
+ color = vec4(entityColor, 1.0f);
+ normal = vec4(0.0f, 0.0f, 0.0f, 1.0f);
+ light = vec4(1.0f, 1.0f, 0.0f, 1.0f);
}
diff --git a/cwd/assets/altcraft/shaders/frag/face.fs b/cwd/assets/altcraft/shaders/frag/face.fs
index 30d44d2..f9af02c 100644
--- a/cwd/assets/altcraft/shaders/frag/face.fs
+++ b/cwd/assets/altcraft/shaders/frag/face.fs
@@ -1,18 +1,23 @@
#version 330 core
-in VS_OUT {
- vec3 Texture;
- vec3 Color;
-} fs_in;
+in vec3 faceTextureUv;
+in vec3 faceAddColor;
+in vec3 faceNormal;
+in vec2 faceLight;
+in float faceAmbientOcclusion;
-out vec4 fragColor;
+layout (location = 0) out vec4 color;
+layout (location = 1) out vec4 normal;
+layout (location = 2) out vec4 light;
uniform sampler2DArray textureAtlas;
void main() {
- vec4 color = texture(textureAtlas,fs_in.Texture);
- if (color.a < 0.3)
+ vec4 col = texture(textureAtlas, faceTextureUv);
+ if (col.a < 0.3)
discard;
- fragColor = vec4(color.rgb * fs_in.Color, 1.0);
+ color = vec4(col.rgb * faceAddColor.rgb, 1.0f);
+ normal = vec4(faceNormal, 1.0f);
+ light = vec4(faceLight / 15.0f, faceAmbientOcclusion, 1.0f);
}
diff --git a/cwd/assets/altcraft/shaders/frag/fbo.fs b/cwd/assets/altcraft/shaders/frag/fbo.fs
deleted file mode 100644
index df624b3..0000000
--- a/cwd/assets/altcraft/shaders/frag/fbo.fs
+++ /dev/null
@@ -1,11 +0,0 @@
-#version 330 core
-
-out vec4 FragColor;
-in vec2 TexCoords;
-
-uniform sampler2D inputTexture;
-
-void main()
-{
- FragColor = texture(inputTexture, TexCoords);
-} \ No newline at end of file
diff --git a/cwd/assets/altcraft/shaders/frag/fwd_entity.fs b/cwd/assets/altcraft/shaders/frag/fwd_entity.fs
new file mode 100644
index 0000000..094aaf2
--- /dev/null
+++ b/cwd/assets/altcraft/shaders/frag/fwd_entity.fs
@@ -0,0 +1,11 @@
+#version 330 core
+
+in vec4 entityWorldPos;
+
+out vec4 fragColor;
+
+uniform vec3 entityColor;
+
+void main() {
+ fragColor = vec4(entityColor, 1.0f);
+}
diff --git a/cwd/assets/altcraft/shaders/frag/fwd_face.fs b/cwd/assets/altcraft/shaders/frag/fwd_face.fs
new file mode 100644
index 0000000..12deab8
--- /dev/null
+++ b/cwd/assets/altcraft/shaders/frag/fwd_face.fs
@@ -0,0 +1,39 @@
+#version 330 core
+
+in vec4 faceWorldPos;
+in vec3 faceTextureUv;
+in vec3 faceAddColor;
+in vec3 faceNormal;
+in vec2 faceLight;
+
+out vec4 fragColor;
+
+uniform sampler2DArray textureAtlas;
+
+layout (std140) uniform Globals {
+ mat4 projView;
+ mat4 proj;
+ mat4 invProj;
+ mat4 view;
+ uvec2 viewportSize;
+ vec4 ssaoKernels[64];
+ float globalTime;
+ float dayTime;
+ float gamma;
+};
+
+void main() {
+ vec4 col = texture(textureAtlas, faceTextureUv);
+ if (col.a < 0.3f)
+ discard;
+
+ float localLight = faceLight.r / 15.0f;
+ float skyLight = faceLight.g / 15.0f;
+ float lightLevel = clamp(localLight + skyLight * dayTime, 0.01f, 1.0f);
+ lightLevel = pow(lightLevel, 3);
+ lightLevel = clamp(lightLevel, 0.005f, 1.0f);
+
+ fragColor = vec4(col.rgb * faceAddColor.rgb * lightLevel, 1.0f);
+
+ fragColor.rgb = pow(fragColor.rgb, vec3(1.0f / gamma));
+}
diff --git a/cwd/assets/altcraft/shaders/frag/fwd_sky.fs b/cwd/assets/altcraft/shaders/frag/fwd_sky.fs
new file mode 100644
index 0000000..9f278b2
--- /dev/null
+++ b/cwd/assets/altcraft/shaders/frag/fwd_sky.fs
@@ -0,0 +1,66 @@
+#version 330 core
+
+in vec3 facePos;
+
+out vec4 fragColor;
+
+layout (std140) uniform Globals {
+ mat4 projView;
+ mat4 proj;
+ mat4 invProj;
+ mat4 view;
+ uvec2 viewportSize;
+ vec4 ssaoKernels[64];
+ float globalTime;
+ float dayTime;
+ float gamma;
+};
+
+uniform sampler2DArray textureAtlas;
+uniform vec4 sunTexture;
+uniform float sunTextureLayer;
+uniform vec4 moonTexture;
+uniform float moonTextureLayer;
+
+const vec4 DaySkyColor = vec4(0.21, 0.4, 1, 1);
+
+const vec3 SunPos = vec3(0, 0.1, 0.5);
+
+const vec3 MoonPos = vec3(0, 0.1, -0.5);
+
+const vec4 NightSkyColor = vec4(0.0, 0.0008, 0.002, 1.0);
+
+vec3 TransformTextureCoord(vec4 TextureAtlasCoords, vec2 UvCoords, float Layer) {
+ float x = TextureAtlasCoords.x;
+ float y = TextureAtlasCoords.y;
+ float w = TextureAtlasCoords.z;
+ float h = TextureAtlasCoords.w;
+ vec2 A = vec2(x, 1 - y - h);
+ vec2 B = vec2(x + w, 1 - y);
+ vec2 transformed = A + UvCoords * (B - A);
+ return vec3(transformed.x, transformed.y, Layer);
+}
+
+vec4 Sun() {
+ vec3 sunDelta = (facePos - SunPos) * 3.0f;
+ float distanceToSun = length(sunDelta);
+ vec4 sunColor = texture(textureAtlas, TransformTextureCoord(sunTexture, (vec2(sunDelta.xy) + 0.5f), sunTextureLayer));
+ vec4 sun = mix(vec4(0, 0, 0, 1), sunColor, clamp(1 - distanceToSun * 2.0f, 0, 1));
+ return sun;
+}
+
+vec4 Moon() {
+ vec3 moonDelta = (facePos - MoonPos) * 4.5f;
+ float distanceToMoon = length(moonDelta);
+ vec4 moonColor = texture(textureAtlas, TransformTextureCoord(moonTexture, (vec2(moonDelta.xy) + 0.5f), moonTextureLayer));
+ vec4 moon = mix(vec4(0, 0, 0, 1),moonColor, clamp(1 - distanceToMoon * 2.0f, 0, 1));
+ return moon;
+}
+
+void main() {
+ fragColor = vec4(mix(NightSkyColor, DaySkyColor, dayTime).rgb, 1.0f);
+ fragColor += vec4(Sun().rgb, 1.0f);
+ fragColor += vec4(Moon().rgb, 1.0f);
+
+ fragColor.rgb = pow(fragColor.rgb, vec3(1.0f / gamma));
+}
diff --git a/cwd/assets/altcraft/shaders/frag/light.fs b/cwd/assets/altcraft/shaders/frag/light.fs
new file mode 100644
index 0000000..a0cda02
--- /dev/null
+++ b/cwd/assets/altcraft/shaders/frag/light.fs
@@ -0,0 +1,83 @@
+#version 330 core
+
+out vec4 fragColor;
+
+in vec2 uv;
+
+uniform sampler2D depthStencil;
+uniform sampler2D color;
+uniform sampler2D normal;
+uniform sampler2D light;
+uniform sampler2D ssao;
+
+uniform int renderBuff;
+uniform bool applySsao;
+
+layout (std140) uniform Globals {
+ mat4 projView;
+ mat4 proj;
+ mat4 invProj;
+ mat4 view;
+ uvec2 viewportSize;
+ vec4 ssaoKernels[64];
+ float globalTime;
+ float dayTime;
+ float gamma;
+};
+
+vec3 RecoverViewWorldPos(vec2 screenPos, float depth) {
+ vec4 viewPos = invProj * vec4(screenPos * 2.0 - 1.0, depth * 2.0 - 1.0, 1.0);
+ return viewPos.xyz / viewPos.w;
+}
+
+void main() {
+ vec4 c = texture(color, uv);
+ vec4 n = texture(normal, uv);
+ n += 1.0f;
+ n /= 2.0f;
+
+ vec4 l = texture(light, uv);
+ float depth = texture(depthStencil, uv).r;
+ float d = (1.0f - depth) * 16.0f;
+ vec4 s = texture(ssao, uv);
+
+ float faceLight = l.r;
+ float skyLight = l.g;
+ float lightLevel = clamp(faceLight + skyLight * dayTime, 0.01f, 1.0f);
+ lightLevel = pow(lightLevel, 3);
+ if (applySsao) {
+ lightLevel *= pow(s.r, 2);
+ }
+ lightLevel = clamp(lightLevel, 0.005f, 1.0f);
+
+ vec4 finalColor = vec4(c.rgb * lightLevel, 1.0f);
+
+ finalColor.rgb = pow(finalColor.rgb, vec3(1.0f / gamma));
+
+ switch(renderBuff) {
+ case 0:
+ fragColor = finalColor;
+ break;
+ case 1:
+ fragColor = c;
+ break;
+ case 2:
+ fragColor = n;
+ break;
+ case 3:
+ fragColor = vec4(RecoverViewWorldPos(uv, depth), 1.0f);
+ break;
+ case 4:
+ fragColor = vec4(0.5f);
+ break;
+ case 5:
+ fragColor = vec4(l.r, l.g, 1.0f - l.b, 1.0f);
+ break;
+ case 6:
+ fragColor = vec4(vec3(d), 1.0f);
+ break;
+ case 7:
+ fragColor = vec4(pow(s.r, 2));
+ break;
+ }
+}
diff --git a/cwd/assets/altcraft/shaders/frag/rml.fs b/cwd/assets/altcraft/shaders/frag/rml.fs
index 54c3f36..fa1c596 100644
--- a/cwd/assets/altcraft/shaders/frag/rml.fs
+++ b/cwd/assets/altcraft/shaders/frag/rml.fs
@@ -1,12 +1,10 @@
#version 330 core
-in VS_OUT {
- vec4 color;
- vec2 tex_coord;
-} fs_in;
+in vec4 color;
+in vec2 uv;
out vec4 fragColor;
void main() {
- fragColor = fs_in.color;
+ fragColor = color;
}
diff --git a/cwd/assets/altcraft/shaders/frag/rmltex.fs b/cwd/assets/altcraft/shaders/frag/rmltex.fs
index d885b3b..af86b5b 100644
--- a/cwd/assets/altcraft/shaders/frag/rmltex.fs
+++ b/cwd/assets/altcraft/shaders/frag/rmltex.fs
@@ -1,14 +1,12 @@
#version 330 core
-uniform sampler2D fontTexture;
-
-in VS_OUT {
- vec4 color;
- vec2 tex_coord;
-} fs_in;
+in vec4 color;
+in vec2 uv;
out vec4 fragColor;
+uniform sampler2D fontTexture;
+
void main() {
- fragColor = fs_in.color * texture(fontTexture, fs_in.tex_coord);
+ fragColor = color * texture(fontTexture, uv);
}
diff --git a/cwd/assets/altcraft/shaders/frag/sky.fs b/cwd/assets/altcraft/shaders/frag/sky.fs
index 53e0cf4..731246a 100644
--- a/cwd/assets/altcraft/shaders/frag/sky.fs
+++ b/cwd/assets/altcraft/shaders/frag/sky.fs
@@ -1,22 +1,37 @@
#version 330 core
-in vec3 pos;
+in vec3 facePos;
-out vec4 fragColor;
+layout (location = 0) out vec4 color;
+layout (location = 1) out vec4 normal;
+layout (location = 2) out vec4 light;
+
+layout (std140) uniform Globals {
+ mat4 projView;
+ mat4 proj;
+ mat4 invProj;
+ mat4 view;
+ uvec2 viewportSize;
+ vec4 ssaoKernels[64];
+ float globalTime;
+ float dayTime;
+ float gamma;
+};
uniform sampler2DArray textureAtlas;
-uniform float DayTime;
uniform vec4 sunTexture;
uniform float sunTextureLayer;
uniform vec4 moonTexture;
uniform float moonTextureLayer;
-const vec4 DaySkyColor = vec4(0.49, 0.66, 1, 1);
+const vec4 DaySkyColor = vec4(0.21, 0.4, 1, 1);
const vec3 SunPos = vec3(0, 0.1, 0.5);
const vec3 MoonPos = vec3(0, 0.1, -0.5);
+const vec4 NightSkyColor = vec4(0.0, 0.0008, 0.002, 1.0);
+
vec3 TransformTextureCoord(vec4 TextureAtlasCoords, vec2 UvCoords, float Layer) {
float x = TextureAtlasCoords.x;
float y = TextureAtlasCoords.y;
@@ -29,7 +44,7 @@ vec3 TransformTextureCoord(vec4 TextureAtlasCoords, vec2 UvCoords, float Layer)
}
vec4 Sun() {
- vec3 sunDelta = (pos - SunPos) * 3.0f;
+ vec3 sunDelta = (facePos - SunPos) * 3.0f;
float distanceToSun = length(sunDelta);
vec4 sunColor = texture(textureAtlas, TransformTextureCoord(sunTexture, (vec2(sunDelta.xy) + 0.5f), sunTextureLayer));
vec4 sun = mix(vec4(0, 0, 0, 1), sunColor, clamp(1 - distanceToSun * 2.0f, 0, 1));
@@ -37,7 +52,7 @@ vec4 Sun() {
}
vec4 Moon() {
- vec3 moonDelta = (pos - MoonPos) * 4.5f;
+ vec3 moonDelta = (facePos - MoonPos) * 4.5f;
float distanceToMoon = length(moonDelta);
vec4 moonColor = texture(textureAtlas, TransformTextureCoord(moonTexture, (vec2(moonDelta.xy) + 0.5f), moonTextureLayer));
vec4 moon = mix(vec4(0, 0, 0, 1),moonColor, clamp(1 - distanceToMoon * 2.0f, 0, 1));
@@ -45,8 +60,10 @@ vec4 Moon() {
}
void main() {
- vec4 starColor = vec4(0.0f, 0.04f, 0.06f, 1.0f);
- fragColor = mix(starColor, DaySkyColor, DayTime);
- fragColor += Sun();
- fragColor += Moon();
+ color = vec4(mix(NightSkyColor, DaySkyColor, dayTime).rgb, 1.0f);
+ color += vec4(Sun().rgb, 1.0f);
+ color += vec4(Moon().rgb, 1.0f);
+ normal = vec4(0.0f, 0.0f, 0.0f, 1.0f);
+ light = vec4(1.0f, 1.0f, 0.0f, 1.0f);
+ gl_FragDepth = 1.0f;
}
diff --git a/cwd/assets/altcraft/shaders/frag/ssao.fs b/cwd/assets/altcraft/shaders/frag/ssao.fs
new file mode 100644
index 0000000..1c9db1f
--- /dev/null
+++ b/cwd/assets/altcraft/shaders/frag/ssao.fs
@@ -0,0 +1,68 @@
+#version 330 core
+
+out vec4 fragColor;
+
+in vec2 uv;
+
+uniform sampler2D normal;
+uniform sampler2D light;
+uniform sampler2D depthStencil;
+uniform sampler2D ssaoNoise;
+
+uniform int ssaoSamples;
+
+layout (std140) uniform Globals {
+ mat4 projView;
+ mat4 proj;
+ mat4 invProj;
+ mat4 view;
+ uvec2 viewportSize;
+ vec4 ssaoKernels[64];
+ float globalTime;
+ float dayTime;
+ float gamma;
+};
+
+const vec2 noiseScale = vec2(4.0f, 4.0f);
+const int kernelSize = 64;
+const float radius = 0.5f;
+const float bias = 0.025f;
+
+vec3 RecoverViewWorldPos(vec2 screenPos, float depth) {
+ vec4 viewPos = invProj * vec4(screenPos * 2.0 - 1.0, depth * 2.0 - 1.0, 1.0);
+ return viewPos.xyz / viewPos.w;
+}
+
+void main() {
+ vec3 normal = texture(normal, uv).xyz;
+ vec3 fragPos = RecoverViewWorldPos(uv, texture(depthStencil, uv).r);
+ vec2 noiseUv = uv * viewportSize / noiseScale;
+
+ vec3 randomVec = texture(ssaoNoise, noiseUv).xyz;
+
+ vec3 tangent = normalize(randomVec - normal * dot(randomVec, normal));
+ vec3 bitangent = cross(normal, tangent);
+ mat3 TBN = mat3(tangent, bitangent, normal);
+
+ float occlusion = 0.0;
+ int samples = min(kernelSize, ssaoSamples);
+ for(int i = 0; i < samples; i++)
+ {
+ vec3 samplePos = TBN * ssaoKernels[i].xyz;
+ samplePos = fragPos + samplePos * radius;
+
+ vec4 offset = vec4(samplePos, 1.0);
+ offset = proj * offset;
+ offset.xyz /= offset.w;
+ offset.xyz = offset.xyz * 0.5 + 0.5;
+
+ float sampleDepth = RecoverViewWorldPos(offset.xy, texture(depthStencil, offset.xy).r).z;
+ float rangeCheck = smoothstep(0.0, 1.0, radius / abs(fragPos.z - sampleDepth));
+ float aoMask = texture(light, offset.xy).b;
+ occlusion += (sampleDepth >= samplePos.z + bias ? 1.0 : 0.0) * rangeCheck * aoMask;
+ }
+
+ occlusion = 1.0f - (occlusion / samples);
+
+ fragColor = vec4(vec3(occlusion), 1.0f);
+}
diff --git a/cwd/assets/altcraft/shaders/vert/entity.vs b/cwd/assets/altcraft/shaders/vert/entity.vs
index e38c54c..8cc7f69 100644
--- a/cwd/assets/altcraft/shaders/vert/entity.vs
+++ b/cwd/assets/altcraft/shaders/vert/entity.vs
@@ -1,10 +1,21 @@
#version 330 core
-in vec3 position;
+in vec3 pos;
-uniform mat4 projView;
uniform mat4 model;
+layout (std140) uniform Globals {
+ mat4 projView;
+ mat4 proj;
+ mat4 invProj;
+ mat4 view;
+ uvec2 viewportSize;
+ vec4 ssaoKernels[64];
+ float globalTime;
+ float dayTime;
+ float gamma;
+};
+
void main() {
- gl_Position = projView * model * vec4(position, 1);
+ gl_Position = projView * model * vec4(pos, 1);
}
diff --git a/cwd/assets/altcraft/shaders/vert/face.vs b/cwd/assets/altcraft/shaders/vert/face.vs
index 93e623d..101e4d0 100644
--- a/cwd/assets/altcraft/shaders/vert/face.vs
+++ b/cwd/assets/altcraft/shaders/vert/face.vs
@@ -1,27 +1,38 @@
#version 330 core
-layout (location = 0) in vec3 position[4];
-layout (location = 4) in vec2 uv[4];
-layout (location = 8) in float uvLayer;
-layout (location = 9) in float animation;
-layout (location = 10) in vec3 color;
-layout (location = 11) in vec2 light;
+in vec3 pos[4];
+in vec2 uv[4];
+in vec2 light[4];
+in vec3 normal;
+in vec3 color;
+in vec3 layerAnimationAo;
-out VS_OUT {
- vec3 Texture;
- vec3 Color;
-} vs_out;
+out vec3 faceTextureUv;
+out vec3 faceNormal;
+out vec3 faceAddColor;
+out vec2 faceLight;
+out float faceAmbientOcclusion;
-uniform float GlobalTime;
-uniform mat4 projView;
-uniform float DayTime;
-uniform float MinLightLevel;
+layout (std140) uniform Globals {
+ mat4 projView;
+ mat4 proj;
+ mat4 invProj;
+ mat4 view;
+ uvec2 viewportSize;
+ vec4 ssaoKernels[64];
+ float globalTime;
+ float dayTime;
+ float gamma;
+};
void main() {
- gl_Position = projView * vec4(position[gl_VertexID], 1.0f);
- vs_out.Texture = vec3(uv[gl_VertexID], uvLayer);
- vs_out.Texture.y -= (uv[2].y - uv[0].y) * trunc(mod(GlobalTime * 4.0f, animation));
+ gl_Position = projView * vec4(pos[gl_VertexID], 1.0f);
- float faceLight = clamp(light.x / 15.0 + (light.y / 15.0) * DayTime, MinLightLevel, 1.0);
- vs_out.Color = mix(color.rgb * faceLight, vec3(1,1,1) * faceLight, float(color == vec3(0,0,0)));
+ faceTextureUv = vec3(uv[gl_VertexID], layerAnimationAo.r);
+ faceTextureUv.y -= (uv[2].y - uv[0].y) * trunc(mod(globalTime * 4.0f, layerAnimationAo.g));
+
+ faceNormal = (view * vec4(normal, 0.0f)).xyz;
+ faceAddColor = color;
+ faceLight = light[gl_VertexID];
+ faceAmbientOcclusion = layerAnimationAo.b;
}
diff --git a/cwd/assets/altcraft/shaders/vert/fbo.vs b/cwd/assets/altcraft/shaders/vert/fbo.vs
deleted file mode 100644
index e1e8966..0000000
--- a/cwd/assets/altcraft/shaders/vert/fbo.vs
+++ /dev/null
@@ -1,11 +0,0 @@
-#version 330 core
-layout (location = 0) in vec2 Pos;
-layout (location = 1) in vec2 TextureCoords;
-
-out vec2 TexCoords;
-
-void main()
-{
- gl_Position = vec4(Pos.x, Pos.y, 0.0, 1.0);
- TexCoords = TextureCoords;
-} \ No newline at end of file
diff --git a/cwd/assets/altcraft/shaders/vert/quad.vs b/cwd/assets/altcraft/shaders/vert/quad.vs
new file mode 100644
index 0000000..9add76d
--- /dev/null
+++ b/cwd/assets/altcraft/shaders/vert/quad.vs
@@ -0,0 +1,23 @@
+#version 330 core
+
+in vec2 pos;
+in vec2 uvPos;
+
+out vec2 uv;
+
+layout (std140) uniform Globals {
+ mat4 projView;
+ mat4 proj;
+ mat4 invProj;
+ mat4 view;
+ uvec2 viewportSize;
+ vec4 ssaoKernels[64];
+ float globalTime;
+ float dayTime;
+ float gamma;
+};
+
+void main() {
+ gl_Position = vec4(pos.x, pos.y, 0.0, 1.0);
+ uv = uvPos;
+}
diff --git a/cwd/assets/altcraft/shaders/vert/rml.vs b/cwd/assets/altcraft/shaders/vert/rml.vs
index bdd3b71..897f49d 100644
--- a/cwd/assets/altcraft/shaders/vert/rml.vs
+++ b/cwd/assets/altcraft/shaders/vert/rml.vs
@@ -1,22 +1,30 @@
#version 330 core
-uniform uvec2 viewportSize;
-uniform vec2 translation;
-uniform mat4 rotationMat;
+in vec2 pos;
+in uvec4 col;
+in vec2 uvPos;
+
+out vec4 color;
+out vec2 uv;
-layout (location = 0) in vec2 pos;
-layout (location = 1) in uvec4 color;
-layout (location = 2) in vec2 tex_coord;
+uniform vec2 translation;
-out VS_OUT {
- vec4 color;
- vec2 tex_coord;
-} vs_out;
+layout (std140) uniform Globals {
+ mat4 projView;
+ mat4 proj;
+ mat4 invProj;
+ mat4 view;
+ uvec2 viewportSize;
+ vec4 ssaoKernels[64];
+ float globalTime;
+ float dayTime;
+ float gamma;
+};
void main() {
float x = ((pos.x + translation.x) / viewportSize.x) * 2.0f - 1.0f;
float y = ((pos.y + translation.y) / viewportSize.y) * 2.0f - 1.0f;
gl_Position = vec4(x, -y, -1.0f, 1.0f);
- vs_out.color = vec4(float(color.x) / 255.0f, float(color.y) / 255.0f, float(color.z) / 255.0f, float(color.w) / 255.0f);
- vs_out.tex_coord = tex_coord;
+ color = vec4(float(col.x) / 255.0f, float(col.y) / 255.0f, float(col.z) / 255.0f, float(col.w) / 255.0f);
+ uv = uvPos;
}
diff --git a/cwd/assets/altcraft/shaders/vert/sky.vs b/cwd/assets/altcraft/shaders/vert/sky.vs
index 0ab261c..c618852 100644
--- a/cwd/assets/altcraft/shaders/vert/sky.vs
+++ b/cwd/assets/altcraft/shaders/vert/sky.vs
@@ -1,13 +1,24 @@
#version 330 core
-in vec3 position;
+in vec3 pos;
-out vec3 pos;
+out vec3 facePos;
-uniform mat4 projView;
uniform mat4 model;
+layout (std140) uniform Globals {
+ mat4 projView;
+ mat4 proj;
+ mat4 invProj;
+ mat4 view;
+ uvec2 viewportSize;
+ vec4 ssaoKernels[64];
+ float globalTime;
+ float dayTime;
+ float gamma;
+};
+
void main() {
- pos = position;
- gl_Position = projView * model * vec4(position, 1);
+ facePos = pos;
+ gl_Position = projView * model * vec4(pos, 1);
}