作业二 提高ssaa中,三角形显示界面两边出现三角横线。
代码如下
if (insideTriangle(x + i, y + j, t.v)) {
auto [alpha, beta, gamma] = computeBarycentric2D(x+i, y+j, t.v);
float w_reciprocal = 1.0 / (alpha / v[0].w() + beta / v[1].w() + gamma / v[2].w());
float z_interpolated = alpha * v[0].z() / v[0].w() + beta * v[1].z() / v[1].w() + gamma * v[2].z() / v[2].w();
z_interpolated *= w_reciprocal;
int buf_ssaa_index = get_ssaa_index(x+i, y+j);
//int buf_index = get_index(x , y );
//int buf_index = get_index(x+i*2, y+j*2);
if (z_interpolated < depth_buf[buf_ssaa_index])
{
//set_pixel(p, t.getColor());
frame_buf[buf_ssaa_index] = t.getColor();
depth_buf[buf_ssaa_index] = z_interpolated;
//deindex += z_interpolated;
}
}
Attachments:
You must be
logged in to view attached files.