#include "atmosphere.glsl" in vec3 ViewDirection; layout(std140, binding = 1) uniform UniformSceneData { vec3 sunPosition; bool useTexture; } sceneData; layout(location = 0) out vec4 outColor; layout(location = 1) out vec4 outBright; layout(binding = 2) uniform samplerCube skyboxSampler; void main() { vec3 result; if(sceneData.useTexture) { result = texture(skyboxSampler, ViewDirection).rgb; } else { result = atmosphere( normalize(ViewDirection), vec3(0, 6372e3, 0), // ray origin sceneData.sunPosition, // position of the sun 22.0, // intensity of the sun 6371e3, // radius of the planet in meters 6471e3, // radius of the atmosphere in meters vec3(5.5e-6, 13.0e-6, 22.4e-6), // Rayleigh scattering coefficient 21e-6, // Mie scattering coefficient 8e3, // Rayleigh scale height 1.2e3, // Mie scale height 0.758 // Mie preferred scattering direction ); } outColor = vec4(result, 1.0); float brightness = dot(outColor.rgb, vec3(0.2126, 0.7152, 0.0722)); if(brightness > 1.6) outBright = vec4(outColor.rgb, 1.0); }