Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2022-05-18 23:12:07 +0300
committerClément Foucault <foucault.clem@gmail.com>2022-05-19 00:01:08 +0300
commit0fcfc4cc5be839da4cbd5aa84443b6954e6ebbf4 (patch)
tree17cf8e13d2550b37ab586286cf2cdbc6b05a744a /source/blender/draw/engines/eevee_next/eevee_shader_shared.hh
parent33c5adba627b60d8a7504704bc5e9c80d7bd5ff0 (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_shader_shared.hh')
-rw-r--r--source/blender/draw/engines/eevee_next/eevee_shader_shared.hh51
1 files changed, 51 insertions, 0 deletions
diff --git a/source/blender/draw/engines/eevee_next/eevee_shader_shared.hh b/source/blender/draw/engines/eevee_next/eevee_shader_shared.hh
index 97fc9c5a547..d9fee1b6073 100644
--- a/source/blender/draw/engines/eevee_next/eevee_shader_shared.hh
+++ b/source/blender/draw/engines/eevee_next/eevee_shader_shared.hh
@@ -74,6 +74,54 @@ BLI_STATIC_ASSERT_ALIGN(CameraData, 16)
/** \} */
/* -------------------------------------------------------------------- */
+/** \name VelocityModule
+ * \{ */
+
+#define VELOCITY_INVALID 512.0
+
+enum eVelocityStep : uint32_t {
+ STEP_PREVIOUS = 0,
+ STEP_NEXT = 1,
+ STEP_CURRENT = 2,
+};
+
+struct VelocityObjectIndex {
+ /** Offset inside #VelocityObjectBuf for each timestep. Indexed using eVelocityStep. */
+ int3 ofs;
+ /** Temporary index to copy this to the #VelocityIndexBuf. */
+ uint resource_id;
+
+#ifdef __cplusplus
+ VelocityObjectIndex() : ofs(-1, -1, -1), resource_id(-1){};
+#endif
+};
+BLI_STATIC_ASSERT_ALIGN(VelocityObjectIndex, 16)
+
+struct VelocityGeometryIndex {
+ /** Offset inside #VelocityGeometryBuf for each timestep. Indexed using eVelocityStep. */
+ int3 ofs;
+ /** If true, compute deformation motion blur. */
+ bool1 do_deform;
+ /** Length of data inside #VelocityGeometryBuf for each timestep. Indexed using eVelocityStep. */
+ int3 len;
+
+ int _pad0;
+
+#ifdef __cplusplus
+ VelocityGeometryIndex() : ofs(-1, -1, -1), do_deform(false), len(-1, -1, -1), _pad0(1){};
+#endif
+};
+BLI_STATIC_ASSERT_ALIGN(VelocityGeometryIndex, 16)
+
+struct VelocityIndex {
+ VelocityObjectIndex obj;
+ VelocityGeometryIndex geo;
+};
+BLI_STATIC_ASSERT_ALIGN(VelocityGeometryIndex, 16)
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
/** \name Ray-Tracing
* \{ */
@@ -131,6 +179,9 @@ float4 utility_tx_sample(sampler2DArray util_tx, float2 uv, float layer)
#ifdef __cplusplus
using CameraDataBuf = draw::UniformBuffer<CameraData>;
+using VelocityIndexBuf = draw::StorageArrayBuffer<VelocityIndex, 16>;
+using VelocityObjectBuf = draw::StorageArrayBuffer<float4x4, 16>;
+using VelocityGeometryBuf = draw::StorageArrayBuffer<float4, 16, true>;
} // namespace blender::eevee
#endif