Fix: Cycles: Shadow terminator logic does not account for OSL bump mapping

The issue here is that the automatic bump shader in OSL adjusts globals.N,
which is used to define each closure's shading normal, but sd->N remains
as it was (unlike SVM, which sets it from svm_node_set_normal).

This is a problem since some code like the shadow terminator stuff uses sd->N,
so to make behavior consistent the fix is to set it from OSL as well.

Pull Request: https://projects.blender.org/blender/blender/pulls/138092
This commit is contained in:
Lukas Stockner
2025-04-28 14:03:55 +02:00
parent 58e1f05160
commit 175686f286
2 changed files with 6 additions and 0 deletions

View File

@@ -168,6 +168,9 @@ void osl_eval_nodes<SHADER_TYPE_SURFACE>(const ThreadKernelGlobalsCPU *kg,
sd->P = P;
sd->dP = dP;
/* Apply bump output to sd->N since it's used for e.g. shadow terminator logic. */
sd->N = TO_FLOAT3(globals->N);
globals->P = TO_VEC3(P);
globals->dPdx = TO_VEC3(dPdx);
globals->dPdy = TO_VEC3(dPdy);

View File

@@ -250,6 +250,9 @@ ccl_device_inline void osl_eval_nodes(KernelGlobals kg,
sd->P = P;
sd->dP = dP;
/* Apply bump output to sd->N since it's used for e.g. shadow terminator logic. */
sd->N = globals.N;
globals.P = P;
globals.dPdx = dPdx;
globals.dPdy = dPdy;