Merge branch 'blender-v3.3-release'
This commit is contained in:
commit
77047d2088
|
@ -412,7 +412,15 @@ void BlenderSync::sync_integrator(BL::ViewLayer &b_view_layer, bool background)
|
|||
integrator->set_direct_light_sampling_type(direct_light_sampling_type);
|
||||
#endif
|
||||
|
||||
const DenoiseParams denoise_params = get_denoise_params(b_scene, b_view_layer, background);
|
||||
DenoiseParams denoise_params = get_denoise_params(b_scene, b_view_layer, background);
|
||||
|
||||
/* No denoising support for vertex color baking, vertices packed into image
|
||||
* buffer have no relation to neighbors. */
|
||||
if (scene->bake_manager->get_baking() &&
|
||||
b_scene.render().bake().target() != BL::BakeSettings::target_IMAGE_TEXTURES) {
|
||||
denoise_params.use = false;
|
||||
}
|
||||
|
||||
integrator->set_use_denoise(denoise_params.use);
|
||||
|
||||
/* Only update denoiser parameters if the denoiser is actually used. This allows to tweak
|
||||
|
|
|
@ -68,8 +68,8 @@ ccl_device_noinline void motion_triangle_shader_setup(KernelGlobals kg,
|
|||
sd->N = Ng;
|
||||
/* Compute derivatives of P w.r.t. uv. */
|
||||
#ifdef __DPDU__
|
||||
sd->dPdu = (verts[0] - verts[2]);
|
||||
sd->dPdv = (verts[1] - verts[2]);
|
||||
sd->dPdu = (verts[1] - verts[0]);
|
||||
sd->dPdv = (verts[2] - verts[0]);
|
||||
#endif
|
||||
/* Compute smooth normal. */
|
||||
if (sd->shader & SHADER_SMOOTH_NORMAL) {
|
||||
|
@ -89,7 +89,7 @@ ccl_device_noinline void motion_triangle_shader_setup(KernelGlobals kg,
|
|||
float u = sd->u;
|
||||
float v = sd->v;
|
||||
float w = 1.0f - u - v;
|
||||
sd->N = (u * normals[0] + v * normals[1] + w * normals[2]);
|
||||
sd->N = (w * normals[0] + u * normals[1] + v * normals[2]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ ccl_device void volume_stack_enter_exit(KernelGlobals kg,
|
|||
break;
|
||||
}
|
||||
|
||||
if (entry.object == sd->object) {
|
||||
if (entry.object == sd->object && entry.shader == sd->shader) {
|
||||
/* Shift back next stack entries. */
|
||||
do {
|
||||
entry = stack_read(i + 1);
|
||||
|
@ -61,7 +61,7 @@ ccl_device void volume_stack_enter_exit(KernelGlobals kg,
|
|||
}
|
||||
|
||||
/* Already in the stack? then we have nothing to do. */
|
||||
if (entry.object == sd->object) {
|
||||
if (entry.object == sd->object && entry.shader == sd->shader) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -408,6 +408,7 @@ void *CustomData_get_layer(const struct CustomData *data, int type);
|
|||
void *CustomData_get_layer_n(const struct CustomData *data, int type, int n);
|
||||
void *CustomData_get_layer_named(const struct CustomData *data, int type, const char *name);
|
||||
int CustomData_get_offset(const struct CustomData *data, int type);
|
||||
int CustomData_get_offset_named(const CustomData *data, int type, const char *name);
|
||||
int CustomData_get_n_offset(const struct CustomData *data, int type, int n);
|
||||
|
||||
int CustomData_get_layer_index(const struct CustomData *data, int type);
|
||||
|
|
|
@ -3477,6 +3477,17 @@ int CustomData_get_n_offset(const CustomData *data, const int type, const int n)
|
|||
return data->layers[layer_index].offset;
|
||||
}
|
||||
|
||||
int CustomData_get_offset_named(const CustomData *data, int type, const char *name)
|
||||
{
|
||||
/* get the layer index of the active layer of type */
|
||||
int layer_index = CustomData_get_named_layer_index(data, type, name);
|
||||
if (layer_index == -1) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return data->layers[layer_index].offset;
|
||||
}
|
||||
|
||||
bool CustomData_set_layer_name(const CustomData *data,
|
||||
const int type,
|
||||
const int n,
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "BKE_attribute.h"
|
||||
#include "BKE_callbacks.h"
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_editmesh.h"
|
||||
#include "BKE_global.h"
|
||||
#include "BKE_image.h"
|
||||
#include "BKE_image_format.h"
|
||||
|
@ -933,7 +934,10 @@ static bool bake_targets_output_external(const BakeAPIRender *bkr,
|
|||
|
||||
/* Vertex Color Bake Targets */
|
||||
|
||||
static bool bake_targets_init_vertex_colors(BakeTargets *targets, Object *ob, ReportList *reports)
|
||||
static bool bake_targets_init_vertex_colors(Main *bmain,
|
||||
BakeTargets *targets,
|
||||
Object *ob,
|
||||
ReportList *reports)
|
||||
{
|
||||
if (ob->type != OB_MESH) {
|
||||
BKE_report(reports, RPT_ERROR, "Color attribute baking is only supported for mesh objects");
|
||||
|
@ -946,6 +950,9 @@ static bool bake_targets_init_vertex_colors(BakeTargets *targets, Object *ob, Re
|
|||
return false;
|
||||
}
|
||||
|
||||
/* Ensure mesh and editmesh topology are in sync. */
|
||||
ED_object_editmode_load(bmain, ob);
|
||||
|
||||
targets->images = MEM_callocN(sizeof(BakeImage), "BakeTargets.images");
|
||||
targets->images_num = 1;
|
||||
|
||||
|
@ -1109,6 +1116,7 @@ static void convert_float_color_to_byte_color(const MPropCol *float_colors,
|
|||
static bool bake_targets_output_vertex_colors(BakeTargets *targets, Object *ob)
|
||||
{
|
||||
Mesh *me = ob->data;
|
||||
BMEditMesh *em = me->edit_mesh;
|
||||
CustomDataLayer *active_color_layer = BKE_id_attributes_active_color_get(&me->id);
|
||||
BLI_assert(active_color_layer != NULL);
|
||||
const eAttrDomain domain = BKE_id_attribute_domain(&me->id, active_color_layer);
|
||||
|
@ -1121,9 +1129,7 @@ static bool bake_targets_output_vertex_colors(BakeTargets *targets, Object *ob)
|
|||
const int totvert = me->totvert;
|
||||
const int totloop = me->totloop;
|
||||
|
||||
MPropCol *mcol = active_color_layer->type == CD_PROP_COLOR ?
|
||||
active_color_layer->data :
|
||||
MEM_malloc_arrayN(totvert, sizeof(MPropCol), __func__);
|
||||
MPropCol *mcol = MEM_malloc_arrayN(totvert, sizeof(MPropCol), __func__);
|
||||
|
||||
/* Accumulate float vertex colors in scene linear color space. */
|
||||
int *num_loops_for_vertex = MEM_callocN(sizeof(int) * me->totvert, "num_loops_for_vertex");
|
||||
|
@ -1143,24 +1149,75 @@ static bool bake_targets_output_vertex_colors(BakeTargets *targets, Object *ob)
|
|||
}
|
||||
}
|
||||
|
||||
if (mcol != active_color_layer->data) {
|
||||
convert_float_color_to_byte_color(mcol, totvert, is_noncolor, active_color_layer->data);
|
||||
MEM_freeN(mcol);
|
||||
if (em) {
|
||||
/* Copy to bmesh. */
|
||||
const int active_color_offset = CustomData_get_offset_named(
|
||||
&em->bm->vdata, active_color_layer->type, active_color_layer->name);
|
||||
BMVert *v;
|
||||
BMIter viter;
|
||||
int i = 0;
|
||||
BM_ITER_MESH (v, &viter, em->bm, BM_VERTS_OF_MESH) {
|
||||
void *data = BM_ELEM_CD_GET_VOID_P(v, active_color_offset);
|
||||
if (active_color_layer->type == CD_PROP_COLOR) {
|
||||
memcpy(data, &mcol[i], sizeof(MPropCol));
|
||||
}
|
||||
else {
|
||||
convert_float_color_to_byte_color(&mcol[i], 1, is_noncolor, data);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* Copy to mesh. */
|
||||
if (active_color_layer->type == CD_PROP_COLOR) {
|
||||
memcpy(active_color_layer->data, mcol, sizeof(MPropCol) * me->totvert);
|
||||
}
|
||||
else {
|
||||
convert_float_color_to_byte_color(mcol, totvert, is_noncolor, active_color_layer->data);
|
||||
}
|
||||
}
|
||||
|
||||
MEM_freeN(mcol);
|
||||
|
||||
MEM_SAFE_FREE(num_loops_for_vertex);
|
||||
}
|
||||
else if (domain == ATTR_DOMAIN_CORNER) {
|
||||
switch (active_color_layer->type) {
|
||||
case CD_PROP_COLOR: {
|
||||
if (em) {
|
||||
/* Copy to bmesh. */
|
||||
const int active_color_offset = CustomData_get_offset_named(
|
||||
&em->bm->ldata, active_color_layer->type, active_color_layer->name);
|
||||
BMFace *f;
|
||||
BMIter fiter;
|
||||
int i = 0;
|
||||
BM_ITER_MESH (f, &fiter, em->bm, BM_FACES_OF_MESH) {
|
||||
BMLoop *l;
|
||||
BMIter liter;
|
||||
BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
|
||||
MPropCol color;
|
||||
zero_v4(color.color);
|
||||
bake_result_add_to_rgba(color.color, &result[i * channels_num], channels_num);
|
||||
i++;
|
||||
|
||||
void *data = BM_ELEM_CD_GET_VOID_P(l, active_color_offset);
|
||||
if (active_color_layer->type == CD_PROP_COLOR) {
|
||||
memcpy(data, &color, sizeof(MPropCol));
|
||||
}
|
||||
else {
|
||||
convert_float_color_to_byte_color(&color, 1, is_noncolor, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* Copy to mesh. */
|
||||
if (active_color_layer->type == CD_PROP_COLOR) {
|
||||
MPropCol *colors = active_color_layer->data;
|
||||
for (int i = 0; i < me->totloop; i++) {
|
||||
zero_v4(colors[i].color);
|
||||
bake_result_add_to_rgba(colors[i].color, &result[i * channels_num], channels_num);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CD_PROP_BYTE_COLOR: {
|
||||
else {
|
||||
MLoopCol *colors = active_color_layer->data;
|
||||
for (int i = 0; i < me->totloop; i++) {
|
||||
MPropCol color;
|
||||
|
@ -1168,10 +1225,7 @@ static bool bake_targets_output_vertex_colors(BakeTargets *targets, Object *ob)
|
|||
bake_result_add_to_rgba(color.color, &result[i * channels_num], channels_num);
|
||||
convert_float_color_to_byte_color(&color, 1, is_noncolor, &colors[i]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
BLI_assert_unreachable();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1201,7 +1255,7 @@ static bool bake_targets_init(const BakeAPIRender *bkr,
|
|||
}
|
||||
}
|
||||
else if (bkr->target == R_BAKE_TARGET_VERTEX_COLORS) {
|
||||
if (!bake_targets_init_vertex_colors(targets, ob, reports)) {
|
||||
if (!bake_targets_init_vertex_colors(bkr->main, targets, ob, reports)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -379,6 +379,8 @@ void register_node_type_cmp_cryptomatte_legacy()
|
|||
node_type_init(&ntype, file_ns::node_init_cryptomatte_legacy);
|
||||
node_type_storage(
|
||||
&ntype, "NodeCryptomatte", file_ns::node_free_cryptomatte, file_ns::node_copy_cryptomatte);
|
||||
ntype.gather_link_search_ops = nullptr;
|
||||
|
||||
nodeRegisterType(&ntype);
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,8 @@ void register_node_type_cmp_sephsva()
|
|||
|
||||
cmp_node_type_base(&ntype, CMP_NODE_SEPHSVA_LEGACY, "Separate HSVA", NODE_CLASS_CONVERTER);
|
||||
ntype.declare = file_ns::cmp_node_sephsva_declare;
|
||||
ntype.gather_link_search_ops = nullptr;
|
||||
|
||||
nodeRegisterType(&ntype);
|
||||
}
|
||||
|
||||
|
@ -56,6 +58,7 @@ void register_node_type_cmp_combhsva()
|
|||
|
||||
cmp_node_type_base(&ntype, CMP_NODE_COMBHSVA_LEGACY, "Combine HSVA", NODE_CLASS_CONVERTER);
|
||||
ntype.declare = file_ns::cmp_node_combhsva_declare;
|
||||
ntype.gather_link_search_ops = nullptr;
|
||||
|
||||
nodeRegisterType(&ntype);
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ void register_node_type_cmp_seprgba()
|
|||
|
||||
cmp_node_type_base(&ntype, CMP_NODE_SEPRGBA_LEGACY, "Separate RGBA", NODE_CLASS_CONVERTER);
|
||||
ntype.declare = file_ns::cmp_node_seprgba_declare;
|
||||
ntype.gather_link_search_ops = nullptr;
|
||||
|
||||
nodeRegisterType(&ntype);
|
||||
}
|
||||
|
@ -56,6 +57,7 @@ void register_node_type_cmp_combrgba()
|
|||
|
||||
cmp_node_type_base(&ntype, CMP_NODE_COMBRGBA_LEGACY, "Combine RGBA", NODE_CLASS_CONVERTER);
|
||||
ntype.declare = file_ns::cmp_node_combrgba_declare;
|
||||
ntype.gather_link_search_ops = nullptr;
|
||||
|
||||
nodeRegisterType(&ntype);
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ void register_node_type_cmp_sepycca()
|
|||
cmp_node_type_base(&ntype, CMP_NODE_SEPYCCA_LEGACY, "Separate YCbCrA", NODE_CLASS_CONVERTER);
|
||||
ntype.declare = file_ns::cmp_node_sepycca_declare;
|
||||
node_type_init(&ntype, file_ns::node_composit_init_mode_sepycca);
|
||||
ntype.gather_link_search_ops = nullptr;
|
||||
|
||||
nodeRegisterType(&ntype);
|
||||
}
|
||||
|
@ -69,6 +70,7 @@ void register_node_type_cmp_combycca()
|
|||
cmp_node_type_base(&ntype, CMP_NODE_COMBYCCA_LEGACY, "Combine YCbCrA", NODE_CLASS_CONVERTER);
|
||||
ntype.declare = file_ns::cmp_node_combycca_declare;
|
||||
node_type_init(&ntype, file_ns::node_composit_init_mode_combycca);
|
||||
ntype.gather_link_search_ops = nullptr;
|
||||
|
||||
nodeRegisterType(&ntype);
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ void register_node_type_cmp_sepyuva()
|
|||
|
||||
cmp_node_type_base(&ntype, CMP_NODE_SEPYUVA_LEGACY, "Separate YUVA", NODE_CLASS_CONVERTER);
|
||||
ntype.declare = file_ns::cmp_node_sepyuva_declare;
|
||||
ntype.gather_link_search_ops = nullptr;
|
||||
|
||||
nodeRegisterType(&ntype);
|
||||
}
|
||||
|
@ -57,6 +58,7 @@ void register_node_type_cmp_combyuva()
|
|||
|
||||
cmp_node_type_base(&ntype, CMP_NODE_COMBYUVA_LEGACY, "Combine YUVA", NODE_CLASS_CONVERTER);
|
||||
ntype.declare = file_ns::cmp_node_combyuva_declare;
|
||||
ntype.gather_link_search_ops = nullptr;
|
||||
|
||||
nodeRegisterType(&ntype);
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@ void register_node_type_sh_sephsv()
|
|||
sh_node_type_base(&ntype, SH_NODE_SEPHSV_LEGACY, "Separate HSV", NODE_CLASS_CONVERTER);
|
||||
ntype.declare = file_ns::node_declare_sephsv;
|
||||
node_type_gpu(&ntype, file_ns::gpu_shader_sephsv);
|
||||
ntype.gather_link_search_ops = nullptr;
|
||||
|
||||
nodeRegisterType(&ntype);
|
||||
}
|
||||
|
@ -75,6 +76,7 @@ void register_node_type_sh_combhsv()
|
|||
sh_node_type_base(&ntype, SH_NODE_COMBHSV_LEGACY, "Combine HSV", NODE_CLASS_CONVERTER);
|
||||
ntype.declare = file_ns::node_declare_combhsv;
|
||||
node_type_gpu(&ntype, file_ns::gpu_shader_combhsv);
|
||||
ntype.gather_link_search_ops = nullptr;
|
||||
|
||||
nodeRegisterType(&ntype);
|
||||
}
|
||||
|
|
|
@ -80,6 +80,7 @@ void register_node_type_sh_seprgb()
|
|||
ntype.declare = file_ns::sh_node_seprgb_declare;
|
||||
node_type_gpu(&ntype, file_ns::gpu_shader_seprgb);
|
||||
ntype.build_multi_function = file_ns::sh_node_seprgb_build_multi_function;
|
||||
ntype.gather_link_search_ops = nullptr;
|
||||
|
||||
nodeRegisterType(&ntype);
|
||||
}
|
||||
|
@ -123,6 +124,7 @@ void register_node_type_sh_combrgb()
|
|||
ntype.declare = file_ns::sh_node_combrgb_declare;
|
||||
node_type_gpu(&ntype, file_ns::gpu_shader_combrgb);
|
||||
ntype.build_multi_function = file_ns::sh_node_combrgb_build_multi_function;
|
||||
ntype.gather_link_search_ops = nullptr;
|
||||
|
||||
nodeRegisterType(&ntype);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue