예제 #1
0
void RayTracer::createSceneFromBook(HitableList& list)
{
	Camera& camera = m_cameraSystem.getCurrentCamera();

	camera.setPosition(vec3(16.857f, 2.0f, 6.474f));
	camera.setYaw(Math::toRadians(247.8f));
	camera.setPitch(Math::toRadians(-4.762f));
	camera.setAperture(0.1f);
	camera.setFocusDistance(17.29f);

	list.add( new Sphere(vec3(0,-1000,0), 1000, new Lambertian(vec3(0.5, 0.5, 0.5))) );

	for (int a = -11; a < 11; a++)
	{
		for (int b = -11; b < 11; b++)
		{
			float choose_mat = getRandom();
			vec3 center(a + 0.9f * getRandom(), 0.2f, b + 0.9f * getRandom());
			if ((center-vec3(4,0.2,0)).length() > 0.9f)
			{ 
				if (choose_mat < 0.8f)
				{
					// diffuse
					list.add( new Sphere(center, 0.2f, new Lambertian(vec3( getRandom()*getRandom(), getRandom()*getRandom(), getRandom()*getRandom()))));
				}
				else if (choose_mat < 0.95f)
				{
					// metal
					list.add( new Sphere(center, 0.2f,
							new Metal(vec3(0.5f*(1.0f + getRandom()), 0.5f*(1.0f + getRandom()), 0.5f*(1.0f + getRandom())), /*roughness*/ 0.5f*getRandom())));
				}
				else
				{
					// glass
					list.add( new Sphere(center, 0.2f, new Dielectric(vec3(0.8f, 0.5f, 0.3f), /*refractive_index*/1.5f)) );
				}
			}
		}
	}

	list.add( new Sphere(vec3(0, 1, 0), 1.0, new Dielectric(vec3(0.8f, 0.5f, 0.3f), /*refractive_index*/1.5f)) );
	list.add( new Sphere(vec3(-4, 1, 0), 1.0, new Lambertian(vec3(0.0, 0.2, 0.9))) );
	list.add( new Sphere(vec3(4, 1, 0), 1.0, new Metal(vec3(0.7, 0.6, 0.5), 0.0)) );

	m_tree.init(list.list(), 0, 0);
}
예제 #2
0
void RayTracer::createSceneOne(HitableList& world, bool loadBunny)
{
	Camera& camera = m_cameraSystem.getCurrentCamera();

	camera.setFieldOfViewDeg(44.6f);

	//camera.setPosition(vec3(0.698890f, 1.275992f, 6.693169f));
	//camera.setYaw(Math::toRadians(188.0f));
	//camera.setPitch(Math::toRadians(-7.744f));
	//camera.setAperture(0.3f);
	//camera.setFocusDistance(7.6f);

	camera.setPosition(vec3(-0.16f, 2.9664f, 14.8691f));
	camera.setYaw(Math::toRadians(178.560333f));
	camera.setPitch(Math::toRadians(-10.8084f));
	camera.setAperture(0.07f);
	camera.setFocusDistance(14.763986f);

	// A big light
	world.add(
		new Sphere(vec3(0.0f, 6.0f, -1.0f), 2.0f,
		new Light(vec3(4.0f, 4.0f, 4.0f)))
		);

	// A small light
	world.add(
		new Sphere(vec3(0.85, 0.3, -0.15f), 0.1f,
		new Light(vec3(16.0f, 16.0f, 16.0f)))
		);

	// A ball
	world.add(
		new Sphere(vec3(0, 0, -1), 0.5f,
		new Lambertian(vec3(0.8f, 0.3f, 0.3f)))
		);
	// The planet
	world.add(
		new Sphere(vec3(0, -100.5f, -1), 100.0f,
		new Lambertian(vec3(0.0f, 0.7f, 0.8f)))
		);
	
	// Metal balls
	world.add(
		new Sphere(vec3(1, 0, -1), 0.5f,
		new Metal(vec3(0.8f, 0.6f, 0.2f), /*roughness*/0.0f))
		);
	world.add(
		new Sphere(vec3(-0.5f, 0.65f, -1), 0.4f,
		new Metal(vec3(0.8f, 0.4f, 0.8f), /*roughness*/0.3f))
		);
	// Dielectric
	world.add(
		new Sphere(vec3(-1, 0, -1), 0.5f,
		new Dielectric(vec3(0.8f, 0.5f, 0.3f), /*refractive_index*/1.5f))
		);
	world.add(
		new Sphere(vec3(-3.15f, 0.1f, -5), 0.6f,
		new Lambertian(vec3(0.05f, 0.2f, 0.8f)))
		);

	///////////////////

	auto bunny = new Mesh(0);
	if (loadBunny)
		bunny->loadModel("./data/models/bunny.obj");
	else bunny->generateBox();

	world.add(bunny);

	m_tree.init(world.list(), 0, 0);
}