The real pickup reflection fix

This commit is contained in:
Sergeanur 2020-07-29 14:56:06 +03:00
parent 2f40c3dc8b
commit 581cb5edfa
6 changed files with 59 additions and 32 deletions

View File

@ -700,15 +700,9 @@ CPickups::DoPickUpEffects(CEntity *entity)
const CVector &pos = entity->GetPosition(); const CVector &pos = entity->GetPosition();
float colorModifier = ((CGeneral::GetRandomNumber() & 0x1F) * 0.015f + 1.0f) * modifiedSin * 0.15f; float colorModifier = ((CGeneral::GetRandomNumber() & 0x1F) * 0.015f + 1.0f) * modifiedSin * 0.15f;
CShadows::StoreStaticShadow( CShadows::StoreStaticShadow((uintptr)entity, SHADOWTYPE_ADDITIVE, gpShadowExplosionTex, &pos, 2.0f, 0.0f, 0.0f, -2.0f, 0,
(uintptr)entity, aWeaponReds[colorId] * colorModifier, aWeaponGreens[colorId] * colorModifier, aWeaponBlues[colorId] * colorModifier, 4.0f,
SHADOWTYPE_ADDITIVE, 1.0f, 40.0f, false, 0.0f);
gpShadowExplosionTex,
&pos,
2.0f, 0.0f, 0.0f, -2.0f,
255, // this is 0 on PC which results in no shadow
aWeaponReds[colorId] * colorModifier, aWeaponGreens[colorId] * colorModifier, aWeaponBlues[colorId] * colorModifier,
4.0f, 1.0f, 40.0f, false, 0.0f);
float radius = (CGeneral::GetRandomNumber() & 0xF) * 0.1f + 3.0f; float radius = (CGeneral::GetRandomNumber() & 0xF) * 0.1f + 3.0f;
CPointLights::AddLight(CPointLights::LIGHT_POINT, pos, CVector(0.0f, 0.0f, 0.0f), radius, aWeaponReds[colorId] * modifiedSin / 256.0f, aWeaponGreens[colorId] * modifiedSin / 256.0f, aWeaponBlues[colorId] * modifiedSin / 256.0f, CPointLights::FOG_NONE, true); CPointLights::AddLight(CPointLights::LIGHT_POINT, pos, CVector(0.0f, 0.0f, 0.0f), radius, aWeaponReds[colorId] * modifiedSin / 256.0f, aWeaponGreens[colorId] * modifiedSin / 256.0f, aWeaponBlues[colorId] * modifiedSin / 256.0f, CPointLights::FOG_NONE, true);
@ -759,11 +753,8 @@ CPickups::DoMineEffects(CEntity *entity)
float s = Sin((float)((CTimer::GetTimeInMilliseconds() + (uintptr)entity) & 0x1FF) * DEGTORAD(360.0f / 0x200)); float s = Sin((float)((CTimer::GetTimeInMilliseconds() + (uintptr)entity) & 0x1FF) * DEGTORAD(360.0f / 0x200));
int32 red = (MAXDIST - dist) * (0.5f * s + 0.5f) / MAXDIST * 64.0f; int32 red = (MAXDIST - dist) * (0.5f * s + 0.5f) / MAXDIST * 64.0f;
CShadows::StoreStaticShadow((uintptr)entity, SHADOWTYPE_ADDITIVE, gpShadowExplosionTex, &pos, CShadows::StoreStaticShadow((uintptr)entity, SHADOWTYPE_ADDITIVE, gpShadowExplosionTex, &pos, 2.0f, 0.0f, 0.0f, -2.0f, 0, red, 0, 0, 4.0f, 1.0f, 40.0f,
2.0f, 0.0f, 0.0f, -2.0f, false, 0.0f);
255, // this is 0 on PC which results in no shadow
red, 0, 0,
4.0f, 1.0f, 40.0f, false, 0.0f);
CCoronas::RegisterCorona((uintptr)entity, red, 0, 0, 255, pos, 0.6f, 60.0f, CCoronas::TYPE_RING, CCoronas::FLARE_NONE, CCoronas::REFLECTION_OFF, CCoronas::LOSCHECK_OFF, CCoronas::STREAK_OFF, 0.0f); CCoronas::RegisterCorona((uintptr)entity, red, 0, 0, 255, pos, 0.6f, 60.0f, CCoronas::TYPE_RING, CCoronas::FLARE_NONE, CCoronas::REFLECTION_OFF, CCoronas::LOSCHECK_OFF, CCoronas::STREAK_OFF, 0.0f);
} }
@ -781,11 +772,8 @@ CPickups::DoMoneyEffects(CEntity *entity)
float s = Sin((float)((CTimer::GetTimeInMilliseconds() + (uintptr)entity) & 0x3FF) * DEGTORAD(360.0f / 0x400)); float s = Sin((float)((CTimer::GetTimeInMilliseconds() + (uintptr)entity) & 0x3FF) * DEGTORAD(360.0f / 0x400));
int32 green = (MAXDIST - dist) * (0.2f * s + 0.3f) / MAXDIST * 64.0f; int32 green = (MAXDIST - dist) * (0.2f * s + 0.3f) / MAXDIST * 64.0f;
CShadows::StoreStaticShadow((uintptr)entity, SHADOWTYPE_ADDITIVE, gpShadowExplosionTex, &pos, CShadows::StoreStaticShadow((uintptr)entity, SHADOWTYPE_ADDITIVE, gpShadowExplosionTex, &pos, 2.0f, 0.0f, 0.0f, -2.0f, 0, 0, green, 0, 4.0f, 1.0f,
2.0f, 0.0f, 0.0f, -2.0f, 40.0f, false, 0.0f);
255, // this is 0 on PC which results in no shadow
0, green, 0,
4.0f, 1.0f, 40.0f, false, 0.0f);
CCoronas::RegisterCorona((uintptr)entity, 0, green, 0, 255, pos, 0.4f, 40.0f, CCoronas::TYPE_RING, CCoronas::FLARE_NONE, CCoronas::REFLECTION_OFF, CCoronas::LOSCHECK_OFF, CCoronas::STREAK_OFF, 0.0f); CCoronas::RegisterCorona((uintptr)entity, 0, green, 0, 255, pos, 0.4f, 40.0f, CCoronas::TYPE_RING, CCoronas::FLARE_NONE, CCoronas::REFLECTION_OFF, CCoronas::LOSCHECK_OFF, CCoronas::STREAK_OFF, 0.0f);
} }
@ -803,11 +791,8 @@ CPickups::DoCollectableEffects(CEntity *entity)
float s = Sin((float)((CTimer::GetTimeInMilliseconds() + (uintptr)entity) & 0x7FF) * DEGTORAD(360.0f / 0x800)); float s = Sin((float)((CTimer::GetTimeInMilliseconds() + (uintptr)entity) & 0x7FF) * DEGTORAD(360.0f / 0x800));
int32 color = (MAXDIST - dist) * (0.5f * s + 0.5f) / MAXDIST * 255.0f; int32 color = (MAXDIST - dist) * (0.5f * s + 0.5f) / MAXDIST * 255.0f;
CShadows::StoreStaticShadow((uintptr)entity, SHADOWTYPE_ADDITIVE, gpShadowExplosionTex, &pos, CShadows::StoreStaticShadow((uintptr)entity, SHADOWTYPE_ADDITIVE, gpShadowExplosionTex, &pos, 2.0f, 0.0f, 0.0f, -2.0f, 0, color, color, color, 4.0f,
2.0f, 0.0f, 0.0f, -2.0f, 1.0f, 40.0f, false, 0.0f);
255, // this is 0 on PC which results in no shadow
color, color, color,
4.0f, 1.0f, 40.0f, false, 0.0f);
CCoronas::RegisterCorona((uintptr)entity, color, color, color, 255, pos, 0.6f, 40.0f, CCoronas::TYPE_RING, CCoronas::FLARE_NONE, CCoronas::REFLECTION_OFF, CCoronas::LOSCHECK_OFF, CCoronas::STREAK_OFF, 0.0f); CCoronas::RegisterCorona((uintptr)entity, color, color, color, 255, pos, 0.6f, 40.0f, CCoronas::TYPE_RING, CCoronas::FLARE_NONE, CCoronas::REFLECTION_OFF, CCoronas::LOSCHECK_OFF, CCoronas::STREAK_OFF, 0.0f);
} }

