diff --git a/examples/occlusion/occdemo.c b/examples/occlusion/occdemo.c index 6a6879d33c..dc43239604 100644 --- a/examples/occlusion/occdemo.c +++ b/examples/occlusion/occdemo.c @@ -422,7 +422,8 @@ void render_big_scene(surface_t* disp) // HACK: always draw occluders to SW Z-buffer even if they didn't pass the rough check if (true || visible) { // also draw to software zbuffer - occ_draw_mesh(culler, sw_zbuffer, &cube_hull.mesh, xform); + //occ_draw_mesh(culler, sw_zbuffer, &cube_hull.mesh, xform); + occ_draw_hull(culler, sw_zbuffer, &cube_hull, xform); } if (visible) { big_scene.stats.num_drawn++; @@ -526,9 +527,9 @@ void render() occ_set_view_and_projection(culler, &g_view, &g_projection); //render_door_scene(disp); - //render_big_scene(disp); + render_big_scene(disp); //render_2d_scene(disp); - render_single_cube_scene(disp); + // render_single_cube_scene(disp); gl_context_end(); @@ -698,7 +699,7 @@ int main() rspq_flush(); uint32_t ticks_end = get_ticks(); - if (false) { + if (true) { double delta = (ticks_end - ticks_start) / (double)TICKS_PER_SECOND; debugf("deltatime: %f ms\n", delta * 1000.0); prof_print_stats(); diff --git a/examples/occlusion/occlusion.h b/examples/occlusion/occlusion.h index 3e30ccdd96..a06fef6aef 100644 --- a/examples/occlusion/occlusion.h +++ b/examples/occlusion/occlusion.h @@ -35,7 +35,7 @@ const float inv_subpixel_scale = 1.0f / SUBPIXEL_SCALE; #define ZBUFFER_UINT_PTR_AT(zbuffer, x, y) ((u_uint16_t *)(zbuffer->buffer + (zbuffer->stride * y + x * sizeof(uint16_t)))) #define DUMP_WHEN_Z_OVERFLOWS 1 -#define SCREENSPACE_BIAS (-0.5f) // bias for (x,y) screenspace coordinates to make them cover RDP draw pixels +#define SCREENSPACE_BIAS (-0.50f) // an empirical bias for (x,y) screenspace coordinates to make them cover OpenGL drawn pixels // Rasky's "defer statement" implementation. #define PPCAT2(n,x) n ## x @@ -232,7 +232,7 @@ void draw_tri( occ_raster_query_result_t* result, surface_t *zbuffer) { - // The -0.5 screenspace bias is added to empirically match SW depth map pixels to hi-rez RDP picture. + // The screenspace bias is added to empirically match SW depth map pixels to hi-rez RDP picture. vec2 v0 = {SUBPIXEL_SCALE * (v0f.x+SCREENSPACE_BIAS) + 0.5f, SUBPIXEL_SCALE * (v0f.y+SCREENSPACE_BIAS) + 0.5f}; vec2 v1 = {SUBPIXEL_SCALE * (v1f.x+SCREENSPACE_BIAS) + 0.5f, SUBPIXEL_SCALE * (v1f.y+SCREENSPACE_BIAS) + 0.5f}; vec2 v2 = {SUBPIXEL_SCALE * (v2f.x+SCREENSPACE_BIAS) + 0.5f, SUBPIXEL_SCALE * (v2f.y+SCREENSPACE_BIAS) + 0.5f}; @@ -504,17 +504,17 @@ void occ_draw_indexed_mesh_flags(occ_culler_t *occ, surface_t *zbuffer, const ma if (tri_normals) { int num_tris = mesh->num_indices/3; - debugf("num_tris: %d\n", num_tris); + // debugf("num_tris: %d\n", num_tris); for (int i = 0; i < num_tris; i++) { float n_model[4] = {tri_normals[i].x, tri_normals[i].y, tri_normals[i].z, 0.f}; float n[4]; //TODO use inverse transpose if non-uniform scale? matrix_mult(&n[0], modelview, &n_model[0]); view_normals[i] = (vec3f){n[0], n[1], n[2]}; - debugf("[%-2d] (%f, %f, %f, %f) -> (%f, %f, %f, %f)\n", - i, - n_model[0], n_model[1], n_model[2], n_model[3], - n[0], n[1], n[2], n[3]); + // debugf("[%-2d] (%f, %f, %f, %f) -> (%f, %f, %f, %f)\n", + // i, + // n_model[0], n_model[1], n_model[2], n_model[3], + // n[0], n[1], n[2], n[3]); } } prof_end(REGION_TRANSFORM); @@ -571,13 +571,12 @@ void occ_draw_indexed_mesh_flags(occ_culler_t *occ, surface_t *zbuffer, const ma } if (tri_neighbors) { + // Silhouette edges join triangles with different view space Z signs for (int j = 0; j < 3; j++) { uint16_t other = tri_neighbors[tri_idx * 3 + j]; - // debugf("j=%d, other=%u\n", j, other); if (other != OCC_NO_EDGE_NEIGHBOR) { vec3f *N_other = &view_normals[other]; if (N_other->z < 0) { - // debugf("tri_idx=%d, N->z = %f, N_other = %f\n", tri_idx, N->z, N_other->z); edge_flag_mask |= (RASTER_FLAG_SHRINK_EDGE_01 << j); } } @@ -896,7 +895,7 @@ bool occ_hull_from_flat_mesh(const occ_mesh_t* mesh_in, occ_hull_t* hull_out) m->num_vertices = 0; // will be incremented in the loop below - bool verbose = true; + bool verbose = false; for (uint32_t vertex_idx=0; vertex_idx < mesh_in->num_vertices; vertex_idx++) { float f[3] = {