Commit c8dd33f5a37b6a6db0b6950d24f9a7cff5ceb799 in OSL changed behavior of shader parameters that reference each other and are also overwritten with an instance value. This is causing the "NormalIn" parameter of a few OSL nodes in Cycles to be set to zero somehow, which should instead have received the value from a "node_geometry" node Cycles generates and connects automatically. I am not entirely sure why that is happening, but these parameters are superfluous anyway, since OSL already provides the necessary data in the global variable "N". So this patch simply removes those parameters (which mimics SVM, where these parameters do not exist either), which also fixes the rendering artifacts that occured with recent OSL. Maniphest Tasks: T101222 Differential Revision: https://developer.blender.org/D16470
33 lines
918 B
Plaintext
33 lines
918 B
Plaintext
/* SPDX-License-Identifier: Apache-2.0
|
|
* Copyright 2011-2022 Blender Foundation */
|
|
|
|
#include "stdcycles.h"
|
|
|
|
shader node_tangent(string attr_name = "geom:tangent",
|
|
string direction_type = "radial",
|
|
string axis = "z",
|
|
output normal Tangent = normalize(dPdu))
|
|
{
|
|
vector T = vector(0.0, 0.0, 0.0);
|
|
|
|
if (direction_type == "uv_map") {
|
|
getattribute(attr_name, T);
|
|
}
|
|
else if (direction_type == "radial") {
|
|
point generated;
|
|
|
|
if (!getattribute("geom:generated", generated))
|
|
generated = P;
|
|
|
|
if (axis == "x")
|
|
T = vector(0.0, -(generated[2] - 0.5), (generated[1] - 0.5));
|
|
else if (axis == "y")
|
|
T = vector(-(generated[2] - 0.5), 0.0, (generated[0] - 0.5));
|
|
else
|
|
T = vector(-(generated[1] - 0.5), (generated[0] - 0.5), 0.0);
|
|
}
|
|
|
|
T = transform("object", "world", T);
|
|
Tangent = cross(N, normalize(cross(T, N)));
|
|
}
|