anchor.diff:    return sqrt(dot(vec3(0.299, 0.587, 0.114) * color*color, vec3(1)));
   }
   
  -vec3 getDirectEmmission(Ray ray, Triangle tri, Hit result, vec3 normal){
  +vec3 getDirectEmmission(vec3 origin, vec3 normal, vec3 incident, float specular){
     vec3 color = vec3(0);
  -  vec3 origin = ray.origin + ray.dir * result.t;
     vec2 range = lightRanges[uint(rand(coords.xy + origin.xy) * numLights)];
     Triangle light = randomLight(origin.xz, range);
     vec3 lightPoint = randomPointOnTriangle(light, origin.zy);
     vec3 dir = normalize(lightPoint - origin);
  -  ray = Ray(origin + normal*EPSILON, dir);
  +  Ray ray = Ray(origin, dir);
     Hit shadow = traverseTree(ray);
     vec3 tspan = ray.dir * shadow.t;
     vec3 span = lightPoint - ray.origin;
  +  float weight = directLightWeight(normal, incident, normalize(span), specular);
     if(abs(shadow.t - length(span)) < EPSILON * 10.0){
       Material mat = createMaterial(shadow.index);
       vec3 lightNormal = barycentricNormal(barycentricWeights(createTriangle(shadow.index), origin), createNormals(shadow.index));
  
positive.code:   return fract(sin(sn) * c);
  }
  
  float getAngle(vec3 a, vec3 b){
    return atan(length(cross(a,b)),a.z);
  }
  
  
negative.code:         oc * axis.z * axis.x - axis.y * s, oc * axis.y * axis.z + axis.x * s, oc * axis.z * axis.z + c);
  }
  
  // GGX importance-sampled microfacet
  vec3 randomNormal(vec3 oNormal, float a, vec3 seed){
    vec2 xi = vec2(rand(seed.xy), rand(seed.zx));
    float phi = 2.0f * M_PI * xi.x;
    float theta = acos(sqrt((1.0f - xi.y)/((a*a - 1.0f) * xi.y + 1.0f)));
    float sinTheta = sin(theta);
    vec3 facet = vec3(cos(phi) * sinTheta, sinTheta * sin(phi), cos(theta));
    float trans = getAngle(oNormal);
    return rotationMatrix(cross(oNormal,vec3(0.0,0.0,1.0)),trans) * facet;
  }
  
  // GGX PDF
  float directLightWeight(vec3 normal, vec3 incidentDir, vec3 lightDir, float a){
    vec3 facetNormal = normalize(lightDir - incidentDir);
    float a2 = a*a;
    float ndm = dot(normal, facetNormal);
    float denom = ndm*ndm * (a2 - 1.0) + 1.0;
    return a2 / (M_PI * denom * denom);
  }
  
  //vec3 randomVec(vec3 normal, vec3 seed){
  