forked from bartvdbraak/blender
Fix T93711: Cycles diffuse/glossy baking does not write alpha
With the change to use render passes internally the alpha channel got lost. Add support for these render passes to output an alpha channel for baking.
This commit is contained in:
parent
14d261d23a
commit
1ac2d2dcb6
@ -141,6 +141,7 @@ bool PassAccessor::get_render_tile_pixels(const RenderBuffers *render_buffers,
|
||||
const PassType type = pass_access_info_.type;
|
||||
const PassMode mode = pass_access_info_.mode;
|
||||
const PassInfo pass_info = Pass::get_info(type, pass_access_info_.include_albedo);
|
||||
int num_written_components = pass_info.num_components;
|
||||
|
||||
if (pass_info.num_components == 1) {
|
||||
/* Single channel passes. */
|
||||
@ -188,8 +189,10 @@ bool PassAccessor::get_render_tile_pixels(const RenderBuffers *render_buffers,
|
||||
else if ((pass_info.divide_type != PASS_NONE || pass_info.direct_type != PASS_NONE ||
|
||||
pass_info.indirect_type != PASS_NONE) &&
|
||||
mode != PassMode::DENOISED) {
|
||||
/* RGB lighting passes that need to divide out color and/or sum direct and indirect. */
|
||||
/* RGB lighting passes that need to divide out color and/or sum direct and indirect.
|
||||
* These can also optionally write alpha like the combined pass. */
|
||||
get_pass_light_path(render_buffers, buffer_params, destination);
|
||||
num_written_components = 4;
|
||||
}
|
||||
else {
|
||||
/* Passes that need no special computation, or denoised passes that already
|
||||
@ -215,7 +218,7 @@ bool PassAccessor::get_render_tile_pixels(const RenderBuffers *render_buffers,
|
||||
}
|
||||
}
|
||||
|
||||
pad_pixels(buffer_params, destination, pass_info.num_components);
|
||||
pad_pixels(buffer_params, destination, num_written_components);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -214,6 +214,21 @@ ccl_device_inline void film_get_pass_pixel_light_path(
|
||||
pixel[0] = f.x;
|
||||
pixel[1] = f.y;
|
||||
pixel[2] = f.z;
|
||||
|
||||
/* Optional alpha channel. */
|
||||
if (kfilm_convert->num_components >= 4) {
|
||||
if (kfilm_convert->pass_combined != PASS_UNUSED) {
|
||||
float scale, scale_exposure;
|
||||
film_get_scale_and_scale_exposure(kfilm_convert, buffer, &scale, &scale_exposure);
|
||||
|
||||
ccl_global const float *in_combined = buffer + kfilm_convert->pass_combined;
|
||||
const float alpha = in_combined[3] * scale;
|
||||
pixel[3] = film_transparency_to_alpha(alpha);
|
||||
}
|
||||
else {
|
||||
pixel[3] = 1.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ccl_device_inline void film_get_pass_pixel_float3(ccl_global const KernelFilmConvert *ccl_restrict
|
||||
|
Loading…
Reference in New Issue
Block a user