         float ambPct=get<7>(input);
 
 
-        int id=0;
-
-        if(primitiveType==TRIANGLE)       id = matIds->getValue(tri_matIdx_tref, hitIdx);
+        int id = 0;
+
+        if(primitiveType == TRIANGLE)       id = matIds->getValue(tri_matIdx_tref, hitIdx);
         else if(primitiveType == SPHERE ) id = sphr_matIds->getValue(sphr_matIdx_tref, hitIdx);
 
-        eavlVector3* matPtr=(eavlVector3*)(&mats[0]+id*12);
-        eavlVector3 ka=matPtr[0];//these could be lerped if it is possible that a single tri could be made of several mats
-        eavlVector3 kd=matPtr[1];
-        eavlVector3 ks=matPtr[2];
-        float matShine=matPtr[3].x;
+        eavlVector3* matPtr = (eavlVector3*)(&mats[0]+id*12);
+        eavlVector3 ka = matPtr[0];//these could be lerped if it is possible that a single tri could be made of several mats
+        eavlVector3 kd = matPtr[1];
+        eavlVector3 ks = matPtr[2];
+        float matShine = matPtr[3].x;
 
 //********************************************************
         //pixel=aColor*abg.x+bColor*abg.y+cColor*abg.z;




        red   = ka.x*ambPct+ (kd.x*lightDiff.x*cosTheta + ks.x*lightSpec.x*specConst)*shadowHit*dist;
        green = ka.y*ambPct+ (kd.y*lightDiff.y*cosTheta + ks.y*lightSpec.y*specConst)*shadowHit*dist;
        blue  = ka.z*ambPct+ (kd.z*lightDiff.z*cosTheta + ks.z*lightSpec.z*specConst)*shadowHit*dist;
        
        /*Color map*/
        float scalar   = get<14>(input);

    EAVL_FUNCTOR tuple<float,float,float> operator()(tuple<int,int,float,float,float,float,float,float,float,float,float,float,float,float,float,float > input)
    {
        //return tuple<float,float,float>(1,0,0);
        int hitIdx = get<0>(input);
        int hit = get<1>(input);
        float specConst;


        if(hitIdx == -1 ) return tuple<float,float,float>(bgColor.x, bgColor.y,bgColor.z);// primary ray never hit anything.
        //return tuple<float,float,float>(0,0,1);
        int primitiveType = get<15>(input);
        

        eavlVector3 normal(get<8>(input), get<9>(input), get<10>(input));
