public override bool Scatter(Ray r, HitRecord hitRecord, out Vector3 attenuation, out Ray scattered) { Vector3 target = hitRecord.HitPoint + hitRecord.SurfaceNormal + VectorHelpers.GetRandomInUnitSphere(); scattered = new Ray(hitRecord.HitPoint, target - hitRecord.HitPoint); attenuation = Texture.GetValue(0, 0, hitRecord.HitPoint); return(true); }
public Vector3 GetValue(float u, float v, Vector3 hitPoint) { double sineFunc(float val) => Math.Sin(10 * val); double sines = sineFunc(hitPoint.X) * sineFunc(hitPoint.Y) * sineFunc(hitPoint.Z); if (sines < 0) { return(OddTexture.GetValue(u, v, hitPoint)); } else { return(EvenTexture.GetValue(u, v, hitPoint)); } }
public override Vector3 Emitted(float u, float v, Vector3 hitPoint) { return(emit.GetValue(u, v, hitPoint)); }