View File

@ -3587,8 +3587,8 @@ CCamera::CalculateDerivedValues(void)
m_cameraMatrix = Invert(m_matrix); m_cameraMatrix = Invert(m_matrix);
float hfov = DEGTORAD(CDraw::GetScaledFOV()/2.0f); float hfov = DEGTORAD(CDraw::GetScaledFOV()/2.0f);
float c = cos(hfov); float c = Cos(hfov);
float s = sin(hfov); float s = Sin(hfov);
// right plane // right plane
m_vecFrustumNormals[0] = CVector(c, -s, 0.0f); m_vecFrustumNormals[0] = CVector(c, -s, 0.0f);

View File

@ -128,11 +128,8 @@ CFire::ProcessFire(void)
lightpos.z = m_vecPos.z + 5.0f; lightpos.z = m_vecPos.z + 5.0f;
if (!m_pEntity) { if (!m_pEntity) {
CShadows::StoreStaticShadow((uintptr)this, SHADOWTYPE_ADDITIVE, gpShadowExplosionTex, &lightpos, CShadows::StoreStaticShadow((uintptr)this, SHADOWTYPE_ADDITIVE, gpShadowExplosionTex, &lightpos, 7.0f, 0.0f, 0.0f, -7.0f, 0, nRandNumber / 2,
7.0f, 0.0f, 0.0f, -7.0f, nRandNumber / 2, 0, 10.0f, 1.0f, 40.0f, 0, 0.0f);
255, // this is 0 on PC which results in no shadow
nRandNumber / 2, nRandNumber / 2, 0,
10.0f, 1.0f, 40.0f, 0, 0.0f);
} }
fGreen = nRandNumber / 128; fGreen = nRandNumber / 128;
fRed = nRandNumber / 128; fRed = nRandNumber / 128;

