Fix T86121: Cycles Attribute returning wrong results with OSL

Fix uninitialized variable in the OSL shader.
This commit is contained in:
Brecht Van Lommel 2021-03-15 20:42:06 +01:00
parent 8f93386e62
commit be51d671b5
Notes: blender-bot 2023-02-14 08:08:56 +01:00
Referenced by issue #86121, Cycles: AttributeNode: Unexpected result when setting a nonexistent attribute
Referenced by issue #85958, Potential candidates for corrective releases
4 changed files with 8 additions and 8 deletions

View File

@ -23,7 +23,7 @@ shader node_attribute(string bump_offset = "center",
output float Fac = 0.0,
output float Alpha = 0.0)
{
float data[4];
float data[4] = {0.0, 0.0, 0.0, 0.0};
getattribute(name, data);
Color = color(data[0], data[1], data[2]);
Vector = point(Color);

View File

@ -42,23 +42,23 @@ shader node_light_path(output float IsCameraRay = 0.0,
getattribute("path:ray_length", RayLength);
int ray_depth;
int ray_depth = 0;
getattribute("path:ray_depth", ray_depth);
RayDepth = (float)ray_depth;
int diffuse_depth;
int diffuse_depth = 0;
getattribute("path:diffuse_depth", diffuse_depth);
DiffuseDepth = (float)diffuse_depth;
int glossy_depth;
int glossy_depth = 0;
getattribute("path:glossy_depth", glossy_depth);
GlossyDepth = (float)glossy_depth;
int transparent_depth;
int transparent_depth = 0;
getattribute("path:transparent_depth", transparent_depth);
TransparentDepth = (float)transparent_depth;
int transmission_depth;
int transmission_depth = 0;
getattribute("path:transmission_depth", transmission_depth);
TransmissionDepth = (float)transmission_depth;
}

View File

@ -31,7 +31,7 @@ shader node_normal_map(normal NormalIn = N,
vector tangent;
vector ninterp;
float tangent_sign;
float is_smooth;
float is_smooth = 0.0;
getattribute("geom:is_smooth", is_smooth);
if (!is_smooth) {

View File

@ -22,7 +22,7 @@ shader node_tangent(normal NormalIn = N,
string axis = "z",
output normal Tangent = normalize(dPdu))
{
vector T;
vector T = vector(0.0, 0.0, 0.0);
if (direction_type == "uv_map") {
getattribute(attr_name, T);