From 293e687389a19b369f312c5c335c9afe7c886be1 Mon Sep 17 00:00:00 2001 From: Party Wumpus <48649272+PartyWumpus@users.noreply.github.com> Date: Tue, 16 Jul 2024 21:03:10 +0100 Subject: [PATCH] renderer: Make shader time always count from zero (#6903) * testing out an initialtime variable * Make time universally start at zero instead of exposing an initial time * Appease the CI --- src/render/OpenGL.cpp | 10 ++++++---- src/render/Shader.hpp | 9 +++++---- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/render/OpenGL.cpp b/src/render/OpenGL.cpp index 8229e210..e127ec2d 100644 --- a/src/render/OpenGL.cpp +++ b/src/render/OpenGL.cpp @@ -858,9 +858,11 @@ void CHyprOpenGLImpl::applyScreenShader(const std::string& path) { return; } - m_sFinalScreenShader.proj = glGetUniformLocation(m_sFinalScreenShader.program, "proj"); - m_sFinalScreenShader.tex = glGetUniformLocation(m_sFinalScreenShader.program, "tex"); - m_sFinalScreenShader.time = glGetUniformLocation(m_sFinalScreenShader.program, "time"); + m_sFinalScreenShader.proj = glGetUniformLocation(m_sFinalScreenShader.program, "proj"); + m_sFinalScreenShader.tex = glGetUniformLocation(m_sFinalScreenShader.program, "tex"); + m_sFinalScreenShader.time = glGetUniformLocation(m_sFinalScreenShader.program, "time"); + if (m_sFinalScreenShader.time != -1) + m_sFinalScreenShader.initialTime = m_tGlobalTimer.getSeconds(); m_sFinalScreenShader.wl_output = glGetUniformLocation(m_sFinalScreenShader.program, "wl_output"); m_sFinalScreenShader.fullSize = glGetUniformLocation(m_sFinalScreenShader.program, "screen_size"); if (m_sFinalScreenShader.fullSize == -1) @@ -1155,7 +1157,7 @@ void CHyprOpenGLImpl::renderTextureInternalWithDamage(SP tex, CBox* pB glUniform1i(shader->tex, 0); if ((usingFinalShader && *PDT == 0) || CRASHING) { - glUniform1f(shader->time, m_tGlobalTimer.getSeconds()); + glUniform1f(shader->time, m_tGlobalTimer.getSeconds() - shader->initialTime); } else if (usingFinalShader && shader->time != -1) { // Don't let time be unitialised glUniform1f(shader->time, 0.f); diff --git a/src/render/Shader.hpp b/src/render/Shader.hpp index 185c3dff..d5a312c3 100644 --- a/src/render/Shader.hpp +++ b/src/render/Shader.hpp @@ -42,9 +42,10 @@ class CShader { GLint gradientLength = -1; GLint angle = -1; - GLint time = -1; - GLint distort = -1; - GLint wl_output = -1; + float initialTime = 0; + GLint time = -1; + GLint distort = -1; + GLint wl_output = -1; // Blur prepare GLint contrast = -1; @@ -64,4 +65,4 @@ class CShader { private: std::unordered_map m_muUniforms; -}; \ No newline at end of file +};