-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Use CDF for irradiance prefiltering #16010
base: master
Are you sure you want to change the base?
Use CDF for irradiance prefiltering #16010
Conversation
Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s). |
packages/dev/core/src/Shaders/ShadersInclude/pbrBlockReflection.fx
Outdated
Show resolved
Hide resolved
Snapshot stored with reference name: Test environment: To test a playground add it to the URL, for example: https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/refs/pull/16010/merge/index.html#WGZLGJ#4600 Links to test babylon tools with this snapshot: https://playground.babylonjs.com/?snapshot=refs/pull/16010/merge To test the snapshot in the playground with a playground ID add it after the snapshot query string: https://playground.babylonjs.com/?snapshot=refs/pull/16010/merge#BCU1XR#0 |
WebGL2 visualization test reporter: |
Visualization tests for WebGPU (Experimental) |
Let us know when you think the PR is ready for review. |
I would like a review whenever you're available. The functionality is complete, I think. |
1468a13
to
2456de6
Compare
I'm getting errors in WebGPU when prefiltering the irradiance. Not sure what's going on yet.
|
packages/dev/core/src/Materials/Textures/Filtering/hdrIrradianceFiltering.ts
Outdated
Show resolved
Hide resolved
packages/dev/core/src/Materials/Textures/Filtering/hdrIrradianceFiltering.ts
Outdated
Show resolved
Hide resolved
@@ -162,6 +166,10 @@ export class IblCdfGenerator { | |||
if (this._iblSource!.isCube) { | |||
size.width *= 4; | |||
size.height *= 2; | |||
// Force the resolution to be a power of 2 because we rely on the | |||
// auto-mipmap generation for the scaled luminance texture. |
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.
I'm not sure I understand this comment, we can generate mipmaps for textures that are not powers of 2?
environmentIrradiance = vEnvironmentIrradiance; | ||
#else | ||
#if defined(USESPHERICALFROMREFLECTIONMAP) || defined(USEIRRADIANCEMAP) | ||
#if !defined(NORMAL) || !defined(USESPHERICALINVERTEX) |
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.
I think it would be better to do:
#if (defined(USESPHERICALFROMREFLECTIONMAP) && (!defined(NORMAL) || !defined(USESPHERICALINVERTEX))) || defined(USEIRRADIANCEMAP)
This error means that a texture has been destroyed before a render command/pass using that texture has been completed. The texture is an RGBA32 float 1024x1024 cube texture, with mipmaps, if that helps you find which texture it is. Your PG is quite complicated because it uses ibl shadows, so it's not easy to find out where the problem comes from... It would help if you could make a simplified reproduction. You can help debug such problems by providing debugging labels to the textures you create through calls to |
Okay, I've pushed some changes. Notably, I'm creating a new The WebGPU error seems to be about the loaded, unfiltered cubemap. It happens only when I'm trying to prefilter both irradiance using the CDF maps and radiance. My interpretation of this is that filtering irradiance with the CDF maps causes this texture to be deleted before the radiance filtering runs. Does that sound right? |
Should this PG crash? It does work for me, with |
No, it shouldn't crash. I used to get the WebGPU errors that I mentioned but, after refactoring the promise logic yesterday, that's gone away. |
@Popov72 let me know when you are all good on this one and I ll do a final pass |
Expanding on the realtime filtering of irradiance, here is the equivalent logic for prefiltering.
If the user specifies
generateHarmonics = false
,prefilterOnLoad = true
andscene.enableIblCdfGenerator()
has been called, then an irradianceTexture will be generated using CDF.