//****glossy reflection
color hitc = 0;
color cumulativeGather = 0;
float numhits = 0;
color cumulativeGatherFinal = 0;
if(glossyRaytraceSwitch == 1) //test for switch
{
//we should really test to see if normals are facing the right way etc but this will do instead
gather("illuminance", P, reflect(I, nf), samplecone, samples, "surface:Ci", hitc)
{
cumulativeGather += hitc;
numhits += 1;
}
cumulativeGather /= numhits; //average glossy rays
cumulativeGather *= glossyRaytraceMult; //multiply brightness
color cumulativeGatherClamped = color clamp(color cumulativeGather, minC, maxGlossyClamp); //clamp it
cumulativeGatherFinal = cumulativeGatherClamped * glossyRaytraceColor * (1-fr) - glossyFacingOffset;
}