Merge branch 'main' into headless-mode
This commit is contained in:
commit
ba0610d857
@ -81,6 +81,13 @@ Turns off block model shading
|
|||||||
|
|
||||||
Determines the presence of the vertex AO effect. Turned-on by default.
|
Determines the presence of the vertex AO effect. Turned-on by default.
|
||||||
|
|
||||||
|
### *culling*
|
||||||
|
|
||||||
|
Face culling mode:
|
||||||
|
- **default** - normal face culling
|
||||||
|
- **optional** - face culling among blocks of the same rendering group can be disabled via the `graphics.dense-render` setting.
|
||||||
|
- **disabled** - face culling among blocks of the same rendering group disabled.
|
||||||
|
|
||||||
## Physics
|
## Physics
|
||||||
|
|
||||||
### *obstacle*
|
### *obstacle*
|
||||||
|
|||||||
@ -82,7 +82,6 @@
|
|||||||
|
|
||||||
При значении `true` блок не препятствует прохождению вертикального луча солнечного света.
|
При значении `true` блок не препятствует прохождению вертикального луча солнечного света.
|
||||||
|
|
||||||
|
|
||||||
### Без освещения - *shadeless*
|
### Без освещения - *shadeless*
|
||||||
|
|
||||||
Выключает освещение на модели блока.
|
Выключает освещение на модели блока.
|
||||||
@ -91,6 +90,13 @@
|
|||||||
|
|
||||||
Определяет наличие эффекта вершинного AO. Включен по-умолчанию.
|
Определяет наличие эффекта вершинного AO. Включен по-умолчанию.
|
||||||
|
|
||||||
|
### Отсечение - *culling*
|
||||||
|
|
||||||
|
Режим отсечения граней:
|
||||||
|
- **default** - обычное отсечение граней
|
||||||
|
- **optional** - отсечение граней среди блоков одной группы отрисовки можно отключить через настройку `graphics.dense-render` (Плотный рендер блоков).
|
||||||
|
- **disabled** - отсечение граней среди блоков одной группы отрисовки отключено.
|
||||||
|
|
||||||
## Физика
|
## Физика
|
||||||
|
|
||||||
### Препятствие - *obstacle*
|
### Препятствие - *obstacle*
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
{
|
{
|
||||||
"texture": "leaves",
|
"texture": "leaves",
|
||||||
"material": "base:grass",
|
"material": "base:grass",
|
||||||
|
"draw-group": 5,
|
||||||
|
"culling": "optional",
|
||||||
"base:durability": 0.7
|
"base:durability": 0.7
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 6.4 KiB After Width: | Height: | Size: 896 B |
BIN
res/content/base/textures/blocks/leaves_opaque.png
Normal file
BIN
res/content/base/textures/blocks/leaves_opaque.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.4 KiB |
@ -41,4 +41,5 @@ function on_open()
|
|||||||
create_setting("graphics.fog-curve", "Fog Curve", 0.1)
|
create_setting("graphics.fog-curve", "Fog Curve", 0.1)
|
||||||
create_setting("graphics.gamma", "Gamma", 0.05, "", "graphics.gamma.tooltip")
|
create_setting("graphics.gamma", "Gamma", 0.05, "", "graphics.gamma.tooltip")
|
||||||
create_checkbox("graphics.backlight", "Backlight", "graphics.backlight.tooltip")
|
create_checkbox("graphics.backlight", "Backlight", "graphics.backlight.tooltip")
|
||||||
|
create_checkbox("graphics.dense-render", "Dense blocks render", "graphics.dense-render.tooltip")
|
||||||
end
|
end
|
||||||
|
|||||||
@ -16,6 +16,7 @@ devtools.traceback=Traceback (most recent call first)
|
|||||||
# Tooltips
|
# Tooltips
|
||||||
graphics.gamma.tooltip=Lighting brightness curve
|
graphics.gamma.tooltip=Lighting brightness curve
|
||||||
graphics.backlight.tooltip=Backlight to prevent total darkness
|
graphics.backlight.tooltip=Backlight to prevent total darkness
|
||||||
|
graphics.dense-render.tooltip=Enables transparency in blocks like leaves
|
||||||
|
|
||||||
# settings
|
# settings
|
||||||
settings.Controls Search Mode=Search by attached button name
|
settings.Controls Search Mode=Search by attached button name
|
||||||
|
|||||||
@ -28,6 +28,7 @@ pack.remove-confirm=Удалить весь поставляемый паком/
|
|||||||
# Подсказки
|
# Подсказки
|
||||||
graphics.gamma.tooltip=Кривая яркости освещения
|
graphics.gamma.tooltip=Кривая яркости освещения
|
||||||
graphics.backlight.tooltip=Подсветка, предотвращающая полную темноту
|
graphics.backlight.tooltip=Подсветка, предотвращающая полную темноту
|
||||||
|
graphics.dense-render.tooltip=Включает прозрачность блоков, таких как листья.
|
||||||
|
|
||||||
# Меню
|
# Меню
|
||||||
menu.Apply=Применить
|
menu.Apply=Применить
|
||||||
@ -67,6 +68,7 @@ world.delete-confirm=Удалить мир безвозвратно?
|
|||||||
# Настройки
|
# Настройки
|
||||||
settings.Ambient=Фон
|
settings.Ambient=Фон
|
||||||
settings.Backlight=Подсветка
|
settings.Backlight=Подсветка
|
||||||
|
settings.Dense blocks render=Плотный рендер блоков
|
||||||
settings.Camera Shaking=Тряска Камеры
|
settings.Camera Shaking=Тряска Камеры
|
||||||
settings.Camera Inertia=Инерция Камеры
|
settings.Camera Inertia=Инерция Камеры
|
||||||
settings.Camera FOV Effects=Эффекты поля зрения
|
settings.Camera FOV Effects=Эффекты поля зрения
|
||||||
|
|||||||
@ -239,10 +239,18 @@ void ContentLoader::loadBlock(
|
|||||||
}
|
}
|
||||||
def.model = *model;
|
def.model = *model;
|
||||||
} else if (!modelTypeName.empty()) {
|
} else if (!modelTypeName.empty()) {
|
||||||
logger.error() << "unknown model " << modelTypeName;
|
logger.error() << "unknown model: " << modelTypeName;
|
||||||
def.model = BlockModel::none;
|
def.model = BlockModel::none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string cullingModeName = to_string(def.culling);
|
||||||
|
root.at("culling").get(cullingModeName);
|
||||||
|
if (auto mode = CullingMode_from(cullingModeName)) {
|
||||||
|
def.culling = *mode;
|
||||||
|
} else {
|
||||||
|
logger.error() << "unknown culling mode: " << cullingModeName;
|
||||||
|
}
|
||||||
|
|
||||||
root.at("material").get(def.material);
|
root.at("material").get(def.material);
|
||||||
|
|
||||||
// rotation profile
|
// rotation profile
|
||||||
|
|||||||
@ -68,6 +68,7 @@ SettingsHandler::SettingsHandler(EngineSettings& settings) {
|
|||||||
builder.section("graphics");
|
builder.section("graphics");
|
||||||
builder.add("fog-curve", &settings.graphics.fogCurve);
|
builder.add("fog-curve", &settings.graphics.fogCurve);
|
||||||
builder.add("backlight", &settings.graphics.backlight);
|
builder.add("backlight", &settings.graphics.backlight);
|
||||||
|
builder.add("dense-render", &settings.graphics.denseRender);
|
||||||
builder.add("gamma", &settings.graphics.gamma);
|
builder.add("gamma", &settings.graphics.gamma);
|
||||||
builder.add("frustum-culling", &settings.graphics.frustumCulling);
|
builder.add("frustum-culling", &settings.graphics.frustumCulling);
|
||||||
builder.add("skybox-resolution", &settings.graphics.skyboxResolution);
|
builder.add("skybox-resolution", &settings.graphics.skyboxResolution);
|
||||||
|
|||||||
@ -6,32 +6,39 @@
|
|||||||
#include "assets/Assets.hpp"
|
#include "assets/Assets.hpp"
|
||||||
#include "content/Content.hpp"
|
#include "content/Content.hpp"
|
||||||
#include "content/ContentPack.hpp"
|
#include "content/ContentPack.hpp"
|
||||||
#include "core_defs.hpp"
|
|
||||||
#include "graphics/core/Atlas.hpp"
|
#include "graphics/core/Atlas.hpp"
|
||||||
#include "maths/UVRegion.hpp"
|
#include "maths/UVRegion.hpp"
|
||||||
#include "voxels/Block.hpp"
|
#include "voxels/Block.hpp"
|
||||||
|
#include "core_defs.hpp"
|
||||||
|
#include "settings.hpp"
|
||||||
|
|
||||||
ContentGfxCache::ContentGfxCache(const Content* content, const Assets& assets)
|
|
||||||
: content(content) {
|
|
||||||
auto indices = content->getIndices();
|
|
||||||
sideregions = std::make_unique<UVRegion[]>(indices->blocks.count() * 6);
|
|
||||||
const auto& atlas = assets.require<Atlas>("blocks");
|
|
||||||
|
|
||||||
const auto& blocks = indices->blocks.getIterable();
|
ContentGfxCache::ContentGfxCache(
|
||||||
for (blockid_t i = 0; i < blocks.size(); i++) {
|
const Content& content,
|
||||||
auto def = blocks[i];
|
const Assets& assets,
|
||||||
|
const GraphicsSettings& settings
|
||||||
|
)
|
||||||
|
: content(content), assets(assets), settings(settings) {
|
||||||
|
refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ContentGfxCache::refresh(const Block& def, const Atlas& atlas) {
|
||||||
for (uint side = 0; side < 6; side++) {
|
for (uint side = 0; side < 6; side++) {
|
||||||
const std::string& tex = def->textureFaces[side];
|
std::string tex = def.textureFaces[side];
|
||||||
|
if (def.culling == CullingMode::OPTIONAL &&
|
||||||
|
!settings.denseRender.get() && atlas.has(tex + "_opaque")) {
|
||||||
|
tex = tex + "_opaque";
|
||||||
|
}
|
||||||
if (atlas.has(tex)) {
|
if (atlas.has(tex)) {
|
||||||
sideregions[i * 6 + side] = atlas.get(tex);
|
sideregions[def.rt.id * 6 + side] = atlas.get(tex);
|
||||||
} else if (atlas.has(TEXTURE_NOTFOUND)) {
|
} else if (atlas.has(TEXTURE_NOTFOUND)) {
|
||||||
sideregions[i * 6 + side] = atlas.get(TEXTURE_NOTFOUND);
|
sideregions[def.rt.id * 6 + side] = atlas.get(TEXTURE_NOTFOUND);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (def->model == BlockModel::custom) {
|
if (def.model == BlockModel::custom) {
|
||||||
auto model = assets.require<model::Model>(def->modelName);
|
auto model = assets.require<model::Model>(def.modelName);
|
||||||
// temporary dirty fix tbh
|
// temporary dirty fix tbh
|
||||||
if (def->modelName.find(':') == std::string::npos) {
|
if (def.modelName.find(':') == std::string::npos) {
|
||||||
for (auto& mesh : model.meshes) {
|
for (auto& mesh : model.meshes) {
|
||||||
size_t pos = mesh.texture.find(':');
|
size_t pos = mesh.texture.find(':');
|
||||||
if (pos == std::string::npos) {
|
if (pos == std::string::npos) {
|
||||||
@ -44,15 +51,26 @@ ContentGfxCache::ContentGfxCache(const Content* content, const Assets& assets)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
models[def->rt.id] = std::move(model);
|
models[def.rt.id] = std::move(model);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ContentGfxCache::refresh() {
|
||||||
|
auto indices = content.getIndices();
|
||||||
|
sideregions = std::make_unique<UVRegion[]>(indices->blocks.count() * 6);
|
||||||
|
const auto& atlas = assets.require<Atlas>("blocks");
|
||||||
|
|
||||||
|
const auto& blocks = indices->blocks.getIterable();
|
||||||
|
for (blockid_t i = 0; i < blocks.size(); i++) {
|
||||||
|
auto def = blocks[i];
|
||||||
|
refresh(*def, atlas);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ContentGfxCache::~ContentGfxCache() = default;
|
ContentGfxCache::~ContentGfxCache() = default;
|
||||||
|
|
||||||
const Content* ContentGfxCache::getContent() const {
|
const Content* ContentGfxCache::getContent() const {
|
||||||
return content;
|
return &content;
|
||||||
}
|
}
|
||||||
|
|
||||||
const model::Model& ContentGfxCache::getModel(blockid_t id) const {
|
const model::Model& ContentGfxCache::getModel(blockid_t id) const {
|
||||||
|
|||||||
@ -10,19 +10,29 @@
|
|||||||
|
|
||||||
class Content;
|
class Content;
|
||||||
class Assets;
|
class Assets;
|
||||||
|
class Atlas;
|
||||||
|
class Block;
|
||||||
struct UVRegion;
|
struct UVRegion;
|
||||||
|
struct GraphicsSettings;
|
||||||
|
|
||||||
namespace model {
|
namespace model {
|
||||||
struct Model;
|
struct Model;
|
||||||
}
|
}
|
||||||
|
|
||||||
class ContentGfxCache {
|
class ContentGfxCache {
|
||||||
const Content* content;
|
const Content& content;
|
||||||
|
const Assets& assets;
|
||||||
|
const GraphicsSettings& settings;
|
||||||
|
|
||||||
// array of block sides uv regions (6 per block)
|
// array of block sides uv regions (6 per block)
|
||||||
std::unique_ptr<UVRegion[]> sideregions;
|
std::unique_ptr<UVRegion[]> sideregions;
|
||||||
std::unordered_map<blockid_t, model::Model> models;
|
std::unordered_map<blockid_t, model::Model> models;
|
||||||
public:
|
public:
|
||||||
ContentGfxCache(const Content* content, const Assets& assets);
|
ContentGfxCache(
|
||||||
|
const Content& content,
|
||||||
|
const Assets& assets,
|
||||||
|
const GraphicsSettings& settings
|
||||||
|
);
|
||||||
~ContentGfxCache();
|
~ContentGfxCache();
|
||||||
|
|
||||||
inline const UVRegion& getRegion(blockid_t id, int side) const {
|
inline const UVRegion& getRegion(blockid_t id, int side) const {
|
||||||
@ -32,4 +42,8 @@ public:
|
|||||||
const model::Model& getModel(blockid_t id) const;
|
const model::Model& getModel(blockid_t id) const;
|
||||||
|
|
||||||
const Content* getContent() const;
|
const Content* getContent() const;
|
||||||
|
|
||||||
|
void refresh(const Block& block, const Atlas& atlas);
|
||||||
|
|
||||||
|
void refresh();
|
||||||
};
|
};
|
||||||
|
|||||||
@ -14,12 +14,17 @@
|
|||||||
#include "world/Level.hpp"
|
#include "world/Level.hpp"
|
||||||
|
|
||||||
LevelFrontend::LevelFrontend(
|
LevelFrontend::LevelFrontend(
|
||||||
Player* currentPlayer, LevelController* controller, Assets& assets
|
Player* currentPlayer,
|
||||||
) : level(*controller->getLevel()),
|
LevelController* controller,
|
||||||
|
Assets& assets,
|
||||||
|
const EngineSettings& settings
|
||||||
|
)
|
||||||
|
: level(*controller->getLevel()),
|
||||||
controller(controller),
|
controller(controller),
|
||||||
assets(assets),
|
assets(assets),
|
||||||
contentCache(std::make_unique<ContentGfxCache>(level.content, assets))
|
contentCache(std::make_unique<ContentGfxCache>(
|
||||||
{
|
*level.content, assets, settings.graphics
|
||||||
|
)) {
|
||||||
assets.store(
|
assets.store(
|
||||||
BlocksPreview::build(
|
BlocksPreview::build(
|
||||||
*contentCache, assets, *level.content->getIndices()
|
*contentCache, assets, *level.content->getIndices()
|
||||||
@ -98,6 +103,10 @@ const Assets& LevelFrontend::getAssets() const {
|
|||||||
return assets;
|
return assets;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ContentGfxCache& LevelFrontend::getContentGfxCache() {
|
||||||
|
return *contentCache;
|
||||||
|
}
|
||||||
|
|
||||||
const ContentGfxCache& LevelFrontend::getContentGfxCache() const {
|
const ContentGfxCache& LevelFrontend::getContentGfxCache() const {
|
||||||
return *contentCache;
|
return *contentCache;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,6 +7,7 @@ class Assets;
|
|||||||
class Player;
|
class Player;
|
||||||
class ContentGfxCache;
|
class ContentGfxCache;
|
||||||
class LevelController;
|
class LevelController;
|
||||||
|
struct EngineSettings;
|
||||||
|
|
||||||
class LevelFrontend {
|
class LevelFrontend {
|
||||||
Level& level;
|
Level& level;
|
||||||
@ -14,12 +15,18 @@ class LevelFrontend {
|
|||||||
const Assets& assets;
|
const Assets& assets;
|
||||||
std::unique_ptr<ContentGfxCache> contentCache;
|
std::unique_ptr<ContentGfxCache> contentCache;
|
||||||
public:
|
public:
|
||||||
LevelFrontend(Player* currentPlayer, LevelController* controller, Assets& assets);
|
LevelFrontend(
|
||||||
|
Player* currentPlayer,
|
||||||
|
LevelController* controller,
|
||||||
|
Assets& assets,
|
||||||
|
const EngineSettings& settings
|
||||||
|
);
|
||||||
~LevelFrontend();
|
~LevelFrontend();
|
||||||
|
|
||||||
Level& getLevel();
|
Level& getLevel();
|
||||||
const Level& getLevel() const;
|
const Level& getLevel() const;
|
||||||
const Assets& getAssets() const;
|
const Assets& getAssets() const;
|
||||||
const ContentGfxCache& getContentGfxCache() const;
|
const ContentGfxCache& getContentGfxCache() const;
|
||||||
|
ContentGfxCache& getContentGfxCache();
|
||||||
LevelController* getController() const;
|
LevelController* getController() const;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -17,6 +17,8 @@
|
|||||||
#include "graphics/render/WorldRenderer.hpp"
|
#include "graphics/render/WorldRenderer.hpp"
|
||||||
#include "graphics/ui/GUI.hpp"
|
#include "graphics/ui/GUI.hpp"
|
||||||
#include "graphics/ui/elements/Menu.hpp"
|
#include "graphics/ui/elements/Menu.hpp"
|
||||||
|
#include "graphics/ui/GUI.hpp"
|
||||||
|
#include "frontend/ContentGfxCache.hpp"
|
||||||
#include "logic/LevelController.hpp"
|
#include "logic/LevelController.hpp"
|
||||||
#include "logic/PlayerController.hpp"
|
#include "logic/PlayerController.hpp"
|
||||||
#include "logic/scripting/scripting.hpp"
|
#include "logic/scripting/scripting.hpp"
|
||||||
@ -55,7 +57,7 @@ LevelScreen::LevelScreen(Engine& engine, std::unique_ptr<Level> levelPtr)
|
|||||||
);
|
);
|
||||||
|
|
||||||
frontend = std::make_unique<LevelFrontend>(
|
frontend = std::make_unique<LevelFrontend>(
|
||||||
player, controller.get(), assets
|
player, controller.get(), assets, settings
|
||||||
);
|
);
|
||||||
worldRenderer = std::make_unique<WorldRenderer>(
|
worldRenderer = std::make_unique<WorldRenderer>(
|
||||||
engine, *frontend, *player
|
engine, *frontend, *player
|
||||||
@ -70,6 +72,11 @@ LevelScreen::LevelScreen(Engine& engine, std::unique_ptr<Level> levelPtr)
|
|||||||
player->chunks->saveAndClear();
|
player->chunks->saveAndClear();
|
||||||
worldRenderer->clear();
|
worldRenderer->clear();
|
||||||
}));
|
}));
|
||||||
|
keepAlive(settings.graphics.denseRender.observe([=](bool) {
|
||||||
|
player->chunks->saveAndClear();
|
||||||
|
worldRenderer->clear();
|
||||||
|
frontend->getContentGfxCache().refresh();
|
||||||
|
}));
|
||||||
keepAlive(settings.camera.fov.observe([=](double value) {
|
keepAlive(settings.camera.fov.observe([=](double value) {
|
||||||
player->fpCamera->setFov(glm::radians(value));
|
player->fpCamera->setFov(glm::radians(value));
|
||||||
}));
|
}));
|
||||||
|
|||||||
@ -8,9 +8,6 @@
|
|||||||
#include "voxels/Chunks.hpp"
|
#include "voxels/Chunks.hpp"
|
||||||
#include "lighting/Lightmap.hpp"
|
#include "lighting/Lightmap.hpp"
|
||||||
#include "frontend/ContentGfxCache.hpp"
|
#include "frontend/ContentGfxCache.hpp"
|
||||||
#include "settings.hpp"
|
|
||||||
|
|
||||||
#include <glm/glm.hpp>
|
|
||||||
|
|
||||||
const glm::vec3 BlocksRenderer::SUN_VECTOR (0.411934f, 0.863868f, -0.279161f);
|
const glm::vec3 BlocksRenderer::SUN_VECTOR (0.411934f, 0.863868f, -0.279161f);
|
||||||
|
|
||||||
@ -342,41 +339,41 @@ void BlocksRenderer::blockCube(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ao) {
|
if (ao) {
|
||||||
if (isOpen(coord + Z, group)) {
|
if (isOpen(coord + Z, block)) {
|
||||||
faceAO(coord, X, Y, Z, texfaces[5], lights);
|
faceAO(coord, X, Y, Z, texfaces[5], lights);
|
||||||
}
|
}
|
||||||
if (isOpen(coord - Z, group)) {
|
if (isOpen(coord - Z, block)) {
|
||||||
faceAO(coord, -X, Y, -Z, texfaces[4], lights);
|
faceAO(coord, -X, Y, -Z, texfaces[4], lights);
|
||||||
}
|
}
|
||||||
if (isOpen(coord + Y, group)) {
|
if (isOpen(coord + Y, block)) {
|
||||||
faceAO(coord, X, -Z, Y, texfaces[3], lights);
|
faceAO(coord, X, -Z, Y, texfaces[3], lights);
|
||||||
}
|
}
|
||||||
if (isOpen(coord - Y, group)) {
|
if (isOpen(coord - Y, block)) {
|
||||||
faceAO(coord, X, Z, -Y, texfaces[2], lights);
|
faceAO(coord, X, Z, -Y, texfaces[2], lights);
|
||||||
}
|
}
|
||||||
if (isOpen(coord + X, group)) {
|
if (isOpen(coord + X, block)) {
|
||||||
faceAO(coord, -Z, Y, X, texfaces[1], lights);
|
faceAO(coord, -Z, Y, X, texfaces[1], lights);
|
||||||
}
|
}
|
||||||
if (isOpen(coord - X, group)) {
|
if (isOpen(coord - X, block)) {
|
||||||
faceAO(coord, Z, Y, -X, texfaces[0], lights);
|
faceAO(coord, Z, Y, -X, texfaces[0], lights);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (isOpen(coord + Z, group)) {
|
if (isOpen(coord + Z, block)) {
|
||||||
face(coord, X, Y, Z, texfaces[5], pickLight(coord + Z), lights);
|
face(coord, X, Y, Z, texfaces[5], pickLight(coord + Z), lights);
|
||||||
}
|
}
|
||||||
if (isOpen(coord - Z, group)) {
|
if (isOpen(coord - Z, block)) {
|
||||||
face(coord, -X, Y, -Z, texfaces[4], pickLight(coord - Z), lights);
|
face(coord, -X, Y, -Z, texfaces[4], pickLight(coord - Z), lights);
|
||||||
}
|
}
|
||||||
if (isOpen(coord + Y, group)) {
|
if (isOpen(coord + Y, block)) {
|
||||||
face(coord, X, -Z, Y, texfaces[3], pickLight(coord + Y), lights);
|
face(coord, X, -Z, Y, texfaces[3], pickLight(coord + Y), lights);
|
||||||
}
|
}
|
||||||
if (isOpen(coord - Y, group)) {
|
if (isOpen(coord - Y, block)) {
|
||||||
face(coord, X, Z, -Y, texfaces[2], pickLight(coord - Y), lights);
|
face(coord, X, Z, -Y, texfaces[2], pickLight(coord - Y), lights);
|
||||||
}
|
}
|
||||||
if (isOpen(coord + X, group)) {
|
if (isOpen(coord + X, block)) {
|
||||||
face(coord, -Z, Y, X, texfaces[1], pickLight(coord + X), lights);
|
face(coord, -Z, Y, X, texfaces[1], pickLight(coord + X), lights);
|
||||||
}
|
}
|
||||||
if (isOpen(coord - X, group)) {
|
if (isOpen(coord - X, block)) {
|
||||||
face(coord, Z, Y, -X, texfaces[0], pickLight(coord - X), lights);
|
face(coord, Z, Y, -X, texfaces[0], pickLight(coord - X), lights);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,6 +13,7 @@
|
|||||||
#include "graphics/core/MeshData.hpp"
|
#include "graphics/core/MeshData.hpp"
|
||||||
#include "maths/util.hpp"
|
#include "maths/util.hpp"
|
||||||
#include "commons.hpp"
|
#include "commons.hpp"
|
||||||
|
#include "settings.hpp"
|
||||||
|
|
||||||
class Content;
|
class Content;
|
||||||
class Mesh;
|
class Mesh;
|
||||||
@ -22,7 +23,6 @@ class Chunks;
|
|||||||
class VoxelsVolume;
|
class VoxelsVolume;
|
||||||
class Chunks;
|
class Chunks;
|
||||||
class ContentGfxCache;
|
class ContentGfxCache;
|
||||||
struct EngineSettings;
|
|
||||||
struct UVRegion;
|
struct UVRegion;
|
||||||
|
|
||||||
class BlocksRenderer {
|
class BlocksRenderer {
|
||||||
@ -118,7 +118,7 @@ class BlocksRenderer {
|
|||||||
bool isOpenForLight(int x, int y, int z) const;
|
bool isOpenForLight(int x, int y, int z) const;
|
||||||
|
|
||||||
// Does block allow to see other blocks sides (is it transparent)
|
// Does block allow to see other blocks sides (is it transparent)
|
||||||
inline bool isOpen(const glm::ivec3& pos, ubyte group) const {
|
inline bool isOpen(const glm::ivec3& pos, const Block& def) const {
|
||||||
auto id = voxelsBuffer->pickBlockId(
|
auto id = voxelsBuffer->pickBlockId(
|
||||||
chunk->x * CHUNK_W + pos.x, pos.y, chunk->z * CHUNK_D + pos.z
|
chunk->x * CHUNK_W + pos.x, pos.y, chunk->z * CHUNK_D + pos.z
|
||||||
);
|
);
|
||||||
@ -126,7 +126,13 @@ class BlocksRenderer {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const auto& block = *blockDefsCache[id];
|
const auto& block = *blockDefsCache[id];
|
||||||
if ((block.drawGroup != group && block.lightPassing) || !block.rt.solid) {
|
if (((block.drawGroup != def.drawGroup) && block.drawGroup) || !block.rt.solid) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if ((def.culling == CullingMode::DISABLED ||
|
||||||
|
(def.culling == CullingMode::OPTIONAL &&
|
||||||
|
settings.graphics.denseRender.get())) &&
|
||||||
|
id == def.rt.id) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return !id;
|
return !id;
|
||||||
|
|||||||
@ -14,7 +14,7 @@ class Chunks;
|
|||||||
class Camera;
|
class Camera;
|
||||||
class Assets;
|
class Assets;
|
||||||
class Player;
|
class Player;
|
||||||
struct Block;
|
class Block;
|
||||||
class Engine;
|
class Engine;
|
||||||
class LevelController;
|
class LevelController;
|
||||||
class WorldRenderer;
|
class WorldRenderer;
|
||||||
|
|||||||
@ -7,7 +7,7 @@
|
|||||||
struct ItemDef;
|
struct ItemDef;
|
||||||
class Assets;
|
class Assets;
|
||||||
class Content;
|
class Content;
|
||||||
struct Block;
|
class Block;
|
||||||
|
|
||||||
class ModelsGenerator {
|
class ModelsGenerator {
|
||||||
public:
|
public:
|
||||||
|
|||||||
@ -63,16 +63,22 @@ struct GraphicsSettings {
|
|||||||
NumberSetting gamma {1.0f, 0.4f, 1.0f};
|
NumberSetting gamma {1.0f, 0.4f, 1.0f};
|
||||||
/// @brief Enable blocks backlight to prevent complete darkness
|
/// @brief Enable blocks backlight to prevent complete darkness
|
||||||
FlagSetting backlight {true};
|
FlagSetting backlight {true};
|
||||||
|
/// @brief Disable culling with 'optional' mode
|
||||||
|
FlagSetting denseRender {true};
|
||||||
/// @brief Enable chunks frustum culling
|
/// @brief Enable chunks frustum culling
|
||||||
FlagSetting frustumCulling {true};
|
FlagSetting frustumCulling {true};
|
||||||
|
/// @brief Skybox texture face resolution
|
||||||
IntegerSetting skyboxResolution {64 + 32, 64, 128};
|
IntegerSetting skyboxResolution {64 + 32, 64, 128};
|
||||||
|
/// @brief Chunk renderer vertices buffer capacity
|
||||||
IntegerSetting chunkMaxVertices {200'000, 0, 4'000'000};
|
IntegerSetting chunkMaxVertices {200'000, 0, 4'000'000};
|
||||||
|
/// @brief Limit of chunk renderers count
|
||||||
IntegerSetting chunkMaxRenderers {6, -4, 32};
|
IntegerSetting chunkMaxRenderers {6, -4, 32};
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DebugSettings {
|
struct DebugSettings {
|
||||||
/// @brief Turns off chunks saving/loading
|
/// @brief Turns off chunks saving/loading
|
||||||
FlagSetting generatorTestMode {false};
|
FlagSetting generatorTestMode {false};
|
||||||
|
/// @brief Write lights cache
|
||||||
FlagSetting doWriteLights {true};
|
FlagSetting doWriteLights {true};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -49,6 +49,30 @@ std::optional<BlockModel> BlockModel_from(std::string_view str) {
|
|||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string to_string(CullingMode mode) {
|
||||||
|
switch (mode) {
|
||||||
|
case CullingMode::DEFAULT:
|
||||||
|
return "default";
|
||||||
|
case CullingMode::OPTIONAL:
|
||||||
|
return "optional";
|
||||||
|
case CullingMode::DISABLED:
|
||||||
|
return "disabled";
|
||||||
|
default:
|
||||||
|
return "unknown";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::optional<CullingMode> CullingMode_from(std::string_view str) {
|
||||||
|
if (str == "default") {
|
||||||
|
return CullingMode::DEFAULT;
|
||||||
|
} else if (str == "optional") {
|
||||||
|
return CullingMode::OPTIONAL;
|
||||||
|
} else if (str == "disabled") {
|
||||||
|
return CullingMode::DISABLED;
|
||||||
|
}
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
CoordSystem::CoordSystem(glm::ivec3 axisX, glm::ivec3 axisY, glm::ivec3 axisZ)
|
CoordSystem::CoordSystem(glm::ivec3 axisX, glm::ivec3 axisY, glm::ivec3 axisZ)
|
||||||
: axisX(axisX), axisY(axisY), axisZ(axisZ) {
|
: axisX(axisX), axisY(axisY), axisZ(axisZ) {
|
||||||
fix = glm::ivec3(0);
|
fix = glm::ivec3(0);
|
||||||
|
|||||||
@ -97,6 +97,15 @@ enum class BlockModel {
|
|||||||
std::string to_string(BlockModel model);
|
std::string to_string(BlockModel model);
|
||||||
std::optional<BlockModel> BlockModel_from(std::string_view str);
|
std::optional<BlockModel> BlockModel_from(std::string_view str);
|
||||||
|
|
||||||
|
enum class CullingMode {
|
||||||
|
DEFAULT,
|
||||||
|
OPTIONAL,
|
||||||
|
DISABLED,
|
||||||
|
};
|
||||||
|
|
||||||
|
std::string to_string(CullingMode mode);
|
||||||
|
std::optional<CullingMode> CullingMode_from(std::string_view str);
|
||||||
|
|
||||||
using BoxModel = AABB;
|
using BoxModel = AABB;
|
||||||
|
|
||||||
/// @brief Common kit of block properties applied to groups of blocks
|
/// @brief Common kit of block properties applied to groups of blocks
|
||||||
@ -142,6 +151,9 @@ public:
|
|||||||
|
|
||||||
std::string modelName = "";
|
std::string modelName = "";
|
||||||
|
|
||||||
|
/// @brief Culling mode
|
||||||
|
CullingMode culling = CullingMode::DEFAULT;
|
||||||
|
|
||||||
/// @brief Does the block passing lights into itself
|
/// @brief Does the block passing lights into itself
|
||||||
bool lightPassing = false;
|
bool lightPassing = false;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user