EEVEE Next: Motion Blur fixes #110114

Merged
Clément Foucault merged 7 commits from pragma37/blender:pull-eevee-next-motion-blur-fixes into main 2023-08-03 12:48:22 +02:00
4 changed files with 30 additions and 27 deletions
Showing only changes of commit bc572dab0d - Show all commits

View File

@ -234,15 +234,15 @@ void MotionBlurModule::render(View &view, GPUTexture **input_tx, GPUTexture **ou
tile_indirection_buf_.clear_to_zero();
const bool swizzle_vector_tx = inst_.render_buffers.vector_tx_format() == GPU_RG16F;
if (swizzle_vector_tx) {
const bool do_motion_vectors_swizzle = inst_.render_buffers.vector_tx_format() == GPU_RG16F;
pragma37 marked this conversation as resolved Outdated

Avoid the _tx suffix. It is reserved for textures. do_motion_vector_swizzle seems better.

Avoid the `_tx` suffix. It is reserved for textures. `do_motion_vector_swizzle` seems better.
if (do_motion_vectors_swizzle) {
/* Change texture swizzling to avoid complexity in gather pass shader. */
GPU_texture_swizzle_set(inst_.render_buffers.vector_tx, "rgrg");
}
inst_.manager->submit(motion_blur_ps_, view);
if (swizzle_vector_tx) {
if (do_motion_vectors_swizzle) {
/* Reset swizzle since this texture might be reused in other places. */
GPU_texture_swizzle_set(inst_.render_buffers.vector_tx, "rgba");
}

View File

@ -404,4 +404,28 @@ void SyncModule::sync_light_probe(Object *ob, ObjectHandle &ob_handle)
/** \} */
void foreach_hair_particle_handle(Object *ob, ObjectHandle ob_handle, HairHandleCallback callback)
{
int sub_key = 1;
LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) {
if (md->type == eModifierType_ParticleSystem) {
ParticleSystem *particle_sys = reinterpret_cast<ParticleSystemModifierData *>(md)->psys;
ParticleSettings *part_settings = particle_sys->part;
const int draw_as = (part_settings->draw_as == PART_DRAW_REND) ? part_settings->ren_as :
part_settings->draw_as;
if (draw_as != PART_DRAW_PATH ||
!DRW_object_is_visible_psys_in_active_context(ob, particle_sys)) {
continue;
}
ObjectHandle particle_sys_handle = {0};
particle_sys_handle.object_key = ObjectKey(ob_handle.object_key.ob, sub_key++);
particle_sys_handle.recalc = particle_sys->recalc;
callback(particle_sys_handle, *md, *particle_sys);
}
}
}
} // namespace blender::eevee

View File

@ -180,30 +180,8 @@ class SyncModule {
void sync_light_probe(Object *ob, ObjectHandle &ob_handle);
};
template<typename F>
void foreach_hair_particle_handle(Object *ob, ObjectHandle ob_handle, F callback)
{
int sub_key = 1;
LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) {
if (md->type == eModifierType_ParticleSystem) {
ParticleSystem *particle_sys = reinterpret_cast<ParticleSystemModifierData *>(md)->psys;
ParticleSettings *part_settings = particle_sys->part;
const int draw_as = (part_settings->draw_as == PART_DRAW_REND) ? part_settings->ren_as :
part_settings->draw_as;
if (draw_as != PART_DRAW_PATH ||
!DRW_object_is_visible_psys_in_active_context(ob, particle_sys)) {
continue;
}
ObjectHandle particle_sys_handle = {0};
particle_sys_handle.object_key = ObjectKey(ob_handle.object_key.ob, sub_key++);
particle_sys_handle.recalc = particle_sys->recalc;
callback(particle_sys_handle, *md, *particle_sys);
}
}
}
using HairHandleCallback = FunctionRef<void(ObjectHandle, ModifierData &, ParticleSystem &)>;
void foreach_hair_particle_handle(Object *ob, ObjectHandle ob_handle, HairHandleCallback callback);
pragma37 marked this conversation as resolved Outdated

Maybe use FunctionRef instead of template.

Maybe use FunctionRef instead of template.
/** \} */

View File

@ -226,6 +226,7 @@ bool VelocityModule::step_object_sync(Object *ob,
void VelocityModule::geometry_steps_fill()
{
/* Perform offset computation and copy into the geometry step buffer. */
uint dst_ofs = 0;
for (VelocityGeometryData &geom : geometry_map.values()) {
uint src_len = GPU_vertbuf_get_vertex_len(geom.pos_buf);