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>2020-06-19 18:02:55 +0300
committerClément Foucault <foucault.clem@gmail.com>2020-06-19 18:05:49 +0300
commitf84414d6e14c42bf0f96b128c35d29bc2da59087 (patch)
tree27bfac79fd3371b3cc58305cb72f1ce39ddbc28a /source/blender/gpu
parente18d6f520693e31a46226821cad1226e400eb0bc (diff)
EEEVEE: Object Motion Blur: Initial Implementation
This adds object motion blur vectors for EEVEE as well as better noise reduction for it. For TAA reprojection we just compute the motion vector on the fly based on camera motion and depth buffer. This makes possible to store another motion vector only for the blurring which is not useful for TAA history fetching. Motion Data is saved per object & per geometry if using deformation blur. We support deformation motion blur by saving previous VBO and modifying the actual GPUBatch for the geometry to include theses VBOs. We store Previous and Next frame motion in the same motion vector buffer (RG for prev and BA for next). This makes non linear motion blur (like rotating objects) less prone to outward/inward blur. We also improve the motion blur post process to expand outside the objects border. We use a tile base approach and the max size of the blur is set via a new render setting. We use a background reconstruction method that needs another setting (Background Separation). Sampling is done using a fixed 8 dithered samples per direction. The final render samples will clear the noise like other stochastic effects. One caveat is that hair particles are not yet supported. Support will come in another patch. Reviewed By: jbakker Differential Revision: https://developer.blender.org/D7297
Diffstat (limited to 'source/blender/gpu')
-rw-r--r--source/blender/gpu/GPU_vertex_buffer.h2
-rw-r--r--source/blender/gpu/GPU_vertex_format.h4
-rw-r--r--source/blender/gpu/intern/gpu_vertex_buffer.c29
-rw-r--r--source/blender/gpu/intern/gpu_vertex_format.c14
4 files changed, 49 insertions, 0 deletions
diff --git a/source/blender/gpu/GPU_vertex_buffer.h b/source/blender/gpu/GPU_vertex_buffer.h
index fe45ec7b78b..f9bdf726930 100644
--- a/source/blender/gpu/GPU_vertex_buffer.h
+++ b/source/blender/gpu/GPU_vertex_buffer.h
@@ -80,6 +80,8 @@ void GPU_vertbuf_init_with_format_ex(GPUVertBuf *, const GPUVertFormat *, GPUUsa
#define GPU_vertbuf_init_with_format(verts, format) \
GPU_vertbuf_init_with_format_ex(verts, format, GPU_USAGE_STATIC)
+GPUVertBuf *GPU_vertbuf_duplicate(GPUVertBuf *verts);
+
uint GPU_vertbuf_size_get(const GPUVertBuf *);
void GPU_vertbuf_data_alloc(GPUVertBuf *, uint v_len);
void GPU_vertbuf_data_resize(GPUVertBuf *, uint v_len);
diff --git a/source/blender/gpu/GPU_vertex_format.h b/source/blender/gpu/GPU_vertex_format.h
index 61b14a4c5c0..34bfbb27823 100644
--- a/source/blender/gpu/GPU_vertex_format.h
+++ b/source/blender/gpu/GPU_vertex_format.h
@@ -124,6 +124,10 @@ BLI_INLINE const char *GPU_vertformat_attr_name_get(const GPUVertFormat *format,
return format->names + attr->names[n_idx];
}
+/* WARNING: Can only rename using a string with same character count.
+ * WARNING: This removes all other aliases of this attrib */
+void GPU_vertformat_attr_rename(GPUVertFormat *format, int attr, const char *new_name);
+
void GPU_vertformat_safe_attr_name(const char *attr_name, char *r_safe_name, uint max_len);
/* format conversion */
diff --git a/source/blender/gpu/intern/gpu_vertex_buffer.c b/source/blender/gpu/intern/gpu_vertex_buffer.c
index 25daabe601d..3b4d469542c 100644
--- a/source/blender/gpu/intern/gpu_vertex_buffer.c
+++ b/source/blender/gpu/intern/gpu_vertex_buffer.c
@@ -85,6 +85,35 @@ void GPU_vertbuf_init_with_format_ex(GPUVertBuf *verts,
}
}
+GPUVertBuf *GPU_vertbuf_duplicate(GPUVertBuf *verts)
+{
+ GPUVertBuf *verts_dst = GPU_vertbuf_create(GPU_USAGE_STATIC);
+ /* Full copy. */
+ *verts_dst = *verts;
+ GPU_vertformat_copy(&verts_dst->format, &verts->format);
+
+ if (verts->vbo_id) {
+ uint buffer_sz = GPU_vertbuf_size_get(verts);
+
+ verts_dst->vbo_id = GPU_buf_alloc();
+
+ glBindBuffer(GL_COPY_READ_BUFFER, verts->vbo_id);
+ glBindBuffer(GL_COPY_WRITE_BUFFER, verts_dst->vbo_id);
+
+ glBufferData(GL_COPY_WRITE_BUFFER, buffer_sz, NULL, convert_usage_type_to_gl(verts->usage));
+
+ glCopyBufferSubData(GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, buffer_sz);
+#if VRAM_USAGE
+ vbo_memory_usage += GPU_vertbuf_size_get(verts);
+#endif
+ }
+
+ if (verts->data) {
+ verts_dst->data = MEM_dupallocN(verts->data);
+ }
+ return verts_dst;
+}
+
/** Same as discard but does not free. */
void GPU_vertbuf_clear(GPUVertBuf *verts)
{
diff --git a/source/blender/gpu/intern/gpu_vertex_format.c b/source/blender/gpu/intern/gpu_vertex_format.c
index b84a7e0f554..585a22277b2 100644
--- a/source/blender/gpu/intern/gpu_vertex_format.c
+++ b/source/blender/gpu/intern/gpu_vertex_format.c
@@ -262,6 +262,20 @@ int GPU_vertformat_attr_id_get(const GPUVertFormat *format, const char *name)
return -1;
}
+void GPU_vertformat_attr_rename(GPUVertFormat *format, int attr_id, const char *new_name)
+{
+ BLI_assert(attr_id > -1 && attr_id < format->attr_len);
+ GPUVertAttr *attr = &format->attrs[attr_id];
+ char *attr_name = (char *)GPU_vertformat_attr_name_get(format, attr, 0);
+ BLI_assert(strlen(attr_name) == strlen(new_name));
+ int i = 0;
+ while (attr_name[i] != '\0') {
+ attr_name[i] = new_name[i];
+ i++;
+ }
+ attr->name_len = 1;
+}
+
/* Encode 8 original bytes into 11 safe bytes. */
static void safe_bytes(char out[11], const char data[8])
{