Skip to content

Commit

Permalink
Revert "Hybrid Sorted Z-Buffered mode"
Browse files Browse the repository at this point in the history
This reverts commits
- 464e654
- f7ffd9f
- 7d1e370
- 497bb9d
  • Loading branch information
Arsunt committed Aug 1, 2020
1 parent 0580db5 commit cb0b2ec
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 110 deletions.
30 changes: 5 additions & 25 deletions 3dsystem/3d_gen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -587,25 +587,10 @@ void __cdecl S_InsertBackground(__int16 *ptrObj) {
if( SavedAppSettings.RenderMode == RM_Hardware ) {
HWR_EnableZBuffer(false, false);
}
#ifdef FEATURE_VIDEOFX_IMPROVED
if( SavedAppSettings.RenderMode == RM_Hardware
&& SavedAppSettings.ZBuffer
&& !SavedAppSettings.DontSortPrimitives )
{
// NOTE: just draw background unsorted right now with ZBuffer disabled
ptrObj = InsertObjectGT4_ZBuffered(ptrObj+1, *ptrObj, ST_FarZ);
ptrObj = InsertObjectGT3_ZBuffered(ptrObj+1, *ptrObj, ST_FarZ);
ptrObj = InsertObjectG4_ZBuffered(ptrObj+1, *ptrObj, ST_FarZ);
ptrObj = InsertObjectG3_ZBuffered(ptrObj+1, *ptrObj, ST_FarZ);
}
else
#endif // FEATURE_VIDEOFX_IMPROVED
{
ptrObj = ins_objectGT4(ptrObj+1, *ptrObj, ST_FarZ);
ptrObj = ins_objectGT3(ptrObj+1, *ptrObj, ST_FarZ);
ptrObj = ins_objectG4(ptrObj+1, *ptrObj, ST_FarZ);
ptrObj = ins_objectG3(ptrObj+1, *ptrObj, ST_FarZ);
}
ptrObj = ins_objectGT4(ptrObj+1, *ptrObj, ST_FarZ);
ptrObj = ins_objectGT3(ptrObj+1, *ptrObj, ST_FarZ);
ptrObj = ins_objectG4(ptrObj+1, *ptrObj, ST_FarZ);
ptrObj = ins_objectG3(ptrObj+1, *ptrObj, ST_FarZ);
if( SavedAppSettings.RenderMode == RM_Hardware ) {
HWR_EnableZBuffer(true, true);
}
Expand Down Expand Up @@ -1022,12 +1007,7 @@ void __cdecl phd_InitWindow(__int16 x, __int16 y, int width, int height, int nea
ins_trans_quad = InsertTransQuad;
}
else if( SavedAppSettings.RenderMode == RM_Hardware ) {
#ifdef FEATURE_VIDEOFX_IMPROVED
if( SavedAppSettings.ZBuffer && SavedAppSettings.DontSortPrimitives )
#else // !FEATURE_VIDEOFX_IMPROVED
if( SavedAppSettings.ZBuffer )
#endif // !FEATURE_VIDEOFX_IMPROVED
{
if( SavedAppSettings.ZBuffer ) {
ins_objectGT3 = InsertObjectGT3_ZBuffered;
ins_objectGT4 = InsertObjectGT4_ZBuffered;
ins_objectG3 = InsertObjectG3_ZBuffered;
Expand Down
12 changes: 2 additions & 10 deletions 3dsystem/3dinsert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,6 @@ static double CalculatePolyZ(SORTTYPE sortType, double z0, double z1, double z2,
CLAMPL(zv, z1);
CLAMPL(zv, z2);
if( z3 > 0.0 ) CLAMPL(zv, z3);
#ifdef FEATURE_VIDEOFX_IMPROVED
if( SavedAppSettings.RenderMode == RM_Hardware
&& SavedAppSettings.ZBuffer
&& !SavedAppSettings.DontSortPrimitives )
{
zv = ( z3 > 0.0 ) ? (zv*4.0 + z0+z1+z2+z3)/8.0 : (zv*3.0 + z0+z1+z2)/6.0;
}
#endif // FEATURE_VIDEOFX_IMPROVED
break;

case ST_FarZ :
Expand Down Expand Up @@ -2471,7 +2463,7 @@ void __cdecl InsertSprite_Sorted(int z, int x0, int y0, int x1, int y1, int spri
bool isShadeEffectBackup = IsShadeEffect;
IsShadeEffect = false;
#ifdef FEATURE_VIDEOFX_IMPROVED
short polyType = POLY_Z_IGNORE | POLY_HWR_WGTmap;
short polyType = POLY_HWR_WGTmap;
if( CHK_ANY(flags, SPR_TINT) ) {
GlobalTint = RGBA_SETALPHA(flags, 0xFF);
}
Expand All @@ -2482,7 +2474,7 @@ void __cdecl InsertSprite_Sorted(int z, int x0, int y0, int x1, int y1, int spri
POLY_HWR_WGTmapSub,
POLY_HWR_WGTmapQrt,
};
polyType = POLY_Z_IGNORE | blend[(flags & SPR_BLEND) >> 29];
polyType = blend[(flags & SPR_BLEND) >> 29];
}
InsertClippedPoly_Textured(nPoints, (float)z, polyType, PhdSpriteInfo[spriteIdx].texPage);
GlobalTint = 0;
Expand Down
2 changes: 0 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added Dozy cheat on *O* key (cheat flag in *"TOMBPC.DAT"* file required). It gives fly mode and full health, use *Shift* key to disable it.
- Lara has golden skin while in Dozy mode (hardware renderer and reflection feature required).
- SFX number limit increased from 256 to 370.
- Z-Buffered mode is improved. Now every polygon is sorted and Z-Buffered, but sprites ignore Z-Buffer, so they're rendered properly, as if Z-Buffer was disabled.
- The "Don't sort transparent polys"* setting from the *"Advanced"* tab has been redesigned to disable the new Z-Buffered mode, instead of just messing the transparent polys (it is recommended to keep this setting unchecked anyway).
- Added automatic cdaudio.dat fix for PaulD's CD Audio solution, if some track has wrong parameters (like in the Steam version).

### The original game bugfixes
Expand Down
4 changes: 0 additions & 4 deletions global/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,6 @@ typedef struct {
#define IFL_REVERSE (0x4000)
#define IFL_CLEARBODY (0x8000)

// HWR poly sort flags
#define POLY_TYPEMASK (0x7FFF)
#define POLY_Z_IGNORE (0x8000)

// Glow tint colors
#define GLOW_FLARE_COLOR (0xFF8080) // Flare
#define GLOW_PISTOL_COLOR (0x3F380F) // Pistol/Magnums/Uzi gunfire
Expand Down
42 changes: 0 additions & 42 deletions specific/hwr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,7 @@ void __cdecl HWR_BeginScene() {
D3DDev->BeginScene();
}

#ifdef FEATURE_VIDEOFX_IMPROVED
void __cdecl HWR_DrawPolyList(int pass) {
#else // FEATURE_VIDEOFX_IMPROVED
void __cdecl HWR_DrawPolyList() {
#endif // FEATURE_VIDEOFX_IMPROVED
DWORD alphaState;
UINT16 *bufPtr;
UINT16 polyType, texPage, vtxCount;
Expand All @@ -239,44 +235,6 @@ void __cdecl HWR_DrawPolyList() {
bufPtr = (UINT16 *)SortBuffer[i]._0;

polyType = *(bufPtr++);
#ifdef FEATURE_VIDEOFX_IMPROVED
if( pass == 1 || pass == 2 ) {
bool zCheck = !CHK_ANY(polyType, POLY_Z_IGNORE);
bool zWrite = false;
bool noBlend = false;
switch( polyType & POLY_TYPEMASK ) {
case POLY_HWR_GTmap:
case POLY_HWR_gouraud:
case POLY_HWR_line:
#ifdef FEATURE_HUD_IMPROVED
case POLY_HWR_healthbar:
case POLY_HWR_airbar:
#endif // FEATURE_HUD_IMPROVED
zWrite = true;
noBlend = true;
break;
case POLY_HWR_WGTmap:
zWrite = false;
noBlend = true;
break;
}
// NOTE: noBlend sprites and zWrite polys are drawn in 1st pass.
// Same sprites are rendered one more time in 2nd pass, but with all other polys.
if( pass == 1 ) {
bool conditon = noBlend && (zWrite || !zCheck);
if( !conditon ) {
continue; // for other polys we need 2nd pass
}
} else {
if( zWrite ) {
continue; // we've drawn all zWrite polys in 1st pass
}
zCheck = true; // zCheck is always enabled for 2nd pass
}
HWR_EnableZBuffer(zWrite, zCheck);
}
polyType &= POLY_TYPEMASK;
#endif // FEATURE_VIDEOFX_IMPROVED
#ifdef FEATURE_HUD_IMPROVED
if( polyType == POLY_HWR_healthbar || polyType == POLY_HWR_airbar ) {
UINT16 x0 = *(bufPtr++);
Expand Down
4 changes: 0 additions & 4 deletions specific/hwr.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@ void __cdecl HWR_TexSource(HWR_TEXHANDLE texSource); // 0x0044D2A0
void __cdecl HWR_EnableColorKey(bool state); // 0x0044D2D0
void __cdecl HWR_EnableZBuffer(bool ZWriteEnable, bool ZEnable); // 0x0044D320
void __cdecl HWR_BeginScene(); // 0x0044D3B0
#ifdef FEATURE_VIDEOFX_IMPROVED
void __cdecl HWR_DrawPolyList(int pass); // 0x0044D3E0
#else // FEATURE_VIDEOFX_IMPROVED
void __cdecl HWR_DrawPolyList(); // 0x0044D3E0
#endif // FEATURE_VIDEOFX_IMPROVED
void __cdecl HWR_LoadTexturePages(int pagesCount, LPVOID pagesBuffer, RGB888 *palette); // 0x0044D560
void __cdecl HWR_FreeTexturePages(); // 0x0044D5F0
void __cdecl HWR_GetPageHandles(); // 0x0044D640
Expand Down
25 changes: 2 additions & 23 deletions specific/output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,21 +191,10 @@ void __cdecl S_OutputPolyList() {
}
} else {
// Hardware renderer
#ifdef FEATURE_VIDEOFX_IMPROVED
// NOTE: DontSortPrimitives option is redesigned to affect opaque only polygons
phd_SortPolyList();
if( SavedAppSettings.ZBuffer && !SavedAppSettings.DontSortPrimitives ) {
HWR_DrawPolyList(1);
HWR_DrawPolyList(2);
} else {
HWR_DrawPolyList(0);
}
#else // !FEATURE_VIDEOFX_IMPROVED
if( !SavedAppSettings.ZBuffer || !SavedAppSettings.DontSortPrimitives ) {
phd_SortPolyList();
}
HWR_DrawPolyList();
#endif // !FEATURE_VIDEOFX_IMPROVED
D3DDev->EndScene();
}
}
Expand Down Expand Up @@ -629,12 +618,7 @@ void __cdecl S_DrawHealthBar(int percent) {
IsShadeEffect = false;

if( HealthBarMode != 0 && SavedAppSettings.RenderMode == RM_Hardware ) {
#ifdef FEATURE_VIDEOFX_IMPROVED
if( SavedAppSettings.ZBuffer && SavedAppSettings.DontSortPrimitives )
#else // FEATURE_VIDEOFX_IMPROVED
if( SavedAppSettings.ZBuffer )
#endif // FEATURE_VIDEOFX_IMPROVED
{
if( SavedAppSettings.ZBuffer ) {
PSX_DrawHealthBar(x0, y0, x1, y1, bar, pixel);
} else {
PSX_InsertHealthBar(x0, y0, x1, y1, bar, pixel);
Expand Down Expand Up @@ -707,12 +691,7 @@ void __cdecl S_DrawAirBar(int percent) {
IsShadeEffect = false;

if( HealthBarMode != 0 && SavedAppSettings.RenderMode == RM_Hardware ) {
#ifdef FEATURE_VIDEOFX_IMPROVED
if( SavedAppSettings.ZBuffer && SavedAppSettings.DontSortPrimitives )
#else // FEATURE_VIDEOFX_IMPROVED
if( SavedAppSettings.ZBuffer )
#endif // FEATURE_VIDEOFX_IMPROVED
{
if( SavedAppSettings.ZBuffer ) {
PSX_DrawAirBar(x0, y0, x1, y1, bar, pixel);
} else {
PSX_InsertAirBar(x0, y0, x1, y1, bar, pixel);
Expand Down

0 comments on commit cb0b2ec

Please sign in to comment.