mirror of
https://github.com/holub/mame
synced 2025-05-19 20:29:09 +03:00
Added two-sided polygon flag and back-face culling to Model 3 video emulation [Naibo Zhang]
From: naibo zhang [naibo_zhang@hotmail.com] Sent: Tuesday, October 13, 2009 6:11 PM To: submit@mamedev.org Subject: Sega Model-3 backface culling & stepstag rename Sega Model-3 video emulation improvement: figured out the flag bit indicating a single-/double-side polygon. Added backface culling code. Some graphic flickering glitches are gone.
This commit is contained in:
parent
4e0c48083f
commit
c089acef32
@ -1124,7 +1124,7 @@ static void draw_model(UINT32 addr)
|
||||
UINT32 *model = (addr >= 0x100000) ? &model3_vrom[addr] : &polygon_ram[addr];
|
||||
UINT32 header[7];
|
||||
int index = 0;
|
||||
int last_polygon = FALSE;
|
||||
int last_polygon = FALSE, back_face = FALSE;
|
||||
int num_vertices;
|
||||
int i, v, vi;
|
||||
float fixed_point_fraction;
|
||||
@ -1216,7 +1216,7 @@ static void draw_model(UINT32 addr)
|
||||
sn[1] *= coordinate_system[1][2];
|
||||
sn[2] *= coordinate_system[2][0];
|
||||
|
||||
/* TODO: backface culling */
|
||||
/* TODO: depth bias */
|
||||
/* transform vertices */
|
||||
for (i = 0; i < num_vertices; i++)
|
||||
{
|
||||
@ -1245,6 +1245,17 @@ static void draw_model(UINT32 addr)
|
||||
num_vertices = clip_polygon(clip_vert, num_vertices, clip_plane[3], clip_vert);
|
||||
num_vertices = clip_polygon(clip_vert, num_vertices, clip_plane[4], clip_vert);
|
||||
|
||||
/* backface culling */
|
||||
if( (header[6] & 0x800000) && (!(header[1] & 0x0010)) ) {
|
||||
if(sn[0]*clip_vert[0].x + sn[1]*clip_vert[0].y + sn[2]*clip_vert[0].pz >0)
|
||||
back_face = 1;
|
||||
else
|
||||
back_face = 0;
|
||||
}
|
||||
else
|
||||
back_face = 0; //no culling for transparent or two-sided polygons
|
||||
|
||||
if(!back_face) {
|
||||
/* homogeneous Z-divide, screen-space transformation */
|
||||
for(i=0; i < num_vertices; i++) {
|
||||
float ooz = 1.0f / clip_vert[i].pz;
|
||||
@ -1295,6 +1306,7 @@ static void draw_model(UINT32 addr)
|
||||
|
||||
render_one(&tri);
|
||||
}
|
||||
}
|
||||
|
||||
++polynum;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user