Skip to content

Comments

Change u_Color to uint#1475

Closed
VReaperV wants to merge 3 commits intoDaemonEngine:masterfrom
VReaperV:u-color-uint
Closed

Change u_Color to uint#1475
VReaperV wants to merge 3 commits intoDaemonEngine:masterfrom
VReaperV:u-color-uint

Conversation

@VReaperV
Copy link
Contributor

Picked from #1473.

u_Color was a vec4 that was being set from a Color object, which only has 8-bit precision per colour, so using up 4 times more memory than that to transfer it was quite atrocious. Instead, pack it into a uint32_t, then use unpackUnorm4x8() to unpack in the shader.

Also adds a macro for unpacking for hardware that doesn't support GL_ARB_gpu_shader5.

@slipher
Copy link
Member

slipher commented Jan 12, 2025

I'm getting some findings with light styles on my diff testing system. I wasn't sure if the difference is real at first, but then I noticed that the correlation between the brightness of the light fixture and the brightness of the rest of the room is broken. Observe how in this screenshot, the closest fixture is bright but the walls are dark. On master they change together.

unvanquished-metro124

Thanks for splitting up the PR, now there will be a lot less stuff to narrow down.

u_Color was a vec4 that was being set from a Color object, which only has 8-bit precision per colour

This is not true btw. tess.svars.color is floating-point. But I added a log to check for ones outside [0, 1] and didn't find any, so that's apparently not the issue.

@VReaperV
Copy link
Contributor Author

tess.svars.color is floating-point.

Apaprently it is indeed, but all the values that are ever assigned to it are either all 0s, all 1s, an 8-bit precision colour (like pStage->constantColor and backEnd.currentEntity->e.shaderRGBA), or are clamped to [0; 1] range.

@VReaperV
Copy link
Contributor Author

I'm getting some findings with light styles on my diff testing system. I wasn't sure if the difference is real at first, but then I noticed that the correlation between the brightness of the light fixture and the brightness of the rest of the room is broken. Observe how in this screenshot, the closest fixture is bright but the walls are dark. On master they change together.

Interestingly enough, I don't get this issue with a build of #1473 on my end, so I might have messed up the cherry-pick somehow (or fixed this issue later without knowing).

`u_Color` was a vec4 that was being set from a `Color` object, which only has 8-bit precision per colour, so using up 4 times more memory than that to transfer it was quite atrocious. Instead, pack it into a uint32_t, then use `unpackUnorm4x8()` to unpack in the shader.

Also adds a macro for unpacking for hardware that doesn't support `GL_ARB_gpu_shader5`.
@VReaperV
Copy link
Contributor Author

I'm getting some findings with light styles on my diff testing system. I wasn't sure if the difference is real at first, but then I noticed that the correlation between the brightness of the light fixture and the brightness of the rest of the room is broken. Observe how in this screenshot, the closest fixture is bright but the walls are dark. On master they change together.

I don't think I'm getting this issue here:
image

When set to >= 0, the value of this cvar (in milliseconds) will be used for time-based shader effects.
@VReaperV
Copy link
Contributor Author

I've added an r_forceRendererTime cvar to make it easier to test time-based effects.

@slipher
Copy link
Member

slipher commented Jan 12, 2025

The time for my screenshot is 2375.

@slipher
Copy link
Member

slipher commented Jan 12, 2025

The bright light with dark walls can also happen on master with some combination of cvars. Need to track down which ones.

@VReaperV
Copy link
Contributor Author

The time for my screenshot is 2375.

I'm getting this at 2375:
image

Could be some combination of graphics settings...

@VReaperV
Copy link
Contributor Author

I'm getting some findings with light styles on my diff testing system. I wasn't sure if the difference is real at first, but then I noticed that the correlation between the brightness of the light fixture and the brightness of the rest of the room is broken. Observe how in this screenshot, the closest fixture is bright but the walls are dark. On master they change together.

What settings are you using there? I've tried both high and low, the result is the same as on my screenshot.

@slipher
Copy link
Member

slipher commented Jan 12, 2025

The bright light with dark walls can also happen on master with some combination of cvars. Need to track down which ones.

That was r_overbrightDefaultClamp 1. So we should make sure clamping is disabled to clearly see the differences. Turning down your r_gamma would also be a good idea.

In the testing script all renderer settings are default, except some resolution/fullscreen stuff.

Try with r_forceRendererTime 2425, that gives a bigger difference than 2375 and is probably closer to my screenshot. I may have over-corrected for the screenshot lag time. Here's before/after shots with 2425.

unvanquished-metro101

unvanquished-metro101

@VReaperV
Copy link
Contributor Author

Apparently this is because ST_STYLELIGHTMAP and ST_STYLECOLORMAP stages are multiplied by the map light factor.

This is being multiplied by tr.mapLightFactor, which can result in values > 1.0, so use a separate uniform for now, and move this value into color modulate later.
@VReaperV
Copy link
Contributor Author

I've added a fix for this, although I plan to move the value into u_ColorModulateColorGen in #1476 since most bits are unused there, and I wanna keep these 2 PR's separate.

@slipher
Copy link
Member

slipher commented Jan 13, 2025

Merging everything together in #1476 seems better to me, rather than spending any more time reviewing or testing some "temp" stuff.

@VReaperV
Copy link
Contributor Author

Sure, I'll do that.

@VReaperV
Copy link
Contributor Author

Updated version now in #1476.

@VReaperV VReaperV closed this Jan 13, 2025
@VReaperV VReaperV deleted the u-color-uint branch January 17, 2025 01:22
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 T-Performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants