Skip to content
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

Procedural IBL Enhancement in CesiumJS #12129

Open
wants to merge 40 commits into
base: main
Choose a base branch
from
Open

Procedural IBL Enhancement in CesiumJS #12129

wants to merge 40 commits into from

Conversation

ggetz
Copy link
Contributor

@ggetz ggetz commented Aug 16, 2024

Description

This pull request introduces a new system for "procedural" lighting that builds on the Image-Based Lighting (IBL) approach in CesiumJS, aimed at improving the realism and visual quality of the default lighting environment. The changes focus on techniques that create a plausible environment map dynamically based on the current lighting conditions an existing atmospheric scattering code which renders the sky.

Image-Based Lighting Sandcastle

After
image

Before
image

Mirror Ball

After
image

Before
image

High Altitude Mirror Ball

After
image

Before
image

Dynamic Lighting

image

TODO: More screenshot comparisons

Key Changes

  • DynamicEnvironmentMapManager: This new component generates lighting value dynamically based on the existing atmospheric calculations. It uses compute command to generate the following when position or sun position has significantly changed.
    • Environment Map: generated to match lighting conditions based on a central location and the current sun position.
    • Specular Environment Maps: Implements several levels of specular maps, corresponding to various degrees of surface roughness. This allows for more nuanced reflections and highlights that better respond to scene lighting.
    • Spherical Harmonic Diffuse Lighting: Computes of spherical harmonic values for diffuse lighting, enhancing the quality and realism of the light diffusion across different surfaces.
  • The computed values from the new IBL setup are directly used in conjunction with the scene's directional light source, primarily the sun, to establish comprehensive lighting effects across models and 3D Tilesets.
  • I've chosen to make the DynamicEnvironmentMapManager options accessible via the Model and Cesium3DTileset only, at least for this PR, mainly due to the performance impact if these values are constantly updated.

Additional Updates

  • Fix Spherical Harmonic reconstruction: as per the filament maintainers
  • Fix for ImageBasedLighting.imageBasedLightingFactor: This property was broken and went unnoticed.
  • Removal of ImageBasedLighting.luminanceAtZenith: This property was removed instead of deprecated because there is no direct equivalent in the new implementation, and is likely not widely used (based on the fact that the above bug went unnoticed).
  • Modifications to CubeMap: New utility functions in support of the operations in DynamicEnvironmentMapManager, such as copying a texture to a specific face.

Issue number and link

N/A

Testing plan

  1. Pull down this branch and run unit tests locally (I had to tweak rendering tests to account for the new lighting. Please double check me here.)
  2. Run the development PBR Lighting sandcastle example and make sure all the sliders/buttons work.
  3. Review all Sandcastle examples and ensure new lighting parameters are adequate for all cases.

Author checklist

  • Fix race condition where the map sometime does not initialize atmosphere values correctly
  • Fix slightly askew environment map orientation
  • Confirm shadows are affecting lighting correctly
  • Expose DynamicEnvironmentMapManager options for Model entities?
  • Any adjustments needed for HDR?
  • Performance pass and testing
  • Cleanup Sandcastle examples-- Streamline existing ones where possible
  • Cleanup pass on shaders
  • I have submitted a Contributor License Agreement
  • I have added my name to CONTRIBUTORS.md
  • I have updated CHANGES.md with a short summary of my change
  • I have added or updated unit tests to ensure consistent code coverage
  • I have updated the inline documentation, and included code examples where relevant
  • I have performed a self-review of my code

Copy link

Thank you for the pull request, @ggetz!

✅ We can confirm we have a CLA on file for you.

if (defined(uniformMap)) {
const manualUniforms = this._manualUniforms;
len = manualUniforms.length;
for (i = 0; i < len; ++i) {
const mu = manualUniforms[i];
mu.value = uniformMap[mu.name]();
try {
Copy link
Contributor Author

@ggetz ggetz Aug 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This update is not strictly necessary, but I found it helpful for debugging.

@ggetz ggetz mentioned this pull request Aug 30, 2024
7 tasks
@ggetz ggetz marked this pull request as ready for review October 4, 2024 13:28
@ggetz
Copy link
Contributor Author

ggetz commented Oct 4, 2024

@jjspace Could you please take a review pass on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant