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-05-12 01:58:53 +0300
committerClément Foucault <foucault.clem@gmail.com>2018-05-13 00:28:55 +0300
commitf9cfb221d64a8f7b5bb89ee36d5ac594d6da34ff (patch)
treeadad1f71d8df8de99e58631a3cca088c64044a3a /source/blender/draw/engines/eevee/shaders/effect_dof_vert.glsl
parent74a08cf12854308af166742f7dcaa5c7c227fcd4 (diff)
Eevee: Depth of field: Smooth out bokeh shape.
Due to the scatter operation being done at half resolution, undersampling is visible at bokeh shape edges (because of the hard cut). This commit adds a smoothing function to minimize the problem. Also optimize the bokeh shape parametrization by precomputing a lot of constants.
Diffstat (limited to 'source/blender/draw/engines/eevee/shaders/effect_dof_vert.glsl')
-rw-r--r--source/blender/draw/engines/eevee/shaders/effect_dof_vert.glsl19
1 files changed, 13 insertions, 6 deletions
diff --git a/source/blender/draw/engines/eevee/shaders/effect_dof_vert.glsl b/source/blender/draw/engines/eevee/shaders/effect_dof_vert.glsl
index dc34f2bd1fc..e28c957d58d 100644
--- a/source/blender/draw/engines/eevee/shaders/effect_dof_vert.glsl
+++ b/source/blender/draw/engines/eevee/shaders/effect_dof_vert.glsl
@@ -1,17 +1,17 @@
uniform vec2 layerSelection;
-uniform vec4 bokehParams;
+uniform vec4 bokehParams[2];
-#define bokeh_sides bokehParams.x /* Polygon Bokeh shape number of sides */
-#define bokeh_rotation bokehParams.y
-#define bokeh_ratio bokehParams.z
-#define bokeh_maxsize bokehParams.w
+#define bokeh_rotation bokehParams[0].x
+#define bokeh_ratio bokehParams[0].y
+#define bokeh_maxsize bokehParams[0].z
-uniform sampler2D colorBuffer;
uniform sampler2D cocBuffer;
+uniform sampler2D colorBuffer;
flat out vec4 color;
+flat out float smoothFac;
out vec2 particlecoord;
#define M_PI 3.1415926535897932384626433832795
@@ -78,4 +78,11 @@ void main()
gl_Position.xy -= 1.0 - 0.5 * texel_size; /* NDC Bottom left */
gl_Position.xy += (0.5 + vec2(texelco) * 2.0) * texel_size;
+ /* don't do smoothing for small sprites */
+ if (coc > 3.0) {
+ smoothFac = 1.0 - 1.5 / coc;
+ }
+ else {
+ smoothFac = 1.0;
+ }
}