diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2017-10-28 00:28:17 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2017-10-28 00:28:17 +0300 |
commit | 1186dec916737b69afecd15030736f6d3361694e (patch) | |
tree | ab0a979ca79802291edf3e1f035df89f69d3e16f /source/blender/draw | |
parent | 6e0ec8868d5208d9b886c6023c2c63dec5f7171f (diff) |
Eevee: Volumetric: Fix Sun lamps not working.
Diffstat (limited to 'source/blender/draw')
-rw-r--r-- | source/blender/draw/engines/eevee/shaders/volumetric_lib.glsl | 10 | ||||
-rw-r--r-- | source/blender/draw/engines/eevee/shaders/volumetric_scatter_frag.glsl | 2 |
2 files changed, 8 insertions, 4 deletions
diff --git a/source/blender/draw/engines/eevee/shaders/volumetric_lib.glsl b/source/blender/draw/engines/eevee/shaders/volumetric_lib.glsl index c13938e141d..68729c6b02b 100644 --- a/source/blender/draw/engines/eevee/shaders/volumetric_lib.glsl +++ b/source/blender/draw/engines/eevee/shaders/volumetric_lib.glsl @@ -68,12 +68,14 @@ float phase_function(vec3 v, vec3 l, float g) vec3 light_volume(LightData ld, vec4 l_vector) { float power; - float dist = max(1e-4, abs(l_vector.w - ld.l_radius)); /* TODO : Area lighting ? */ /* XXX : Removing Area Power. */ /* TODO : put this out of the shader. */ if (ld.l_type == AREA) { - power = 0.0962 * (ld.l_sizex * ld.l_sizey * 4.0f * M_PI); + power = 0.0962 * (ld.l_sizex * ld.l_sizey * 4.0 * M_PI); + } + else if (ld.l_type == SUN) { + power = 1.0; } else { power = 0.0248 * (4.0 * ld.l_radius * ld.l_radius * M_PI * M_PI); @@ -83,7 +85,9 @@ vec3 light_volume(LightData ld, vec4 l_vector) float lum = dot(ld.l_color, vec3(0.3, 0.6, 0.1)); /* luminance approx. */ vec3 tint = (lum > 0.0) ? ld.l_color / lum : vec3(1.0); /* normalize lum. to isolate hue+sat */ - lum = min(lum * power / (l_vector.w * l_vector.w), volume_light_clamp); + power /= (l_vector.w * l_vector.w); + + lum = min(lum * power, volume_light_clamp); return tint * lum; } diff --git a/source/blender/draw/engines/eevee/shaders/volumetric_scatter_frag.glsl b/source/blender/draw/engines/eevee/shaders/volumetric_scatter_frag.glsl index ec695b2f0ac..af7e0f0d17e 100644 --- a/source/blender/draw/engines/eevee/shaders/volumetric_scatter_frag.glsl +++ b/source/blender/draw/engines/eevee/shaders/volumetric_scatter_frag.glsl @@ -50,7 +50,7 @@ void main() LightData ld = lights_data[i]; vec4 l_vector; - l_vector.xyz = ld.l_position - worldPosition; + l_vector.xyz = (ld.l_type == SUN) ? -ld.l_forward : ld.l_position - worldPosition; l_vector.w = length(l_vector.xyz); float Vis = light_visibility(ld, worldPosition, l_vector); |