3D游戏编程大师技巧(上下册) 9.1分
读书笔记 3D裁剪
麻子

函数Clip_Polys_RENDERLIST4DV2有问题 在处理CLIP_POLY_Y_PLANE的时候,应该 z_factor = 0.5f * cam.viewplane_height / cam.view_dist; 而不是 z_factor = 0.5f * cam.viewplane_width / cam.view_dist; --------- 补充, 裁剪后未处理顶点法线,Gouraud着色方式下有问题,

修正前
修正后

修正代码节选: (num_verts_in == 2 时) // 法线插值, fixed by mazi if (curr_poly->attr & POLY4DV2_ATTR_SHADE_MODE_GOURAUD) { n01.x = curr_poly->vert_list_trans[v0].nx + (curr_poly->vert_list_trans[v1].nx - curr_poly->vert_list_trans[v0].nx) * t1; n01.y = curr_poly->vert_list_trans[v0].ny + (curr_poly->vert_list_trans[v1].ny - curr_poly->vert_list_trans[v0].ny) * t1; n01.z = curr_poly->vert_list_trans[v0].nz + (curr_poly->vert_list_trans[v1].nz - curr_poly->vert_list_trans[v0].nz) * t1; n01.normalize(); n02.x = curr_poly->vert_list_trans[v0].nx + (curr_poly->vert_list_trans[v2].nx - curr_poly->vert_list_trans[v0].nx) * t2; n02.y = curr_poly->vert_list_trans[v0].ny + (curr_poly->vert_list_trans[v2].ny - curr_poly->vert_list_trans[v0].ny) * t2; n02.z = curr_poly->vert_list_trans[v0].nz + (curr_poly->vert_list_trans[v2].nz - curr_poly->vert_list_trans[v0].nz) * t2; n02.normalize(); // poly 1 curr_poly->vert_list_trans[v0].normal = n01; // poly 2 temp_poly.vert_list_trans[v1].normal = n01; temp_poly.vert_list_trans[v0].normal = n02; }

3
《3D游戏编程大师技巧(上下册)》的全部笔记 16篇
豆瓣
免费下载 iOS / Android 版客户端