public override Vector3 Shade(ShadeRec sr) { Vector3 L = base.Shade(sr); Vector3 wo = -sr.Ray.Direction; Vector3 wi = Vector3.Zero(); Vector3 fr = reflective.Sample_F(sr, wo, ref wi); Ray reflected_ray = new Ray(sr.HitPoint, wi); reflected_ray.Depth = sr.Depth + 1; L += fr * sr.World.Tracer.TraceRay(reflected_ray, sr.Depth + 1) * Vector3.Dot(sr.Normal, wi); return(L); }
public override Vector3 Shade(ShadeRec sr) { Vector3 L = base.Shade(sr); Vector3 wo = -sr.Ray.Direction; Vector3 wi = Vector3.Zero(); Vector3 fr = reflective.Sample_F(sr, wo, ref wi); Ray reflected_ray = new Ray(sr.HitPoint, wi); if (specular_btdf.TIR(sr)) { L += sr.World.Tracer.TraceRay(reflected_ray, sr.Depth + 1); } else { Vector3 wt = Vector3.Zero(); Vector3 ft = specular_btdf.Sample_F(sr, wo, ref wt); Ray transmitted_ray = new Ray(sr.HitPoint, wt); L += fr * sr.World.Tracer.TraceRay(reflected_ray, sr.Depth + 1) * Vector3.AbsDot(sr.Normal, wi); L += ft * sr.World.Tracer.TraceRay(transmitted_ray, sr.Depth + 1) * Vector3.AbsDot(sr.Normal, wt); //this is very important for transparent rendering } return(L); }