-
Notifications
You must be signed in to change notification settings - Fork 81
Fix the alpha gamma value when rendering legacy diffuse textures and materials #4601
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
base: develop
Are you sure you want to change the base?
Conversation
…materials With the new PBR renderer, the faces using alpha blend with a simple diffuse texture or a Blinn-Phong material are badly rendered (way too opaque), which breaks rendering for an enormous amount of "legacy" (pre-PBR) objects. It has been proposed (1) to introduce a new "alpha gamma" parameter for faces, that would need to be set on legacy contents in order to fix the latter, which would also force to introduce a no-mod permission exception for this parameter alone, so that people owning a legacy no-mod object could still manually edit it to fix its rendering. This proposal is ill-conceived: how can anyone, in their right mind, hope that *every* owner of *every* "legacy" object using alpha blending in SL will bother to edit the said object (supposing they even know they can do it and how to do it) ??? The *proper* solution is to fix the renderer itself, and automatically apply a gamma correction factor to faces *not bearing* a glTF material. This commit implements this fix (which is now part of the Cool VL Viewer and proves that it works very nicely). It implements the same kind of rendering fix (at the shader level) as (2), but instead automatically detects faces rendering with a PBR material, and applies the correction to all faces *not* using such a material. In the event you want to let contents creators use linear alpha channels in objects mixing legacy BP materials and PBR materials (even though I fail to see how a creator would want to do that at all), I suggest you implement an additional flag for faces, that could be set to antagonize this auto-fix (this would let full leeway about the alpha channel scale for newly created contents while not requiring to implement some weird no-mod permission exception since this flag would be set by the creator themselves). In the mean time, this fix solves one of the remaining major issues seen with the PBR renderer. (1) https://feedback.secondlife.com/bug-reports/p/pbr-client-opacity-issue-on-textures-with-alpha-channel-windows (2) secondlife#2668
Unfortunately, the issue, due to how long it's been since we released PBR, is not as a trivial as "just bring back a 10+ year old hack". When you have something in the wild for longer than just a few months, you need to have additional parameters to better support legacy content, and new content that was produced since. If we had that parameter exposed I'd say your fix is maybe 90% of the way there. Unfortunately, we have no such parameter and no good way to automatically set it. So this has a very high likelihood of breaking BP content made since PBR. We can't really accept this until someone on the server can add a parameter to support this work. We ditched the last attempt to add this due to concerns around the previous attempt's permissions bypass for a dedicated alpha gamma parameter. I'll leave this open for the time being - I've been wanting some kind of "legacy alpha blend" param for longtime that we can automatically populate for content made prior to PBR's release that we can at least apply a sane default to (on prior to Firestorm's PBR update for example, off for anything made after, and let people toggle it on mod items). The biggest problem has been trying to make a decision on the specific metric we should use to default that parameter to on or off - as with anything like this, the concern is how much content we're gonna break if we make the wrong decision. |
Well, PBR broke 20+ years of contents. How much does that count when compared to the rare, newer contents, built post-PBR, using legacy materials or simple diffuse textures with linear alpha (Gimp, Photoshop & Co do not even produce those for diffuse textures, so rendering textures coming from them without the alpha-gamma fix is wrong) ? Newer builds use PBR materials, and those are unaffected by this fix... |
So the fun part about all of this from a rendering theory standpoint is our alpha blending was wrong for 20+ years. The blinn-phong alpha blending hack that I added in some time ago was to mitigate breaking content at the time - and likely should have never made it into the codebase in the first place when we made the partial switch to a gamma correct pipeline. As of right now, we already have a ton of chaos over "I like |
This is sadly unreliable: the creation date is set at the prim creation, but what happens if you use an old prim (e.g. a megaprim created in 2006) and then apply a new (PBR-compatible) texture with a linear alpha to it ?...
I still think LL should first and foremost repair the breakages which occurred due to the hasted PBR release (which was, sadly, barely worth an alpha-quality release): the more LL waits, the more "newly induced breakages" will happen... |
Parameterization first. Then we can talk about the specific fields we use to set a sane default for that. |
Just as an update to this: We've been discussing it internally, and this is the parameters we're likely to go with:
I'll provide more info once we've determined a shipping vehicle for this - it's not likely to make it into 2025.07 (the next release), but rather 2025.08 (the release after) |
Thus, only usable on mod-ok objects ?... Or so I understand, since:
A very bad idea, indeed. Glad it is abandoned.
That's good ! FYI, I have been tinkering with my hack these past two days: there is indeed a problem with it and with some textures on alpha faces, as well as with BP materials. The problem is that the legacy materials and diffuse alpha textures should be rendered in a SRGBA buffer, and not converted to the linear space... Trying to compensate just for the gamma is insufficient. I made changes (that will be in the next Cool VL Viewer release), and was about to commit them to this PR:
|
Yeah- so those inconsistencies is why we’re opting for an alpha gamma parameter more generally. The original idea was to have three, and I’m inclined to keep it that way:
There aren’t many great ways to handle this behavior unfortunately- as we started to standardize the pipe with PBR that resulted in a lot of the old hacks becoming fragile. So random boosting and such is expected to try and match legacy behavior- and I expect that it’ll get weirder with stuff like physically based lighting and the like. But we’ll cross that bridge when we get to it. |
Description
With the new PBR renderer, the faces using alpha blend with a simple diffuse texture or a Blinn-Phong material are badly rendered (way too opaque), which breaks rendering for an enormous amount of "legacy" (pre-PBR) objects.
It has been proposed (1) to introduce a new "alpha gamma" parameter for faces, that would need to be set on legacy contents in order to fix the latter, which would also force to introduce a no-mod permission exception for this parameter alone, so that people owning a legacy no-mod object could still manually edit it to fix its rendering.
This proposal is ill-conceived: how can anyone, in their right mind, hope that every owner of every "legacy" object using alpha blending in SL will bother to edit the said object (supposing they even know they can do it and how to do it) ???
The proper solution is to fix the renderer itself, and automatically apply a gamma correction factor to faces not bearing a glTF material.
This commit implements this fix (which is now part of the Cool VL Viewer and proves that it works very nicely). It implements the same kind of rendering fix (at the shader level) as (2), but instead automatically detects faces rendering with a PBR material, and applies the correction to all faces not using such a material.
In the event you want to let contents creators use linear alpha channels in objects mixing legacy BP materials and PBR materials (even though I fail to see how a creator would want to do that at all), I suggest you implement an additional flag for faces, that could be set to antagonize this auto-fix (this would let full leeway about the alpha channel scale for newly created contents while not requiring to implement some weird no-mod permission exception since this flag would be set by the creator themselves).
In the mean time, this fix solves one of the remaining major issues seen with the PBR renderer.
Related Issues
(1) https://feedback.secondlife.com/bug-reports/p/pbr-client-opacity-issue-on-textures-with-alpha-channel-windows
(2) #2668