Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make shader time always count from zero #6903

Merged
merged 3 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/render/OpenGL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -1155,7 +1157,7 @@ void CHyprOpenGLImpl::renderTextureInternalWithDamage(SP<CTexture> 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);
Expand Down
9 changes: 5 additions & 4 deletions src/render/Shader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -64,4 +65,4 @@ class CShader {

private:
std::unordered_map<std::string, GLint> m_muUniforms;
};
};
Loading