public RGBColor pathShade(ShadeRec rec, int depth) {
		RGBColor L=new RGBColor(RGBColor.black);
		int lightnum=rec.w.ls.size();
		Light cur;
		for(int i=0;i<lightnum;i++){
			cur=rec.w.ls.get(i);
			if(cur instanceof AreaLight){
				AreaLight arealight=(AreaLight)cur;
				boolean shadowed=false;
				arealight.randsam();
				Vector3D w=arealight.direction(rec);

				Ray shadowray=new Ray(rec.local_hit_point,w);
				Normal n=rec.normal;
				double dot=w.dot(n);

				Normal r=n.multiply(2.0*dot).add(new Normal(w.minus()));
				double dotr=r.dot(rec.r.d.minus());
				double ksr=Math.pow(dotr, shininess);
				shadowed=arealight.shadowed(shadowray, rec);

				if(!shadowed){
					if(dot>0.0)
						L.plusEqual( diffuse.get().multiply(cur.radiance(rec).multiply(dot*arealight.G(rec))));
					if(dotr>0.0)
						L.plusEqual(specular.get().multiply(cur.radiance(rec).multiply(dot*ksr*arealight.G(rec))));
				}
			}

		}

		double prob =random.nextDouble();
		double faktor=1.0;
		if(depth>0)
			if(prob<0.5)
				return L;
			else{
				faktor=0.5;
			}

		Vector3D n=sample(rec,rec.r.d.minus());
		Vector3D wo=rec.r.d;
		double ndotwo = rec.normal.dot(wo.minus());
		Vector3D r = wo.add(new Vector3D(rec.normal.multiply(2.0* ndotwo)));

		// double phong_lobe = Math.pow(n.dot(r), shininess);
		//  double pdfs = phong_lobe * (rec.normal.dot(n));
		//double pdfs =  (rec.normal.dot(n));

		//   System.out.println(n);
		double pdfd = (rec.normal.dot(n));
		if(pdfd>0.001) { // for rays going bak into objekt{
			prob=random.nextDouble();
			if(prob<0.5)
				L.plusEqual(diffuse.get().multiply(rec.w.tracer.trace_ray(new Ray(rec.local_hit_point,n.hat()), depth+1,false)).multiply(pdfd/(faktor*0.5)) );
			else
				L.plusEqual(specular.get().multiply(rec.w.tracer.trace_ray(new Ray(rec.local_hit_point,r), depth+1,false)).multiply(1/(0.5*faktor)));

		}



		return L;
	}