Principled v2 combined changes for 4.0 #112848

Closed
Brecht Van Lommel wants to merge 16 commits from brecht:principled into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
1 changed files with 11 additions and 15 deletions
Showing only changes of commit c41f6e313a - Show all commits

View File

@ -73,7 +73,7 @@ ccl_device void flatten_closure_tree(KernelGlobals kg,
int layer_stack_level = -1;
float3 layer_albedo = zero_float3();
while (closure) {
while (true) {
switch (closure->id) {
case OSL_CLOSURE_MUL_ID: {
ccl_private const OSLClosureMul *mul = static_cast<ccl_private const OSLClosureMul *>(
@ -134,7 +134,12 @@ ccl_device void flatten_closure_tree(KernelGlobals kg,
break;
}
if (stack_size > 0) {
/* Pop the next closure from the stack (or return if we're done). */
do {
if (stack_size == 0) {
return;
}
weight = weight_stack[--stack_size];
closure = closure_stack[stack_size];
if (stack_size == layer_stack_level) {
@ -142,22 +147,13 @@ ccl_device void flatten_closure_tree(KernelGlobals kg,
* account for the layering. */
weight *= saturatef(1.0f - reduce_max(safe_divide_color(layer_albedo, weight)));
layer_stack_level = -1;
/* If it's fully occluded, skip the base layer we just popped from the stack and grab
* the next entry instead. */
if (is_zero(weight)) {
/* If it's fully occluded, skip the base layer we just popped from the stack and grab
* the next entry instead. */
if (stack_size > 0) {
weight = weight_stack[--stack_size];
closure = closure_stack[stack_size];
}
else {
closure = nullptr;
}
continue;
}
}
}
else {
closure = nullptr;
}
} while (closure == nullptr);
}
}