Example #1
0
inline vector3f get_specular(double *spc, primitive *pri, ray &r, kdtree &kdtree, int depth) {
	vector3f specular(0.0, 0.0, 0.0);
	if (spc[0] + spc[1] + spc[2] > eps)
	{
		vector3f surface_normal(pri->get_normal(r.origin));
		ray specular_ray(r.origin, r.direction - 2 * (r.direction * surface_normal) * surface_normal);
		specular = map_mul(get_ray_trace(specular_ray, kdtree, depth + 1), vector3f(spc));
	}
	return specular;
}
Example #2
0
			void simple_cube_shade(Mesh<VertexT> & mesh)
			{
				// Look at each face
				for (std::size_t c = 0; c < mesh.vertices.size(); c += 4) {
					Vec3 normal = surface_normal(mesh.vertices[c].position, mesh.vertices[c+1].position, mesh.vertices[c+2].position);

					mesh.vertices[c+0].normal = normal;
					mesh.vertices[c+1].normal = normal;
					mesh.vertices[c+2].normal = normal;
					mesh.vertices[c+3].normal = normal;

					mesh.vertices[c+0].mapping = Vec2(1, 0);
					mesh.vertices[c+1].mapping = Vec2(0, 0);
					mesh.vertices[c+2].mapping = Vec2(1, 1);
					mesh.vertices[c+3].mapping = Vec2(0, 1);
				}
			}