trackbar track-width semantic update + gamma setting trackbar
This commit is contained in:
@@ -101,7 +101,7 @@ assetload::postfunc assetload::atlas(
|
||||
atlas->prepare();
|
||||
assets->store(atlas, name);
|
||||
|
||||
// FIXME
|
||||
// TODO
|
||||
for (const auto& file : names) {
|
||||
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.backlight", &settings.graphics.backlight);
|
||||
map.emplace("graphics.gamma", &settings.graphics.gamma);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
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("backlight", &*settings.graphics.backlight);
|
||||
graphics.add("frustum-culling", &settings.graphics.frustumCulling);
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "../../voxels/ChunksStorage.h"
|
||||
#include "../../lighting/Lightmap.h"
|
||||
#include "../../frontend/ContentGfxCache.h"
|
||||
#include "../../settings.h"
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
@@ -23,7 +24,7 @@ BlocksRenderer::BlocksRenderer(
|
||||
size_t capacity,
|
||||
const Content* content,
|
||||
const ContentGfxCache* cache,
|
||||
const EngineSettings& settings
|
||||
const EngineSettings* settings
|
||||
) : content(content),
|
||||
vertexOffset(0),
|
||||
indexOffset(0),
|
||||
@@ -448,7 +449,7 @@ void BlocksRenderer::render(const voxel* voxels) {
|
||||
void BlocksRenderer::build(const Chunk* chunk, const ChunksStorage* chunks) {
|
||||
this->chunk = chunk;
|
||||
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;
|
||||
vertexOffset = 0;
|
||||
indexOffset = indexSize = 0;
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#include <glm/glm.hpp>
|
||||
#include "../../voxels/voxel.h"
|
||||
#include "../../typedefs.h"
|
||||
#include "../../settings.h"
|
||||
|
||||
class Content;
|
||||
class Mesh;
|
||||
@@ -16,6 +15,7 @@ class Chunks;
|
||||
class VoxelsVolume;
|
||||
class ChunksStorage;
|
||||
class ContentGfxCache;
|
||||
struct EngineSettings;
|
||||
struct UVRegion;
|
||||
|
||||
class BlocksRenderer {
|
||||
@@ -35,7 +35,7 @@ class BlocksRenderer {
|
||||
|
||||
const Block* const* blockDefsCache;
|
||||
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 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;
|
||||
void render(const voxel* voxels);
|
||||
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();
|
||||
|
||||
void build(const Chunk* chunk, const ChunksStorage* chunks);
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "../../graphics/core/Mesh.hpp"
|
||||
#include "../../voxels/Chunk.h"
|
||||
#include "../../world/Level.h"
|
||||
#include "../../settings.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <glm/glm.hpp>
|
||||
@@ -20,7 +21,7 @@ public:
|
||||
RendererWorker(
|
||||
Level* level,
|
||||
const ContentGfxCache* cache,
|
||||
const EngineSettings& settings
|
||||
const EngineSettings* settings
|
||||
) : level(level),
|
||||
renderer(RENDERER_CAPACITY, level->content, cache, settings)
|
||||
{}
|
||||
@@ -34,7 +35,7 @@ public:
|
||||
ChunksRenderer::ChunksRenderer(
|
||||
Level* level,
|
||||
const ContentGfxCache* cache,
|
||||
const EngineSettings& settings
|
||||
const EngineSettings* settings
|
||||
) : level(level),
|
||||
threadPool(
|
||||
"chunks-render-pool",
|
||||
|
||||
@@ -10,13 +10,13 @@
|
||||
#include "../../voxels/Block.h"
|
||||
#include "../../voxels/ChunksStorage.h"
|
||||
#include "../../util/ThreadPool.hpp"
|
||||
#include "../../settings.h"
|
||||
|
||||
class Mesh;
|
||||
class Chunk;
|
||||
class Level;
|
||||
class BlocksRenderer;
|
||||
class ContentGfxCache;
|
||||
struct EngineSettings;
|
||||
|
||||
struct RendererResult {
|
||||
glm::ivec2 key;
|
||||
@@ -34,7 +34,7 @@ public:
|
||||
ChunksRenderer(
|
||||
Level* level,
|
||||
const ContentGfxCache* cache,
|
||||
const EngineSettings& settings
|
||||
const EngineSettings* settings
|
||||
);
|
||||
virtual ~ChunksRenderer();
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ WorldRenderer::WorldRenderer(Engine* engine, LevelFrontend* frontend, Player* pl
|
||||
renderer = std::make_unique<ChunksRenderer>(
|
||||
level,
|
||||
frontend->getContentGfxCache(),
|
||||
engine->getSettings()
|
||||
&engine->getSettings()
|
||||
);
|
||||
batch3d = std::make_unique<Batch3D>(4096);
|
||||
|
||||
@@ -154,7 +154,7 @@ void WorldRenderer::renderLevel(
|
||||
shader->use();
|
||||
shader->uniformMatrix("u_proj", camera->getProjection());
|
||||
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_fogCurve", settings.graphics.fogCurve.get());
|
||||
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->rect(pos.x, pos.y, size.x, size.y);
|
||||
|
||||
float width = size.x;
|
||||
float t = (value - min) / (max-min+trackWidth*step);
|
||||
float width = size.x - trackWidth;
|
||||
float t = (value - min) / (max-min);
|
||||
|
||||
batch->setColor(trackColor);
|
||||
int actualWidth = size.x * (trackWidth / (max-min+trackWidth*step) * step);
|
||||
batch->rect(pos.x + width * t, pos.y, actualWidth, size.y);
|
||||
batch->rect(pos.x + width * t, pos.y, trackWidth, size.y);
|
||||
}
|
||||
|
||||
void TrackBar::setSupplier(doublesupplier supplier) {
|
||||
@@ -51,9 +50,9 @@ void TrackBar::setConsumer(doubleconsumer consumer) {
|
||||
|
||||
void TrackBar::mouseMove(GUI*, int x, int y) {
|
||||
glm::vec2 pos = calcPos();
|
||||
value = x;
|
||||
value = x - trackWidth/2;
|
||||
value -= pos.x;
|
||||
value = (value)/size.x * (max-min+trackWidth*step);
|
||||
value = (value)/(size.x-trackWidth) * (max-min);
|
||||
value += min;
|
||||
value = (value > max) ? max : value;
|
||||
value = (value < min) ? min : value;
|
||||
|
||||
+1
-1
@@ -60,7 +60,7 @@ struct GraphicsSettings {
|
||||
/// @brief Fog opacity is calculated as `pow(depth*k, fogCurve)` where k depends on chunksLoadDistance.
|
||||
/// 1.0 is linear, 2.0 is quadratic
|
||||
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
|
||||
FlagSetting backlight = {true};
|
||||
/// @brief Enable chunks frustum culling
|
||||
|
||||
Reference in New Issue
Block a user