[Bf-blender-cvs] [dc1a1d6a2ad] cycles-x: Cycles X: fix/improve handling of mismatches between render pass components
Brecht Van Lommel
noreply at git.blender.org
Thu Jul 29 15:32:51 CEST 2021
Commit: dc1a1d6a2adafb0a8873f93e1eddedb46beaacf6
Author: Brecht Van Lommel
Date: Wed Jul 28 17:34:59 2021 +0200
Branches: cycles-x
https://developer.blender.org/rBdc1a1d6a2adafb0a8873f93e1eddedb46beaacf6
Cycles X: fix/improve handling of mismatches between render pass components
Rules are as follows now:
* Single channel pass: can be read into buffer with 1, 3 or 4 channels
* Motion and cryptomatte passes: must be read into buffer with 4 channels
* RGB, RGBA and vector passes: can be read into buffer with 3 or 4 channels
Differential Revision: https://developer.blender.org/D12063
===================================================================
M intern/cycles/integrator/pass_accessor.cpp
M intern/cycles/kernel/kernel_film.h
===================================================================
diff --git a/intern/cycles/integrator/pass_accessor.cpp b/intern/cycles/integrator/pass_accessor.cpp
index 051ac2e4bd0..0abf35484ea 100644
--- a/intern/cycles/integrator/pass_accessor.cpp
+++ b/intern/cycles/integrator/pass_accessor.cpp
@@ -149,10 +149,8 @@ bool PassAccessor::get_render_tile_pixels(const RenderBuffers *render_buffers,
const PassMode mode = pass_access_info_.mode;
const PassInfo pass_info = Pass::get_info(type);
- DCHECK_LE(pass_info.num_components, destination.num_components)
- << "Number of components mismatch for " << pass_type_as_string(type);
-
if (pass_info.num_components == 1) {
+ /* Single channel passes. */
if (mode == PassMode::DENOISED) {
/* Denoised passes store their final pixels, no need in special calculation. */
get_pass_float(render_buffers, buffer_params, destination);
@@ -173,50 +171,51 @@ bool PassAccessor::get_render_tile_pixels(const RenderBuffers *render_buffers,
get_pass_float(render_buffers, buffer_params, destination);
}
}
- else if (pass_info.num_components == 3) {
- if (mode == PassMode::DENOISED) {
- /* Denoised passes store their final pixels, no need in special calculation. */
- get_pass_float3(render_buffers, buffer_params, destination);
- }
- else if (pass_info.divide_type != PASS_NONE) {
- /* RGB lighting passes that need to divide out color */
- get_pass_divide_even_color(render_buffers, buffer_params, destination);
- }
- else if (type == PASS_SHADOW_CATCHER) {
- get_pass_shadow_catcher(render_buffers, buffer_params, destination);
- }
- else {
- /* RGB/vector */
- get_pass_float3(render_buffers, buffer_params, destination);
- }
+ else if (type == PASS_MOTION) {
+ /* Motion pass. */
+ DCHECK_EQ(destination.num_components, 4) << "Motion pass must have 4 components";
+ get_pass_motion(render_buffers, buffer_params, destination);
+ }
+ else if (type == PASS_CRYPTOMATTE) {
+ /* Cryptomatte pass. */
+ DCHECK_EQ(destination.num_components, 4) << "Cryptomatte pass must have 4 components";
+ get_pass_cryptomatte(render_buffers, buffer_params, destination);
}
- else if (pass_info.num_components == 4) {
+ else {
+ /* RGB, RGBA and vector passes. */
+ DCHECK(destination.num_components == 3 || destination.num_components == 4)
+ << pass_type_as_string(type) << " pass must have 3 or 4 components";
+
if (type == PASS_SHADOW_CATCHER_MATTE && pass_access_info_.use_approximate_shadow_catcher) {
/* Denoised matte with shadow needs to do calculation (will use denoised shadow catcher pass
* to approximate shadow with). */
get_pass_shadow_catcher_matte_with_shadow(render_buffers, buffer_params, destination);
}
- else if (mode == PassMode::DENOISED) {
- /* Denoised passes store their final pixels, no need in special calculation. */
- if (type == PASS_COMBINED || type == PASS_SHADOW_CATCHER ||
- type == PASS_SHADOW_CATCHER_MATTE) {
- get_pass_combined(render_buffers, buffer_params, destination);
- }
- else {
- get_pass_float4(render_buffers, buffer_params, destination);
- }
- }
- else if (type == PASS_MOTION) {
- get_pass_motion(render_buffers, buffer_params, destination);
- }
- else if (type == PASS_CRYPTOMATTE) {
- get_pass_cryptomatte(render_buffers, buffer_params, destination);
+ else if (type == PASS_SHADOW_CATCHER && mode != PassMode::DENOISED) {
+ /* Shadow catcher pass. */
+ get_pass_shadow_catcher(render_buffers, buffer_params, destination);
}
- else if (type == PASS_COMBINED || type == PASS_SHADOW_CATCHER_MATTE) {
- get_pass_combined(render_buffers, buffer_params, destination);
+ else if (pass_info.divide_type != PASS_NONE && mode != PassMode::DENOISED) {
+ /* RGB lighting passes that need to divide out color. */
+ get_pass_divide_even_color(render_buffers, buffer_params, destination);
}
else {
- get_pass_float4(render_buffers, buffer_params, destination);
+ /* Passes that need no special computation, or denoised passes that already
+ * had the computation done. */
+ if (pass_info.num_components == 3) {
+ get_pass_float3(render_buffers, buffer_params, destination);
+ }
+ else if (pass_info.num_components == 4) {
+ if (type == PASS_COMBINED || type == PASS_SHADOW_CATCHER ||
+ type == PASS_SHADOW_CATCHER_MATTE) {
+ /* Passes with transparency as 4th component. */
+ get_pass_combined(render_buffers, buffer_params, destination);
+ }
+ else {
+ /* Passes with alpha as 4th component. */
+ get_pass_float4(render_buffers, buffer_params, destination);
+ }
+ }
}
}
diff --git a/intern/cycles/kernel/kernel_film.h b/intern/cycles/kernel/kernel_film.h
index bada8b1eec4..00607d7a970 100644
--- a/intern/cycles/kernel/kernel_film.h
+++ b/intern/cycles/kernel/kernel_film.h
@@ -437,7 +437,9 @@ ccl_device_inline void film_get_pass_pixel_shadow_catcher_matte_with_shadow(
pixel[0] = pixel_value.x;
pixel[1] = pixel_value.y;
pixel[2] = pixel_value.z;
- pixel[3] = pixel_value.w;
+ if (kfilm_convert->num_components == 4) {
+ pixel[3] = pixel_value.w;
+ }
}
/* --------------------------------------------------------------------
More information about the Bf-blender-cvs
mailing list