Cycles: add Ray Length output to Light Path node. This gives the distance travelled
by the last light ray. One use case for this might be to do absorption. Patch #31232 by Agustin benavidez, see this blog post for details: http://agus3d.blogspot.com.ar/2012/05/blender-cycles-ray-length-node-output.html
This commit is contained in:
@@ -77,6 +77,7 @@ __device_inline void shader_setup_from_ray(KernelGlobals *kg, ShaderData *sd,
|
||||
sd->N = Ng;
|
||||
sd->I = -ray->D;
|
||||
sd->shader = shader;
|
||||
sd->ray_length = isect->t;
|
||||
|
||||
/* smooth normal */
|
||||
if(sd->shader & SHADER_SMOOTH_NORMAL)
|
||||
@@ -127,7 +128,7 @@ __device_inline void shader_setup_from_ray(KernelGlobals *kg, ShaderData *sd,
|
||||
|
||||
__device void shader_setup_from_sample(KernelGlobals *kg, ShaderData *sd,
|
||||
const float3 P, const float3 Ng, const float3 I,
|
||||
int shader, int object, int prim, float u, float v, float time)
|
||||
int shader, int object, int prim, float u, float v, float t, float time)
|
||||
{
|
||||
/* vectors */
|
||||
sd->P = P;
|
||||
@@ -145,6 +146,7 @@ __device void shader_setup_from_sample(KernelGlobals *kg, ShaderData *sd,
|
||||
sd->u = u;
|
||||
sd->v = v;
|
||||
#endif
|
||||
sd->ray_length = t;
|
||||
|
||||
/* detect instancing, for non-instanced the object index is -object-1 */
|
||||
#ifdef __INSTANCING__
|
||||
@@ -242,7 +244,7 @@ __device void shader_setup_from_displace(KernelGlobals *kg, ShaderData *sd,
|
||||
|
||||
/* watch out: no instance transform currently */
|
||||
|
||||
shader_setup_from_sample(kg, sd, P, Ng, I, shader, object, prim, u, v, TIME_INVALID);
|
||||
shader_setup_from_sample(kg, sd, P, Ng, I, shader, object, prim, u, v, 0.0f, TIME_INVALID);
|
||||
}
|
||||
|
||||
/* ShaderData setup from ray into background */
|
||||
@@ -259,6 +261,7 @@ __device_inline void shader_setup_from_background(KernelGlobals *kg, ShaderData
|
||||
#ifdef __MOTION__
|
||||
sd->time = ray->time;
|
||||
#endif
|
||||
sd->ray_length = 0.0f;
|
||||
|
||||
#ifdef __INSTANCING__
|
||||
sd->object = ~0;
|
||||
|
Reference in New Issue
Block a user