mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-07 03:51:50 +00:00
add gfx.blockwraps.set_tints
This commit is contained in:
parent
e423c74628
commit
c47432c979
5 changed files with 54 additions and 22 deletions
|
|
@ -68,6 +68,7 @@ void BlockWrapsRenderer::draw(BlockWrapper& wrapper, const Texture* texture) {
|
|||
glm::vec3(1.01f),
|
||||
wrapper.uvRegions,
|
||||
light,
|
||||
wrapper.tints.data(),
|
||||
wrapper.emission,
|
||||
cullingBits
|
||||
);
|
||||
|
|
@ -82,6 +83,7 @@ void BlockWrapsRenderer::draw(BlockWrapper& wrapper, const Texture* texture) {
|
|||
size * glm::vec3(1.01f),
|
||||
wrapper.uvRegions,
|
||||
light,
|
||||
wrapper.tints.data(),
|
||||
wrapper.emission,
|
||||
cullingBits
|
||||
);
|
||||
|
|
@ -152,12 +154,16 @@ void BlockWrapsRenderer::draw(const DrawContext& pctx, const Player& player) {
|
|||
}
|
||||
|
||||
u64id_t BlockWrapsRenderer::add(
|
||||
const glm::ivec3& position, const std::string& texture, float emission
|
||||
const glm::ivec3& position,
|
||||
const std::string& texture,
|
||||
const glm::vec3& tint,
|
||||
float emission
|
||||
) {
|
||||
u64id_t id = nextWrapper++;
|
||||
wrappers[id] = std::make_unique<BlockWrapper>(BlockWrapper {
|
||||
position,
|
||||
{texture, texture, texture, texture, texture, texture},
|
||||
{tint, tint, tint, tint, tint, tint},
|
||||
emission});
|
||||
return id;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,15 +1,16 @@
|
|||
#pragma once
|
||||
|
||||
#include "assets/assets_util.hpp"
|
||||
#include "voxels/Block.hpp"
|
||||
#include "MainBatch.hpp"
|
||||
#include "typedefs.hpp"
|
||||
|
||||
#include <array>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
#include <map>
|
||||
|
||||
#include "assets/assets_util.hpp"
|
||||
#include "voxels/Block.hpp"
|
||||
#include "MainBatch.hpp"
|
||||
#include "typedefs.hpp"
|
||||
#include <glm/vec4.hpp>
|
||||
|
||||
class Assets;
|
||||
class Player;
|
||||
|
|
@ -22,6 +23,7 @@ class DrawContext;
|
|||
struct BlockWrapper {
|
||||
glm::ivec3 position;
|
||||
std::array<std::string, 6> textureFaces {};
|
||||
std::array<glm::vec3, 6> tints {};
|
||||
float emission = 0.0f;
|
||||
|
||||
// --- render cache ---
|
||||
|
|
@ -54,7 +56,10 @@ public:
|
|||
void draw(const DrawContext& ctx, const Player& player);
|
||||
|
||||
u64id_t add(
|
||||
const glm::ivec3& position, const std::string& texture, float emission
|
||||
const glm::ivec3& position,
|
||||
const std::string& texture,
|
||||
const glm::vec3& tint,
|
||||
float emission
|
||||
);
|
||||
|
||||
BlockWrapper* get(u64id_t id) const;
|
||||
|
|
|
|||
|
|
@ -86,7 +86,8 @@ void MainBatch::cube(
|
|||
const glm::vec3& coord,
|
||||
const glm::vec3& size,
|
||||
const UVRegion(&texfaces)[6],
|
||||
const glm::vec4& tint,
|
||||
const glm::vec4& lights,
|
||||
const glm::vec3 tints[],
|
||||
float emission,
|
||||
uint8_t cullingBits
|
||||
) {
|
||||
|
|
@ -98,42 +99,42 @@ void MainBatch::cube(
|
|||
quad(
|
||||
coord + Z * size.z * 0.5f,
|
||||
X, Y, Z, glm::vec2(size.x, size.y),
|
||||
do_tint((1.0f - emission) * 0.8 + emission) * tint,
|
||||
glm::vec3(1.0f), texfaces[5]
|
||||
do_tint((1.0f - emission) * 0.8 + emission) * lights,
|
||||
tints[5], texfaces[5]
|
||||
);
|
||||
if (cullingBits & 0x10)
|
||||
quad(
|
||||
coord - Z * size.z * 0.5f,
|
||||
-X, Y, -Z, glm::vec2(size.x, size.y),
|
||||
do_tint((1.0f - emission) * 0.9 + emission) * tint,
|
||||
glm::vec3(1.0f), texfaces[4]
|
||||
do_tint((1.0f - emission) * 0.9 + emission) * lights,
|
||||
tints[4], texfaces[4]
|
||||
);
|
||||
if (cullingBits & 0x8)
|
||||
quad(
|
||||
coord + Y * size.y * 0.5f,
|
||||
-X, Z, Y, glm::vec2(size.x, size.z),
|
||||
do_tint((1.0f - emission) * 1.0 + emission) * tint,
|
||||
glm::vec3(1.0f), texfaces[3]
|
||||
do_tint((1.0f - emission) * 1.0 + emission) * lights,
|
||||
tints[3], texfaces[3]
|
||||
);
|
||||
if (cullingBits & 0x4)
|
||||
quad(
|
||||
coord - Y * size.y * 0.5f,
|
||||
X, Z, -Y, glm::vec2(size.x, size.z),
|
||||
do_tint((1.0f - emission) * 0.7 + emission) * tint,
|
||||
glm::vec3(1.0f), texfaces[2]
|
||||
do_tint((1.0f - emission) * 0.7 + emission) * lights,
|
||||
tints[2], texfaces[2]
|
||||
);
|
||||
if (cullingBits & 0x2)
|
||||
quad(
|
||||
coord + X * size.x * 0.5f,
|
||||
-Z, Y, X, glm::vec2(size.z, size.y),
|
||||
do_tint((1.0f - emission) * 0.8 + emission) * tint,
|
||||
glm::vec3(1.0f), texfaces[1]
|
||||
do_tint((1.0f - emission) * 0.8 + emission) * lights,
|
||||
tints[1], texfaces[1]
|
||||
);
|
||||
if (cullingBits & 0x1)
|
||||
quad(
|
||||
coord - X * size.x * 0.5f,
|
||||
Z, Y, -X, glm::vec2(size.z, size.y),
|
||||
do_tint((1.0f - emission) * 0.9 + emission) * tint,
|
||||
glm::vec3(1.0f), texfaces[0]
|
||||
do_tint((1.0f - emission) * 0.9 + emission) * lights,
|
||||
tints[0], texfaces[0]
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -151,7 +151,8 @@ public:
|
|||
const glm::vec3& coord,
|
||||
const glm::vec3& size,
|
||||
const UVRegion(&texfaces)[6],
|
||||
const glm::vec4& tint,
|
||||
const glm::vec4& lights,
|
||||
const glm::vec3 tints[],
|
||||
float emission,
|
||||
uint8_t cullingBits = 0xFF
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue