diff options
author | Hans Goudey <h.goudey@me.com> | 2022-04-14 06:07:31 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2022-04-14 06:07:31 +0300 |
commit | f31c3f8114616bb8964c8e7e67cbcb79e269ffef (patch) | |
tree | e7b52d08710a991226253245436fd1ba068d91c8 /source/blender/draw/engines/eevee/eevee_motion_blur.c | |
parent | f84f9eb8ed439e5d3409f15109bdb67cd87b7fcf (diff) |
Curves: Split curve EEVEE/workbench functions from particle hair
The GPU evaluation for curves will have to change significantly from the
current particle hair drawing code, due to its more general use cases
and support for more curve types. To simplify that process and avoid
introducing regressions for the rendering of hair particle systems,
this commit splits drawing functions for the curves object and
particle hair.
The changes are just inlining of functions and copying code
where necessary.
Differential Revision: https://developer.blender.org/D14576
Diffstat (limited to 'source/blender/draw/engines/eevee/eevee_motion_blur.c')
-rw-r--r-- | source/blender/draw/engines/eevee/eevee_motion_blur.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/source/blender/draw/engines/eevee/eevee_motion_blur.c b/source/blender/draw/engines/eevee/eevee_motion_blur.c index fbc19a01a8b..0ef2e11131e 100644 --- a/source/blender/draw/engines/eevee/eevee_motion_blur.c +++ b/source/blender/draw/engines/eevee/eevee_motion_blur.c @@ -270,6 +270,57 @@ void EEVEE_motion_blur_hair_cache_populate(EEVEE_ViewLayerData *UNUSED(sldata), } } +void EEVEE_motion_blur_curves_cache_populate(EEVEE_ViewLayerData *UNUSED(sldata), + EEVEE_Data *vedata, + Object *ob) +{ + EEVEE_PassList *psl = vedata->psl; + EEVEE_StorageList *stl = vedata->stl; + EEVEE_EffectsInfo *effects = stl->effects; + + if (!DRW_state_is_scene_render() || psl->velocity_hair == NULL) { + return; + } + + /* For now we assume curves objects are always moving. */ + EEVEE_ObjectMotionData *mb_data = EEVEE_motion_blur_object_data_get(&effects->motion_blur, ob); + if (mb_data == NULL) { + return; + } + + int mb_step = effects->motion_blur_step; + /* Store transform. */ + copy_m4_m4(mb_data->obmat[mb_step], ob->obmat); + + EEVEE_HairMotionData *mb_curves = EEVEE_motion_blur_curves_data_get(mb_data, ob); + + if (mb_step == MB_CURR) { + /* Fill missing matrices if the object was hidden in previous or next frame. */ + if (is_zero_m4(mb_data->obmat[MB_PREV])) { + copy_m4_m4(mb_data->obmat[MB_PREV], mb_data->obmat[MB_CURR]); + } + if (is_zero_m4(mb_data->obmat[MB_NEXT])) { + copy_m4_m4(mb_data->obmat[MB_NEXT], mb_data->obmat[MB_CURR]); + } + + GPUTexture *tex_prev = mb_curves->psys[0].step_data[MB_PREV].hair_pos_tx; + GPUTexture *tex_next = mb_curves->psys[0].step_data[MB_NEXT].hair_pos_tx; + + DRWShadingGroup *grp = DRW_shgroup_curves_create_sub(ob, effects->motion_blur.hair_grp, NULL); + DRW_shgroup_uniform_mat4(grp, "prevModelMatrix", mb_data->obmat[MB_PREV]); + DRW_shgroup_uniform_mat4(grp, "currModelMatrix", mb_data->obmat[MB_CURR]); + DRW_shgroup_uniform_mat4(grp, "nextModelMatrix", mb_data->obmat[MB_NEXT]); + DRW_shgroup_uniform_texture(grp, "prvBuffer", tex_prev); + DRW_shgroup_uniform_texture(grp, "nxtBuffer", tex_next); + DRW_shgroup_uniform_bool(grp, "useDeform", &mb_curves->use_deform, 1); + } + else { + /* Store vertex position buffer. */ + mb_curves->psys[0].step_data[mb_step].hair_pos = DRW_curves_pos_buffer_get(ob); + mb_curves->use_deform = true; + } +} + void EEVEE_motion_blur_cache_populate(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *vedata, Object *ob) |