public RColor illumination(P3 p, SceneObject so) { P3 surfaceNormal = so.shape.normal(p); float shade = surfaceNormal.dotProduct(this.direction); if (shade < 0) { return new RColor(0, 0, 0); } else { return this.color.scalarMultiply(shade); } }
public RColor Coloring(P3 p, Ray r, SceneObject so) { P2 textureLoc = so.shape.toP2(p); RColor textureColor = so.texture.texture(textureLoc); RColor sumOfLights = new RColor(0, 0, 0); RColor lightColor; foreach (Light lightSource in Form1.lights) { lightColor = lightSource.illumination(p,so); sumOfLights = sumOfLights.add(lightColor); } return RColor.multiplyColor(textureColor, sumOfLights); }
public RColor illumination(P3 p, SceneObject so) { return this.color; }