Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/engines/eevee/eevee_motion_blur.c
| Show First 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | |||||
| static struct { | static struct { | ||||
| /* Motion Blur */ | /* Motion Blur */ | ||||
| struct GPUShader *motion_blur_sh; | struct GPUShader *motion_blur_sh; | ||||
| } e_data = {NULL}; /* Engine data */ | } e_data = {NULL}; /* Engine data */ | ||||
| extern char datatoc_effect_motion_blur_frag_glsl[]; | extern char datatoc_effect_motion_blur_frag_glsl[]; | ||||
| static void eevee_motion_blur_camera_get_matrix_at_time(Scene *scene, | static void eevee_motion_blur_camera_get_matrix_at_time( | ||||
| Scene *scene, | |||||
| ARegion *region, | ARegion *region, | ||||
| RegionView3D *rv3d, | RegionView3D *rv3d, | ||||
| View3D *v3d, | View3D *v3d, | ||||
| Object *camera, | Object *camera, | ||||
| float time, | const AnimationEvalContext *anim_eval_context, | ||||
| float r_mat[4][4]) | float r_mat[4][4]) | ||||
| { | { | ||||
| float obmat[4][4]; | float obmat[4][4]; | ||||
| /* HACK */ | /* HACK */ | ||||
| Object cam_cpy = *camera; | Object cam_cpy = *camera; | ||||
| Camera camdata_cpy = *(Camera *)(camera->data); | Camera camdata_cpy = *(Camera *)(camera->data); | ||||
| cam_cpy.data = &camdata_cpy; | cam_cpy.data = &camdata_cpy; | ||||
| /* Reset original pointers, so direct evaluation does not attempt to flush | /* Reset original pointers, so direct evaluation does not attempt to flush | ||||
| * animation back to the original object: otherwise viewport with motion | * animation back to the original object: otherwise viewport with motion | ||||
| * blur enabled will always loose non-keyed changes. */ | * blur enabled will always loose non-keyed changes. */ | ||||
| cam_cpy.id.orig_id = NULL; | cam_cpy.id.orig_id = NULL; | ||||
| camdata_cpy.id.orig_id = NULL; | camdata_cpy.id.orig_id = NULL; | ||||
| const DRWContextState *draw_ctx = DRW_context_state_get(); | const DRWContextState *draw_ctx = DRW_context_state_get(); | ||||
| /* Past matrix */ | /* Past matrix */ | ||||
| /* FIXME : This is a temporal solution that does not take care of parent animations */ | /* FIXME : This is a temporal solution that does not take care of parent animations */ | ||||
| /* Recalc Anim manually */ | /* Recalc Anim manually */ | ||||
| BKE_animsys_evaluate_animdata(&camdata_cpy.id, camdata_cpy.adt, time, ADT_RECALC_ALL, false); | BKE_animsys_evaluate_animdata( | ||||
| BKE_object_where_is_calc_time(draw_ctx->depsgraph, scene, &cam_cpy, time); | &camdata_cpy.id, camdata_cpy.adt, anim_eval_context, ADT_RECALC_ALL, false); | ||||
| BKE_object_where_is_calc_time( | |||||
| draw_ctx->depsgraph, scene, &cam_cpy, anim_eval_context->eval_time); | |||||
| /* Compute winmat */ | /* Compute winmat */ | ||||
| CameraParams params; | CameraParams params; | ||||
| BKE_camera_params_init(¶ms); | BKE_camera_params_init(¶ms); | ||||
| if (v3d != NULL) { | if (v3d != NULL) { | ||||
| BKE_camera_params_from_view3d(¶ms, draw_ctx->depsgraph, v3d, rv3d); | BKE_camera_params_from_view3d(¶ms, draw_ctx->depsgraph, v3d, rv3d); | ||||
| BKE_camera_params_compute_viewplane(¶ms, region->winx, region->winy, 1.0f, 1.0f); | BKE_camera_params_compute_viewplane(¶ms, region->winx, region->winy, 1.0f, 1.0f); | ||||
| ▲ Show 20 Lines • Show All 58 Lines • ▼ Show 20 Lines | if (camera && (camera->type == OB_CAMERA) && (camera->data != NULL)) { | ||||
| copy_m4_m4(effects->prev_drw_persmat, persmat); | copy_m4_m4(effects->prev_drw_persmat, persmat); | ||||
| } | } | ||||
| } | } | ||||
| effects->motion_blur_mat_cached = view_is_valid && !DRW_state_is_image_render(); | effects->motion_blur_mat_cached = view_is_valid && !DRW_state_is_image_render(); | ||||
| /* Current matrix */ | /* Current matrix */ | ||||
| if (effects->motion_blur_mat_cached == false) { | if (effects->motion_blur_mat_cached == false) { | ||||
| eevee_motion_blur_camera_get_matrix_at_time( | const AnimationEvalContext anim_eval_context = BKE_animsys_eval_context( | ||||
| scene, region, rv3d, v3d, ob_camera_eval, ctime, effects->current_world_to_ndc); | draw_ctx->depsgraph, ctime); | ||||
| eevee_motion_blur_camera_get_matrix_at_time(scene, | |||||
| region, | |||||
| rv3d, | |||||
| v3d, | |||||
| ob_camera_eval, | |||||
| &anim_eval_context, | |||||
| effects->current_world_to_ndc); | |||||
| } | } | ||||
| /* Only continue if camera is not being keyed */ | /* Only continue if camera is not being keyed */ | ||||
| if (DRW_state_is_image_render() || | if (DRW_state_is_image_render() || | ||||
| compare_m4m4(persmat, effects->current_world_to_ndc, 0.0001f)) { | compare_m4m4(persmat, effects->current_world_to_ndc, 0.0001f)) { | ||||
| /* Past matrix */ | /* Past matrix */ | ||||
| if (effects->motion_blur_mat_cached == false) { | if (effects->motion_blur_mat_cached == false) { | ||||
| eevee_motion_blur_camera_get_matrix_at_time( | const AnimationEvalContext anim_eval_context = BKE_animsys_eval_context( | ||||
| scene, region, rv3d, v3d, ob_camera_eval, ctime - delta, effects->past_world_to_ndc); | draw_ctx->depsgraph, ctime - delta); | ||||
| eevee_motion_blur_camera_get_matrix_at_time(scene, | |||||
| region, | |||||
| rv3d, | |||||
| v3d, | |||||
| ob_camera_eval, | |||||
| &anim_eval_context, | |||||
| effects->past_world_to_ndc); | |||||
| #if 0 /* for future high quality blur */ | #if 0 /* for future high quality blur */ | ||||
| /* Future matrix */ | /* Future matrix */ | ||||
| const AnimationEvalContext anim_eval_context = BKE_animsys_eval_context(draw_ctx->depsgraph, | |||||
| ctime + delta); | |||||
| eevee_motion_blur_camera_get_matrix_at_time( | eevee_motion_blur_camera_get_matrix_at_time( | ||||
| scene, region, rv3d, v3d, ob_camera_eval, ctime + delta, effects->future_world_to_ndc); | scene, region, rv3d, v3d, ob_camera_eval, &anim_eval_context, effects->future_world_to_ndc); | ||||
| #endif | #endif | ||||
| invert_m4_m4(effects->current_ndc_to_world, effects->current_world_to_ndc); | invert_m4_m4(effects->current_ndc_to_world, effects->current_world_to_ndc); | ||||
| } | } | ||||
| effects->motion_blur_mat_cached = true; | effects->motion_blur_mat_cached = true; | ||||
| effects->motion_blur_samples = scene_eval->eevee.motion_blur_samples; | effects->motion_blur_samples = scene_eval->eevee.motion_blur_samples; | ||||
| if (!e_data.motion_blur_sh) { | if (!e_data.motion_blur_sh) { | ||||
| ▲ Show 20 Lines • Show All 53 Lines • Show Last 20 Lines | |||||