diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2022-05-18 23:12:07 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2022-05-19 00:01:08 +0300 |
commit | 0fcfc4cc5be839da4cbd5aa84443b6954e6ebbf4 (patch) | |
tree | 17cf8e13d2550b37ab586286cf2cdbc6b05a744a /source/blender/draw/engines/eevee_next/eevee_sync.cc | |
parent | 33c5adba627b60d8a7504704bc5e9c80d7bd5ff0 (diff) |
EEVEE-Next: Add Velocity module
This module allow tracking of object and geometry data accross time.
This commit adds no user visible changes.
It work in both viewport (*) and render mode, gives correct motion
for any camera projection type and is compatible with displacement (**).
It is a huge improvement upon the old EEVEE velocity which was only used
for motion blur and only available in render.
It is also an improvement for speed as the animated objects do not need to
be rendered a 3rd time. The code is also much cleaner: no GPUVertBuf
duplication, no GPUBatch amendment, no special cases for different geometry
types, no DRWShadingGroup per object, no double buffering of velocity.
The module is still work in progress as the final output may still be
flawed.
(*): Viewport support is already working but there might be some cases where
mapping will fail. For instance if topology changes but not vertex count.
(**): Displacement does not contribute to motion vectors. Surfaces using
displacement will have the same motion vectors as if they were not displaced.
Diffstat (limited to 'source/blender/draw/engines/eevee_next/eevee_sync.cc')
-rw-r--r-- | source/blender/draw/engines/eevee_next/eevee_sync.cc | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/source/blender/draw/engines/eevee_next/eevee_sync.cc b/source/blender/draw/engines/eevee_next/eevee_sync.cc index efa5fdc89ab..42af251d770 100644 --- a/source/blender/draw/engines/eevee_next/eevee_sync.cc +++ b/source/blender/draw/engines/eevee_next/eevee_sync.cc @@ -104,7 +104,9 @@ static inline void shgroup_geometry_call(DRWShadingGroup *grp, void SyncModule::sync_mesh(Object *ob, ObjectHandle &ob_handle) { - MaterialArray &material_array = inst_.materials.material_array_get(ob); + bool has_motion = inst_.velocity.step_object_sync(ob, ob_handle.object_key, ob_handle.recalc); + + MaterialArray &material_array = inst_.materials.material_array_get(ob, has_motion); GPUBatch **mat_geom = DRW_cache_object_surface_material_get( ob, material_array.gpu_materials.data(), material_array.gpu_materials.size()); @@ -129,9 +131,6 @@ void SyncModule::sync_mesh(Object *ob, ObjectHandle &ob_handle) is_alpha_blend = is_alpha_blend || material->is_alpha_blend_transparent; } - UNUSED_VARS(ob_handle); - // shading_passes.velocity.mesh_add(ob, ob_handle); - // shadows.sync_object(ob, ob_handle, is_shadow_caster, is_alpha_blend); } @@ -156,8 +155,11 @@ struct gpIterData { int vcount = 0; bool instancing = false; - gpIterData(Instance &inst_, Object *ob_) - : inst(inst_), ob(ob_), material_array(inst_.materials.material_array_get(ob_)) + gpIterData(Instance &inst_, Object *ob_, ObjectHandle &ob_handle) + : inst(inst_), + ob(ob_), + material_array(inst_.materials.material_array_get( + ob_, inst_.velocity.step_object_sync(ob, ob_handle.object_key, ob_handle.recalc))) { cfra = DEG_get_ctime(inst.depsgraph); }; @@ -253,16 +255,12 @@ void SyncModule::sync_gpencil(Object *ob, ObjectHandle &ob_handle) /* TODO(fclem): Waiting for a user option to use the render engine instead of gpencil engine. */ return; - gpIterData iter(inst_, ob); + gpIterData iter(inst_, ob, ob_handle); BKE_gpencil_visible_stroke_iter((bGPdata *)ob->data, nullptr, gpencil_stroke_sync, &iter); gpencil_drawcall_flush(iter); - UNUSED_VARS(ob_handle); - /* TODO(fclem) Gpencil velocity. */ - // shading_passes.velocity.gpencil_add(ob, ob_handle); - // bool is_caster = true; /* TODO material.shadow.shgrp. */ // bool is_alpha_blend = true; /* TODO material.is_alpha_blend. */ // shadows.sync_object(ob, ob_handle, is_caster, is_alpha_blend); @@ -304,12 +302,13 @@ void SyncModule::sync_curves(Object *ob, ObjectHandle &ob_handle, ModifierData * mat_nr = part_settings->omat; } - Material &material = inst_.materials.material_get(ob, mat_nr - 1, MAT_GEOM_CURVES); + bool has_motion = inst_.velocity.step_object_sync(ob, ob_handle.object_key, ob_handle.recalc); + Material &material = inst_.materials.material_get(ob, has_motion, mat_nr - 1, MAT_GEOM_CURVES); shgroup_curves_call(material.shading, ob, part_sys, modifier_data); shgroup_curves_call(material.prepass, ob, part_sys, modifier_data); shgroup_curves_call(material.shadow, ob, part_sys, modifier_data); - UNUSED_VARS(ob_handle); + /* TODO(fclem) Hair velocity. */ // shading_passes.velocity.gpencil_add(ob, ob_handle); |