public override Vector3 Area_Light_Shade(ShadeRec sr) { Vector3 wo = -sr.Ray.Direction; Vector3 L = ambient.RHO(sr, wo) * sr.World.AmbientLight.L(sr); int num_lights = sr.World.Lights.Count; for (int j = 0; j < num_lights; j++) { Vector3 wi = sr.World.Lights[j].GetDirection(sr); float ndotwi = Vector3.Dot(sr.Normal, wi); if (ndotwi > 0.0) { if (Shadows) { bool in_shadow = false; if (sr.World.Lights[j].Shadows) { Ray shadowRay = new Ray(sr.HitPoint, wi); in_shadow = sr.World.Lights[j].InShadow(shadowRay, sr); } if (!in_shadow) L += (diffuse.F(sr, wo, wi) + specular.F(sr, wo, wi)) * sr.World.Lights[j].L(sr) * ndotwi * sr.World.Lights[j].G(sr) / sr.World.Lights[j].PDF(sr); } else { L += (diffuse.F(sr, wo, wi) + specular.F(sr, wo, wi)) * sr.World.Lights[j].L(sr) * ndotwi * sr.World.Lights[j].G(sr) / sr.World.Lights[j].PDF(sr); } } } return (L); }
public override bool Hit(Ray ray, ref float tmin, ref ShadeRec sr) { if (bbox.Hit(ray)) return base.Hit(ray, ref tmin, ref sr); else return false; }
public override bool Hit(Ray ray, ref float tmin, ref ShadeRec sr) { Vector3 v0 = (Mesh.Vertices[index0]); Vector3 v1 = (Mesh.Vertices[index1]); Vector3 v2 = (Mesh.Vertices[index2]); float a = v0.X - v1.X, b = v0.X - v2.X, c = ray.Direction.X, d = v0.X - ray.Position.X; float e = v0.Y - v1.Y, f = v0.Y - v2.Y, g = ray.Direction.Y, h = v0.Y - ray.Position.Y; float i = v0.Z - v1.Z, j = v0.Z - v2.Z, k = ray.Direction.Z, l = v0.Z - ray.Position.Z; float m = f * k - g * j, n = h * k - g * l, p = f * l - h * j; float q = g * i - e * k, s = e * j - f * i; float inv_denom = 1.0f / (a * m + b * q + c * s); float e1 = d * m - b * n - c * p; float beta = e1 * inv_denom; if (beta < 0.0) return (false); float r = e * l - h * i; float e2 = a * n + d * q + c * r; float gamma = e2 * inv_denom; if (gamma < 0.0) return (false); if (beta + gamma > 1.0) return (false); float e3 = a * p - b * r + d * s; float t = e3 * inv_denom; if (t < MathHelper.Epsilon) return (false); tmin = t; sr.Normal = interpolate_normal(beta, gamma); // for smooth shading sr.LocalHitPoint = ray.Position + t * ray.Direction; return (true); }
public override Vector3 Area_Light_Shade(ShadeRec sr) { Vector3 wo = -sr.Ray.Direction; Vector3 L = ambient.RHO(sr, wo) * sr.World.AmbientLight.L(sr); int num_lights = sr.World.Lights.Count; for (int j = 0; j < num_lights; j++) { Light light_ptr = sr.World.Lights[j]; Vector3 wi = light_ptr.GetDirection(sr); //compute_direction ? wi.Normalize(); float ndotwi = Vector3.Dot(sr.Normal, wi); float ndotwo = Vector3.Dot(sr.Normal, wo); if (ndotwi > 0.0 && ndotwo > 0.0) { bool in_shadow = false; if (sr.World.Lights[j].Shadows) { Ray shadow_ray = new Ray(sr.HitPoint, wi); in_shadow = light_ptr.InShadow(shadow_ray, sr); } if (!in_shadow) L += diffuse.F(sr, wo, wi) * light_ptr.L(sr) * light_ptr.G(sr) * ndotwi / sr.World.Lights[j].PDF(sr); } } return (L); }
public override void RenderScene(World world) { Vector3 L; ViewPlane vp = new ViewPlane(world.ViewPlane); Ray ray = new Ray(); int depth = 0; Vector2 pp = new Vector2(); vp.S /= Zoom; ray.Position = Position; int n = (int)MathHelper.Sqrt((float)vp.NumSamples); for (int r = 0; r < vp.VRes; r++) for (int c = 0; c < vp.HRes; c++) { L = new Vector3(0, 0, 0); for (int p = 0; p < n; p++) for (int q = 0; q < n; q++) { pp.X = vp.S * (c - 0.5f * vp.HRes + (q + 0.5f) / n); pp.Y = vp.S * (r - 0.5f * vp.VRes + (p + 0.5f) / n); ray.Direction = GetDirection(pp); L += world.Tracer.TraceRay(ray, depth); } L /= ((float)vp.NumSamples); L *= ExposureTime; world.Screen.AddPixel(r, c, L); } }
public override bool ShadowHit(Ray ray, ref float tmin) { if (!Shadows) return false; Vector3 v0 = (Mesh.Vertices[index0]); Vector3 v1 = (Mesh.Vertices[index1]); Vector3 v2 = (Mesh.Vertices[index2]); float a = v0.X - v1.X, b = v0.X - v2.X, c = ray.Direction.X, d = v0.X - ray.Position.X; float e = v0.Y - v1.Y, f = v0.Y - v2.Y, g = ray.Direction.Y, h = v0.Y - ray.Position.Y; float i = v0.Z - v1.Z, j = v0.Z - v2.Z, k = ray.Direction.Z, l = v0.Z - ray.Position.Z; float m = f * k - g * j, n = h * k - g * l, p = f * l - h * j; float q = g * i - e * k, s = e * j - f * i; float inv_denom = 1.0f / (a * m + b * q + c * s); float e1 = d * m - b * n - c * p; float beta = e1 * inv_denom; if (beta < 0.0) return (false); float r = e * l - h * i; float e2 = a * n + d * q + c * r; float gamma = e2 * inv_denom; if (gamma < 0.0) return (false); if (beta + gamma > 1.0) return (false); float e3 = a * p - b * r + d * s; float t = e3 * inv_denom; if (t < MathHelper.Epsilon) return (false); tmin = t; return (true); }
public override void RenderStereo(World world, float x, int offset) { Vector3 L; ViewPlane vp = world.ViewPlane; Ray ray = new Ray(); int depth = 0; Vector2 pp, sp; int n = (int)MathHelper.Sqrt((float)vp.NumSamples); vp.S /= Zoom; ray.Position = Position; for (int r = 0; r < vp.VRes; r++) for (int c = 0; c < vp.HRes; c++) { L = Vector3.Zero; ; for (int p = 0; p < n; p++) for (int q = 0; q < n; q++) { sp = vp.Sampler.SampleUnitSquare(); pp = new Vector2(); pp.X = vp.S * (((float)c) - 0.5f * ((float)vp.HRes) + sp.X) + x; pp.Y = vp.S * (((float)r) - 0.5f * ((float)vp.VRes) + sp.Y); ray.Direction = get_direction(pp); L += world.Tracer.TraceRay(ray, depth); } L /= vp.NumSamples; L *= ExposureTime; world.Screen.AddPixel(r, c + offset, L); } }
public override void RenderStereo(World world, float x, int offset) { Vector3 L = Vector3.Zero; ViewPlane vp = world.ViewPlane; Ray ray = new Ray(); int depth = 0; Vector2 pp = new Vector2(); Vector2 sp = new Vector2(); vp.S /= Zoom; ray.Position = Position; for (int r = 0; r < vp.VRes; r++) for (int c = 0; c < vp.HRes; c++) { L = new Vector3(0, 0, 0); for (int j = 0; j < vp.NumSamples; j++) { sp = vp.Sampler.SampleUnitSquare(); pp.X = vp.S * (c - 0.5f * vp.HRes + sp.X) + x; pp.Y = vp.S * (r - 0.5f * vp.VRes + sp.Y); ray.Direction = GetDirection(pp); L += world.Tracer.TraceRay(ray, depth); } L /= vp.NumSamples; L *= ExposureTime; world.Screen.AddPixel(r, c + offset, L); } }
public override bool Hit(Ray ray, ref float tmin, ref ShadeRec sr) { if (!bbox.Hit(ray)) return false; float t = 0; Vector3 normal = new Vector3(), local_hit_point = Vector3.Zero; bool hit = false; tmin = float.MaxValue; int num_objects = Objects.Count; for (int j = 0; j < num_objects; j++) if (Objects[j].Hit(ray, ref t,ref sr) && (t < tmin)) { hit = true; tmin = t; Material = Objects[j].GetMaterial(); normal = sr.Normal; local_hit_point = sr.LocalHitPoint; } if (hit) { sr.T = tmin; sr.Normal = normal; sr.LocalHitPoint = local_hit_point; } return (hit); }
public override void RenderScene(World world) { Vector3 L; ViewPlane vp = world.ViewPlane; Ray ray = new Ray(); int depth = 0; Vector2 pp; int n = (int)MathHelper.Sqrt((float)vp.NumSamples); vp.S /= Zoom; ray.Position = Position; for (int r = 0; r < vp.VRes; r++) for (int c = 0; c < vp.HRes; c++) { L = Vector3.Zero; ; for (int p = 0; p < n; p++) for (int q = 0; q < n; q++) { pp.X = vp.S * (((float)c) - 0.5f * ((float)vp.HRes) + (((float)q) + 0.5f) / ((float)n)); pp.Y = vp.S * (((float)r) - 0.5f * ((float)vp.VRes) + (((float)p) + 0.5f) / ((float)n)); ray.Direction = Target - Position; ray.Direction.Normalize(); Vector3 temp = get_direction(pp); ray.Position = Position + temp; L += world.Tracer.TraceRay(ray, depth); } L /= vp.NumSamples; L *= ExposureTime; world.Screen.AddPixel(r, c, L); } }
public override bool ShadowHit(Ray ray, ref float tmin) { if (!Shadows) return false; if (!bbox.Hit(ray)) return (false); float t = Vector3.Dot((center - ray.Position), normal) / Vector3.Dot(ray.Direction, normal); if (t <= MathHelper.Epsilon) return (false); Vector3 p = ray.Position + t * ray.Direction; float v = center.DistanceSquared(p); if (v < w_squared && v > i_squared) { double phi = MathHelper.Atan2(p.X, p.Z); if (phi < 0.0) phi += MathHelper.TwoPI; if (phi <= max_azimuth && phi >= min_azimuth) { tmin = t; return true; } else return false; } else return false; }
public override void RenderStereo(World world, float x, int offset) { Vector3 L = Vector3.Zero; Ray ray = new Ray(); ViewPlane vp = (world.ViewPlane); int depth = 0; Vector2 sp, pp, dp, lp; // sample point in [0, 1] X [0, 1] vp.S /= Zoom; for (int r = 0; r < vp.VRes; r++) // up for (int c = 0; c < vp.HRes; c++) { // across L = Vector3.Zero; for (int n = 0; n < vp.NumSamples; n++) { sp = vp.Sampler.SampleUnitSquare(); pp = new Vector2(); pp.X = vp.S * (c - vp.HRes / 2.0f + sp.X); pp.Y = vp.S * (r - vp.VRes / 2.0f + sp.Y); dp = Sampler.SampleUnitDisk(); lp = dp * Radius; ray.Position = Position + lp.X * U + lp.Y * V; ray.Direction = ray_direction(pp, lp); L += world.Tracer.TraceRay(ray, depth); } L /= vp.NumSamples; L *= ExposureTime; world.Screen.AddPixel(r, c + offset, L); } }
public override void RenderScene(World world) { Vector3 L; Ray ray = new Ray(); ViewPlane vp = world.ViewPlane; int depth = 0; Vector2 sp; // sample point in [0, 1] X [0, 1] Vector2 pp; // sample point on a pixel Vector2 dp; // sample point on unit disk Vector2 lp; // sample point on lens vp.S /= Zoom; for (int r = 0; r < vp.VRes; r++) // up for (int c = 0; c < vp.HRes; c++) { // across L = new Vector3(0, 0, 0); for (int n = 0; n < vp.NumSamples; n++) { sp = vp.Sampler.SampleUnitSquare(); pp = new Vector2(); pp.X = vp.S * (((float)c) - ((float)vp.HRes) / 2.0f + sp.X); pp.Y = vp.S * (((float)r) - ((float)vp.VRes) / 2.0f + sp.Y); dp = Sampler.SampleUnitDisk(); lp = dp * Radius; ray.Position = Position + lp.Y * U + lp.Y * V; ray.Direction = ray_direction(pp, lp); L += world.Tracer.TraceRay(ray, depth); } L /= vp.NumSamples; L *= ExposureTime; world.Screen.AddPixel(r, c, L); } }
internal static ShadeRec trace(Tracer tr, Ray ray) { ShadeRec sr = new ShadeRec(tr.World); float t = 0; Vector3 normal = Vector3.Zero; Vector3 local_hit_point = Vector3.Zero; float tmin = float.MaxValue; int num_objects = tr.World.Objects.Count; for (int j = 0; j < num_objects; j++) if (tr.World.Objects[j].Hit(ray, ref t, ref sr) && (t < tmin)) { sr.Hit_an_object = true; tmin = t; sr.Material = tr.World.Objects[j].Material; sr.HitPoint = ray.Position + t * ray.Direction; normal = sr.Normal; local_hit_point = sr.LocalHitPoint; } if (sr.Hit_an_object) { sr.T = tmin; sr.Normal = normal; sr.LocalHitPoint = local_hit_point; } return sr; }
public ShadeRec HitObjects(Ray ray) { ShadeRec sr = new ShadeRec(this); float t = 0; Vector3 normal = Vector3.Zero; Vector3 local_hit_point = Vector3.Zero; float tmin = float.MaxValue; int num_objects = Objects.Count; for (int j = 0; j < num_objects; j++) { if (Objects[j].Hit(ray, ref t, ref sr) && (t < tmin)) { sr.Hit_an_object = true; tmin = t; sr.Material = Objects[j].GetMaterial(); sr.HitPoint = ray.Position + t * ray.Direction; normal = sr.Normal; local_hit_point = sr.LocalHitPoint; } } if (sr.Hit_an_object) { sr.T = tmin; sr.Normal = normal; sr.LocalHitPoint = local_hit_point; } return (sr); }
public override void RenderScene(World world) { Vector3 L; ViewPlane vp = (world.ViewPlane); int hres = vp.HRes; int vres = vp.VRes; float s = vp.S; Ray ray = new Ray(); int depth = 0; Vector2 sp; // sample point in [0, 1] X [0, 1] Vector2 pp; // sample point on the pixel ray.Position = Position; for (int r = 0; r < vres; r++) // up for (int c = 0; c < hres; c++) { // across L = new Vector3(0, 0, 0); for (int j = 0; j < vp.NumSamples; j++) { sp = vp.Sampler.SampleUnitSquare(); pp = new Vector2(); pp.X = s * (c - 0.5f * hres + sp.X); pp.Y = s * (r - 0.5f * vres + sp.Y); ray.Direction = ray_direction(pp, hres, vres, s); L += world.Tracer.TraceRay(ray, depth); } L /= vp.NumSamples; L *= ExposureTime; world.Screen.AddPixel(r, c, L); } }
public override bool Hit(Ray ray, ref float tmin, ref ShadeRec sr) { float t; Vector3 temp = ray.Position - center; float a = Vector3.Dot(ray.Direction, ray.Direction); float b = 2.0f * Vector3.Dot(temp, ray.Direction); float c = Vector3.Dot(temp, temp) - radius * radius; float disc = b * b - 4.0f * a * c; if (disc < 0.0) return (false); else { float e = MathHelper.Sqrt(disc); float denom = 2.0f * a; t = (-b - e) / denom; if (t > MathHelper.BigEpsilon) { tmin = t; sr.Normal = -(temp + t * ray.Direction) / radius; sr.LocalHitPoint = ray.Position + t * ray.Direction; return (true); } t = (-b + e) / denom; if (t > MathHelper.BigEpsilon) { tmin = t; sr.Normal = -(temp + t * ray.Direction) / radius; sr.LocalHitPoint = ray.Position + t * ray.Direction; return (true); } } return (false); }
public override bool ShadowHit(Ray ray, ref float tmin) { if (!Shadows) return false; float t; Vector3 temp = ray.Position - Center; float a = Vector3.Dot(ray.Direction, ray.Direction); float b = 2.0f * Vector3.Dot(temp, ray.Direction); float c = Vector3.Dot(temp, temp) - Radius * Radius; float disc = b * b - 4.0f * a * c; if (disc < 0.0) return (false); else { float e = MathHelper.Sqrt(disc); float denom = 2.0f * a; t = (-b - e) / denom; // smaller root if (t > MathHelper.BigEpsilon) { tmin = t; return (true); } t = (-b + e) / denom; // larger root if (t > MathHelper.BigEpsilon) { tmin = t; return (true); } } return (false); }
public override bool ShadowHit(Ray ray, ref float tmin) { if (bbox.Hit(ray)) return base.ShadowHit(ray, ref tmin); else return false; }
public override bool Hit(Ray ray, ref float tmin, ref ShadeRec sr) { if (box.Hit(ray)) { return m.Hit(ray, ref tmin, ref sr); } return false; }
public override Vector3 TraceRay(Ray ray) { ShadeRec sr = World.HitObjects(ray); if (sr.Hit_an_object) return sr.Color; else return World.Background; }
public override Vector3 Path_Shade(ShadeRec sr) { Vector3 wo = -sr.Ray.Direction; Vector3 wi = Vector3.Zero; float pdf = 0; Vector3 fr = reflective.Sample_F(sr, wo, ref wi, ref pdf); Ray reflected_ray = new Ray(sr.HitPoint, wi); return (fr * sr.World.Tracer.TraceRay(reflected_ray, sr.Depth + 1) * (sr.Normal * wi) / pdf); }
public override bool ShadowHit(Ray ray, ref float tmin) { if (Shadows) { float t; Vector3 temp = ray.Position - center; float a = Vector3.Dot(ray.Direction, ray.Direction); float b = 2.0f * Vector3.Dot(temp, ray.Direction); float c = Vector3.Dot(temp, temp) - radius * radius; float disc = b * b - 4.0f * a * c; if (disc < 0.0) return (false); else { float e = MathHelper.Sqrt(disc); float denom = 2.0f * a; t = (-b - e) / denom; // smaller root if (t > MathHelper.Epsilon) { Vector3 hit = ray.Position + t * ray.Direction - center; float phi = MathHelper.Atan2(hit.X, hit.Z); if (phi < 0.0) phi += MathHelper.TwoPI; if (hit.Y <= radius * cos_theta_min && hit.Y >= radius * cos_theta_max && phi >= phi_min && phi <= phi_max) { tmin = t; return (true); } } t = (-b + e) / denom; // larger root if (t > MathHelper.Epsilon) { Vector3 hit = ray.Position + t * ray.Direction - center; float phi = MathHelper.Atan2(hit.X, hit.Z); if (phi < 0.0) phi += MathHelper.TwoPI; if (hit.Y <= radius * cos_theta_min && hit.Y >= radius * cos_theta_max && phi >= phi_min && phi <= phi_max) { tmin = t; return (true); } } } return (false); } return false; }
public override bool InShadow(Ray ray, ShadeRec sr) { float t = float.MaxValue; int num_objects = sr.World.Objects.Count; float d = Vector3.Distance(Location, (ray.Position)); for (int j = 0; j < num_objects; j++) if (sr.World.Objects[j].ShadowHit(ray, ref t) && t < d) return (true); return (false); }
public override bool InShadow(Ray ray, ShadeRec sr) { float t = float.MaxValue; // may be need an initialization int num_objects = sr.World.Objects.Count; float d = (Position - ray.Position).Length(); for (int j = 0; j < num_objects; j++) if (sr.World.Objects[j].ShadowHit(ray, ref t) && t < d) return (true); return (false); }
public override bool Hit(Ray ray, ref float tmin, ref ShadeRec sr) { float t; float ox = ray.Position.X; float oy = ray.Position.Y; float oz = ray.Position.Z; float dx = ray.Direction.X; float dy = ray.Direction.Y; float dz = ray.Direction.Z; float a = dx * dx + dz * dz; float b = 2.0f * (ox * dx + oz * dz); float c = ox * ox + oz * oz - radius * radius; float disc = b * b - 4.0f * a * c; if (disc < 0.0) return (false); else { float e = MathHelper.Sqrt(disc); float denom = 2.0f * a; t = (-b - e) / denom; // smaller root if (t > MathHelper.Epsilon) { float yhit = oy + t * dy; if (yhit > y0 && yhit < y1) { tmin = t; sr.Normal = new Vector3((ox + t * dx) * inv_radius, 0.0f, (oz + t * dz) * inv_radius); sr.Normal.Normalize(); if (Vector3.Dot(-ray.Direction, sr.Normal) < 0.0f) sr.Normal = -sr.Normal; sr.LocalHitPoint = ray.Position + tmin * ray.Direction; return (true); } } t = (-b + e) / denom; // larger root if (t > MathHelper.Epsilon) { float yhit = oy + t * dy; if (yhit > y0 && yhit < y1) { tmin = t; sr.Normal = new Vector3((ox + t * dx) * inv_radius, 0.0f, (oz + t * dz) * inv_radius); sr.Normal.Normalize(); if (Vector3.Dot(-ray.Direction, sr.Normal) < 0.0f) sr.Normal = -sr.Normal; sr.LocalHitPoint = ray.Position + tmin * ray.Direction; return (true); } } } return (false); }
public override bool Hit(Ray ray, ref float tmin, ref ShadeRec sr) { float t = 0; float ox = ray.Position.X; float oy = ray.Position.Y; float oz = ray.Position.Z; float dx = ray.Direction.X; float dy = ray.Direction.Y; float dz = ray.Direction.Z; float h2r2 = h * h / (r * r); float a = h2r2 * dx * dx + h2r2 * dz * dz - dy * dy; float b = 2.0f * (h2r2 * ox * dx - oy * dy + h * dy + h2r2 * oz * dz); float c = h2r2 * ox * ox - oy * oy + 2 * h * oy - h * h + h2r2 * oz * oz; float disc = b * b - 4.0f * a * c; if (disc < 0.0) return (false); else { float e = MathHelper.Sqrt(disc); float denom = 2.0f * a; t = (-b - e) / denom; // smaller root if (t > MathHelper.Epsilon) { Vector3 hitpoint = ray.Position + t * ray.Direction; if (hitpoint.Y > 0 && hitpoint.Y < h) { tmin = t; sr.Normal = new Vector3(2.0f * h * hitpoint.X / r, -2.0f * (hitpoint.Y - h), 2.0f * h * hitpoint.Z / r); sr.Normal.Normalize(); if (Vector3.Dot(-ray.Direction, sr.Normal) < 0.0) sr.Normal = -sr.Normal; sr.LocalHitPoint = ray.Position + tmin * ray.Direction; return (true); } } t = (-b + e) / denom; // larger root if (t > MathHelper.Epsilon) { Vector3 hitpoint = ray.Position + t * ray.Direction; if (hitpoint.Y > 0 && hitpoint.Y < h) { tmin = t; sr.Normal = new Vector3(2.0f * h * hitpoint.X / r, -2.0f * (hitpoint.Y - h), 2.0f * h * hitpoint.Z / r); sr.Normal.Normalize(); if (Vector3.Dot(-ray.Direction, sr.Normal) < 0.0) sr.Normal = -sr.Normal; sr.LocalHitPoint = ray.Position + tmin * ray.Direction; return (true); } } } return (false); }
public override Vector3 Area_Light_Shade(ShadeRec sr) { Vector3 L = (base.Area_Light_Shade(sr)); Vector3 wo = (-sr.Ray.Direction); Vector3 wi = Vector3.Zero; float pdf = 0; Vector3 fr = (glossy_specular.Sample_F(sr, wo, ref wi, ref pdf)); Ray reflected_ray = new Ray(sr.HitPoint, wi); L += fr * sr.World.Tracer.TraceRay(reflected_ray, sr.Depth + 1) * (Vector3.Dot(sr.Normal, wi)) / pdf; return (L); }
public override bool ShadowHit(Ray ray, ref float tmin) { if (Shadows) { float t; float ox = ray.Position.X; float oy = ray.Position.Y; float oz = ray.Position.Z; float dx = ray.Direction.X; float dy = ray.Direction.Y; float dz = ray.Direction.Z; float a = dx * dx + dz * dz; float b = 2.0f * (ox * dx + oz * dz); float c = ox * ox + oz * oz - radius * radius; float disc = b * b - 4.0f * a * c; if (disc < 0.0f) return (false); else { float e = MathHelper.Sqrt(disc); float denom = 2.0f * a; t = (-b - e) / denom; // smaller root if (t > MathHelper.Epsilon) { float yhit = oy + t * dy; if (yhit > y0 && yhit < y1) { if (t < tmin) { tmin = t; return (true); } } } t = (-b + e) / denom; // larger root if (t > MathHelper.Epsilon) { float yhit = oy + t * dy; if (yhit > y0 && yhit < y1) { if (t < tmin) { tmin = t; // this is very important return (true); } } } } return (false); } return false; }
public override bool InShadow(Ray ray, ShadeRec sr) { float t = float.MaxValue; int num_objects = sr.World.Objects.Count; for (int j = 0; j < num_objects; j++) { if (sr.World.Objects[j].ShadowHit(ray, ref t)) return true; } return (false); }