-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
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
Restore energy loss in indirect (IBL) specular lighting via multiscattering approximation #15644
Conversation
Sweet. Thanks for this!
We'll see. It depends on the performance ramifications. Your remaining questions are basically rhetorical... If you want to refactor the shader code, that would be fine with me. I find the |
@bhouston @spidersharma03 do these changes look good to you? |
Some perf testing, it looks like this might be slighty slightly less performant than the current implementation, but practically the same. Haven't given too much of an eye to optimization yet. It'd be helpful if someone could check it out on iOS. Test case, 64 objects mostly filling the screen
Mobile Results
Linux Laptop, 800x800
Sounds great, I can take care in a follow up |
FWIW: iPhone 6, Safari: ~48 fps current; ~42 fps proposed. |
iPhone SE, Safari: 33fps before and after. |
Is there any way this could be precalculated into the ibl map, even in an
approximate fashion just to maintain energy?
…On Sat, Jan 26, 2019, 3:54 PM Don McCurdy ***@***.*** wrote:
iPhone SE, Safari: 33fps before and after.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#15644 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAj6_Y5Ow25EnqG9rE62eM14HNvsq4Glks5vHMCcgaJpZM4aT26j>
.
|
Moto G6 (Adreno 506): 6fps before and after |
563c76c
to
6985e72
Compare
Updated PR with Also as a quick double check, this is what the DFG approximation looks like generated in |
Shouldn't |
I'd hardwire it, then, and remove the |
Wasn't sure about the (small) performance delta, and figured this would be the best way for opt in -- happy to remove the flag if should be enabled for all MeshPhysicalMaterials with PMREMs -- which maybe MeshPhysicalMaterial over MeshStandardMaterial is sufficient opt-in for potentially higher cost for more accurate renderings |
I think this should apply to both |
SGTM -- should it continue being a boolean for folks to disable? |
Is there any other reason for that boolean apart from a few extra ms? If not, I would remove the boolean altogether (and avoid complexity). |
@mrdoob that's the only reason, and maybe my lack of confidence with physics 😄 |
4d423e1
to
ec8bb95
Compare
@selfshadow saw your comment right before I force pushed latest changes, so sorry if I blew it away! I did update the coefficient to 1/21 however. Thanks! @mrdoob Removed preserveEnergy property and enable multiscatter for both Standard/Physical if |
src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js
Outdated
Show resolved
Hide resolved
cdafc23
to
feadf90
Compare
multiscattering via Fdez-Agüera's "A Multiple-Scattering Microfacet Model for Real-Time Image-based Lighting".
feadf90
to
4e8486f
Compare
Updated the styling of the glsl strings 👍 |
Thanks! |
Before: After: However, Before: After: Before: After: |
@mrdoob noted, will take a look! |
What exactly are you seeing? I see no visible difference. Maybe I am missing something... I have only seen significant visible difference in real-world examples (that is, non-furnace tests) for rough-metallic surfaces. Maybe @jsantell has seen otherwise... |
If you open both links in different tabs and switch between one and the other you'll see the new version has more light details. |
The difference is extremely subtle. Using www.diffchecker.com/image-diff on |
The only lighting that's changed is an extra specular lobe for metal surfaces so the change is most noticeable on very rough metallic surfaces, where previously the specular light was lost |
Potential fix for the dark fresnel border: #15673 |
@jsantell I think we should note in the migration guide that the rendering of |
@Mugen87 to take a crack at it, "MeshStandardMaterial and MeshPhysicalMaterial now preserve energy for IBL lighting, resulting in brighter, more accurate colors for metallic materials with high roughness values when lit via a map generated by PMREMGenerator." |
Perfect! I've added your suggestion to the guide. |
I guess my eyes can see extremely subtle things at this point 😅 |
Currently, for metal surfaces (MeshPhysicsMaterial, MeshStandardMaterial), as the roughness of the material increases, the surface darkens if lit via IBL+PMREM (possibly #7489?). For fully metal surfaces (conductors), all incoming irradiance should equal outgoing radiance (F0=1) -- like a mirror (metalness=1, roughness=0). Even if the metal is rough (metalness=1, roughness=1), the same amount of energy should be reflected off of the material.
There is the white furnace test, which has a uniformly lit enironment with fully metal, white spheres with varying degrees of roughness. As these surfaces are fully metal, all incoming light must be reflected, and should be indistinguishable from the environment. If the spheres are visible, then some energy is either lost or gained.
Currently, energy is lost as metal surfaces increase in roughness:
BRDFs only account for a single scattering of light -- for rough, metal surfaces, light will bounce around microfacets after the initial scattering before reaching the viewer, which isn't accounted for in BRDF models.
via Filament's beautiful docs
There are several sampling and preprocessing methods that aid in real-time approximation of multiscattering light, but ultimately, I was able to get Fdez-Agüera's method (A Multiple-Scattering Microfacet
Model for Real-Time Image-based Lighting) working well, and used a DFG approximation from Filament instead of a DFG LUT .
Above, on the left is r100, on the right is this branch -- from top to bottom, metal surface with increasing roughness, rough surface with increasing metalness, metal surface with increasing roughness, nonmetal increasing rough surface). Much more energy is retained on rough, metal objects with this change.
Above is the single-scattering specular indirect lighting only (left), only the multiscattering (center), and both (combined). Currently in r100, only the single-scattering is visible.
Perhaps the least exciting image, above is the furnace test with these changes. All incoming light equals the outgoing light, making the spheres invisible.
Now a handful of questions:
defined( USE_ENVMAP ) && defined( ENVMAP_TYPE_CUBE_UV )
, but mostly I'm checking to see if a radiance map exists.