[FEAT] Chapter 11 is done.
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 28 KiB |
@@ -258,7 +258,7 @@ const double IntersectionData::n2(void) const
|
|||||||
|
|
||||||
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
||||||
|
|
||||||
double IntersectionData::schlick(void)
|
double IntersectionData::schlick(void) const
|
||||||
{
|
{
|
||||||
double the_cos, the_r0;
|
double the_cos, the_r0;
|
||||||
|
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ namespace Raytracer
|
|||||||
void set_n2(double an_n2);
|
void set_n2(double an_n2);
|
||||||
const double n2(void) const;
|
const double n2(void) const;
|
||||||
|
|
||||||
double schlick(void);
|
double schlick(void) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_is_inside;
|
bool m_is_inside;
|
||||||
|
|||||||
@@ -167,8 +167,17 @@ Color World::shade_hit(const IntersectionData &an_intersection_data, uint32_t a_
|
|||||||
Shape *the_object = an_intersection_data.object();
|
Shape *the_object = an_intersection_data.object();
|
||||||
Color the_surface = the_object->material().lighting(the_object, m_light, an_intersection_data.over_point(),
|
Color the_surface = the_object->material().lighting(the_object, m_light, an_intersection_data.over_point(),
|
||||||
an_intersection_data.eyev(), an_intersection_data.normalv(), the_shadowed);
|
an_intersection_data.eyev(), an_intersection_data.normalv(), the_shadowed);
|
||||||
|
|
||||||
Color the_reflected = reflected_color(an_intersection_data, a_remaining);
|
Color the_reflected = reflected_color(an_intersection_data, a_remaining);
|
||||||
Color the_refracted = refracted_color(an_intersection_data, a_remaining);
|
Color the_refracted = refracted_color(an_intersection_data, a_remaining);
|
||||||
|
|
||||||
|
Material &the_material = an_intersection_data.object()->material();
|
||||||
|
if ((the_material.reflective() > 0) && (the_material.transparency() > 0))
|
||||||
|
{
|
||||||
|
double the_reflectance = an_intersection_data.schlick();
|
||||||
|
return the_surface + (the_reflected * the_reflectance) + the_refracted * (1 - the_reflectance);
|
||||||
|
}
|
||||||
|
|
||||||
return the_surface + the_reflected + the_refracted;
|
return the_surface + the_reflected + the_refracted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user