-
Notifications
You must be signed in to change notification settings - Fork 3.5k
IBL Shadows - Init passes only after voxelization #16527
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: master
Are you sure you want to change the base?
Conversation
Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s). |
@@ -199,6 +203,10 @@ export class _IblShadowsSpatialBlurPass { | |||
width: Math.max(1.0, Math.floor(this._engine.getRenderWidth() * scaleFactor)), | |||
height: Math.max(1.0, Math.floor(this._engine.getRenderHeight() * scaleFactor)), | |||
}; | |||
// Don't resize if the size is the same as the current size. | |||
if (this._outputTexture.getSize().width === newSize.width && this._outputTexture.getSize().height === newSize.height) { |
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 also added logic to prevent resizing if the size hasn't actually changed. I assume that resizing the procedural texture may result in the shader program needing to be recreated so I was trying to prevent this from happening.
// onAfterRenderTargetsRenderObservable is called twice during a frame and we only want to render | ||
// on the second call, after the scene has been rendered to the GBuffer. | ||
this._scene.onAfterRenderTargetsRenderObservable.add(() => { | ||
if (++counter == 2) { |
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 still don't like this counter logic and I feel like it might be related to the problem. The onAfterRenderTargetsRenderObservable
fires twice during a frame and I only want to run these passes once, after the geometry buffer is rendered and before the main render. Is there a better way to do this?
I think I've verified that the uniform does exist by doing a |
Another thing to note is that I can't reproduce this issue in Firefox or Safari. It only seems to happen in Chrome and Edge. |
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/16527/merge/index.html#WGZLGJ#4600 Links to test babylon tools with this snapshot: https://playground.babylonjs.com/?snapshot=refs/pull/16527/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/16527/merge#BCU1XR#0 |
WebGL2 visualization test reporter: |
Visualization tests for WebGPU |
Okay, I've been investigating the issue where the shadow accumulation isn't working initially after loading the IBL Shadow Demo playground. On some loads, the shadows will appear noisy and not accumulate over multiple frames. Note that this issue never happens if you have Spector.js enabled, which is why I had such a hard time reproducing it originally.
The actual issue is that the uniform,
accumulationParameters
fails to be set withWebGL: INVALID_OPERATION: uniform4f: location is not from the associated program
Even though this fails, the uniform value is still cached and Babylon doesn't set the uniform again until the value changes. That is why accumulation appears to be disabled until you move the camera (which causes the uniform to change and update).
I have not been able to figure out why the uniform set fails in the first place. It seems to be consistently the 3rd render that fails. Before that, the uniform is set successfully and, as far as I can tell, the shader program isn't updated after that point. And after the failure, the uniform can be set again.
The one thing that I was able to change to make the issue seem to go away was to put enough of a delay on the rendering of the accumulation pass. I've added logic to only start rendering the accumulation pass once the first voxelization is complete. This is fine since we can't render shadows until this is done anyway but I don't know why it should fix the problem.