*On 11/05/2015 at 12:08, xxxxxxxx wrote:*

User Information:

Cinema 4D Version: 15

Platform: Windows ; Mac OSX ;

Language(s) : C++ ;

---------

Working on a shader that calculates the distance from front surface of object to back surface of object.

basic code is:

if (sd->vd != nullptr)

{

SurfaceIntersection si = SurfaceIntersection();

Vector64 point = sd->vd->p;

while (sd->vd->TraceGeometry(sd->vd->ray, 999999, sd->vd->lhit, &si) == true)

{

if (sd->vd->op == si.op)

{

distance += (si.p - point).GetLength();

point = si.p;

}

}

}

In theory this should intersect the first point, trace to the next unique object intersection incrementing the distance. This will continue until the ray exits ( which should occur because the material has no refraction, internal reflections ). Removed the normal checks to simplify.

The trace is bouncing between the traced intersection and the original intersection forever.

Ama