#6497 Score: 0
oxine
Participant
9 pts

修改起来很方便,把xy以及射线的生成挪到spp循环内部就行了,这样可以节省一次循环

for (int k = 0; k < spp; k++){
	//generate primary ray direction
	float x = (2 * (i + get_random_float()) / (float)scene.width - 1) * imageAspectRatio * scale;
	float y = (1 - 2 * (j + get_random_float()) / (float)scene.height) * scale;
	Vector3f dir = normalize(Vector3f(-x, y, 1));
	auto index = j*scene.width + i;
        framebuffer[index] += scene.castRay(Ray(eye_pos, dir), 0) / spp;
}

在低spp情况下也能获取不错的效果

Attachments:
You must be logged in to view attached files.