summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cwd/shaders/face.fs3
-rw-r--r--src/Render.cpp11
-rw-r--r--src/Render.hpp1
-rw-r--r--src/RendererWorld.cpp6
4 files changed, 18 insertions, 3 deletions
diff --git a/cwd/shaders/face.fs b/cwd/shaders/face.fs
index 62a2d37..4872f06 100644
--- a/cwd/shaders/face.fs
+++ b/cwd/shaders/face.fs
@@ -10,6 +10,7 @@ in VS_OUT {
uniform sampler2DArray textureAtlas;
uniform vec2 windowSize;
uniform float DayTime;
+uniform float MinLightLevel;
vec3 rgb2hsv(vec3 c)
{
@@ -41,7 +42,7 @@ void main() {
float light = fs_in.Light.x / 15.0;
float skyLight = (fs_in.Light.y / 15.0) * DayTime;
- float faceLight = clamp(light + skyLight,0.2,1.0);
+ float faceLight = clamp(light + skyLight,MinLightLevel,1.0);
color = vec4(color.rgb * faceLight, color.a);
gl_FragColor = color;
diff --git a/src/Render.cpp b/src/Render.cpp
index ea3252c..c1f7f2c 100644
--- a/src/Render.cpp
+++ b/src/Render.cpp
@@ -40,6 +40,7 @@ Render::Render(unsigned int windowWidth, unsigned int windowHeight,
fieldVsync = Settings::ReadBool("vsync", false);
fieldWireframe = Settings::ReadBool("wireframe", false);
fieldFlight = Settings::ReadBool("flight", false);
+ fieldBrightness = Settings::ReadDouble("brightness", 0.2f);
//Apply settings
if (fieldSensetivity != sensetivity)
@@ -66,6 +67,7 @@ Render::~Render() {
Settings::WriteBool("vsync", fieldVsync);
Settings::WriteBool("wireframe", fieldWireframe);
Settings::WriteBool("flight", fieldFlight);
+ Settings::WriteDouble("brightness", fieldBrightness);
Settings::Save();
ImGui_ImplSdlGL3_Shutdown();
@@ -561,6 +563,8 @@ void Render::RenderGui() {
ImGui::SliderFloat("Render distance", &fieldDistance, 1.0f, 16.0f);
+ ImGui::SliderFloat("Brightness", &fieldBrightness, 0.0f, 1.0f);
+
ImGui::SliderFloat("Sensetivity", &fieldSensetivity, 0.01f, 1.0f);
ImGui::SliderFloat("Target FPS", &fieldTargetFps, 1.0f, 300.0f);
@@ -570,7 +574,7 @@ void Render::RenderGui() {
ImGui::Checkbox("VSync", &fieldVsync);
ImGui::Checkbox("Creative flight", &fieldFlight);
-
+
if (ImGui::Button("Apply settings")) {
if (fieldDistance != world->MaxRenderingDistance) {
world->MaxRenderingDistance = fieldDistance;
@@ -590,6 +594,8 @@ void Render::RenderGui() {
} else
SDL_GL_SetSwapInterval(0);
+ PUSH_EVENT("SetMinLightLevel", fieldBrightness);
+
}
ImGui::Separator();
@@ -623,7 +629,7 @@ void Render::InitEvents() {
stateString = "Loading terrain...";
world = std::make_unique<RendererWorld>(GlobalState::GetGameState());
world->MaxRenderingDistance = fieldDistance;
- PUSH_EVENT("UpdateSectionsRender", 0);
+ PUSH_EVENT("UpdateSectionsRender", 0);
});
listener.RegisterHandler("RemoveLoadingScreen", [this](const Event&) {
@@ -632,6 +638,7 @@ void Render::InitEvents() {
GlobalState::SetState(State::Playing);
glClearColor(0, 0, 0, 1.0f);
world->GameStatePtr()->player->isFlying = this->fieldFlight;
+ PUSH_EVENT("SetMinLightLevel", fieldBrightness);
});
listener.RegisterHandler("ConnectionFailed", [this](const Event& eventData) {
diff --git a/src/Render.hpp b/src/Render.hpp
index 272e14f..1157ebb 100644
--- a/src/Render.hpp
+++ b/src/Render.hpp
@@ -41,6 +41,7 @@ class Render {
bool fieldWireframe;
bool fieldVsync;
bool fieldFlight;
+ float fieldBrightness;
void SetMouseCapture(bool IsCaptured);
diff --git a/src/RendererWorld.cpp b/src/RendererWorld.cpp
index dcfcc24..2ed2620 100644
--- a/src/RendererWorld.cpp
+++ b/src/RendererWorld.cpp
@@ -243,6 +243,11 @@ RendererWorld::RendererWorld(GameState* ptr) {
sections.erase(it);
});
+ listener->RegisterHandler("SetMinLightLevel", [this](const Event& eventData) {
+ auto value = eventData.get<float>();
+ glUniform1f(glGetUniformLocation(blockShader->Program, "MinLightLevel"), value);
+ });
+
for (int i = 0; i < numOfWorkers; i++)
workers.push_back(std::thread(&RendererWorld::WorkerFunction, this, i));
@@ -421,6 +426,7 @@ void RendererWorld::PrepareRender() {
blockShader = new Shader("./shaders/face.vs", "./shaders/face.fs");
blockShader->Use();
glUniform1i(glGetUniformLocation(blockShader->Program, "textureAtlas"), 0);
+ glUniform1f(glGetUniformLocation(blockShader->Program, "MinLightLevel"), 0.2f);
entityShader = new Shader("./shaders/entity.vs", "./shaders/entity.fs");