mirror of
https://github.com/CookiePLMonster/SilentPatch.git
synced 2024-12-28 23:03:01 +05:00
III/VC/SA: Disable alpha test for stored shadows too
This commit is contained in:
parent
86f1c60267
commit
2be613a75b
2 changed files with 35 additions and 5 deletions
|
@ -56,6 +56,18 @@ namespace StaticShadowAlphaFix
|
||||||
|
|
||||||
RwD3D8SetRenderState( 15, alphaTestVal );
|
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 =============
|
// ============= Delayed patches =============
|
||||||
|
@ -147,16 +159,19 @@ namespace Common {
|
||||||
{
|
{
|
||||||
using namespace StaticShadowAlphaFix;
|
using namespace StaticShadowAlphaFix;
|
||||||
|
|
||||||
// TODO: Offset for III
|
|
||||||
#if _GTA_III
|
#if _GTA_III
|
||||||
constexpr ptrdiff_t offset = 0xF;
|
constexpr ptrdiff_t offset = 0xF;
|
||||||
#elif _GTA_VC
|
#elif _GTA_VC
|
||||||
constexpr ptrdiff_t offset = 0x14;
|
constexpr ptrdiff_t offset = 0x14;
|
||||||
#endif
|
#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 );
|
ReadCall( renderStaticShadows, orgRenderStaticShadows );
|
||||||
InjectHook( renderStaticShadows, RenderStaticShadows_StateFix );
|
InjectHook( renderStaticShadows, RenderStaticShadows_StateFix );
|
||||||
|
|
||||||
|
renderStaticShadows += 5;
|
||||||
|
ReadCall( renderStaticShadows, orgRenderStoredShadows );
|
||||||
|
InjectHook( renderStaticShadows, RenderStoredShadows_StateFix );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1627,6 +1627,15 @@ namespace StaticShadowAlphaFix
|
||||||
RwRenderStateSet( rwRENDERSTATEALPHATESTFUNCTION, (void*)rwALPHATESTFUNCTIONALWAYS );
|
RwRenderStateSet( rwRENDERSTATEALPHATESTFUNCTION, (void*)rwALPHATESTFUNCTIONALWAYS );
|
||||||
orgRenderStaticShadows();
|
orgRenderStaticShadows();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void (*orgRenderStoredShadows)();
|
||||||
|
static void RenderStoredShadows_StateFix()
|
||||||
|
{
|
||||||
|
RwScopedRenderState state(rwRENDERSTATEALPHATESTFUNCTION);
|
||||||
|
|
||||||
|
RwRenderStateSet( rwRENDERSTATEALPHATESTFUNCTION, (void*)rwALPHATESTFUNCTIONALWAYS );
|
||||||
|
orgRenderStoredShadows();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// ============= LS-RP Mode stuff =============
|
// ============= LS-RP Mode stuff =============
|
||||||
|
@ -4210,6 +4219,9 @@ void Patch_SA_10()
|
||||||
|
|
||||||
ReadCall( 0x53E0C3, orgRenderStaticShadows );
|
ReadCall( 0x53E0C3, orgRenderStaticShadows );
|
||||||
InjectHook( 0x53E0C3, RenderStaticShadows_StateFix );
|
InjectHook( 0x53E0C3, RenderStaticShadows_StateFix );
|
||||||
|
|
||||||
|
ReadCall( 0x53E0C8, orgRenderStoredShadows );
|
||||||
|
InjectHook( 0x53E0C8, RenderStoredShadows_StateFix );
|
||||||
}
|
}
|
||||||
|
|
||||||
#if FULL_PRECISION_D3D
|
#if FULL_PRECISION_D3D
|
||||||
|
@ -5647,9 +5659,12 @@ void Patch_SA_NewBinaries_Common()
|
||||||
{
|
{
|
||||||
using namespace StaticShadowAlphaFix;
|
using namespace StaticShadowAlphaFix;
|
||||||
|
|
||||||
auto renderStaticShadows = get_pattern( "52 E8 ? ? ? ? E8 ? ? ? ? E8", 1 + 5 + 5 );
|
auto renderStaticShadows = pattern( "52 E8 ? ? ? ? E8 ? ? ? ? E8" ).get_one();
|
||||||
ReadCall( renderStaticShadows, orgRenderStaticShadows );
|
ReadCall( renderStaticShadows.get<void>( 1 + 5 + 5 ), orgRenderStaticShadows );
|
||||||
InjectHook( renderStaticShadows, RenderStaticShadows_StateFix );
|
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 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue