diff --git a/src/frontend/ContentGfxCache.cpp b/src/frontend/ContentGfxCache.cpp index 3e425510..59fe4caa 100644 --- a/src/frontend/ContentGfxCache.cpp +++ b/src/frontend/ContentGfxCache.cpp @@ -26,4 +26,4 @@ ContentGfxCache::ContentGfxCache(const Content* content, Assets* assets) { } } } -} \ No newline at end of file +} diff --git a/src/frontend/hud.cpp b/src/frontend/hud.cpp index 9c6eac80..5e17ca08 100644 --- a/src/frontend/hud.cpp +++ b/src/frontend/hud.cpp @@ -123,6 +123,16 @@ HudRenderer::HudRenderer(Engine* engine, Level* level, const ContentGfxCache* ca sub->add(box); panel->add(sub); } + { + TrackBar* bar = new TrackBar(0.0f, 1.0f, 1.0f, 0.02f, 2); + bar->supplier([=]() { + return level->skyLightMutliplier; + }); + bar->consumer([=](double val) { + level->skyLightMutliplier = val; + }); + panel->add(bar); + } panel->refresh(); menu->reset(); diff --git a/src/frontend/world_render.cpp b/src/frontend/world_render.cpp index 63545d43..4b3a1544 100644 --- a/src/frontend/world_render.cpp +++ b/src/frontend/world_render.cpp @@ -109,6 +109,8 @@ void WorldRenderer::draw(const GfxContext& pctx, Camera* camera, bool occlusion) const Viewport& viewport = pctx.getViewport(); int displayWidth = viewport.getWidth(); int displayHeight = viewport.getHeight(); + + float skyLightMutliplier = level->skyLightMutliplier; { GfxContext ctx = pctx.sub(); ctx.depthTest(true); @@ -117,6 +119,7 @@ void WorldRenderer::draw(const GfxContext& pctx, Camera* camera, bool occlusion) EngineSettings& settings = engine->getSettings(); vec3 skyColor(0.7f, 0.81f, 1.0f); + skyColor *= skyLightMutliplier; Window::setBgColor(skyColor); Window::clear(); @@ -128,7 +131,7 @@ void WorldRenderer::draw(const GfxContext& pctx, Camera* camera, bool occlusion) shader->uniformMatrix("u_proj", camera->getProjection()); shader->uniformMatrix("u_view", camera->getView()); shader->uniform1f("u_gamma", 1.6f); - shader->uniform3f("u_skyLightColor", 1.1f,1.1f,1.1f); + shader->uniform3f("u_skyLightColor", vec3(1.1f) * skyLightMutliplier); shader->uniform3f("u_fogColor", skyColor); shader->uniform1f("u_fogFactor", fogFactor); shader->uniform1f("u_fogCurve", settings.graphics.fogCurve); diff --git a/src/frontend/world_render.h b/src/frontend/world_render.h index 00391159..53dfc9d3 100644 --- a/src/frontend/world_render.h +++ b/src/frontend/world_render.h @@ -32,7 +32,6 @@ class WorldRenderer { bool drawChunk(size_t index, Camera* camera, Shader* shader, bool occlusion); void drawChunks(Chunks* chunks, Camera* camera, Shader* shader, bool occlusion); public: - WorldRenderer(Engine* engine, Level* level, const ContentGfxCache* cache); ~WorldRenderer(); diff --git a/src/graphics/ImageData.cpp b/src/graphics/ImageData.cpp index bc45df56..fbd56b86 100644 --- a/src/graphics/ImageData.cpp +++ b/src/graphics/ImageData.cpp @@ -68,7 +68,8 @@ void ImageData::flipY() { for (uint x = 0; x < width; x++) { for (uint c = 0; c < size; c++) { ubyte temp = pixels[(y * width + x) * size + c]; - pixels[(y * width + x) * size + c] = pixels[((height-y-1) * width + x) * size + c]; + pixels[(y * width + x) * size + c] = + pixels[((height-y-1) * width + x) * size + c]; pixels[((height-y-1) * width + x) * size + c] = temp; } } @@ -209,8 +210,8 @@ void ImageData::fixAlphaColor() { ubyte* pixels = static_cast(data); // Fixing black transparent pixels for Mip-Mapping - for (int ly = 0; ly < height-1; ly++) { - for (int lx = 0; lx < width-1; lx++) { + for (uint ly = 0; ly < height-1; ly++) { + for (uint lx = 0; lx < width-1; lx++) { if (pixels[((ly) * width + lx) * 4 + 3]) { for (int c = 0; c < 3; c++) { int val = pixels[((ly) + + lx) * 4 + c]; diff --git a/src/world/Level.h b/src/world/Level.h index 084b9cd3..6e3e7cc4 100644 --- a/src/world/Level.h +++ b/src/world/Level.h @@ -31,6 +31,8 @@ public: LevelEvents* events; const EngineSettings& settings; + float skyLightMutliplier = 1.0f; // will be replaced with day-night cycle + Level(World* world, const Content* content, Player* player,