-
-
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
NodeMaterial: Added energy preservation flag #17163
Conversation
Thanks! |
It does not make sense for a proper PBR model to have energy preservation as an option. At some point I expect the shaders will be corrected or improved and this property will be removed. |
I agree with your thinking, we could leave this option by default and remove this define and property? |
@WestLangley Should we remove the non-ENERGY_PRESERVATION code? |
I create a PR in case of @WestLangley approved the changes. |
I think @jsantell is going to have to be involved in this decision as he was the one who added that code block. |
I think that |
@sunag. So you understand the issue, please do an experiment and make the following change: In #if defined( USE_ENVMAP ) && defined( PHYSICAL ) && ( defined( ENVMAP_TYPE_CUBE_UV ) || defined( ENVMAP_TYPE_CUBE ) )
irradiance += getLightProbeIndirectIrradiance( /*lightProbe,*/ geometry, maxMipLevel );
#endif
If your browser implements seamless mipmapping, it should look pretty good; if not, it will look terrible. Since seamless mipmapping was not supported, the irradiance term was removed. Maybe we can add it back now for the non-PMREM use case.
|
Did I remember correctly that seamless mipmapping is something WebGL2 supported? |
@mrdoob I think that @WestLangley is referring at extension |
On my mac mips do appear to be seamless. Maybe @sunag is right and it is the extension... |
@WestLangley if your mips example is related with the availability of #if defined( USE_ENVMAP ) && defined( PHYSICAL ) && ( defined( ENVMAP_TYPE_CUBE_UV ) ||
( defined( ENVMAP_TYPE_CUBE ) && defined( TEXTURE_LOD_EXT ) ) )
irradiance += getLightProbeIndirectIrradiance( /*lightProbe,*/ geometry, maxMipLevel );
#endif |
Energy preservation as an option makes sense at the very least for a perf improvement if wanted. I think this could be confusing in the future -- is it possible that this would be fixed if the via @ @WestLangley #17102 (comment)
Great observation. This is something we should look into if |
It affects others lights that use @WestLangley I will make some tests to compare the quality of pre-processed map PREM with LOD using the same map. |
About optimization, this could not be like this too? // Both indirect specular and diffuse light accumulate here
// if energy preservation enabled, and PMREM provided.
if ( irradiance > 0. ) { |
I have previously suggested that we should pass in a single irradiance spherical harmonic into the shader that is a representation of all irradiant light sources (indirect diffuse) here: And further expanded here: This would simplify the code and our in-shader model. Irradiance would then not be queried from the PMREM but rather than SH representation. The PMREM would only be used for indirect specular, not indirect diffuse. |
This justifies my tests here: |
I expected About the name. this not should be |
@bhouston I have found that HDR and spherical harmonics do not work well together. HDR can have a high dynamic range, and that can not be accommodated by SH3; it leads to ringing and negative irradiance. There have been hacks proposed to counter those artifacts, but they are... hacks. Instead, users should be able to specify a radiance map and an irradiance map. In fact, I think this makes sense:
|
A LightProbe can be a cube map. If the probe models irradiance, it can be a small cube map. In my opinion, SH is not a good technique for modeling irradiance from HDR sources. |
I believe @WestLangley you are talking about high contrast HDR maps. The issue isn't the range, spherical harmonics handle range well, it is the high contrast that is the problem. This was discussed in the glTF working group. As a result of this the Babylon project wrote this up -- and I do support this approach: https://medium.com/@babylonjs/using-high-contrast-image-based-lighting-in-babylon-js-627ac721f20 I know Norbert Nopper though strongly disagreed with this approach -- thus he aligns with you. I love the approach Babylon.js advocates though. The reason I love it is that irradiance maps in my opinion are not supposed to capture the influence of strong punctual or directional light source -- you should instead use a strong punctual/direction light source instead. Otherwise you need to move away from SH in your LightProbe tetrahedralization to diffuse cube maps everywhere -- argh. There are two strong camps on this both of whom have strong opinions -- I had this argument with Norbert. With glTF this lead to them implementing both approaches. |
@bhouston I used the phrase "high dynamic range", which to me means what I assume you mean by "high contrast". So you either have to hack the image or hack the spherical harmonics. In either case, SH does not work properly in this use case. We can support SH3 for other use cases, but I would not use SH3 to model irradiance from an arbitrary HDR radiance map. I would use a small cube map, instead. That is just my suggestion, but I don't feel that strongly about it. |
@bhouston I am talking about the case where the user provides an HDR cube map, and the library computes both PMREM and the irradiance for the user. (I'm not sure if you support that workflow, but it sounds nice to me.) I agree, if the user wants to provide the irradiance map, there is no reason we can't support irradiance maps in an SH3 or cube map format. |
Description
Energy Preservation
is a characteristic of global light, not only IBL PREM how is today defined. This makes customized materials like NodeMaterial do not use these important equations for Physically-Based Material.Although it is a subtle difference, it can be noted an improvement in the incidence of lights in the fresnel area. Now, this can be applied in materials than use dynamic lights too, not only if have IBL PREM for example.
Quote: https://marmoset.co/posts/basic-theory-of-physically-based-rendering/
References
Energy Compensation
in #16977 Enterprise PBREnergy conservation
in https://learnopengl.com/PBR/TheoryENERGY CONSERVATION
in https://marmoset.co/posts/basic-theory-of-physically-based-rendering/Others
Issue #17102
Images bellow in this case is used a simple cube map.
/ping @WestLangley @bhouston