III/VC/SA: Disable alpha test for stored shadows too

This commit is contained in:
Silent 2019-12-08 12:27:33 +01:00
parent 86f1c60267
commit 2be613a75b
No known key found for this signature in database
GPG key ID: AE53149BB0C45AF1
2 changed files with 35 additions and 5 deletions

View file

@ -56,6 +56,18 @@ namespace StaticShadowAlphaFix
RwD3D8SetRenderState( 15, alphaTestVal );
}
static void (*orgRenderStoredShadows)();
static void RenderStoredShadows_StateFix()
{
RwUInt32 alphaTestVal = 0;
RwD3D8GetRenderState( 15, &alphaTestVal ); // D3DRS_ALPHATESTENABLE
RwD3D8SetRenderState( 15, FALSE );
orgRenderStoredShadows();
RwD3D8SetRenderState( 15, alphaTestVal );
}
};
// ============= Delayed patches =============
@ -147,16 +159,19 @@ namespace Common {
{
using namespace StaticShadowAlphaFix;
// TODO: Offset for III
#if _GTA_III
constexpr ptrdiff_t offset = 0xF;
#elif _GTA_VC
constexpr ptrdiff_t offset = 0x14;
#endif
void* renderStaticShadows = ReadCallFrom( get_pattern( "E8 ? ? ? ? A1 ? ? ? ? 85 C0 74 05" ), offset );
uintptr_t renderStaticShadows = reinterpret_cast<uintptr_t>(ReadCallFrom( get_pattern( "E8 ? ? ? ? A1 ? ? ? ? 85 C0 74 05" ), offset ));
ReadCall( renderStaticShadows, orgRenderStaticShadows );
InjectHook( renderStaticShadows, RenderStaticShadows_StateFix );
renderStaticShadows += 5;
ReadCall( renderStaticShadows, orgRenderStoredShadows );
InjectHook( renderStaticShadows, RenderStoredShadows_StateFix );
}
}

View file

@ -1627,6 +1627,15 @@ namespace StaticShadowAlphaFix
RwRenderStateSet( rwRENDERSTATEALPHATESTFUNCTION, (void*)rwALPHATESTFUNCTIONALWAYS );
orgRenderStaticShadows();
}
static void (*orgRenderStoredShadows)();
static void RenderStoredShadows_StateFix()
{
RwScopedRenderState state(rwRENDERSTATEALPHATESTFUNCTION);
RwRenderStateSet( rwRENDERSTATEALPHATESTFUNCTION, (void*)rwALPHATESTFUNCTIONALWAYS );
orgRenderStoredShadows();
}
};
// ============= LS-RP Mode stuff =============
@ -4210,6 +4219,9 @@ void Patch_SA_10()
ReadCall( 0x53E0C3, orgRenderStaticShadows );
InjectHook( 0x53E0C3, RenderStaticShadows_StateFix );
ReadCall( 0x53E0C8, orgRenderStoredShadows );
InjectHook( 0x53E0C8, RenderStoredShadows_StateFix );
}
#if FULL_PRECISION_D3D
@ -5647,9 +5659,12 @@ void Patch_SA_NewBinaries_Common()
{
using namespace StaticShadowAlphaFix;
auto renderStaticShadows = get_pattern( "52 E8 ? ? ? ? E8 ? ? ? ? E8", 1 + 5 + 5 );
ReadCall( renderStaticShadows, orgRenderStaticShadows );
InjectHook( renderStaticShadows, RenderStaticShadows_StateFix );
auto renderStaticShadows = pattern( "52 E8 ? ? ? ? E8 ? ? ? ? E8" ).get_one();
ReadCall( renderStaticShadows.get<void>( 1 + 5 + 5 ), orgRenderStaticShadows );
InjectHook( renderStaticShadows.get<void>( 1 + 5 + 5 ), RenderStaticShadows_StateFix );
ReadCall( renderStaticShadows.get<void>( 1 + 5 + 5 + 5 ), orgRenderStoredShadows );
InjectHook( renderStaticShadows.get<void>( 1 + 5 + 5 + 5 ), RenderStoredShadows_StateFix );
}
}