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

Use colorModulateColorGen instead of disabling vertex color #1514

Merged
merged 1 commit into from
Jan 29, 2025

Conversation

VReaperV
Copy link
Contributor

@VReaperV VReaperV commented Jan 22, 2025

Originally, vertex color array was disabled if colorGen CGEN_VERTEX or CGEN_ONE_MINUS_VERTEX or alphaGen CGEN_VERTEX or CGEN_ONE_MINUS_VERTEX were used, resulting in the shader receiving the default OpenGL values for the disabled arrays (0.0, 0.0, 0.0, 1.0).

Now it will instead be set via setting a bit in u_ColorModulateColorGen, which allows skipping the vertex format change - changing the vertex format can require doing quite a lot in the driver i. e. being slower. It will also be necessary for the geometry cache.

Also fixed the incorrect lighting with tr.mapOverBrightBits = 3 (#1522).

@VReaperV VReaperV added T-Improvement Improvement for an existing feature A-Renderer labels Jan 22, 2025
@VReaperV VReaperV force-pushed the colormod-vertex branch 4 times, most recently from 9f18b21 to 21ac5dc Compare January 26, 2025 21:56
@VReaperV
Copy link
Contributor Author

I've added a fix for #1522 here, since this pr changes the relevant code anyway.

Originally, vertex color array was disabled if colorGen CGEN_VERTEX or CGEN_ONE_MINUS_VERTEX or alphaGen CGEN_VERTEX or CGEN_ONE_MINUS_VERTEX were used,
resulting in the shader receiving the default OpenGL values for the disabled arrays (0.0, 0.0, 0.0, 1.0).

Now it will instead be set via setting a bit in `u_ColorModulateColorGen`, which allows skipping the vertex format change. It will also be necessary for the geometry cache.

Also fixes incorrect lighting with `tr.mapOverBrightBits = 3`.
@slipher
Copy link
Member

slipher commented Jan 29, 2025

LGTM

/* Originally, this controlled whether the vertex color array was used,
now it does the equivalent by setting the color in the shader in such way as if it was using
the default OpenGL values for the disabled arrays (0.0, 0.0, 0.0, 1.0)
This allows to skip the vertex format change */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that related to "Vertex shader in program 11 is being recompiled based on GL state." warnings?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be. On my end I got this warn for the deformVertexes shader, which does use data taken from attr_Color. Perhaps the driver was optimising all attr_Color and derivative usages out when the attrib was disabled, then had to recompile when it got enabled.

@VReaperV VReaperV merged commit 4166989 into DaemonEngine:master Jan 29, 2025
9 checks passed
@VReaperV VReaperV deleted the colormod-vertex branch January 29, 2025 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Renderer T-Improvement Improvement for an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Lightmaps are broken with r_overbrightDefaultExponent 3
2 participants