Skip to content

Add atmospheric scattering effect #17

@shadowmage45

Description

@shadowmage45

Will be based on Bruneton's Improved Scattering.

  • Rewritten to HLSL
  • Updated to be made compatible with Post Process Package v2
  • Tested to be functional in KSP
  • Needs work to turn off the stock effects gracefully

KSP Implementation TODO:

  • Add the effect to the standard config window, load/save system
  • Disable stock atmosphere rendering (both ground and space), only when atmo rendering is enabled
  • Loading of atmosphere configurations.
  • Main Menu
  • Map Scenes
  • Model culling based on parameters. Don't do a render pass for models that are not visible in the camera.

Known Issues & TODO (Shader and Effect Implementations):

  • Update compute shaders to use the HLSL includes - samplers/etc are already in DX11 format, so might not be much needed.
  • Banding on the horizon when it is occluded by an object in front of the horizon.
    • Does not appear to be caused by an NAN/INF. Testing for those does not reveal anything out of the ordinary.
    • The banding occurs inside the GetRadianceToPoint method, and is present in the evaluated difference between the scatter and scatter_p variables.
    • Everything (a bit below) the horizon renders properly.
    • Need to test if the demo scene exhibits the same behavior in
  • Aliasing in places where depth sampling is used
  • Need some directional testing, will occasionally get phantom atmospheres rendered when the real atmopshere is behind the camera (these are caused by one of the depth-test fixes)
  • Need to clean up branching and all of the depth based testing, optimizations in general
  • Validation for use of multiple atmospheres, optimizations (shader)
    • Cheaper to loop from render (single vars, set many times), or inside shader (array vars, set once)?
  • Clean up effect handling so that each Model gets its own PropertySheet for binding to, run these in the effect loop.
  • Can the scale factor be adjusted safely at runtime, or does it truly interfere with the precomputed data?
  • How to render and add a normals buffer for use by the screen-space effect? (could also use this for screen-space reflections).
  • Add support for multiple light sources.
    • Use reflected 'moonlight' as a second light-source on Kerbin.
    • This would have to be done as a second pass, using different 'sun' coordinates and much lower exposure, and then added into the first. Can utilize the same Model as the sunlit pass as the atmospheric properties are the same. (maybe? there is the whole 'solar luminance' input stuff..)

Will also be investigating the inclusion of some built-in basic atmospheric scattering effects (very simple stuff).
https://forum.unity.com/threads/vapor-volumetric-scattering-open-source.500634/
https://github.com/Scrawk/Brunetons-Improved-Atmospheric-Scattering
https://github.com/Scrawk/Brunetons-Atmospheric-Scatter
https://www.alanzucconi.com/2017/10/10/atmospheric-scattering-1/
https://davidson16807.github.io/tectonics.js//2019/03/24/fast-atmospheric-scattering.html
https://www.alanzucconi.com/2019/09/13/believable-caustics-reflections/
https://github.com/GuitarBro/VolumeCloud/tree/StackV2
https://github.com/yangrc1234/VolumeCloud
https://github.com/yangrc1234/AtmosphereScatter
https://gamedev.stackexchange.com/questions/131978/shader-reconstructing-position-from-depth-in-vr-through-projection-matrix/140924#140924
https://forum.unity.com/threads/world-space-position-in-a-post-processing-shader.114392/
https://answers.unity.com/questions/1584649/how-do-you-port-old-shaders-to-hlsl-so-they-work-w.html
https://forum.unity.com/threads/screen-space-multiple-scattering.446647/page-3#post-3316350
fix for world-space recomposition from fulscreen triangle bullshit
https://grrava.blogspot.com/2018/08/more-foggy-adventures.html
https://michaldrobot.com/2014/04/01/gcn-execution-patterns-in-full-screen-passes/
https://github.com/SlightlyMad/VolumetricLights -- volumetric shadows (light shadow map grab with command buffer IMPORTANT)
https://catlikecoding.com/unity/tutorials/rendering/part-7/ -- shadow rendering
https://www.shadertoy.com/view/ldSGzR -- screen-space bump mapping
https://medium.com/@shahriyarshahrabi/custom-shadow-mapping-in-unity-c42a81e1bbf8
https://github.com/IRCSS/UnityRaymarching

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions