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

Skybox support? #1

Open
louisGreenland opened this issue Jan 23, 2020 · 6 comments
Open

Skybox support? #1

louisGreenland opened this issue Jan 23, 2020 · 6 comments
Labels
enhancement New feature or request

Comments

@louisGreenland
Copy link

Great work! Is it possible to get some sort of skybox support with this atmospheric scattering effect?

@simeonradivoev
Copy link
Owner

It should be easy, given that the scattering is just a post-processing effect. Does it not work with Unity's Skybox system?

@simeonradivoev
Copy link
Owner

Ah it seems the skybox is rendered after lighting. So for skybox support to be added, the atmospheric scattering needs to be turned into an effect for the post-processing stack.

@simeonradivoev simeonradivoev added the enhancement New feature or request label Jan 23, 2020
@louisGreenland
Copy link
Author

I was literally just about to post that haha. I wouldn't know how to go about doing that since I am not at all a shader expert. Another issue seems to be the effect glitching at long distances, not sure if this is a floating point issue that could be solved with a floating origin method but I thought i'd let you know anyways. Great stuff!
Unity_QFnMK2TEEy

@adellari
Copy link

adellari commented Jan 5, 2021

@louisGreenland The floating point issues are caused by these lines in AtmosphericScatter.shader:

     float3 attenuation;
     float irradianceFactor = 0;
     float3 inscat = GetInscatteredLight(wpos,viewDir,attenuation,irradianceFactor);
     float3 reflected = GetReflectedLight(wpos, depth,attenuation,irradianceFactor, normal,surfaceColor);

where attenuation is used without proper initialization.
This can of course be easily fixed by changing the first line to

float3 attenuation = float3(0., 0., 0.);

thus removing the visual artifacts

@adellari
Copy link

adellari commented Jan 5, 2021

Ah it seems the skybox is rendered after lighting. So for skybox support to be added, the atmospheric scattering needs to be turned into an effect for the post-processing stack.

Alternatively, using a custom skybox shader with blending mode

Blend One One 

works like a charm since the image effect's blending in AtmosphericScattering.shader is

OneMinusSrcAlpha

@dev-bre
Copy link

dev-bre commented Sep 25, 2022

@adellari can you please expand how to fix this?
I am not expert in shaders, but I am trying to have the sun properly rendered in the sky.
Any chance you can provide an example of custom skybox which would work?

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

No branches or pull requests

4 participants