Skip to content

Commit

Permalink
client: render: fixed invalid bloom texture mip size calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
SNMetamorph committed Oct 10, 2024
1 parent 97c8674 commit cf5a7d2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
8 changes: 4 additions & 4 deletions client/render/gl_postprocess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -794,13 +794,13 @@ void RenderBloom()
int w = glState.width;
int h = glState.height;
glsl_program_t *shader = RI->currentshader;
const int mipCount = 1 + floor(log2(Q_max(glState.width, glState.height)));
const int mipCount = GL_TextureMipCount(w, h);

// render and blur mips
for (int i = 0; i < mipCount; i++)
for (int i = 0; i < (mipCount - 1); i++)
{
w /= 2;
h /= 2;
w = Q_max(1, w / 2);
h = Q_max(1, h / 2);

pglViewport(0, 0, w, h);
for (int j = 0; j < shader->numUniforms; j++)
Expand Down
9 changes: 5 additions & 4 deletions client/render/gl_rmisc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -810,17 +810,18 @@ void GL_InitTempScreenFBO()
GL_CheckFBOStatus(tr.screen_hdr_fbo);

// generate screen fbo texture mips
const int mipCount = 1 + floor(log2(Q_max(glState.width, glState.height)));
const int mipCount = GL_TextureMipCount(glState.width, glState.height);
const int fboCount = mipCount - 1; // don't take mip 0 into account

if (tr.screen_hdr_fbo_mip)
{
pglDeleteFramebuffers(mipCount, tr.screen_hdr_fbo_mip);
pglDeleteFramebuffers(fboCount, tr.screen_hdr_fbo_mip);
delete[] tr.screen_hdr_fbo_mip;
tr.screen_hdr_fbo_mip = nullptr;
}

tr.screen_hdr_fbo_mip = new uint32_t[mipCount];
for (int i = 0; i < mipCount; i++)
tr.screen_hdr_fbo_mip = new uint32_t[fboCount];
for (int i = 0; i < fboCount; i++)
{
pglGenFramebuffers(1, &tr.screen_hdr_fbo_mip[i]);
pglBindFramebuffer(GL_FRAMEBUFFER_EXT, tr.screen_hdr_fbo_mip[i]);
Expand Down

0 comments on commit cf5a7d2

Please sign in to comment.