Cycles / OSL:

* Ray Length is now available in OSL (via get_attribute)
This commit is contained in:
Thomas Dinges 2012-10-16 22:42:05 +00:00
parent c9fdf6e496
commit b4a83e1d0e
2 changed files with 13 additions and 1 deletions

@ -25,7 +25,8 @@ shader node_light_path(
output float IsGlossyRay = 0.0,
output float IsSingularRay = 0.0,
output float IsReflectionRay = 0.0,
output float IsTransmissionRay = 0.0)
output float IsTransmissionRay = 0.0,
output float RayLength = 0.0)
{
IsCameraRay = raytype("camera");
IsShadowRay = raytype("shadow");
@ -34,5 +35,7 @@ shader node_light_path(
IsSingularRay = raytype("singular");
IsReflectionRay = raytype("reflection");
IsTransmissionRay = raytype("refraction");
getattribute("std::ray_length", RayLength);
}

@ -460,6 +460,15 @@ static bool get_object_standard_attribute(KernelGlobals *kg, ShaderData *sd, ust
return true;
}
/* Ray Length */
else if (name == "std::ray_length") {
float fval[3];
fval[0] = sd->ray_length;
fval[1] = fval[2] = 0.0; /* derivates set to 0 */
set_attribute_float(fval, type, derivatives, val);
return true;
}
else
return false;
}