Skip to content
Snippets Groups Projects
Commit 33bc9a99 authored by Alexander Gauggel's avatar Alexander Gauggel
Browse files

[#82] Add small ambient light factor to volumetric lighting

parent 8a60170c
No related branches found
No related tags found
1 merge request!70Resolve "Voxel cone tracing"
Pipeline #26017 passed
...@@ -2,10 +2,11 @@ ...@@ -2,10 +2,11 @@
#define LIGHT_INFO_INC #define LIGHT_INFO_INC
struct LightInfo{ struct LightInfo{
vec3 L; float padding; vec3 L;
vec3 sunColor; float padding;
float sunStrength; vec3 sunColor;
mat4 lightMatrix; float sunStrength;
mat4 lightMatrix;
}; };
#endif // #ifndef LIGHT_INFO_INC #endif // #ifndef LIGHT_INFO_INC
\ No newline at end of file
...@@ -81,6 +81,7 @@ vec3 volumetricLighting(vec3 colorIn, vec3 V, vec3 pos, float d){ ...@@ -81,6 +81,7 @@ vec3 volumetricLighting(vec3 colorIn, vec3 V, vec3 pos, float d){
vec3 scatteringCoefficient = vec3(0.005); vec3 scatteringCoefficient = vec3(0.005);
vec3 absorptionCoefficient = vec3(0.01); vec3 absorptionCoefficient = vec3(0.01);
vec3 extinctionCoefficient = scatteringCoefficient + absorptionCoefficient; vec3 extinctionCoefficient = scatteringCoefficient + absorptionCoefficient;
vec3 ambientLight = vec3(0.2);
float noiseScale = 0.1; float noiseScale = 0.1;
pos += V * noiseScale * interleavedGradientNoise(gl_FragCoord.xy); pos += V * noiseScale * interleavedGradientNoise(gl_FragCoord.xy);
...@@ -91,6 +92,8 @@ vec3 volumetricLighting(vec3 colorIn, vec3 V, vec3 pos, float d){ ...@@ -91,6 +92,8 @@ vec3 volumetricLighting(vec3 colorIn, vec3 V, vec3 pos, float d){
vec3 light = lightInfo.sunColor * lightInfo.sunStrength; vec3 light = lightInfo.sunColor * lightInfo.sunStrength;
float shadow = shadowTest(samplePoint, lightInfo, shadowMap, shadowMapSampler, vec2(0)); float shadow = shadowTest(samplePoint, lightInfo, shadowMap, shadowMapSampler, vec2(0));
light *= shadow; light *= shadow;
light += ambientLight;
color += phase * light * scatteringCoefficient * stepSize; color += phase * light * scatteringCoefficient * stepSize;
color *= exp(-stepSize * extinctionCoefficient); color *= exp(-stepSize * extinctionCoefficient);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment