Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2018-11-15 21:41:15 +0300
committerClément Foucault <foucault.clem@gmail.com>2018-11-15 22:04:47 +0300
commit1b321048a7ebbb99d62c8d8e74446153ef487a59 (patch)
treeafc153fe72ef11b0de9ef9def0d54de09c5b5799 /source/blender/draw/engines/eevee/shaders/lightprobe_filter_glossy_frag.glsl
parentf8964809b82e679d58669342ee0035db01a6c0c9 (diff)
Eevee: Add Glossy Reflection clamping
This enables reducing the noise comming from very bright light sources (like a sun) that can be found in distant HDRIs. The lost energy may be replaced manually by a sunlight that compensate the this loss. This clamping only concerns Reflection Cubmaps and is done on all on all of them. Setting to 0.0 disables it (default).
Diffstat (limited to 'source/blender/draw/engines/eevee/shaders/lightprobe_filter_glossy_frag.glsl')
-rw-r--r--source/blender/draw/engines/eevee/shaders/lightprobe_filter_glossy_frag.glsl14
1 files changed, 13 insertions, 1 deletions
diff --git a/source/blender/draw/engines/eevee/shaders/lightprobe_filter_glossy_frag.glsl b/source/blender/draw/engines/eevee/shaders/lightprobe_filter_glossy_frag.glsl
index bb23051b7e5..fdfee54f368 100644
--- a/source/blender/draw/engines/eevee/shaders/lightprobe_filter_glossy_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/lightprobe_filter_glossy_frag.glsl
@@ -6,11 +6,17 @@ uniform float lodFactor;
uniform float lodMax;
uniform float paddingSize;
uniform float intensityFac;
+uniform float fireflyFactor;
in vec3 worldPosition;
out vec4 FragColor;
+float brightness(vec3 c)
+{
+ return max(max(c.r, c.g), c.b);
+}
+
vec3 octahedral_to_cubemap_proj(vec2 co)
{
co = co * 2.0 - 1.0;
@@ -77,7 +83,13 @@ void main() {
/* http://http.developer.nvidia.com/GPUGems3/gpugems3_ch20.html : Equation 13 */
float lod = clamp(lodFactor - 0.5 * log2(pdf * dist), 0.0, lodMax) ;
- out_radiance += textureLod(probeHdr, L, lod).rgb * NL;
+ vec3 l_col = textureLod(probeHdr, L, lod).rgb;
+
+ /* Clamped brightness. */
+ float luma = max(1e-8, brightness(l_col));
+ l_col *= 1.0 - max(0.0, luma - fireflyFactor) / luma;
+
+ out_radiance += l_col * NL;
weight += NL;
}
}