Fix #119692: Cycles render issue with light tree and light linking
When using light linking with the light tree, the root index of a mesh light subtree can be 0. The current code assumed this wasn't possible, and as such it caused rendering issues, specifically the incorrect computation of the PDF of certain mesh lights during forward path tracing. So we adjust the code to allow mesh light subtree root node indices of 0. This was worked on by Alaska, Sergey, and Weizhen Pull Request: https://projects.blender.org/blender/blender/pulls/119770
This commit is contained in:
parent
aede88be85
commit
43cef92f66
|
@ -796,7 +796,7 @@ ccl_device float light_tree_pdf(KernelGlobals kg,
|
||||||
|
|
||||||
ccl_global const KernelLightTreeEmitter *kemitter = &kernel_data_fetch(light_tree_emitters,
|
ccl_global const KernelLightTreeEmitter *kemitter = &kernel_data_fetch(light_tree_emitters,
|
||||||
index_emitter);
|
index_emitter);
|
||||||
int root_index;
|
int subtree_root_index;
|
||||||
uint bit_trail, target_emitter;
|
uint bit_trail, target_emitter;
|
||||||
|
|
||||||
if (is_triangle(kemitter)) {
|
if (is_triangle(kemitter)) {
|
||||||
|
@ -805,16 +805,17 @@ ccl_device float light_tree_pdf(KernelGlobals kg,
|
||||||
target_emitter = kernel_data_fetch(object_to_tree, object_emitter);
|
target_emitter = kernel_data_fetch(object_to_tree, object_emitter);
|
||||||
ccl_global const KernelLightTreeEmitter *kmesh = &kernel_data_fetch(light_tree_emitters,
|
ccl_global const KernelLightTreeEmitter *kmesh = &kernel_data_fetch(light_tree_emitters,
|
||||||
target_emitter);
|
target_emitter);
|
||||||
root_index = kmesh->mesh.node_id;
|
subtree_root_index = kmesh->mesh.node_id;
|
||||||
ccl_global const KernelLightTreeNode *kroot = &kernel_data_fetch(light_tree_nodes, root_index);
|
ccl_global const KernelLightTreeNode *kroot = &kernel_data_fetch(light_tree_nodes,
|
||||||
|
subtree_root_index);
|
||||||
bit_trail = kroot->bit_trail;
|
bit_trail = kroot->bit_trail;
|
||||||
|
|
||||||
if (kroot->type == LIGHT_TREE_INSTANCE) {
|
if (kroot->type == LIGHT_TREE_INSTANCE) {
|
||||||
root_index = kroot->instance.reference;
|
subtree_root_index = kroot->instance.reference;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
root_index = 0;
|
subtree_root_index = -1;
|
||||||
bit_trail = kemitter->bit_trail;
|
bit_trail = kemitter->bit_trail;
|
||||||
target_emitter = index_emitter;
|
target_emitter = index_emitter;
|
||||||
}
|
}
|
||||||
|
@ -856,13 +857,13 @@ ccl_device float light_tree_pdf(KernelGlobals kg,
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (root_index) {
|
if (subtree_root_index != -1) {
|
||||||
/* Arrived at the mesh light. Continue with the subtree. */
|
/* Arrived at the mesh light. Continue with the subtree. */
|
||||||
float unused;
|
float unused;
|
||||||
light_tree_to_local_space<false>(kg, object_emitter, P, N, unused);
|
light_tree_to_local_space<false>(kg, object_emitter, P, N, unused);
|
||||||
|
|
||||||
node_index = root_index;
|
node_index = subtree_root_index;
|
||||||
root_index = 0;
|
subtree_root_index = -1;
|
||||||
target_emitter = index_emitter;
|
target_emitter = index_emitter;
|
||||||
bit_trail = kemitter->bit_trail;
|
bit_trail = kemitter->bit_trail;
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Reference in New Issue