Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/intern
diff options
context:
space:
mode:
authorSergey Sharybin <sergey@blender.org>2021-05-11 21:36:15 +0300
committerSergey Sharybin <sergey@blender.org>2021-05-12 11:06:11 +0300
commit7e823969b59487c5dc2f032424a12365aa95145c (patch)
treeb28e14e44fa61a79a9e859597036956ea03a3cc4 /intern
parent7f3436363388af9e9fe5c8578dee8997c078bb16 (diff)
Fix non-finite tangent in Cycles with missing UV map
Was causing calculation issues later on in the kernel. This change catches the most obvious case: missing attribute. The old code was trying to set tangent to 0, but because it was transformed as a normal it got converted to non-finite value. This change makes it so that no transform is involved and 0 is written directly to the SVM stack. To cover all cases it will require using safe_normalize() in this node and in the normal transform function. This is more involved change from performance point of view, would be nice to verify whether we really want to go this route. I've left asserts in the BSDF allocation functions. Don't have strong connection to them, but think they are handy and are not different from having an assert in the path radiance checks. Differential Revision: https://developer.blender.org/D11235
Diffstat (limited to 'intern')
-rw-r--r--intern/cycles/kernel/closure/alloc.h4
-rw-r--r--intern/cycles/kernel/svm/svm_tex_coord.h9
2 files changed, 10 insertions, 3 deletions
diff --git a/intern/cycles/kernel/closure/alloc.h b/intern/cycles/kernel/closure/alloc.h
index 5b74a868e72..99a5a675976 100644
--- a/intern/cycles/kernel/closure/alloc.h
+++ b/intern/cycles/kernel/closure/alloc.h
@@ -57,6 +57,8 @@ ccl_device ccl_addr_space void *closure_alloc_extra(ShaderData *sd, int size)
ccl_device_inline ShaderClosure *bsdf_alloc(ShaderData *sd, int size, float3 weight)
{
+ kernel_assert(isfinite3_safe(weight));
+
const float sample_weight = fabsf(average(weight));
/* Use comparison this way to help dealing with non-finite weight: if the average is not finite
@@ -81,6 +83,8 @@ ccl_device_inline ShaderClosure *bsdf_alloc_osl(ShaderData *sd,
float3 weight,
void *data)
{
+ kernel_assert(isfinite3_safe(weight));
+
const float sample_weight = fabsf(average(weight));
/* Use comparison this way to help dealing with non-finite weight: if the average is not finite
diff --git a/intern/cycles/kernel/svm/svm_tex_coord.h b/intern/cycles/kernel/svm/svm_tex_coord.h
index 4fe940f1a67..fc46bb584be 100644
--- a/intern/cycles/kernel/svm/svm_tex_coord.h
+++ b/intern/cycles/kernel/svm/svm_tex_coord.h
@@ -370,10 +370,13 @@ ccl_device void svm_node_tangent(KernelGlobals *kg, ShaderData *sd, float *stack
if (direction_type == NODE_TANGENT_UVMAP) {
/* UV map */
- if (desc.offset == ATTR_STD_NOT_FOUND)
- tangent = make_float3(0.0f, 0.0f, 0.0f);
- else
+ if (desc.offset == ATTR_STD_NOT_FOUND) {
+ stack_store_float3(stack, tangent_offset, zero_float3());
+ return;
+ }
+ else {
tangent = attribute_value;
+ }
}
else {
/* radial */