44 if (!inst_.is_viewport() && !inst_.is_baking() &&
46 !inst_.motion_blur.postfx_enabled())
49 const Scene *scene = inst_.scene;
54 inst_.set_time(initial_time);
75 if (!is_velocity_type || (!partsys_is_visible && !object_is_visible)) {
82 if (partsys_is_visible) {
84 ObjectHandle ob_handle(ob_ref, resource_handle, info.recalc_flags, info.sub_key);
90 if (object_is_visible) {
105 step_object_sync_render(inst_, ob_ref);
115 step_time[step_] = inst_.scene->r.cfra + inst_.scene->r.subframe;
127 bool has_motion = object_has_velocity(ob_handle.
object) ||
133 if (!has_motion && !has_deform) {
144 auto add_cb = [&]() {
148 inst_.scene, ob_handle.
object, &hair_particle->
psys, &hair_particle->
md);
168 has_deform =
data.has_data();
171 bool any_instance_has_motion =
false;
188 vel.
id = velocity_id;
198 if (inst_.is_viewport()) {
211 if (step_ ==
STEP_CURRENT && has_motion ==
true && has_deform ==
false) {
214 if (inst_.is_viewport()) {
215 any_instance_has_motion |= obmat_curr != obmat_prev;
219 any_instance_has_motion |= (obmat_curr != obmat_prev) || (obmat_curr != obmat_next);
224 if (!has_motion && !has_deform) {
236 return has_deform || any_instance_has_motion;
255 inst_.info_append_i18n(
256 "Error: Could not allocate velocity geometry buffer. Only object and camera velocities "
259 vel.geo.len[step_] = -1;
260 vel.geo.ofs[step_] = -1;
277 if (!pos_buf || geom.len == 0) {
281 if (format->stride == 16) {
284 geom.ofs *
sizeof(
float4),
286 geom.len *
sizeof(
float4));
292 copy_ps.
push_constant(
"vertex_stride",
int(format->stride / 4));
296 copy_ps.
dispatch(
int3(group_len_x / verts_per_thread, 1, 1));
301 inst_.manager->submit(copy_ps);
309 vel.geo.len[step_] = geom.
len;
310 vel.geo.ofs[step_] = geom.
ofs;
328 vel.obj.ofs[step_a] = vel.obj.ofs[step_b];
329 vel.obj.ofs[step_b] =
uint(-1);
330 vel.geo.ofs[step_a] = vel.geo.ofs[step_b];
331 vel.geo.len[step_a] = vel.geo.len[step_b];
332 vel.geo.ofs[step_b] =
uint(-1);
333 vel.geo.len[step_b] =
uint(-1);
337 if (inst_.is_viewport()) {
368 if (item.value.obj.resource_index ==
uint32_t(-1)) {
369 deleted_obj.
append(item.key);
372 max_resource_index_ =
max_uu(max_resource_index_, item.value.obj.resource_index);
376 for (
auto &key : deleted_obj) {
386 if (inst_.is_viewport()) {
392 vel.geo.do_deform = pos_buf !=
nullptr &&
402 vel.obj.resource_index =
uint(-1);
413bool VelocityModule::object_has_velocity(
const Object *ob)
426 const bool object_moves =
true;
431bool VelocityModule::object_is_deform(
const Object *ob)
445 if (inst_.is_viewport()) {
456 if (inst_.is_viewport()) {
General operations, lookup, etc. for blender objects.
Types and defines for representing Rigid Body entities.
constexpr IndexRange()=default
void append(const T &value)
int instances_count() const
float4x4 object_to_world(int instance_index) const
ResourceHandle sub_handle(int index) const
void resize(int64_t new_size)
void shader_set(gpu::Shader *shader)
void dispatch(int group_len)
void state_set(DRWState state, int clip_plane_count=0)
void barrier(GPUBarrier type)
void push_constant(const char *name, const float &data)
void bind_ssbo(const char *name, gpu::StorageBuf *buffer)
A running instance of the engine.
ObjectHandle sync_object(const ObjectRef &ob_ref, const ResourceHandleRange &res_handle, uint sub_key=0)
float step_time_delta_get(eVelocityStep start, eVelocityStep end) const
Map< ObjectKey, VelocityObjectData > velocity_map
std::array< CameraDataBuf *, 3 > camera_steps
bool step_object_sync(const ObjectHandle &ob_handle, HairParticleInfo const *hair_particle=nullptr)
bool camera_changed_projection() const
std::array< VelocityObjectBuf *, 3 > object_steps
void geometry_steps_fill()
VelocityIndexBuf indirection_buf
bool camera_has_motion() const
std::array< VelocityGeometryBuf *, 3 > geometry_steps
void step_sync(eVelocityStep step, float time)
Map< uint64_t, VelocityGeometryData > geometry_map
#define VERTEX_COPY_GROUP_SIZE
VecBase< float, D > step(VecOp< float, D >, VecOp< float, D >) RET
detail::Pass< command::DrawCommandBuf > PassSimple
gpu::VertBuf * curves_pos_buffer_get(Object *object)
gpu::VertBuf * hair_pos_buffer_get(Scene *scene, Object *object, ParticleSystem *psys, ModifierData *md)
gpu::Batch * DRW_cache_mesh_surface_get(Object *ob)
gpu::VertBuf * DRW_pointcloud_position_and_radius_buffer_get(Object *ob)
static void step_object_sync_render(Instance &inst, ObjectRef &ob_ref)
void foreach_hair_particle(Instance &inst, ObjectRef &ob_ref, HairHandleCallback callback)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
unsigned __int64 uint64_t
bool BKE_object_moves_in_time(const Object *object, bool recurse_parent)
bool DRW_object_is_renderable(const Object *ob)
MINLINE uint max_uu(uint a, uint b)
MINLINE int max_ii(int a, int b)
const GPUVertFormat * GPU_vertbuf_get_format(const gpu::VertBuf *verts)
MatBase< float, 4, 4 > float4x4
int DRW_object_visibility_in_active_context(const Object *ob)
void DRW_render_object_iter(RenderEngine *engine, Depsgraph *depsgraph, std::function< void(draw::ObjectRef &, RenderEngine *, Depsgraph *)> callback)
VecBase< float, 4 > float4
int GPU_max_work_group_count(int index)
VecBase< int32_t, 3 > int3
BMesh const char void * data
size_t GPU_max_storage_buffer_size()
int BKE_object_is_deform_modified(Scene *scene, Object *ob)
@ GPU_BARRIER_SHADER_STORAGE
void DRW_submission_end()
void GPU_storagebuf_copy_sub_from_vertbuf(gpu::StorageBuf *ssbo, gpu::VertBuf *src, uint dst_offset, uint src_offset, uint copy_size)
Copy a part of a vertex buffer to a storage buffer.
@ EEVEE_RENDER_PASS_VECTOR
MINLINE uint divide_ceil_u(uint a, uint b)
void DRW_submission_start()
uint GPU_vertbuf_get_vertex_len(const gpu::VertBuf *verts)
MINLINE uint ceil_to_multiple_u(uint a, uint b)
struct RigidBodyOb * rigidbody_object
const ResourceHandleRange res_handle
struct VelocityObjectIndex obj