EEVEE-Next: Fix Vector render pass

This commit is contained in:
2022-07-25 21:25:38 +02:00
parent aacdaa7b1a
commit 0830ff55d8
6 changed files with 17 additions and 8 deletions

View File

@@ -183,20 +183,17 @@ void Film::init(const int2 &extent, const rcti *output_rect)
* Using the render pass ensure we store the center depth. */
render_passes |= EEVEE_RENDER_PASS_Z;
}
/* TEST */
render_passes |= EEVEE_RENDER_PASS_VECTOR;
}
else {
/* Render Case. */
render_passes = eViewLayerEEVEEPassType(inst_.view_layer->eevee.render_passes);
render_passes |= EEVEE_RENDER_PASS_COMBINED;
#define ENABLE_FROM_LEGACY(name_legacy, name_eevee) \
SET_FLAG_FROM_TEST(render_passes, \
(inst_.view_layer->passflag & SCE_PASS_##name_legacy) != 0, \
EEVEE_RENDER_PASS_##name_eevee);
ENABLE_FROM_LEGACY(COMBINED, COMBINED)
ENABLE_FROM_LEGACY(Z, Z)
ENABLE_FROM_LEGACY(MIST, MIST)
ENABLE_FROM_LEGACY(NORMAL, NORMAL)
@@ -209,6 +206,7 @@ void Film::init(const int2 &extent, const rcti *output_rect)
ENABLE_FROM_LEGACY(DIFFUSE_DIRECT, DIFFUSE_LIGHT)
ENABLE_FROM_LEGACY(GLOSSY_DIRECT, SPECULAR_LIGHT)
ENABLE_FROM_LEGACY(ENVIRONMENT, ENVIRONMENT)
ENABLE_FROM_LEGACY(VECTOR, VECTOR)
#undef ENABLE_FROM_LEGACY
}
@@ -458,6 +456,10 @@ float2 Film::pixel_jitter_get() const
eViewLayerEEVEEPassType Film::enabled_passes_get() const
{
if (inst_.is_viewport() && data_.use_reprojection) {
/* Enable motion vector rendering but not the accumulation buffer. */
return enabled_passes_ | EEVEE_RENDER_PASS_VECTOR;
}
return enabled_passes_;
}

View File

@@ -60,6 +60,7 @@ void Instance::init(const int2 &output_res,
sampling.init(scene);
camera.init();
film.init(output_res, output_rect);
velocity.init();
main_view.init();
}
@@ -240,7 +241,6 @@ void Instance::render_frame(RenderLayer *render_layer, const char *view_name)
if (rp) {
float *result = film.read_pass(pass_type);
if (result) {
std::cout << "read " << pass_name << std::endl;
BLI_mutex_lock(&render->update_render_passes_mutex);
/* WORKAROUND: We use texture read to avoid using a framebuffer to get the render result.
* However, on some implementation, we need a buffer with a few extra bytes for the read to

View File

@@ -32,13 +32,17 @@ namespace blender::eevee {
void VelocityModule::init()
{
if (inst_.render && (inst_.film.enabled_passes_get() & EEVEE_RENDER_PASS_VECTOR)) {
/* No motion blur and the vector pass was requested. Do the step sync here. */
if (inst_.render && (inst_.film.enabled_passes_get() & EEVEE_RENDER_PASS_VECTOR) != 0 &&
true /* TODO(fclem) Motion blur */) {
/* No motion blur and the vector pass was requested. Do the steps sync here. */
const Scene *scene = inst_.scene;
float initial_time = scene->r.cfra + scene->r.subframe;
step_sync(STEP_PREVIOUS, initial_time - 1.0f);
step_sync(STEP_NEXT, initial_time + 1.0f);
inst_.set_time(initial_time);
step_ = STEP_CURRENT;
/* Let the main sync loop handle the current step. */
}
}

View File

@@ -636,6 +636,8 @@ void film_process_data(ivec2 texel_film, out vec4 out_color, out float out_depth
vec4 normal = texelFetch(normal_tx, film_sample.texel, 0);
float depth = texelFetch(depth_tx, film_sample.texel, 0).x;
vec4 vector = velocity_resolve(vector_tx, film_sample.texel, depth);
/* Transform to pixel space. */
vector *= vec4(film_buf.render_extent, -film_buf.render_extent);
film_store_depth(texel_film, depth, out_depth);
film_store_data(texel_film, film_buf.normal_id, normal, out_color);

View File

@@ -56,6 +56,7 @@ vec4 velocity_background(vec3 vV)
/**
* Load and resolve correct velocity as some pixels might still not have correct
* motion data for performance reasons.
* Returns motion vector in render UV space.
*/
vec4 velocity_resolve(sampler2D vector_tx, ivec2 texel, float depth)
{

View File

@@ -37,7 +37,7 @@ typedef enum eViewLayerEEVEEPassType {
EEVEE_RENDER_PASS_CRYPTOMATTE = (1 << 16),
EEVEE_RENDER_PASS_VECTOR = (1 << 17),
} eViewLayerEEVEEPassType;
#define EEVEE_RENDER_PASS_MAX_BIT 17
#define EEVEE_RENDER_PASS_MAX_BIT 18
/* #ViewLayerAOV.type */
typedef enum eViewLayerAOVType {