-
Notifications
You must be signed in to change notification settings - Fork 3.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
IBL shadowing #15106
base: master
Are you sure you want to change the base?
IBL shadowing #15106
Conversation
Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s). |
Snapshot stored with reference name: Test environment: To test a playground add it to the URL, for example: https://babylonsnapshots.z22.web.core.windows.net/refs/pull/15106/merge/index.html#WGZLGJ#4600 Links to test babylon tools with this snapshot: https://playground.babylonjs.com/?snapshot=refs/pull/15106/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/15106/merge#BCU1XR#0 |
Visualization tests for WebGPU (Experimental) |
WebGL2 visualization test reporter: |
Visualization tests for WebGPU (Experimental) |
Would it be possible to get some general feedback about whether this is the right approach for implementing something like this in Babylon? I've modeled this after the DepthPeelingRenderer, which is a scene component, but maybe this should be a pipeline? |
I'll take a look at it early next week. |
Here are some quick comments, but not a full review, as I probably won't be able to follow up because I'll be away for a few months in a couple of days, and it's only in draft mode:
As for your question about implementation, I think a rendering pipeline would indeed be better suited, as it would better isolate the code from the rest of the engine. I also wonder about performance... |
Excellent, feedback, @Popov72! Thank you. Regarding performance, yes, it's a lot of draw calls to generate the voxel grid and it isn't really suited to dynamic scenes for that reason (at least in it's current form). There are optimizations yet to be made but, to be honest, most of the work I have ahead of me is for improving the quality rather than the performance. Enjoy your time off! |
I turned this into a pipeline but I'm not yet using the |
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.
Just a few suggestions to get the build running correctly. One task is one me (to fix the post-build script from processing commented code).
import { FreeCamera } from "../../Cameras/freeCamera"; | ||
import { PostProcessRenderPipeline } from "../../PostProcesses/RenderPipeline/postProcessRenderPipeline"; | ||
import { PostProcessRenderEffect } from "core/PostProcesses/RenderPipeline/postProcessRenderEffect"; | ||
import type { Camera } from "core/Cameras"; |
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.
import type { Camera } from "core/Cameras"; | |
import type { Camera } from "core/Cameras/camera"; |
import type { AbstractEngine } from "../../Engines/abstractEngine"; | ||
import type { Scene } from "../../scene"; | ||
import { Vector4 } from "../../Maths/math.vector"; | ||
// import { Logger } from "../Misc/logger"; |
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.
Sorry, this is on me! Should be ignored, but our post-build script doesn't detect it as a comment. I will fix the script for future builds.
// import { Logger } from "../Misc/logger"; | |
// import { Logger } from "../../Misc/logger"; |
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.
You can ignore these comments (of the commented imports) if you merge from master
import { ProceduralTexture } from "../../Materials/Textures/Procedurals/proceduralTexture"; | ||
import type { IProceduralTextureCreationOptions } from "../../Materials/Textures/Procedurals/proceduralTexture"; | ||
// import { EffectRenderer, EffectWrapper } from "../Materials/effectRenderer"; | ||
// import { Logger } from "../Misc/logger"; |
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.
Same thing here
// import { Logger } from "../Misc/logger"; | |
// import { Logger } from "../../Misc/logger"; |
import type { AbstractEngine } from "../../Engines/abstractEngine"; | ||
import type { Scene } from "../../scene"; | ||
import { Vector4 } from "../../Maths/math.vector"; | ||
// import { Logger } from "../Misc/logger"; |
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.
// import { Logger } from "../Misc/logger"; | |
// import { Logger } from "../../Misc/logger"; |
import type { AbstractEngine } from "../../Engines/abstractEngine"; | ||
import type { Scene } from "../../scene"; | ||
import { Matrix, Vector2, Vector4 } from "../../Maths/math.vector"; | ||
// import { Logger } from "../Misc/logger"; |
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.
// import { Logger } from "../Misc/logger"; | |
// import { Logger } from "../../Misc/logger"; |
9c64ff8
to
7421115
Compare
This PR adds an
IblShadowsRenderPipeline
that adds shadowing for image-based lighting (IBL). It's applied as a post process after rendering your scene. You must assign an HDR environment withsetIblTexture
to enable the shadowing. Both cubemaps and equirectangular projected IBL's work.This pipeline builds a voxel grid for all the meshes in the scene that you want to cast shadows. You can exclude meshes (e.g. the skybox, ground plane, etc.) by calling
addExcludedMesh
on the pipeline. The voxel grid needs to be re-generated every time something in the scene moves and this can be an expensive operation (depending on the voxel resolution) so it's most suitable for static scenes in its current form. Note that the camera can move and the IBL environment is free to rotate or change completely without having to rebuild the voxel grid.Using this voxel grid, shadows are generated by sampling the IBL and then applied to the scene as a greyscale approximation. In combination with this, we can also calculate screen-space shadows to handle shadowing of small details.
Some important exposed settings:
Updating the voxel grid:
updateSceneBounds
to get the shadows to rebuild.Things that still need work: