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>2020-06-11 16:05:21 +0300
committerClément Foucault <foucault.clem@gmail.com>2020-06-11 16:05:21 +0300
commit8ac06377a51e25594314af903b4e4774bd3db8de (patch)
treebf4bfce3c004ce47e10f2b253a55c16a2595ac64
parenta0c947ed4c1bb144efb111a9bbbb3ae926d375df (diff)
EEVEE: Motion Blur: Fix camera near/far values uniforms
-rw-r--r--source/blender/draw/engines/eevee/eevee_motion_blur.c17
-rw-r--r--source/blender/draw/engines/eevee/eevee_private.h5
-rw-r--r--source/blender/draw/engines/eevee/shaders/effect_motion_blur_frag.glsl10
3 files changed, 22 insertions, 10 deletions
diff --git a/source/blender/draw/engines/eevee/eevee_motion_blur.c b/source/blender/draw/engines/eevee/eevee_motion_blur.c
index c768ada8772..612695b849b 100644
--- a/source/blender/draw/engines/eevee/eevee_motion_blur.c
+++ b/source/blender/draw/engines/eevee/eevee_motion_blur.c
@@ -97,9 +97,7 @@ static void eevee_motion_blur_past_persmat_get(const CameraParams *past_params,
}
#endif
-int EEVEE_motion_blur_init(EEVEE_ViewLayerData *UNUSED(sldata),
- EEVEE_Data *vedata,
- Object *UNUSED(camera))
+int EEVEE_motion_blur_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *vedata, Object *camera)
{
EEVEE_StorageList *stl = vedata->stl;
EEVEE_FramebufferList *fbl = vedata->fbl;
@@ -125,6 +123,16 @@ int EEVEE_motion_blur_init(EEVEE_ViewLayerData *UNUSED(sldata),
DRW_view_persmat_get(NULL, effects->motion_blur.camera[mb_step].persinv, true);
}
+ if (camera != NULL) {
+ Camera *cam = camera->data;
+ effects->motion_blur_near_far[0] = cam->clip_start;
+ effects->motion_blur_near_far[1] = cam->clip_end;
+ }
+ else {
+ /* Not supported yet. */
+ BLI_assert(0);
+ }
+
#if 0 /* For when we can do viewport motion blur. */
/* Update Motion Blur Matrices */
if (camera && (camera->type == OB_CAMERA) && (camera->data != NULL)) {
@@ -175,6 +183,7 @@ int EEVEE_motion_blur_init(EEVEE_ViewLayerData *UNUSED(sldata),
effects->cam_params_init = false;
}
#endif
+
effects->motion_blur_max = 32;
const float *fs_size = DRW_viewport_size_get();
int tx_size[2] = {1 + ((int)fs_size[0] / effects->motion_blur_max),
@@ -274,6 +283,8 @@ void EEVEE_motion_blur_cache_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Dat
DRW_shgroup_uniform_texture_ref_ex(
grp, "tileMaxBuffer", &effects->velocity_tiles_expand_tx, state);
DRW_shgroup_uniform_int_copy(grp, "maxBlurRadius", effects->motion_blur_max);
+ DRW_shgroup_uniform_vec2(grp, "nearFar", effects->motion_blur_near_far, 1);
+ DRW_shgroup_uniform_bool_copy(grp, "isPerspective", DRW_view_is_persp_get(NULL));
DRW_shgroup_uniform_vec2(grp, "viewportSize", DRW_viewport_size_get(), 1);
DRW_shgroup_uniform_vec2(grp, "viewportSizeInv", DRW_viewport_invert_size_get(), 1);
DRW_shgroup_call_procedural_triangles(grp, NULL, 1);
diff --git a/source/blender/draw/engines/eevee/eevee_private.h b/source/blender/draw/engines/eevee/eevee_private.h
index 1c3de12473a..2d117ac25fd 100644
--- a/source/blender/draw/engines/eevee/eevee_private.h
+++ b/source/blender/draw/engines/eevee/eevee_private.h
@@ -670,8 +670,9 @@ typedef struct EEVEE_EffectsInfo {
CameraParams past_cam_params;
CameraParams current_cam_params;
float motion_blur_sample_offset;
- char motion_blur_step; /* Which step we are evaluating. */
- int motion_blur_max; /* Maximum distance in pixels a motion blured pixel can cover. */
+ char motion_blur_step; /* Which step we are evaluating. */
+ int motion_blur_max; /* Maximum distance in pixels a motion blured pixel can cover. */
+ float motion_blur_near_far[2]; /* Camera near/far clip distances (positive). */
bool cam_params_init;
/* TODO(fclem) Only used in render mode for now.
* This is because we are missing a per scene persistent place to hold this. */
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 04a8a989ed6..68ac66171b6 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
@@ -25,12 +25,12 @@ uniform int samples;
uniform float sampleOffset;
uniform vec2 viewportSize;
uniform vec2 viewportSizeInv;
-/* TODO plug scene value */
-uniform vec2 nearFar = vec2(0.1, 100.0); /* Near & far view depths values */
-/* TODO make sure ortho works */
+uniform bool isPerspective;
+uniform vec2 nearFar; /* Near & far view depths values */
+
#define linear_depth(z) \
- ((true) ? (nearFar.x * nearFar.y) / (z * (nearFar.x - nearFar.y) + nearFar.y) : \
- z * (nearFar.y - nearFar.x) + nearFar.x) /* Only true for camera view! */
+ ((isPerspective) ? (nearFar.x * nearFar.y) / (z * (nearFar.x - nearFar.y) + nearFar.y) : \
+ z * (nearFar.y - nearFar.x) + nearFar.x) /* Only true for camera view! */
in vec4 uvcoordsvar;