Skip to content

Commit

Permalink
Node brightness over time
Browse files Browse the repository at this point in the history
  • Loading branch information
pevernow authored and pevernow committed Sep 11, 2021
1 parent 1334e93 commit 33bd03d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/client/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ void GUImanager::showdebuginfo()
"Yaw:" + std::to_string(*yaw) + " Pitch : " + std::to_string(*pitch);
std::string choose = "PointThing:" + *pointThing;
ImGui::Text("%d draw calls", bgfx::getStats()->numDraw);
ImGui::Text("Time: %d:%d", *time / 60, *time % 60);
ImGui::Text("Time: %02d:%02d", *time / 60, *time % 60);
ImGui::Text(choose.c_str());
ImGui::Text(fps.c_str());

Expand Down
16 changes: 15 additions & 1 deletion src/client/renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,20 @@ bool Renderer::init(

void Renderer::makeDrawCache()
{
// Calc Light Offset by time
double SkyLightOffset = 0;
if (world->time <= 4.5 * 60) { // Before 4.5am
SkyLightOffset = -7;
} else if (world->time > 4.5 * 60 && world->time <= 8 * 60) { // Morning
SkyLightOffset = max(-7 + (world->time - 4.5 * 60) * 0.034, 0.0);
} else if (world->time > 8 * 60 && world->time <= 17 * 60) {
SkyLightOffset = 0;
} else if (world->time > 17 * 60 && world->time <= 19 * 60) {
SkyLightOffset = min(0 - (world->time - 17 * 60) * 0.06, -7.0);
} else if (world->time > 19 * 60) {
SkyLightOffset = -7;
}

int tmSize = typemanager->blockmodel.size();

vector<Block*> renderList;
Expand Down Expand Up @@ -240,7 +254,7 @@ void Renderer::makeDrawCache()
bx::mtxTranslate(mtx, block->x, block->y, block->z);
float* id = (float*)&data[64];
id[0] = block->id - 1;
id[1] = block->sun_light;
id[1] = max(min(block->sun_light + (int)SkyLightOffset, 15), 0);
id[2] = 0;
id[3] = 0;
/*
Expand Down

0 comments on commit 33bd03d

Please sign in to comment.