Home › Forums › GAMES在线课程(现代计算机图形学入门)讨论区 › 作业7 简单抗锯齿出现毛边 › Reply To: 作业7 简单抗锯齿出现毛边
修改起来很方便,把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情况下也能获取不错的效果