Skip to content

Commit

Permalink
add block 'shadeless' property
Browse files Browse the repository at this point in the history
  • Loading branch information
MihailRis committed Jun 15, 2024
1 parent 4d962e8 commit ea53009
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 6 deletions.
1 change: 1 addition & 0 deletions res/content/base/blocks/blue_lamp.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"texture": "blue_lamp",
"emission": [0, 0, 15],
"shadeless": true,
"material": "base:glass"
}
1 change: 1 addition & 0 deletions res/content/base/blocks/green_lamp.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"texture": "green_lamp",
"emission": [0, 15, 0],
"shadeless": true,
"material": "base:glass"
}
5 changes: 3 additions & 2 deletions res/content/base/blocks/lamp.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"texture": "lamp",
"emission": [15, 14, 13]
}
"emission": [15, 14, 13],
"shadeless": true
}
1 change: 1 addition & 0 deletions res/content/base/blocks/lightbulb.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
"rotation": "pipe",
"light-passing": true,
"sky-light-passing": true,
"shadeless": true,
"material": "base:glass"
}
1 change: 1 addition & 0 deletions res/content/base/blocks/red_lamp.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"texture": "red_lamp",
"emission": [15, 0, 0],
"shadeless": true,
"material": "base:glass"
}
1 change: 1 addition & 0 deletions res/content/base/blocks/torch.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"model": "aabb",
"hitbox": [0.4375, 0.0, 0.4375, 0.125, 0.5, 0.125],
"light-passing": true,
"shadeless": true,
"obstacle": false,
"rotation": "pipe"
}
3 changes: 2 additions & 1 deletion src/content/ContentLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,12 @@ void ContentLoader::loadBlock(Block& def, const std::string& name, const fs::pat
root->flag("obstacle", def.obstacle);
root->flag("replaceable", def.replaceable);
root->flag("light-passing", def.lightPassing);
root->flag("sky-light-passing", def.skyLightPassing);
root->flag("shadeless", def.shadeless);
root->flag("breakable", def.breakable);
root->flag("selectable", def.selectable);
root->flag("grounded", def.grounded);
root->flag("hidden", def.hidden);
root->flag("sky-light-passing", def.skyLightPassing);
root->num("draw-group", def.drawGroup);
root->str("picking-item", def.pickingItem);
root->str("script-name", def.scriptName);
Expand Down
6 changes: 3 additions & 3 deletions src/graphics/render/BlocksRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -440,19 +440,19 @@ void BlocksRenderer::render(const voxel* voxels) {
int z = (i / CHUNK_D) % CHUNK_W;
switch (def.model) {
case BlockModel::block:
blockCube(x, y, z, texfaces, &def, vox.state, !def.rt.emissive);
blockCube(x, y, z, texfaces, &def, vox.state, !def.shadeless);
break;
case BlockModel::xsprite: {
blockXSprite(x, y, z, vec3(1.0f),
texfaces[FACE_MX], texfaces[FACE_MZ], 1.0f);
break;
}
case BlockModel::aabb: {
blockAABB(ivec3(x,y,z), texfaces, &def, vox.state.rotation, !def.rt.emissive);
blockAABB(ivec3(x,y,z), texfaces, &def, vox.state.rotation, !def.shadeless);
break;
}
case BlockModel::custom: {
blockCustomModel(ivec3(x, y, z), &def, vox.state.rotation, !def.rt.emissive);
blockCustomModel(ivec3(x, y, z), &def, vox.state.rotation, !def.shadeless);
break;
}
default:
Expand Down
3 changes: 3 additions & 0 deletions src/voxels/Block.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ class Block {

/// @brief Does the block passing top-down sky lights into itself
bool skyLightPassing = false;

/// @brief Does block model have shading
bool shadeless = false;

/// @brief Is the block a physical obstacle
bool obstacle = true;
Expand Down

0 comments on commit ea53009

Please sign in to comment.