fix u_timer behaviour when paused

This commit is contained in:
MihailRis
2024-07-18 13:50:57 +03:00
parent 3549c1f326
commit 2c1adcedbd
3 changed files with 9 additions and 5 deletions
+4 -2
View File
@@ -170,7 +170,7 @@ void WorldRenderer::renderLevel(
shader->use();
shader->uniformMatrix("u_proj", camera->getProjection());
shader->uniformMatrix("u_view", camera->getView());
shader->uniform1f("u_timer", Window::time());
shader->uniform1f("u_timer", timer);
shader->uniform1f("u_gamma", settings.graphics.gamma.get());
shader->uniform1f("u_fogFactor", fogFactor);
shader->uniform1f("u_fogCurve", settings.graphics.fogCurve.get());
@@ -301,8 +301,10 @@ void WorldRenderer::draw(
Camera* camera,
bool hudVisible,
bool pause,
float delta,
PostProcessing* postProcessing
){
timer += delta * !pause;
auto world = level->getWorld();
const Viewport& vp = pctx.getViewport();
camera->aspect = vp.getWidth() / static_cast<float>(vp.getHeight());
@@ -343,7 +345,7 @@ void WorldRenderer::draw(
// Rendering fullscreen quad with
auto screenShader = assets->get<Shader>("screen");
screenShader->use();
screenShader->uniform1f("u_timer", Window::time());
screenShader->uniform1f("u_timer", timer);
screenShader->uniform1f("u_dayTime", level->getWorld()->daytime);
postProcessing->render(pctx, screenShader);
}
+2
View File
@@ -40,6 +40,7 @@ class WorldRenderer {
std::unique_ptr<Skybox> skybox;
std::unique_ptr<Batch3D> batch3d;
std::unique_ptr<ModelBatch> modelBatch;
float timer = 0.0f;
bool drawChunk(size_t index, Camera* camera, Shader* shader, bool culling);
void drawChunks(Chunks* chunks, Camera* camera, Shader* shader);
@@ -73,6 +74,7 @@ public:
Camera* camera,
bool hudVisible,
bool pause,
float delta,
PostProcessing* postProcessing
);
void drawBorders(int sx, int sy, int sz, int ex, int ey, int ez);