rendered paste body// global illumination: add recursively computed reflection below this line while(maxReflectionsLeft > 0) { Vec3 nN = nearestHit.normal; Vec3 tD = this.direction.times(-1.0f); tD.normalize(); Vec3 tO = this.origin; Vec3 nO = nearestHit.location; //Vec3 nD = ((nN.times(nN.dot(tD.minus(tO)))).times(2.0f)).minus(tD.minus(tO)); // Vec3 nD = (nN.times(2.0f).times(tD.add(tO).dot(nN))).minus(tD.add(tO)); // Vec3 nD = (nN.times(2.0f).times(tD.add(tO).dot(nN))).minus(tD.add(tO)); Vec3 nD = (tD).times(-1.0f).add(nN.times(2.0f).times(tD.dot(nN))); // nD.normalize(); maxReflectionsLeft --; if(nO == nearestHit.location) { Ray reflection = new Ray (nO, nD); color = color.add(reflection.trace(nearestHit.object, maxReflectionsLeft).times(nearestHit.object.material.reflectance)); } //if(currentObject != null) addColor = addColor.times(currentObject.material.reflectance); }