-
Notifications
You must be signed in to change notification settings - Fork 62
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
Fix r_forceAmbient comparison #1510
base: master
Are you sure you want to change the base?
Conversation
for the peanut gallery, why was the before comparison wrong? |
|
I meant in the commit message or PR description. |
1eb37cd
to
32c0a87
Compare
Oh, sure, I added it to the commit description. |
Setting it to 0 ought to mean no modification to the light grid. But if I set Before r_forceAmbient changes (with any cvar value as it makes no difference): With this PR and Also I think the light factor handling should be different. IMO it should target the final light value, not the pre-lightfactor-scaling value. With the max value of .3 something even seems to overflow somehow and it is less bright than with 0. |
I've added both of these changes here. |
IIUC the worldspawn |
Not entirely. This seems to be an XreaL feature, and from what I can tell: There might be a slight difference in doing this check on lightGrid points rather than the interpolated value, but I don't think it would make much of a difference. |
Oh right, |
I think that's because it was originally used for entities as well, but the |
61cc149
to
1d3667a
Compare
Anyway, if there are no further concerns with these changes, I'll merge them a bit later. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/engine/renderer/tr_bsp.cpp
Outdated
if ( tr.legacyOverBrightClamping ) | ||
{ | ||
R_ColorShiftLightingBytes( tmpAmbient ); | ||
R_ColorShiftLightingBytes( tmpDirected ); | ||
} | ||
|
||
const byte forceAmbientNormalised = floatToUnorm8( r_forceAmbient.Get() ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The overbright is still not taken into account in non-clamped mode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't that what the multiplication by lightFactor
does in the shader?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we request minimum light of 0.4 then that should be applied as x = max(0.1, x) in the light grid since it will be multiplied later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
0.1 being 0.4 / tr.mapLightFactor
? Or where does it come from?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes that's right
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But beside that, I don't really see where the lightGrid values would be multiplied by anything extra in case of r_forceAmbient
being < the value in the lightGrid. It's just substituting the values after they're normalised to [0; 1] range.
src/engine/renderer/tr_init.cpp
Outdated
Cvar::Range<Cvar::Cvar<float>> r_forceAmbient( "r_forceAmbient", "Minimal light amount in lightGrid", Cvar::NONE, | ||
0.125f, 0.0f, 0.3f ); | ||
Cvar::Range<Cvar::Cvar<float>> r_forceAmbient( "r_forceAmbient", "Minimal light amount in lightGrid; -1 to use map value", Cvar::NONE, | ||
0.125f, -1.0f, 0.3f ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The _color
keyword is used in a lot of extant maps, sometimes with pretty large values. I imagine it must have some meaning for q3map2 which is distinct from this XReal renderer's meaning. Maybe we should remove the _color
worldspawn key (leaving just ambientColor
) so that it doesn't mess up those maps.
Should probably be cheat, that's a big cheat to make models always displayed brightly. Maybe a bigger cheat even than r_gamma since you could make only the targets be bright, rather than everything
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's this in q3map:
https://github.com/id-Software/Quake-III-Arena/blob/dbe4ddb10315479fc00086f08e25d968b4b43c49/q3map/lightv.c#L4941
But I can't find any notion of that being used in the game's code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that's what I'm saying. _color
is intended for the map compiler and interpreting it like that in the renderer seems bad and wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the check for _color
key.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about the cheat comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question... Maybe it should just be restricted to a lower range? The problem is that there are no real gameplay means of lighting up an area (firebomb with dynamic lights doesn't really count).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting idea, maybe this could be an alternative to r_gamma
that degrades the map's aesthetics less.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I was thinking that too.
420a9a8
to
b8b0936
Compare
fb9d9ca
to
05e4367
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still getting altered grid lighting for all the maps I test (nano, plat23 and sokolov). Sokolov has the biggest difference (much brighter). I'm still confused why this is happening... reading the code it looks like there should be no difference as long as ambientColor
and r_forceAmbient
are not set.
src/engine/renderer/tr_init.cpp
Outdated
Cvar::Range<Cvar::Cvar<float>> r_forceAmbient( "r_forceAmbient", "Minimal light amount in lightGrid", Cvar::NONE, | ||
0.125f, 0.0f, 0.3f ); | ||
Cvar::Range<Cvar::Cvar<float>> r_forceAmbient( "r_forceAmbient", "Minimal light amount in lightGrid; -1 to use map value", Cvar::NONE, | ||
0.125f, -1.0f, 0.3f ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about the cheat comment?
779b491
to
3fd76e5
Compare
Any specific viewpos? I checked on Sokolov at spectator spawn after rebasing and fixing |
3fd76e5
to
647e7fb
Compare
How are you going to check at the spectator spawn? There need to be players or buildables to see the light grid changes. I'm seeing the differences on buildables as in the screenshots posted upthread. |
Well, I just built the same buildings in that are on this branch and on 0.55.2. |
(it also affects the first-person weapon) |
If I check out this PR and go to the alien base on Sokolov, it is still a lot brighter. Closer to the second screenshot than the first in #1510 (comment) |
I see. I assumed -1 is supposed to be the default value. So is that an intentional change, to light everything up so it is easier to see for gameplay purposes or something? |
Not really, I just didn't touch the default value. |
If that is not intentional then let's set it to -1 |
Yeah, that makes sense, changed now. |
r_forceAmbient ranges in [0.0; 0.3], while tmpAmbient is in range of [0; 255].
Allow using 0 as an actual value.
Avoid overflow and incorrect results due to the overbright shift. Also fix `r_forceAmbient` affecting lightGrid points inside of walls.
`_color` is used by q3map2 for some internal purposes, so don't use it here.
This cvar used to have no effect after lightGrid code was moved to GLSL, so disable it by default to keep the lighting the same.
1c774bb
to
b12f641
Compare
No description provided.