src/raytracer.cc
branchpyrit
changeset 25 b8232edee786
parent 22 76b7bd51d64a
child 30 33f95441790e
equal deleted inserted replaced
24:d0d76e8a5203 25:b8232edee786
    98 		return bg_colour;
    98 		return bg_colour;
    99 	} else {
    99 	} else {
   100 		Colour acc = Colour();
   100 		Colour acc = Colour();
   101 		Vector3 P = ray.o + ray.dir * nearest_distance; // point of intersection
   101 		Vector3 P = ray.o + ray.dir * nearest_distance; // point of intersection
   102 		Vector3 normal = nearest_shape->normal(P);
   102 		Vector3 normal = nearest_shape->normal(P);
       
   103 		// make shapes double sided
       
   104 		if (dot(normal, ray.dir) > 0.0)
       
   105 			normal = - normal;
   103 		acc = PhongShader_ambient(*nearest_shape->material, P);
   106 		acc = PhongShader_ambient(*nearest_shape->material, P);
   104 
   107 
   105 		vector<Light*>::iterator light;
   108 		vector<Light*>::iterator light;
   106 		for (light = lights.begin(); light != lights.end(); light++) {
   109 		for (light = lights.begin(); light != lights.end(); light++) {
   107 			Vector3 jo, L = (*light)->pos - P; // direction vector to light
   110 			Vector3 jo, L = (*light)->pos - P; // direction vector to light