summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cwd/assets/altcraft/scripts/ui.lua1
-rw-r--r--cwd/assets/altcraft/ui/options-styles.rcss2
-rw-r--r--cwd/assets/altcraft/ui/options.rml6
-rw-r--r--src/Render.cpp3
-rw-r--r--src/RendererSectionData.cpp9
-rw-r--r--src/RendererSectionData.hpp2
-rw-r--r--src/RendererWorld.cpp7
-rw-r--r--src/RendererWorld.hpp5
8 files changed, 21 insertions, 14 deletions
diff --git a/cwd/assets/altcraft/scripts/ui.lua b/cwd/assets/altcraft/scripts/ui.lua
index 5973fc4..b8a7329 100644
--- a/cwd/assets/altcraft/scripts/ui.lua
+++ b/cwd/assets/altcraft/scripts/ui.lua
@@ -8,6 +8,7 @@ local options = {
targetFps = 60,
vsync = false,
wireframe = false,
+ smoothlight = false,
ssaoSamples = 0,
ssaoScale = 0.5,
}
diff --git a/cwd/assets/altcraft/ui/options-styles.rcss b/cwd/assets/altcraft/ui/options-styles.rcss
index 4822580..13c20d2 100644
--- a/cwd/assets/altcraft/ui/options-styles.rcss
+++ b/cwd/assets/altcraft/ui/options-styles.rcss
@@ -80,5 +80,5 @@ input.range sliderarrowinc {
width: 45%;
height: 8%;
position: fixed;
- margin: 3% auto auto;
+ margin: 0% auto auto;
}
diff --git a/cwd/assets/altcraft/ui/options.rml b/cwd/assets/altcraft/ui/options.rml
index 7211ef2..4529487 100644
--- a/cwd/assets/altcraft/ui/options.rml
+++ b/cwd/assets/altcraft/ui/options.rml
@@ -62,6 +62,12 @@
</div>
<div class="option">
+ <label>Smooth lighting</label>
+ <input type="checkbox" id="smoothlight" />
+ <span id="smoothlight-val"></span>
+ </div>
+
+ <div class="option">
<label>Ambient occlusion quality</label>
<input type="range" min="0" max="64" step="4" id="ssaoSamples" />
<span id="ssaoSamples-val"></span>
diff --git a/src/Render.cpp b/src/Render.cpp
index 304f25f..fe9dc04 100644
--- a/src/Render.cpp
+++ b/src/Render.cpp
@@ -534,7 +534,7 @@ void Render::InitEvents() {
listener.RegisterHandler("PlayerConnected", [this](const Event&) {
stateString = "Loading terrain...";
- world = std::make_unique<RendererWorld>(fbTarget, Settings::ReadBool("deffered", false));
+ world = std::make_unique<RendererWorld>(fbTarget, Settings::ReadBool("deffered", false), Settings::ReadBool("smoothlight", false));
world->MaxRenderingDistance = Settings::ReadDouble("renderDistance", 2.0f);
PUSH_EVENT("UpdateSectionsRender", 0);
});
@@ -606,6 +606,7 @@ void Render::InitEvents() {
listener.RegisterHandler("SettingsUpdate", [this](const Event& eventData) {
if (world) {
+ world->smoothLighting = Settings::ReadBool("smoothlight", false);
float renderDistance = Settings::ReadDouble("renderDistance", 2.0f);
if (renderDistance != world->MaxRenderingDistance) {
world->MaxRenderingDistance = renderDistance;
diff --git a/src/RendererSectionData.cpp b/src/RendererSectionData.cpp
index b5260f4..761dd14 100644
--- a/src/RendererSectionData.cpp
+++ b/src/RendererSectionData.cpp
@@ -59,7 +59,7 @@ float InterpolateBlockLightness(const BlockLightness& light, const glm::vec3 &po
return (glm::max)(xLight, (glm::max)(yLight, zLight));
}
-void AddFacesByBlockModel(RendererSectionData& data, const BlockFaces& model, const glm::mat4& transform, bool visibility[FaceDirection::none], const Vector &pos, const SectionsData &sections) {
+void AddFacesByBlockModel(RendererSectionData& data, const BlockFaces& model, const glm::mat4& transform, bool visibility[FaceDirection::none], const Vector &pos, const SectionsData &sections, bool smoothLighting) {
glm::vec3 absPos = (sections.data[1][1][1].GetPosition() * 16).glm();
for (const auto& face : model.faces) {
if (face.visibility != FaceDirection::none) {
@@ -100,8 +100,7 @@ void AddFacesByBlockModel(RendererSectionData& data, const BlockFaces& model, co
vertexData.layerAnimationAo.g = face.frames;
vertexData.colors = face.color;
- bool useSmoothLighting = true;
- if (useSmoothLighting) {
+ if (smoothLighting) {
for (size_t i = 0; i < 4; i++) {
glm::vec3 baseLightPos = vertexData.positions[i] - absPos;
glm::vec3 lightPos = baseLightPos + normal * 0.5f;
@@ -188,7 +187,7 @@ std::array<BlockId, 4096> SetBlockIdData(const SectionsData &sections) {
return blockIdData;
}
-RendererSectionData ParseSection(const SectionsData &sections) {
+RendererSectionData ParseSection(const SectionsData &sections, bool smoothLighting) {
OPTICK_EVENT();
RendererSectionData data;
@@ -214,7 +213,7 @@ RendererSectionData ParseSection(const SectionsData &sections) {
transform = glm::translate(baseOffset, vec.glm());
BlockFaces *model = GetInternalBlockModel(block, idModels);
- AddFacesByBlockModel(data, *model, transform, blockVisibility[y * 256 + z * 16 + x], vec, sections);
+ AddFacesByBlockModel(data, *model, transform, blockVisibility[y * 256 + z * 16 + x], vec, sections, smoothLighting);
}
}
}
diff --git a/src/RendererSectionData.hpp b/src/RendererSectionData.hpp
index 9eb99ad..0f9ade6 100644
--- a/src/RendererSectionData.hpp
+++ b/src/RendererSectionData.hpp
@@ -74,4 +74,4 @@ struct RendererSectionData {
bool forced = false;
};
-RendererSectionData ParseSection(const SectionsData &sections); \ No newline at end of file
+RendererSectionData ParseSection(const SectionsData &sections, bool smoothLighting);
diff --git a/src/RendererWorld.cpp b/src/RendererWorld.cpp
index 057cf1e..af177d7 100644
--- a/src/RendererWorld.cpp
+++ b/src/RendererWorld.cpp
@@ -26,7 +26,7 @@ void RendererWorld::WorkerFunction(size_t workerId) {
return;
size_t id = std::get<1>(data);
bool forced = std::get<2>(data);
- parsing[id].renderer = ParseSection(parsing[id].data);
+ parsing[id].renderer = ParseSection(parsing[id].data, smoothLighting);
parsing[id].renderer.forced = forced;
PUSH_EVENT("SectionParsed", id);
});
@@ -153,8 +153,9 @@ void RendererWorld::UpdateAllSections(VectorF playerPos) {
}
}
-RendererWorld::RendererWorld(std::shared_ptr<Gal::Framebuffer> target, bool defferedShading) {
- OPTICK_EVENT();
+RendererWorld::RendererWorld(std::shared_ptr<Gal::Framebuffer> target, bool defferedShading, bool smoothLighting) {
+ OPTICK_EVENT();
+ this->smoothLighting = smoothLighting;
MaxRenderingDistance = 2;
numOfWorkers = _max(1, (signed int) std::thread::hardware_concurrency() - 2);
diff --git a/src/RendererWorld.hpp b/src/RendererWorld.hpp
index 184323d..438c022 100644
--- a/src/RendererWorld.hpp
+++ b/src/RendererWorld.hpp
@@ -55,7 +55,7 @@ class RendererWorld {
std::shared_ptr<Gal::PipelineInstance> skyPipelineInstance;
std::shared_ptr<Gal::Buffer> skyBuffer;
public:
- RendererWorld(std::shared_ptr<Gal::Framebuffer> target, bool defferedShading);
+ RendererWorld(std::shared_ptr<Gal::Framebuffer> target, bool defferedShading, bool smoothLighting);
~RendererWorld();
void Render(float screenRatio);
@@ -63,8 +63,7 @@ public:
double MaxRenderingDistance;
- float shaderDayTime;
-
void Update(double timeToUpdate);
+ bool smoothLighting;
};