View File

@ -796,6 +796,8 @@ CShadows::RenderStaticShadows(void)
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void *)TRUE); RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void *)TRUE);
RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void *)FALSE); RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void *)FALSE);
SetAlphaTest(0);
for ( int32 i = 0; i < MAX_STATICSHADOWS; i++ ) for ( int32 i = 0; i < MAX_STATICSHADOWS; i++ )
aStaticShadows[i].m_bRendered = false; aStaticShadows[i].m_bRendered = false;
@ -849,6 +851,7 @@ CShadows::RenderStaticShadows(void)
RenderBuffer::RenderStuffInBuffer(); RenderBuffer::RenderStuffInBuffer();
} }
} }
RestoreAlphaTest();
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void *)FALSE); RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void *)FALSE);
RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void *)TRUE); RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void *)TRUE);

View File

@ -611,3 +611,37 @@ CameraCreate(RwInt32 width, RwInt32 height, RwBool zBuffer)
WRAPPER void _TexturePoolsInitialise() { EAXJMP(0x598B10); } WRAPPER void _TexturePoolsInitialise() { EAXJMP(0x598B10); }
WRAPPER void _TexturePoolsShutdown() { EAXJMP(0x598B30); } WRAPPER void _TexturePoolsShutdown() { EAXJMP(0x598B30); }
#endif #endif
#if defined(FIX_BUGS) && defined(GTA_PC)
RwUInt32 saved_alphafunc, saved_alpharef;
void
SetAlphaTest(RwUInt32 alpharef)
{
#ifdef LIBRW
saved_alphafunc = rw::GetRenderState(rw::ALPHATESTFUNC);
saved_alpharef = rw::GetRenderState(rw::ALPHATESTREF);
rw::SetRenderState(rw::ALPHATESTFUNC, rw::ALPHAGREATEREQUAL);
rw::SetRenderState(rw::ALPHATESTREF, 0);
#else
RwD3D8GetRenderState(D3DRS_ALPHAFUNC, &saved_alphafunc);
RwD3D8GetRenderState(D3DRS_ALPHAREF, &saved_alpharef);
RwD3D8SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL);
RwD3D8SetRenderState(D3DRS_ALPHAREF, alpharef);
#endif
}
void
RestoreAlphaTest()
{
#ifdef LIBRW
rw::SetRenderState(rw::ALPHATESTFUNC, saved_alphafunc);
rw::SetRenderState(rw::ALPHATESTREF, saved_alpharef);
#else
RwD3D8SetRenderState(D3DRS_ALPHAFUNC, saved_alphafunc);
RwD3D8SetRenderState(D3DRS_ALPHAREF, saved_alpharef);
#endif
}
#endif

View File

@ -52,4 +52,12 @@ RwCamera *CameraCreate(RwInt32 width,
void _TexturePoolsInitialise(); void _TexturePoolsInitialise();
void _TexturePoolsShutdown(); void _TexturePoolsShutdown();
#if defined(FIX_BUGS) && defined (GTA_PC)
void SetAlphaTest(RwUInt32 alpharef);
void RestoreAlphaTest();
#else
#define SetAlphaTest(a) (0)
#define RestoreAlphaTest() (0)
#endif