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_pipeline.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_pipeline.cc')
-rw-r--r-- | source/blender/draw/engines/eevee_next/eevee_pipeline.cc | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/source/blender/draw/engines/eevee_next/eevee_pipeline.cc b/source/blender/draw/engines/eevee_next/eevee_pipeline.cc index e31372e770d..8ae19eeebb8 100644 --- a/source/blender/draw/engines/eevee_next/eevee_pipeline.cc +++ b/source/blender/draw/engines/eevee_next/eevee_pipeline.cc @@ -54,11 +54,17 @@ void ForwardPipeline::sync() { DRWState state = DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS; prepass_ps_ = DRW_pass_create("Forward.Opaque.Prepass", state); + prepass_velocity_ps_ = DRW_pass_create("Forward.Opaque.Prepass.Velocity", + state | DRW_STATE_WRITE_COLOR); state |= DRW_STATE_CULL_BACK; prepass_culled_ps_ = DRW_pass_create("Forward.Opaque.Prepass.Culled", state); + prepass_culled_velocity_ps_ = DRW_pass_create("Forward.Opaque.Prepass.Velocity", + state | DRW_STATE_WRITE_COLOR); - DRW_pass_link(prepass_ps_, prepass_culled_ps_); + DRW_pass_link(prepass_ps_, prepass_velocity_ps_); + DRW_pass_link(prepass_velocity_ps_, prepass_culled_ps_); + DRW_pass_link(prepass_culled_ps_, prepass_culled_velocity_ps_); } { DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL; @@ -110,11 +116,17 @@ DRWShadingGroup *ForwardPipeline::material_opaque_add(::Material *blender_mat, G return grp; } -DRWShadingGroup *ForwardPipeline::prepass_opaque_add(::Material *blender_mat, GPUMaterial *gpumat) +DRWShadingGroup *ForwardPipeline::prepass_opaque_add(::Material *blender_mat, + GPUMaterial *gpumat, + bool has_motion) { - DRWPass *pass = (blender_mat->blend_flag & MA_BL_CULL_BACKFACE) ? prepass_culled_ps_ : - prepass_ps_; + DRWPass *pass = (blender_mat->blend_flag & MA_BL_CULL_BACKFACE) ? + (has_motion ? prepass_culled_velocity_ps_ : prepass_culled_ps_) : + (has_motion ? prepass_velocity_ps_ : prepass_ps_); DRWShadingGroup *grp = DRW_shgroup_material_create(gpumat, pass); + if (has_motion) { + inst_.velocity.bind_resources(grp); + } return grp; } @@ -181,15 +193,19 @@ DRWShadingGroup *ForwardPipeline::prepass_transparent_add(::Material *blender_ma } void ForwardPipeline::render(const DRWView *view, + Framebuffer &prepass_fb, + Framebuffer &combined_fb, GPUTexture *depth_tx, GPUTexture *UNUSED(combined_tx)) { - UNUSED_VARS(view, depth_tx); + UNUSED_VARS(view, depth_tx, prepass_fb, combined_fb); // HiZBuffer &hiz = inst_.hiz_front; DRW_stats_group_start("ForwardOpaque"); + GPU_framebuffer_bind(prepass_fb); DRW_draw_pass(prepass_ps_); + // hiz.set_dirty(); // if (inst_.raytracing.enabled()) { @@ -199,6 +215,7 @@ void ForwardPipeline::render(const DRWView *view, // inst_.shadows.set_view(view, depth_tx); + GPU_framebuffer_bind(combined_fb); DRW_draw_pass(opaque_ps_); DRW_stats_group_end(); |