Views: 6,915,763 | Homepage | Main | Rules/FAQ | Memberlist | Active users | Last posts | Calendar | Stats | Online users | Search | 04-25-24 04:22 PM |
Guest: |
0 users reading GPU3D: culling research | 1 bot |
Main - Development - GPU3D: culling research | Hide post layouts | New reply |
Arisotura |
| ||
Big fire melon magical melon girl Level: 56 Posts: 512/889 EXP: 1347817 Next: 50359 Since: 03-28-17 From: France Last post: 1 hour ago Last view: 37 min. ago |
okay so
// culling
this is the culling code that melonDS employs atm. it's not too far away from what the DS seems to use. however:
// TODO: work out how it works on the real thing // the normalization part is a wild guess Vertex *v0, *v1, *v2, *v3; s64 normalX, normalY, normalZ; s64 dot; v0 = &TempVertexBuffer[0]; v1 = &TempVertexBuffer[1]; v2 = &TempVertexBuffer[2]; v3 = &TempVertexBuffer[3]; normalX = ((s64)(v0->Position[1]-v1->Position[1]) * (v2->Position[3]-v1->Position[3])) - ((s64)(v0->Position[3]-v1->Position[3]) * (v2->Position[1]-v1->Position[1])); normalY = ((s64)(v0->Position[3]-v1->Position[3]) * (v2->Position[0]-v1->Position[0])) - ((s64)(v0->Position[0]-v1->Position[0]) * (v2->Position[3]-v1->Position[3])); normalZ = ((s64)(v0->Position[0]-v1->Position[0]) * (v2->Position[1]-v1->Position[1])) - ((s64)(v0->Position[1]-v1->Position[1]) * (v2->Position[0]-v1->Position[0])); while ((((normalX>>31) ^ (normalX>>63)) != 0) || (((normalY>>31) ^ (normalY>>63)) != 0) || (((normalZ>>31) ^ (normalZ>>63)) != 0)) { normalX >>= 4; normalY >>= 4; normalZ >>= 4; } dot = ((s64)v1->Position[0] * normalX) + ((s64)v1->Position[1] * normalY) + ((s64)v1->Position[3] * normalZ); bool facingview = (dot < 0); if (facingview) { if (!(CurPolygonAttr & (1<<7))) { LastStripPolygon = NULL; return; } } else if (dot > 0) { if (!(CurPolygonAttr & (1<<6))) { LastStripPolygon = NULL; return; } } * on the DS, polygons always pass culling if they have v0==v2 or v1==v2, even if cull mode is 0. ** this would imply that the DS uses v2 as a base vertex. melonDS is using v1. ** it only checks X, Y and W. Z can be whatever. * cases of dot=0 pass both culling modes 1 and 2, but not 0 (unless they match the exception above). * the DS employs some mechanism for reducing precision of the normal components as needed so it doesn't overflow. the mechanism is weird tho. but for example specific input can cause erroneous cases of dot=0. *actually, testing tends to hint the DS is using v0 as a base. ____________________ Kuribo64 |
Main - Development - GPU3D: culling research | Hide post layouts | New reply |
Page rendered in 0.028 seconds. (2048KB of memory used) MySQL - queries: 26, rows: 73/73, time: 0.015 seconds. Acmlmboard 2.064 (2018-07-20) © 2005-2008 Acmlm, Xkeeper, blackhole89 et al. |