Fix T100914: Cycles faceting with combined Bump and Displacement
Port over small part of ray differentials refactor in e949d6da5b
that
accidentally fixed this bug. Ensure ray differentials are orthogonal to
the normal.
This commit is contained in:
parent
a6c0d0a0e3
commit
19ae71c113
Notes:
blender-bot
2023-02-13 22:38:46 +01:00
Referenced by issue #100749, Blender LTS: Maintenance Task 3.3 Referenced by issue #100914, Cycles shows transmission in displaced shader as black Referenced by issue #100899, Regression: Drag and Drop seems to be broken for image files from desktop
|
@ -17,6 +17,8 @@
|
|||
#include "kernel/osl/globals.h"
|
||||
#include "kernel/osl/services.h"
|
||||
#include "kernel/osl/shader.h"
|
||||
|
||||
#include "kernel/util/differential.h"
|
||||
// clang-format on
|
||||
|
||||
#include "scene/attribute.h"
|
||||
|
@ -199,13 +201,20 @@ void OSLShader::eval_surface(const KernelGlobalsCPU *kg,
|
|||
(void)found;
|
||||
assert(found);
|
||||
|
||||
differential3 dP;
|
||||
memcpy(&sd->P, data, sizeof(float) * 3);
|
||||
memcpy(&sd->dP.dx, data + 3, sizeof(float) * 3);
|
||||
memcpy(&sd->dP.dy, data + 6, sizeof(float) * 3);
|
||||
memcpy(&dP.dx, data + 3, sizeof(float) * 3);
|
||||
memcpy(&dP.dy, data + 6, sizeof(float) * 3);
|
||||
|
||||
object_position_transform(kg, sd, &sd->P);
|
||||
object_dir_transform(kg, sd, &sd->dP.dx);
|
||||
object_dir_transform(kg, sd, &sd->dP.dy);
|
||||
object_dir_transform(kg, sd, &dP.dx);
|
||||
object_dir_transform(kg, sd, &dP.dy);
|
||||
|
||||
const float dP_radius = differential_make_compact(dP);
|
||||
|
||||
make_orthonormals(sd->Ng, &sd->dP.dx, &sd->dP.dy);
|
||||
sd->dP.dx *= dP_radius;
|
||||
sd->dP.dy *= dP_radius;
|
||||
|
||||
globals->P = TO_VEC3(sd->P);
|
||||
globals->dPdx = TO_VEC3(sd->dP.dx);
|
||||
|
|
|
@ -21,16 +21,19 @@ ccl_device_noinline void svm_node_enter_bump_eval(KernelGlobals kg,
|
|||
const AttributeDescriptor desc = find_attribute(kg, sd, ATTR_STD_POSITION_UNDISPLACED);
|
||||
|
||||
if (desc.offset != ATTR_STD_NOT_FOUND) {
|
||||
float3 P, dPdx, dPdy;
|
||||
P = primitive_surface_attribute_float3(kg, sd, desc, &dPdx, &dPdy);
|
||||
differential3 dP;
|
||||
float3 P = primitive_surface_attribute_float3(kg, sd, desc, &dP.dx, &dP.dy);
|
||||
|
||||
object_position_transform(kg, sd, &P);
|
||||
object_dir_transform(kg, sd, &dPdx);
|
||||
object_dir_transform(kg, sd, &dPdy);
|
||||
object_dir_transform(kg, sd, &dP.dx);
|
||||
object_dir_transform(kg, sd, &dP.dy);
|
||||
|
||||
const float dP_radius = differential_make_compact(dP);
|
||||
|
||||
sd->P = P;
|
||||
sd->dP.dx = dPdx;
|
||||
sd->dP.dy = dPdy;
|
||||
make_orthonormals(sd->Ng, &sd->dP.dx, &sd->dP.dy);
|
||||
sd->dP.dx *= dP_radius;
|
||||
sd->dP.dy *= dP_radius;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue