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

WIP: Hillarie Phisically Based Atmosphere Shader #376

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from

Conversation

mate-h
Copy link

@mate-h mate-h commented Feb 21, 2024

Physically Based Atmosphere

This PR is implementing a LUT based production ready approach to physically based atmosphere based on Sebastian Hillarie's research and some of my own research.

Approach involves compute shaders with the following look up tables (LUTs):

  • Transmittance / Optical depth as a function of zenith and azimuth
  • Multiple Scattering approximation
  • Sky-View LUT
  • (WIP) Aerial Perspective 3D LUT

References

https://github.com/sebh/UnrealEngineSkyAtmosphere

https://sebh.github.io/publications/egsr2020.pdf

https://github.com/mate-h/sky-model

Screenshot / demo

Top: new atmospheric shader, bottom: current atmospheric shader.

@hellmor
Copy link
Collaborator

hellmor commented Feb 27, 2024

Thank you very much for the PR submitted to Orillusion. We have carefully reviewed the specific code submitted, and the diffuse reflection effect is excellent. It surpasses our originally implemented algorithm, offering richer and more vibrant colors in the early morning! It's impressive and will surely provide a more noticeable enhancement for many developers using the related features.

Based on this PR submission, we would like to offer some suggestions:

  1. The current PR lacks completeness in terms of functionality, such as the absence of the sun's display and hiding options, and the sun's brightness and radius parameters are also not utilized.

  2. We hope to improve the display of the sun. Then, we can decide whether to override the existing functionality or extract this PR as an extension.

What are your thoughts on these suggestions?

Thank you very much! The Orillusion team is always open for communication.

@mate-h
Copy link
Author

mate-h commented Feb 28, 2024

First I'd like to thank you for spending the time to leave feedback. I agree with all of your suggestions, I was sharing this code early while still work in progress for exactly this reason.

Sun rendering

I have a couple approaches in mind for rendering the sun disk.

  1. Move the original code to render sun disk
    I could move the parts of the original shader that renders the sun's disk. However this has some limitations due to the fact that it's rendering it into sky box environment texture with limited resolution. This will show the sun disk in a slightly pixelated way, and I noticed that it does not correctly produce a specular reflection on materials. When you add directional light into the scene that produces correct specular highlights.

  2. Utilize the Sky View LUT to render the sky as a post processing effect
    The main idea for this approach is to use the sky view lookup table and the camera matrices as well as a fullscreen quad to dynamically render the sky in real time. This approach could add a custom sun shader on top that would render the sun's disk at native resolution. We still need to keep the sky box for reflections in the scene of course.

Post processing

Couple improvements I can think of in the post processing step:

  • Apply the aerial perspective to geometry by adding the in-scattered light in the scene using the depth buffer and aerial perspective 3D LUT
  • alternatively perform a raymarch toward the geometry and sample the cascading shadow map as well to produce physically accurate atmospheric volumetric shadows (a.k.a. sun rays / god rays). This step could be a boolean setting on the Atmospheric component itself since it's performance intensive. would only want to enable on desktop devices or devices with enough performance.
  • Lens flare effect and bloom of the Sun's disk
  • HDR and tone mapping

While some of these improvements may be out of scope for a single PR, I do think that the HDR part is important to address to produce correct IBL on the PBR materials. Please advise how I can use the sky box as a HDR environment texture, and whether we could/should have the tone mapping step on the entire scene as a postprocessing step instead of a per-shader basis.

Extracting Extension

For extracting this as an extension I am assuming you would want it to be a separately installable NPM package, do you have documentation or code examples I could refer to for this? Is it a priority to extract it into an extension? I propose this name:

@orillusion/atmosphere

Thank you for your feedback in advance and I look forward to working on this more.

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

Successfully merging this pull request may close these issues.

None yet

2 participants