Merged smooth lighting config options.

This commit is contained in:
Quentin Bazin 2020-06-29 14:46:40 +02:00
parent 466c0cff67
commit abbf55fd21
6 changed files with 20 additions and 15 deletions

View File

@ -14,8 +14,7 @@ isCrosshairVisible = true
-- Graphics -- Graphics
renderDistance = 8 renderDistance = 8
isTorchSmoothLightingEnabled = true isSmoothLightingEnabled = true
isSunSmoothLightingEnabled = true
isAmbientOcclusionEnabled = false isAmbientOcclusionEnabled = false
isWireframeModeEnabled = false isWireframeModeEnabled = false
isFullscreenModeEnabled = false isFullscreenModeEnabled = false

View File

@ -45,8 +45,7 @@ bool Config::isCrosshairVisible = true;
// Graphics // Graphics
u16 Config::renderDistance = 8; u16 Config::renderDistance = 8;
bool Config::isTorchSmoothLightingEnabled = true; bool Config::isSmoothLightingEnabled = true;
bool Config::isSunSmoothLightingEnabled = true;
bool Config::isAmbientOcclusionEnabled = false; bool Config::isAmbientOcclusionEnabled = false;
bool Config::isWireframeModeEnabled = false; bool Config::isWireframeModeEnabled = false;
bool Config::isFullscreenModeEnabled = false; bool Config::isFullscreenModeEnabled = false;
@ -81,8 +80,7 @@ void Config::loadConfigFromFile(const char *filename) {
isCrosshairVisible = lua["isCrosshairVisible"].get_or(isCrosshairVisible); isCrosshairVisible = lua["isCrosshairVisible"].get_or(isCrosshairVisible);
renderDistance = lua["renderDistance"].get_or(renderDistance); renderDistance = lua["renderDistance"].get_or(renderDistance);
isTorchSmoothLightingEnabled = lua["isTorchSmoothLightingEnabled"].get_or(isTorchSmoothLightingEnabled); isSmoothLightingEnabled = lua["isSmoothLightingEnabled"].get_or(isSmoothLightingEnabled);
isSunSmoothLightingEnabled = lua["isSunSmoothLightingEnabled"].get_or(isSunSmoothLightingEnabled);
isAmbientOcclusionEnabled = lua["isAmbientOcclusionEnabled"].get_or(isAmbientOcclusionEnabled); isAmbientOcclusionEnabled = lua["isAmbientOcclusionEnabled"].get_or(isAmbientOcclusionEnabled);
isWireframeModeEnabled = lua["isWireframeModeEnabled"].get_or(isWireframeModeEnabled); isWireframeModeEnabled = lua["isWireframeModeEnabled"].get_or(isWireframeModeEnabled);
isFullscreenModeEnabled = lua["isFullscreenModeEnabled"].get_or(isFullscreenModeEnabled); isFullscreenModeEnabled = lua["isFullscreenModeEnabled"].get_or(isFullscreenModeEnabled);
@ -118,8 +116,7 @@ void Config::saveConfigToFile(const char *filename) {
file << "isCrosshairVisible = " << (isCrosshairVisible ? "true" : "false") << std::endl; file << "isCrosshairVisible = " << (isCrosshairVisible ? "true" : "false") << std::endl;
file << std::endl; file << std::endl;
file << "renderDistance = " << renderDistance << std::endl; file << "renderDistance = " << renderDistance << std::endl;
file << "isTorchSmoothLightingEnabled = " << (isTorchSmoothLightingEnabled ? "true" : "false") << std::endl; file << "isSmoothLightingEnabled = " << (isSmoothLightingEnabled ? "true" : "false") << std::endl;
file << "isSunSmoothLightingEnabled = " << (isSunSmoothLightingEnabled ? "true" : "false") << std::endl;
file << "isAmbientOcclusionEnabled = " << (isAmbientOcclusionEnabled ? "true" : "false") << std::endl; file << "isAmbientOcclusionEnabled = " << (isAmbientOcclusionEnabled ? "true" : "false") << std::endl;
file << "isWireframeModeEnabled = " << (isWireframeModeEnabled ? "true" : "false") << std::endl; file << "isWireframeModeEnabled = " << (isWireframeModeEnabled ? "true" : "false") << std::endl;
file << "isFullscreenModeEnabled = " << (isFullscreenModeEnabled ? "true" : "false") << std::endl; file << "isFullscreenModeEnabled = " << (isFullscreenModeEnabled ? "true" : "false") << std::endl;

View File

@ -44,8 +44,7 @@ namespace Config {
// Graphics // Graphics
extern u16 renderDistance; extern u16 renderDistance;
extern bool isTorchSmoothLightingEnabled; extern bool isSmoothLightingEnabled;
extern bool isSunSmoothLightingEnabled;
extern bool isAmbientOcclusionEnabled; extern bool isAmbientOcclusionEnabled;
extern bool isWireframeModeEnabled; extern bool isWireframeModeEnabled;
extern bool isFullscreenModeEnabled; extern bool isFullscreenModeEnabled;

View File

@ -201,9 +201,17 @@ void SettingsMenuState::addGraphicsButtons() {
addToggleButton("Wireframe Mode", Config::isWireframeModeEnabled, false); addToggleButton("Wireframe Mode", Config::isWireframeModeEnabled, false);
addToggleButton("Torch Smooth Lighting", Config::isTorchSmoothLightingEnabled, true); m_menuWidget.addButton(std::string("Smooth Lighting: ") + (Config::isSmoothLightingEnabled ? "ON" : "OFF"), [&] (TextButton &button) {
addToggleButton("Sun Smooth Lighting", Config::isSunSmoothLightingEnabled, true); Config::isSmoothLightingEnabled = !Config::isSmoothLightingEnabled;
addToggleButton("Ambient Occlusion", Config::isAmbientOcclusionEnabled, true); button.setText(std::string("Smooth Lighting: ") + (Config::isSmoothLightingEnabled ? "ON" : "OFF"));
m_aoButton->setEnabled(!Config::isSmoothLightingEnabled);
World::isReloadRequested = true;
});
m_aoButton = &addToggleButton("Ambient Occlusion", Config::isAmbientOcclusionEnabled, true);
m_aoButton->setEnabled(!Config::isSmoothLightingEnabled);
m_menuWidget.addButton("GUI Scale: " + std::to_string(Config::guiScale), [this] (TextButton &button) { m_menuWidget.addButton("GUI Scale: " + std::to_string(Config::guiScale), [this] (TextButton &button) {
Config::guiScale = 1 + (Config::guiScale + 1) % 3; Config::guiScale = 1 + (Config::guiScale + 1) % 3;

View File

@ -82,6 +82,8 @@ class SettingsMenuState : public InterfaceState {
}; };
MenuState m_state = MenuState::Main; MenuState m_state = MenuState::Main;
TextButton *m_aoButton = nullptr;
}; };
#endif // SETTINGSMENUSTATE_HPP_ #endif // SETTINGSMENUSTATE_HPP_

View File

@ -238,13 +238,13 @@ inline void ChunkBuilder::addFace(s8f x, s8f y, s8f z, s8f f, const ClientChunk
vertices[v].texCoord[0] = gk::qlerp(blockTexCoords.x, blockTexCoords.x + blockTexCoords.sizeX, U); vertices[v].texCoord[0] = gk::qlerp(blockTexCoords.x, blockTexCoords.x + blockTexCoords.sizeX, U);
vertices[v].texCoord[1] = gk::qlerp(blockTexCoords.y, blockTexCoords.y + blockTexCoords.sizeY, V); vertices[v].texCoord[1] = gk::qlerp(blockTexCoords.y, blockTexCoords.y + blockTexCoords.sizeY, V);
if (Config::isSunSmoothLightingEnabled && block.drawType() != BlockDrawType::Liquid) if (Config::isSmoothLightingEnabled && block.drawType() != BlockDrawType::Liquid)
vertices[v].lightValue[0] = getLightForVertex(Light::Sun, x, y, z, *neighbourOfs[v], normal, chunk); vertices[v].lightValue[0] = getLightForVertex(Light::Sun, x, y, z, *neighbourOfs[v], normal, chunk);
else else
vertices[v].lightValue[0] = chunk.lightmap().getSunlight(x + normal.x, y + normal.y, z + normal.z); vertices[v].lightValue[0] = chunk.lightmap().getSunlight(x + normal.x, y + normal.y, z + normal.z);
int torchlight = chunk.lightmap().getTorchlight(x, y, z); int torchlight = chunk.lightmap().getTorchlight(x, y, z);
if (Config::isTorchSmoothLightingEnabled && torchlight == 0 && block.drawType() != BlockDrawType::Liquid) if (Config::isSmoothLightingEnabled && torchlight == 0 && block.drawType() != BlockDrawType::Liquid)
vertices[v].lightValue[1] = getLightForVertex(Light::Torch, x, y, z, *neighbourOfs[v], normal, chunk); vertices[v].lightValue[1] = getLightForVertex(Light::Torch, x, y, z, *neighbourOfs[v], normal, chunk);
else else
vertices[v].lightValue[1] = chunk.lightmap().getTorchlight(x + normal.x, y + normal.y, z + normal.z); vertices[v].lightValue[1] = chunk.lightmap().getTorchlight(x + normal.x, y + normal.y, z + normal.z);