diff --git a/projects/voxelization/resources/shaders/lightInfo.inc b/projects/voxelization/resources/shaders/lightInfo.inc index 7cbf605e4e54342743855d5f380db857da12f5f5..a87f9ce7bebc1db1688dd20dd80608e99925755a 100644 --- a/projects/voxelization/resources/shaders/lightInfo.inc +++ b/projects/voxelization/resources/shaders/lightInfo.inc @@ -2,10 +2,11 @@ #define LIGHT_INFO_INC struct LightInfo{ - vec3 L; float padding; - vec3 sunColor; - float sunStrength; - mat4 lightMatrix; + vec3 L; + float padding; + vec3 sunColor; + float sunStrength; + mat4 lightMatrix; }; #endif // #ifndef LIGHT_INFO_INC \ No newline at end of file diff --git a/projects/voxelization/resources/shaders/shader.frag b/projects/voxelization/resources/shaders/shader.frag index 0569abd16f1f5d75dd4155ecdb706b8a16784993..ff8968ca05d090703236c70bd2fef2f9f9784dde 100644 --- a/projects/voxelization/resources/shaders/shader.frag +++ b/projects/voxelization/resources/shaders/shader.frag @@ -81,6 +81,7 @@ vec3 volumetricLighting(vec3 colorIn, vec3 V, vec3 pos, float d){ vec3 scatteringCoefficient = vec3(0.005); vec3 absorptionCoefficient = vec3(0.01); vec3 extinctionCoefficient = scatteringCoefficient + absorptionCoefficient; + vec3 ambientLight = vec3(0.2); float noiseScale = 0.1; pos += V * noiseScale * interleavedGradientNoise(gl_FragCoord.xy); @@ -91,6 +92,8 @@ vec3 volumetricLighting(vec3 colorIn, vec3 V, vec3 pos, float d){ vec3 light = lightInfo.sunColor * lightInfo.sunStrength; float shadow = shadowTest(samplePoint, lightInfo, shadowMap, shadowMapSampler, vec2(0)); light *= shadow; + light += ambientLight; + color += phase * light * scatteringCoefficient * stepSize; color *= exp(-stepSize * extinctionCoefficient); }