summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cwd/assets/altcraft/shaders/frag/light.fs30
-rw-r--r--src/Render.cpp16
-rw-r--r--src/Render.hpp1
-rw-r--r--src/RenderConfigs.cpp1
-rw-r--r--src/RenderConfigs.hpp8
5 files changed, 52 insertions, 4 deletions
diff --git a/cwd/assets/altcraft/shaders/frag/light.fs b/cwd/assets/altcraft/shaders/frag/light.fs
index 12ab841..6d05884 100644
--- a/cwd/assets/altcraft/shaders/frag/light.fs
+++ b/cwd/assets/altcraft/shaders/frag/light.fs
@@ -11,18 +11,40 @@ uniform sampler2D light;
uniform sampler2D depthStencil;
uniform float dayTime;
+uniform int renderBuff;
void main() {
vec4 c = texture(color, uv);
vec4 n = texture(normal, uv);
vec4 ac = texture(addColor, uv);
- vec4 an = texture(light, uv);
+ vec4 l = texture(light, uv);
float d = 1.0f - texture(depthStencil, uv).r;
- float faceLight = an.r;
- float skyLight = an.g;
+ float faceLight = l.r;
+ float skyLight = l.g;
float lightLevel = clamp(faceLight + skyLight * dayTime, 0.2f, 1.0f);
vec3 faceColor = mix(ac.rgb * lightLevel, vec3(1,1,1) * lightLevel, float(ac.rgb == vec3(0,0,0)));
- fragColor = vec4(c.rgb * faceColor, 1.0f);
+ vec4 finalColor = vec4(c.rgb * faceColor, 1.0f);
+
+ switch(renderBuff) {
+ case 0:
+ fragColor = finalColor;
+ break;
+ case 1:
+ fragColor = c;
+ break;
+ case 2:
+ fragColor = n;
+ break;
+ case 3:
+ fragColor = ac;
+ break;
+ case 4:
+ fragColor = l;
+ break;
+ case 5:
+ fragColor = vec4(d, d, d, 1.0f);
+ break;
+ }
}
diff --git a/src/Render.cpp b/src/Render.cpp
index 48114b0..148ec27 100644
--- a/src/Render.cpp
+++ b/src/Render.cpp
@@ -335,6 +335,22 @@ void Render::HandleEvents() {
break;
}
+ case SDL_SCANCODE_F9: {
+ if (sdlKeyMods & KMOD_CTRL) {
+ renderBuff = 0;
+ } else if (sdlKeyMods & KMOD_SHIFT) {
+ renderBuff--;
+ if (renderBuff < 0)
+ renderBuff = 0;
+ } else {
+ renderBuff++;
+ if (renderBuff > gbuffer->GetMaxRenderBuffers())
+ renderBuff = 0;
+ }
+ gbuffer->SetRenderBuff(renderBuff);
+ break;
+ }
+
default:
break;
}
diff --git a/src/Render.hpp b/src/Render.hpp
index 379ca66..8bdcd63 100644
--- a/src/Render.hpp
+++ b/src/Render.hpp
@@ -48,6 +48,7 @@ class Render {
Rml::Context* rmlContext;
unsigned short sdlKeyMods = 0;
bool hideRml = false;
+ size_t renderBuff = 0;
void SetMouseCapture(bool IsCaptured);
diff --git a/src/RenderConfigs.cpp b/src/RenderConfigs.cpp
index 86418c2..2867bc6 100644
--- a/src/RenderConfigs.cpp
+++ b/src/RenderConfigs.cpp
@@ -68,6 +68,7 @@ Gbuffer::Gbuffer(size_t geomW, size_t geomH, size_t lightW, size_t lightH) {
lightPPC->AddStaticTexture("light", light);
lightPPC->AddStaticTexture("depthStencil", depthStencil);
lightPPC->AddShaderParameter("dayTime", Gal::Type::Float);
+ lightPPC->AddShaderParameter("renderBuff", Gal::Type::Int32);
lightPPC->SetVertexShader(gal->LoadVertexShader(vertexSource));
lightPPC->SetPixelShader(gal->LoadPixelShader(pixelSource));
diff --git a/src/RenderConfigs.hpp b/src/RenderConfigs.hpp
index 94e96bb..9b535ca 100644
--- a/src/RenderConfigs.hpp
+++ b/src/RenderConfigs.hpp
@@ -41,4 +41,12 @@ public:
void SetDayTime(float dayTime) {
lightPipeline->SetShaderParameter("dayTime", dayTime);
}
+
+ int GetMaxRenderBuffers() {
+ return 5;
+ }
+
+ void SetRenderBuff(int renderBuff) {
+ lightPipeline->SetShaderParameter("renderBuff", renderBuff);
+ }
};