renderer: implement native sRGB support#1687
Conversation
c914db4 to
ce0a6e3
Compare
|
Hmmm… I don't know where to write the line Edit: Nowhere, it should not be used in our case. |
You only really need to call it once, it's global state and will affect all sRGB framebuffers. |
|
Which framebuffer should be sRGB there? |
ce0a6e3 to
387cac8
Compare
|
As a matter of fact, I have zero confidence this implementation is correct, unlike the GLSL alternative implementation. Said otherway, I know how to implement the whole computation myself in GLSL, but I don't know how to configure OpenGL to let it do the computation by itself without me writing the explicit computation. The GLSL implementation is a math algorithm, the OpenGL implementation is a puzzle. |
387cac8 to
feee7ff
Compare
|
@VReaperV what is expected if I, for example, set upload an image with |
86e853b to
b2f3100
Compare
The question is now likely irrelevant. |
|
It now works with both maps built with and without the But you have to disable the tone mapper when running maps compiled with I don't know anything about the tone mapper so I don't know if something is wrong. Right now the camera post-process GLSL shader doesn't run in linear space because colorgrades were done for the non-linear space. |
8702bec to
b2a9fba
Compare
|
The 2D rendering is done like before, as @slipher suggested:
Actually it makes many things far easier, especially it doesn't require to know how the map should be rendered to render the UI, and it means the UI isn't affected by what's done there. |
|
Wait, why would we even want GL_FRAMEBUFFER_SRGB? I don't think it can do anything useful for us. Apparently it is only useful for converting from colors linear to sRGB at a final stage of rendering, as described here. In principle, this is something we need to do at the point of the I wonder why GL_FRAMEBUFFER_SRGB would have any effect in the current version of the code though. Supposedly you have to create the framebuffer with an SRGB format for it to have an effect but the code does not appear to do that. |
|
What I understood (but maybe I'm wrong), is that once Maybe we also need to set |
|
Also, something I've read (but I may be wrong) is that sRGB variants only exist for 8-bit formats, and some of our framebuffers are 16-bit… I don't know what to do with that information. |
5383610 to
4e28980
Compare
|
I found various people complaining of buggy handling of the framebuffer SRGB stuff. Like Nvidia applies it even when the framebuffer was not created as sRGB, or that Intel doesn't do it at all... another reason not to use it. Some more random considerations:
|
4e28980 to
acceb04
Compare
|
Hmm, comparing a Xonotic map like |
This is what is happening, |
043ac4b to
af3e2f5
Compare
|
So, it looks like everything is now ready. |
2a23a18 to
90d0fe8
Compare
|
So I believe all we had to care about is now taken care. |
|
We need a way to disable rim lighting when the linear pipeline is used. But we don't need to implement that to merge this branch. What we need is to implement this swithc before releasing. |
Well, it's only bad to mix linear pipeline + rim lighting + reflection mapping. |
slipher
left a comment
There was a problem hiding this comment.
I made some comments a couple days ago but apparently they didn't go through.
src/engine/renderer/tr_backend.cpp
Outdated
| if ( ( backEnd.refdef.rdflags & ( RDF_NOWORLDMODEL | RDF_NOBLOOM ) ) | ||
| || !glConfig2.bloom || backEnd.viewParms.portalLevel > 0 ) { | ||
| || !glConfig2.bloom || backEnd.viewParms.portalLevel > 0 | ||
| || !tr.worldLinearizeTexture ) |
There was a problem hiding this comment.
I interpreted that preset disable bloom thing as you saying that it would ruin sRGB-aware maps, lol. Anyway if you think bloom looks fine in the linear space (I haven't tested), just get rid of this part. I like to use it as-is so the software should get out the way and let me choose my own settings.
src/engine/renderer/tr_local.h
Outdated
| enum | ||
| { | ||
| EXP_NONE, | ||
| EXP_NORM = BIT( 0 ), |
There was a problem hiding this comment.
I guess this should be called EXP_CLAMP since that's what it does. It clamps, not normalizes.
6094f74 to
04a09fd
Compare
Now taken care of. |
|
LGTM Some non-blocking comments:
|
|
I believe this sentence in a commit message is outdated: |
04a09fd to
925128b
Compare
Ah yes, now fixed. |
It's probably something similar to blended stuff. Taking care of a migration path for existing assets to the new pipeline would have to be taken care in future efforts. |
|
Many thanks to all who reviewed that in one way or another! ❤️ |





Implement native sRGB support.
Obsoletes #1543:
It includes the commit from #1686:
This is based on an even older branch from 2019 as I initially tested native sRGB support before attempting to implement it in GLSL.
I rebased on current
masterand merged improvements from thesrgb-naivebranch as it implemented more corner cases than this one.It still suffers from the problems I faced in 2019: 2D colors are wrong. I need help on that part.
Status: