diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2017-05-10 16:58:18 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2017-05-10 17:03:25 +0300 |
commit | 45207bf3ce96f008496caf1be8166fd09065c4a0 (patch) | |
tree | 2cac0276dd3aa7cd97e6619ba66f9889d1c88a85 /source/blender/draw/engines/eevee/shaders | |
parent | fdf2d8bb9592bd3a650b35d8bbd8a633169ac026 (diff) |
Eevee: Post process parameters.
-Display almost all parameters.
-Made some small adjustment to motion blur to support FOV motion blur.
-Made DOF max radius a parameter.
Diffstat (limited to 'source/blender/draw/engines/eevee/shaders')
3 files changed, 22 insertions, 9 deletions
diff --git a/source/blender/draw/engines/eevee/shaders/effect_dof_frag.glsl b/source/blender/draw/engines/eevee/shaders/effect_dof_frag.glsl index 0eaee94165d..e77379744d1 100644 --- a/source/blender/draw/engines/eevee/shaders/effect_dof_frag.glsl +++ b/source/blender/draw/engines/eevee/shaders/effect_dof_frag.glsl @@ -10,10 +10,12 @@ uniform vec3 dofParams; #define dof_distance dofParams.y #define dof_invsensorsize dofParams.z -uniform vec3 bokehParams; +uniform vec4 bokehParams; #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 uniform vec2 nearFar; /* Near & far view depths values */ 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 3899365a771..e75ffe236f1 100644 --- a/source/blender/draw/engines/eevee/shaders/effect_dof_vert.glsl +++ b/source/blender/draw/engines/eevee/shaders/effect_dof_vert.glsl @@ -4,6 +4,13 @@ in vec2 uvs; uniform vec2 layerSelection; +uniform vec4 bokehParams; + +#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 + uniform sampler2D colorBuffer; uniform sampler2D cocBuffer; @@ -28,7 +35,7 @@ void step_scatter() float coc = dot(layerSelection, texelFetch(cocBuffer, texelco, 0).rg); /* Clamp to max size for performance */ - coc = min(coc, 100.0); + coc = min(coc, bokeh_maxsize); if (coc >= 1.0) { color = texelFetch(colorBuffer, texelco, 0); diff --git a/source/blender/draw/engines/eevee/shaders/effect_motion_blur_frag.glsl b/source/blender/draw/engines/eevee/shaders/effect_motion_blur_frag.glsl index e603769c9c8..8960b339a61 100644 --- a/source/blender/draw/engines/eevee/shaders/effect_motion_blur_frag.glsl +++ b/source/blender/draw/engines/eevee/shaders/effect_motion_blur_frag.glsl @@ -2,7 +2,6 @@ uniform sampler2D colorBuffer; uniform sampler2D depthBuffer; -uniform float blurAmount; /* current frame */ uniform mat4 currInvViewProjMatrix; @@ -14,7 +13,9 @@ in vec4 uvcoordsvar; out vec4 FragColor; -#define MAX_SAMPLE 16 +#define MAX_SAMPLE 64 + +uniform int samples; float wang_hash_noise(uint s) { @@ -37,7 +38,8 @@ void main() ndc_pos.xy = uvcoordsvar.xy; ndc_pos.z = texture(depthBuffer, uvcoordsvar.xy).x; - float noise = 2.0 * wang_hash_noise(0u) / MAX_SAMPLE; + float inv_samples = 1.0 / float(samples); + float noise = 2.0 * wang_hash_noise(0u) * inv_samples; /* Normalize Device Coordinates are [-1, +1]. */ ndc_pos = ndc_pos * 2.0 - 1.0; @@ -50,10 +52,12 @@ void main() vec4 old_ndc = pastViewProjMatrix * vec4(world_pos, 1.0); old_ndc.xyz /= old_ndc.w; /* Perspective divide */ - vec2 motion = (ndc_pos.xy - old_ndc.xy) * blurAmount; + vec2 motion = (ndc_pos.xy - old_ndc.xy) * 0.25; /* 0.25 fit cycles ref */ - const float inc = 2.0 / MAX_SAMPLE; - for (float i = -1.0 + noise; i < 1.0; i += inc) { - FragColor += texture(colorBuffer, uvcoordsvar.xy + motion * i) / MAX_SAMPLE; + float inc = 2.0 * inv_samples; + float i = -1.0 + noise; + for (int j = 0; j < samples && j < MAX_SAMPLE; j++) { + FragColor += texture(colorBuffer, uvcoordsvar.xy + motion * i) * inv_samples; + i += inc; } } |