summaryrefslogtreecommitdiffstats
path: root/cwd
diff options
context:
space:
mode:
authorLaG1924 <lag1924@gmail.com>2021-11-28 12:16:29 +0100
committerLaG1924 <lag1924@gmail.com>2021-11-28 12:16:29 +0100
commit8286ddda96a5f2925d342d0ce115aa00ae5d94ec (patch)
treeaa46a01fb6230a5c994046c7b4823ae1b35c2c37 /cwd
parentChanged shaders to use SPB (diff)
downloadAltCraft-8286ddda96a5f2925d342d0ce115aa00ae5d94ec.tar
AltCraft-8286ddda96a5f2925d342d0ce115aa00ae5d94ec.tar.gz
AltCraft-8286ddda96a5f2925d342d0ce115aa00ae5d94ec.tar.bz2
AltCraft-8286ddda96a5f2925d342d0ce115aa00ae5d94ec.tar.lz
AltCraft-8286ddda96a5f2925d342d0ce115aa00ae5d94ec.tar.xz
AltCraft-8286ddda96a5f2925d342d0ce115aa00ae5d94ec.tar.zst
AltCraft-8286ddda96a5f2925d342d0ce115aa00ae5d94ec.zip
Diffstat (limited to 'cwd')
-rw-r--r--cwd/assets/altcraft/scripts/ui.lua2
-rw-r--r--cwd/assets/altcraft/shaders/frag/light.fs11
-rw-r--r--cwd/assets/altcraft/shaders/frag/sky.fs14
-rw-r--r--cwd/assets/altcraft/shaders/vert/entity.vs1
-rw-r--r--cwd/assets/altcraft/shaders/vert/face.vs1
-rw-r--r--cwd/assets/altcraft/shaders/vert/fbo.vs1
-rw-r--r--cwd/assets/altcraft/shaders/vert/light.vs1
-rw-r--r--cwd/assets/altcraft/shaders/vert/pp.vs1
-rw-r--r--cwd/assets/altcraft/shaders/vert/rml.vs1
-rw-r--r--cwd/assets/altcraft/shaders/vert/sky.vs1
-rw-r--r--cwd/assets/altcraft/ui/options.rml6
11 files changed, 27 insertions, 13 deletions
diff --git a/cwd/assets/altcraft/scripts/ui.lua b/cwd/assets/altcraft/scripts/ui.lua
index b938737..10791d1 100644
--- a/cwd/assets/altcraft/scripts/ui.lua
+++ b/cwd/assets/altcraft/scripts/ui.lua
@@ -1,5 +1,5 @@
local options = {
- brightness = 0.2,
+ gamma = 2.2,
flight = false,
mouseSensetivity = 0.1,
renderDistance = 2,
diff --git a/cwd/assets/altcraft/shaders/frag/light.fs b/cwd/assets/altcraft/shaders/frag/light.fs
index 07eb3ec..117e0ef 100644
--- a/cwd/assets/altcraft/shaders/frag/light.fs
+++ b/cwd/assets/altcraft/shaders/frag/light.fs
@@ -17,6 +17,7 @@ layout (std140) uniform Globals {
uvec2 viewportSize;
float globalTime;
float dayTime;
+ float gamma;
};
void main() {
@@ -24,15 +25,19 @@ void main() {
vec4 n = texture(normal, uv);
vec4 ac = texture(addColor, uv);
vec4 l = texture(light, uv);
- float d = 1.0f - texture(depthStencil, uv).r;
+ float d = (1.0f - texture(depthStencil, uv).r) * 16.0f;
float faceLight = l.r;
float skyLight = l.g;
- float lightLevel = clamp(faceLight + skyLight * dayTime, 0.2f, 1.0f);
+ float lightLevel = clamp(faceLight + skyLight * dayTime, 0.01f, 1.0f);
+ lightLevel = pow(lightLevel, 3);
+ lightLevel = clamp(lightLevel, 0.005f, 1.0f);
vec3 faceColor = mix(ac.rgb * lightLevel, vec3(1,1,1) * lightLevel, float(ac.rgb == vec3(0,0,0)));
vec4 finalColor = vec4(c.rgb * faceColor, 1.0f);
+ finalColor.rgb = pow(finalColor.rgb, vec3(1.0f / gamma));
+
switch(renderBuff) {
case 0:
fragColor = finalColor;
@@ -50,7 +55,7 @@ void main() {
fragColor = l;
break;
case 5:
- fragColor = vec4(d, d, d, 1.0f);
+ fragColor = vec4(vec3(d), 1.0f);
break;
}
}
diff --git a/cwd/assets/altcraft/shaders/frag/sky.fs b/cwd/assets/altcraft/shaders/frag/sky.fs
index 32b7da0..1e36dd3 100644
--- a/cwd/assets/altcraft/shaders/frag/sky.fs
+++ b/cwd/assets/altcraft/shaders/frag/sky.fs
@@ -1,6 +1,6 @@
#version 330 core
-in vec3 pos;
+in vec3 facePos;
layout (location = 0) out vec4 color;
layout (location = 1) out vec4 normal;
@@ -12,6 +12,7 @@ layout (std140) uniform Globals {
uvec2 viewportSize;
float globalTime;
float dayTime;
+ float gamma;
};
uniform sampler2DArray textureAtlas;
@@ -20,12 +21,14 @@ 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;
@@ -38,7 +41,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));
@@ -46,7 +49,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));
@@ -54,8 +57,7 @@ vec4 Moon() {
}
void main() {
- vec4 starColor = vec4(0.0f, 0.04f, 0.06f, 1.0f);
- color = vec4(mix(starColor, DaySkyColor, dayTime).rgb, 1.0f);
+ 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);
diff --git a/cwd/assets/altcraft/shaders/vert/entity.vs b/cwd/assets/altcraft/shaders/vert/entity.vs
index b2f1db6..4acaa93 100644
--- a/cwd/assets/altcraft/shaders/vert/entity.vs
+++ b/cwd/assets/altcraft/shaders/vert/entity.vs
@@ -9,6 +9,7 @@ layout (std140) uniform Globals {
uvec2 viewportSize;
float globalTime;
float dayTime;
+ float gamma;
};
void main() {
diff --git a/cwd/assets/altcraft/shaders/vert/face.vs b/cwd/assets/altcraft/shaders/vert/face.vs
index 5fb9357..70c24c8 100644
--- a/cwd/assets/altcraft/shaders/vert/face.vs
+++ b/cwd/assets/altcraft/shaders/vert/face.vs
@@ -18,6 +18,7 @@ layout (std140) uniform Globals {
uvec2 viewportSize;
float globalTime;
float dayTime;
+ float gamma;
};
void main() {
diff --git a/cwd/assets/altcraft/shaders/vert/fbo.vs b/cwd/assets/altcraft/shaders/vert/fbo.vs
index e490da5..cfde14e 100644
--- a/cwd/assets/altcraft/shaders/vert/fbo.vs
+++ b/cwd/assets/altcraft/shaders/vert/fbo.vs
@@ -10,6 +10,7 @@ layout (std140) uniform Globals {
uvec2 viewportSize;
float globalTime;
float dayTime;
+ float gamma;
};
void main() {
diff --git a/cwd/assets/altcraft/shaders/vert/light.vs b/cwd/assets/altcraft/shaders/vert/light.vs
index 0033107..4e551f8 100644
--- a/cwd/assets/altcraft/shaders/vert/light.vs
+++ b/cwd/assets/altcraft/shaders/vert/light.vs
@@ -10,6 +10,7 @@ layout (std140) uniform Globals {
uvec2 viewportSize;
float globalTime;
float dayTime;
+ float gamma;
};
void main() {
diff --git a/cwd/assets/altcraft/shaders/vert/pp.vs b/cwd/assets/altcraft/shaders/vert/pp.vs
index 0033107..4e551f8 100644
--- a/cwd/assets/altcraft/shaders/vert/pp.vs
+++ b/cwd/assets/altcraft/shaders/vert/pp.vs
@@ -10,6 +10,7 @@ layout (std140) uniform Globals {
uvec2 viewportSize;
float globalTime;
float dayTime;
+ float gamma;
};
void main() {
diff --git a/cwd/assets/altcraft/shaders/vert/rml.vs b/cwd/assets/altcraft/shaders/vert/rml.vs
index d82308e..ea78825 100644
--- a/cwd/assets/altcraft/shaders/vert/rml.vs
+++ b/cwd/assets/altcraft/shaders/vert/rml.vs
@@ -14,6 +14,7 @@ layout (std140) uniform Globals {
uvec2 viewportSize;
float globalTime;
float dayTime;
+ float gamma;
};
void main() {
diff --git a/cwd/assets/altcraft/shaders/vert/sky.vs b/cwd/assets/altcraft/shaders/vert/sky.vs
index e580843..617caed 100644
--- a/cwd/assets/altcraft/shaders/vert/sky.vs
+++ b/cwd/assets/altcraft/shaders/vert/sky.vs
@@ -11,6 +11,7 @@ layout (std140) uniform Globals {
uvec2 viewportSize;
float globalTime;
float dayTime;
+ float gamma;
};
void main() {
diff --git a/cwd/assets/altcraft/ui/options.rml b/cwd/assets/altcraft/ui/options.rml
index 485dcba..c5758be 100644
--- a/cwd/assets/altcraft/ui/options.rml
+++ b/cwd/assets/altcraft/ui/options.rml
@@ -8,9 +8,9 @@
<body class="body-options">
<form>
<div class="option">
- <label>Brightness</label>
- <input type="range" min="0.0" max="1.0" step="0.01" id="brightness" />
- <span id="brightness-val"></span>
+ <label>Gamma</label>
+ <input type="range" min="1.0" max="3.0" step="0.1" id="gamma" />
+ <span id="gamma-val"></span>
</div>
<div class="option">