trackbar track-width semantic update + gamma setting trackbar
This commit is contained in:
parent
b1a79e3a6e
commit
8be0d157c2
@ -1,4 +1,4 @@
|
|||||||
function create_setting(id, name, step, track_width, postfix)
|
function create_setting(id, name, step, postfix)
|
||||||
local info = core.get_setting_info(id)
|
local info = core.get_setting_info(id)
|
||||||
if postfix == nil then
|
if postfix == nil then
|
||||||
postfix = ""
|
postfix = ""
|
||||||
@ -10,7 +10,7 @@ function create_setting(id, name, step, track_width, postfix)
|
|||||||
min=info.min,
|
min=info.min,
|
||||||
max=info.max,
|
max=info.max,
|
||||||
step=step,
|
step=step,
|
||||||
track_width=track_width,
|
track_width=12,
|
||||||
postfix=postfix
|
postfix=postfix
|
||||||
}))
|
}))
|
||||||
end
|
end
|
||||||
@ -31,10 +31,11 @@ function create_checkbox(id, name)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function on_open()
|
function on_open()
|
||||||
create_setting("chunks.load-distance", "Load Distance", 1, 3)
|
create_setting("chunks.load-distance", "Load Distance", 1)
|
||||||
create_setting("chunks.load-speed", "Load Speed", 1, 1)
|
create_setting("chunks.load-speed", "Load Speed", 1)
|
||||||
create_setting("graphics.fog-curve", "Fog Curve", 0.1, 2)
|
create_setting("graphics.fog-curve", "Fog Curve", 0.1)
|
||||||
create_setting("camera.fov", "FOV", 1, 4, "°")
|
create_setting("graphics.gamma", "Gamma", 0.05)
|
||||||
|
create_setting("camera.fov", "FOV", 1, "°")
|
||||||
create_checkbox("display.vsync", "V-Sync")
|
create_checkbox("display.vsync", "V-Sync")
|
||||||
create_checkbox("graphics.backlight", "Backlight")
|
create_checkbox("graphics.backlight", "Backlight")
|
||||||
create_checkbox("camera.shaking", "Camera Shaking")
|
create_checkbox("camera.shaking", "Camera Shaking")
|
||||||
|
|||||||
@ -41,6 +41,7 @@ settings.Load Distance=Дистанция Загрузки
|
|||||||
settings.Load Speed=Скорость Загрузки
|
settings.Load Speed=Скорость Загрузки
|
||||||
settings.Fog Curve=Кривая Тумана
|
settings.Fog Curve=Кривая Тумана
|
||||||
settings.Backlight=Подсветка
|
settings.Backlight=Подсветка
|
||||||
|
settings.Gamma=Гамма
|
||||||
settings.V-Sync=Вертикальная Синхронизация
|
settings.V-Sync=Вертикальная Синхронизация
|
||||||
settings.Camera Shaking=Тряска Камеры
|
settings.Camera Shaking=Тряска Камеры
|
||||||
settings.Master Volume=Общая Громкость
|
settings.Master Volume=Общая Громкость
|
||||||
|
|||||||
@ -101,7 +101,7 @@ assetload::postfunc assetload::atlas(
|
|||||||
atlas->prepare();
|
atlas->prepare();
|
||||||
assets->store(atlas, name);
|
assets->store(atlas, name);
|
||||||
|
|
||||||
// FIXME
|
// TODO
|
||||||
for (const auto& file : names) {
|
for (const auto& file : names) {
|
||||||
animation(assets, paths, "textures", file, atlas);
|
animation(assets, paths, "textures", file, atlas);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -28,6 +28,7 @@ SettingsHandler::SettingsHandler(EngineSettings& settings) {
|
|||||||
|
|
||||||
map.emplace("graphics.fog-curve", &settings.graphics.fogCurve);
|
map.emplace("graphics.fog-curve", &settings.graphics.fogCurve);
|
||||||
map.emplace("graphics.backlight", &settings.graphics.backlight);
|
map.emplace("graphics.backlight", &settings.graphics.backlight);
|
||||||
|
map.emplace("graphics.gamma", &settings.graphics.gamma);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<dynamic::Value> SettingsHandler::getValue(const std::string& name) const {
|
std::unique_ptr<dynamic::Value> SettingsHandler::getValue(const std::string& name) const {
|
||||||
@ -128,7 +129,7 @@ toml::Wrapper* create_wrapper(EngineSettings& settings) {
|
|||||||
camera.add("sensitivity", &*settings.camera.sensitivity);
|
camera.add("sensitivity", &*settings.camera.sensitivity);
|
||||||
|
|
||||||
toml::Section& graphics = wrapper->add("graphics");
|
toml::Section& graphics = wrapper->add("graphics");
|
||||||
graphics.add("gamma", &settings.graphics.gamma);
|
graphics.add("gamma", &*settings.graphics.gamma);
|
||||||
graphics.add("fog-curve", &*settings.graphics.fogCurve);
|
graphics.add("fog-curve", &*settings.graphics.fogCurve);
|
||||||
graphics.add("backlight", &*settings.graphics.backlight);
|
graphics.add("backlight", &*settings.graphics.backlight);
|
||||||
graphics.add("frustum-culling", &settings.graphics.frustumCulling);
|
graphics.add("frustum-culling", &settings.graphics.frustumCulling);
|
||||||
|
|||||||
@ -9,6 +9,7 @@
|
|||||||
#include "../../voxels/ChunksStorage.h"
|
#include "../../voxels/ChunksStorage.h"
|
||||||
#include "../../lighting/Lightmap.h"
|
#include "../../lighting/Lightmap.h"
|
||||||
#include "../../frontend/ContentGfxCache.h"
|
#include "../../frontend/ContentGfxCache.h"
|
||||||
|
#include "../../settings.h"
|
||||||
|
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
|
|
||||||
@ -23,7 +24,7 @@ BlocksRenderer::BlocksRenderer(
|
|||||||
size_t capacity,
|
size_t capacity,
|
||||||
const Content* content,
|
const Content* content,
|
||||||
const ContentGfxCache* cache,
|
const ContentGfxCache* cache,
|
||||||
const EngineSettings& settings
|
const EngineSettings* settings
|
||||||
) : content(content),
|
) : content(content),
|
||||||
vertexOffset(0),
|
vertexOffset(0),
|
||||||
indexOffset(0),
|
indexOffset(0),
|
||||||
@ -448,7 +449,7 @@ void BlocksRenderer::render(const voxel* voxels) {
|
|||||||
void BlocksRenderer::build(const Chunk* chunk, const ChunksStorage* chunks) {
|
void BlocksRenderer::build(const Chunk* chunk, const ChunksStorage* chunks) {
|
||||||
this->chunk = chunk;
|
this->chunk = chunk;
|
||||||
voxelsBuffer->setPosition(chunk->x * CHUNK_W - 1, 0, chunk->z * CHUNK_D - 1);
|
voxelsBuffer->setPosition(chunk->x * CHUNK_W - 1, 0, chunk->z * CHUNK_D - 1);
|
||||||
chunks->getVoxels(voxelsBuffer, settings.graphics.backlight.get());
|
chunks->getVoxels(voxelsBuffer, settings->graphics.backlight.get());
|
||||||
overflow = false;
|
overflow = false;
|
||||||
vertexOffset = 0;
|
vertexOffset = 0;
|
||||||
indexOffset = indexSize = 0;
|
indexOffset = indexSize = 0;
|
||||||
|
|||||||
@ -6,7 +6,6 @@
|
|||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
#include "../../voxels/voxel.h"
|
#include "../../voxels/voxel.h"
|
||||||
#include "../../typedefs.h"
|
#include "../../typedefs.h"
|
||||||
#include "../../settings.h"
|
|
||||||
|
|
||||||
class Content;
|
class Content;
|
||||||
class Mesh;
|
class Mesh;
|
||||||
@ -16,6 +15,7 @@ class Chunks;
|
|||||||
class VoxelsVolume;
|
class VoxelsVolume;
|
||||||
class ChunksStorage;
|
class ChunksStorage;
|
||||||
class ContentGfxCache;
|
class ContentGfxCache;
|
||||||
|
struct EngineSettings;
|
||||||
struct UVRegion;
|
struct UVRegion;
|
||||||
|
|
||||||
class BlocksRenderer {
|
class BlocksRenderer {
|
||||||
@ -35,7 +35,7 @@ class BlocksRenderer {
|
|||||||
|
|
||||||
const Block* const* blockDefsCache;
|
const Block* const* blockDefsCache;
|
||||||
const ContentGfxCache* const cache;
|
const ContentGfxCache* const cache;
|
||||||
const EngineSettings& settings;
|
const EngineSettings* settings;
|
||||||
|
|
||||||
void vertex(const glm::vec3& coord, float u, float v, const glm::vec4& light);
|
void vertex(const glm::vec3& coord, float u, float v, const glm::vec4& light);
|
||||||
void index(int a, int b, int c, int d, int e, int f);
|
void index(int a, int b, int c, int d, int e, int f);
|
||||||
@ -90,7 +90,7 @@ class BlocksRenderer {
|
|||||||
glm::vec4 pickSoftLight(float x, float y, float z, const glm::ivec3& right, const glm::ivec3& up) const;
|
glm::vec4 pickSoftLight(float x, float y, float z, const glm::ivec3& right, const glm::ivec3& up) const;
|
||||||
void render(const voxel* voxels);
|
void render(const voxel* voxels);
|
||||||
public:
|
public:
|
||||||
BlocksRenderer(size_t capacity, const Content* content, const ContentGfxCache* cache, const EngineSettings& settings);
|
BlocksRenderer(size_t capacity, const Content* content, const ContentGfxCache* cache, const EngineSettings* settings);
|
||||||
virtual ~BlocksRenderer();
|
virtual ~BlocksRenderer();
|
||||||
|
|
||||||
void build(const Chunk* chunk, const ChunksStorage* chunks);
|
void build(const Chunk* chunk, const ChunksStorage* chunks);
|
||||||
|
|||||||
@ -4,6 +4,7 @@
|
|||||||
#include "../../graphics/core/Mesh.hpp"
|
#include "../../graphics/core/Mesh.hpp"
|
||||||
#include "../../voxels/Chunk.h"
|
#include "../../voxels/Chunk.h"
|
||||||
#include "../../world/Level.h"
|
#include "../../world/Level.h"
|
||||||
|
#include "../../settings.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
@ -20,7 +21,7 @@ public:
|
|||||||
RendererWorker(
|
RendererWorker(
|
||||||
Level* level,
|
Level* level,
|
||||||
const ContentGfxCache* cache,
|
const ContentGfxCache* cache,
|
||||||
const EngineSettings& settings
|
const EngineSettings* settings
|
||||||
) : level(level),
|
) : level(level),
|
||||||
renderer(RENDERER_CAPACITY, level->content, cache, settings)
|
renderer(RENDERER_CAPACITY, level->content, cache, settings)
|
||||||
{}
|
{}
|
||||||
@ -34,7 +35,7 @@ public:
|
|||||||
ChunksRenderer::ChunksRenderer(
|
ChunksRenderer::ChunksRenderer(
|
||||||
Level* level,
|
Level* level,
|
||||||
const ContentGfxCache* cache,
|
const ContentGfxCache* cache,
|
||||||
const EngineSettings& settings
|
const EngineSettings* settings
|
||||||
) : level(level),
|
) : level(level),
|
||||||
threadPool(
|
threadPool(
|
||||||
"chunks-render-pool",
|
"chunks-render-pool",
|
||||||
|
|||||||
@ -10,13 +10,13 @@
|
|||||||
#include "../../voxels/Block.h"
|
#include "../../voxels/Block.h"
|
||||||
#include "../../voxels/ChunksStorage.h"
|
#include "../../voxels/ChunksStorage.h"
|
||||||
#include "../../util/ThreadPool.hpp"
|
#include "../../util/ThreadPool.hpp"
|
||||||
#include "../../settings.h"
|
|
||||||
|
|
||||||
class Mesh;
|
class Mesh;
|
||||||
class Chunk;
|
class Chunk;
|
||||||
class Level;
|
class Level;
|
||||||
class BlocksRenderer;
|
class BlocksRenderer;
|
||||||
class ContentGfxCache;
|
class ContentGfxCache;
|
||||||
|
struct EngineSettings;
|
||||||
|
|
||||||
struct RendererResult {
|
struct RendererResult {
|
||||||
glm::ivec2 key;
|
glm::ivec2 key;
|
||||||
@ -34,7 +34,7 @@ public:
|
|||||||
ChunksRenderer(
|
ChunksRenderer(
|
||||||
Level* level,
|
Level* level,
|
||||||
const ContentGfxCache* cache,
|
const ContentGfxCache* cache,
|
||||||
const EngineSettings& settings
|
const EngineSettings* settings
|
||||||
);
|
);
|
||||||
virtual ~ChunksRenderer();
|
virtual ~ChunksRenderer();
|
||||||
|
|
||||||
|
|||||||
@ -45,7 +45,7 @@ WorldRenderer::WorldRenderer(Engine* engine, LevelFrontend* frontend, Player* pl
|
|||||||
renderer = std::make_unique<ChunksRenderer>(
|
renderer = std::make_unique<ChunksRenderer>(
|
||||||
level,
|
level,
|
||||||
frontend->getContentGfxCache(),
|
frontend->getContentGfxCache(),
|
||||||
engine->getSettings()
|
&engine->getSettings()
|
||||||
);
|
);
|
||||||
batch3d = std::make_unique<Batch3D>(4096);
|
batch3d = std::make_unique<Batch3D>(4096);
|
||||||
|
|
||||||
@ -154,7 +154,7 @@ void WorldRenderer::renderLevel(
|
|||||||
shader->use();
|
shader->use();
|
||||||
shader->uniformMatrix("u_proj", camera->getProjection());
|
shader->uniformMatrix("u_proj", camera->getProjection());
|
||||||
shader->uniformMatrix("u_view", camera->getView());
|
shader->uniformMatrix("u_view", camera->getView());
|
||||||
shader->uniform1f("u_gamma", settings.graphics.gamma);
|
shader->uniform1f("u_gamma", settings.graphics.gamma.get());
|
||||||
shader->uniform1f("u_fogFactor", fogFactor);
|
shader->uniform1f("u_fogFactor", fogFactor);
|
||||||
shader->uniform1f("u_fogCurve", settings.graphics.fogCurve.get());
|
shader->uniform1f("u_fogCurve", settings.graphics.fogCurve.get());
|
||||||
shader->uniform1f("u_dayTime", level->getWorld()->daytime);
|
shader->uniform1f("u_dayTime", level->getWorld()->daytime);
|
||||||
|
|||||||
@ -33,12 +33,11 @@ void TrackBar::draw(const GfxContext* pctx, Assets* assets) {
|
|||||||
batch->setColor(hover ? hoverColor : color);
|
batch->setColor(hover ? hoverColor : color);
|
||||||
batch->rect(pos.x, pos.y, size.x, size.y);
|
batch->rect(pos.x, pos.y, size.x, size.y);
|
||||||
|
|
||||||
float width = size.x;
|
float width = size.x - trackWidth;
|
||||||
float t = (value - min) / (max-min+trackWidth*step);
|
float t = (value - min) / (max-min);
|
||||||
|
|
||||||
batch->setColor(trackColor);
|
batch->setColor(trackColor);
|
||||||
int actualWidth = size.x * (trackWidth / (max-min+trackWidth*step) * step);
|
batch->rect(pos.x + width * t, pos.y, trackWidth, size.y);
|
||||||
batch->rect(pos.x + width * t, pos.y, actualWidth, size.y);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackBar::setSupplier(doublesupplier supplier) {
|
void TrackBar::setSupplier(doublesupplier supplier) {
|
||||||
@ -51,9 +50,9 @@ void TrackBar::setConsumer(doubleconsumer consumer) {
|
|||||||
|
|
||||||
void TrackBar::mouseMove(GUI*, int x, int y) {
|
void TrackBar::mouseMove(GUI*, int x, int y) {
|
||||||
glm::vec2 pos = calcPos();
|
glm::vec2 pos = calcPos();
|
||||||
value = x;
|
value = x - trackWidth/2;
|
||||||
value -= pos.x;
|
value -= pos.x;
|
||||||
value = (value)/size.x * (max-min+trackWidth*step);
|
value = (value)/(size.x-trackWidth) * (max-min);
|
||||||
value += min;
|
value += min;
|
||||||
value = (value > max) ? max : value;
|
value = (value > max) ? max : value;
|
||||||
value = (value < min) ? min : value;
|
value = (value < min) ? min : value;
|
||||||
|
|||||||
@ -60,7 +60,7 @@ struct GraphicsSettings {
|
|||||||
/// @brief Fog opacity is calculated as `pow(depth*k, fogCurve)` where k depends on chunksLoadDistance.
|
/// @brief Fog opacity is calculated as `pow(depth*k, fogCurve)` where k depends on chunksLoadDistance.
|
||||||
/// 1.0 is linear, 2.0 is quadratic
|
/// 1.0 is linear, 2.0 is quadratic
|
||||||
NumberSetting fogCurve {1.6f, 1.0f, 6.0f};
|
NumberSetting fogCurve {1.6f, 1.0f, 6.0f};
|
||||||
float gamma = 1.0f;
|
NumberSetting gamma = {1.0f, 0.5f, 2.0f};
|
||||||
/// @brief Enable blocks backlight to prevent complete darkness
|
/// @brief Enable blocks backlight to prevent complete darkness
|
||||||
FlagSetting backlight = {true};
|
FlagSetting backlight = {true};
|
||||||
/// @brief Enable chunks frustum culling
|
/// @brief Enable chunks frustum culling
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user