protected Vector3 Color(Ray ray, int depth, int max_depth) { HitData hit_data = new HitData(); if (Hit(ray, 0.01f, MAX_HIT_DISTANCE, ref hit_data)) { Ray scattered = new Ray(); Vector3 attenuation = Vector3.Zero; IMaterialScatter material_scatter = MaterialScatters.GetMaterialScatter(hit_data.Material); Vector3 emit = material_scatter.Emit(hit_data.Material, ray, hit_data); if (depth < max_depth && material_scatter.Scatter(hit_data.Material, ray, hit_data, ref attenuation, ref scattered)) { return(emit + attenuation * Color(scattered, depth + 1, max_depth)); } else { return(emit); } } return(Vector3.Zero); }
private static void AddScatter(IMaterial material, IMaterialScatter scatter) { material_scatters.Add(material.TypeName, scatter); }