Skip to content

Commit

Permalink
implement texture workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
xan1242 committed Feb 23, 2023
1 parent a7aca00 commit f6f216c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 2 additions & 0 deletions NFSMW_XenonEffects.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
[MAIN]
; The filename of the texture pack. It must contain the "MAIN" texture.
TexturePack = GLOBAL\XenonEffects.tpk
; Loads the texture via D3D device directly instead of the ingame loader (shader). Only use this if you have issues. (e.g. NextGenGraphics)
UseD3DDeviceTexture = 0
; Enables contrails
Contrails = 1
; Enables contrails in NIS
Expand Down
18 changes: 17 additions & 1 deletion dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ bool bLimitSparkRate = true;
bool bNISContrails = false;
bool bUseCGStyle = false;
bool bPassShadowMap = false;
bool bUseD3DDeviceTexture = false;
float ContrailTargetFPS = 30.0f;
float SparkTargetFPS = 60.0f;
float ContrailSpeed = 44.0f;
Expand Down Expand Up @@ -2375,7 +2376,20 @@ void __stdcall XSpriteManager_DrawBatch(eView* view)
if (sm->mTexture)
{
GameSetTexture(sm->mTexture, 0);
if (bUseD3DDeviceTexture)
{
LPDIRECT3DTEXTURE9 texMain = *(LPDIRECT3DTEXTURE9*)(*(uint32_t*)(sm->mTexture) + 0x18);
g_D3DDevice->SetTexture(0, texMain);
g_D3DDevice->SetRenderState(D3DRS_ALPHAREF, (DWORD)0x000000B0);
g_D3DDevice->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE);
g_D3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
g_D3DDevice->SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATER);
g_D3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
g_D3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);
g_D3DDevice->SetRenderState(D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_RED | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_BLUE);
}
else
GameSetTexture(sm->mTexture, 0);
}
effect->CommitChanges();
Expand Down Expand Up @@ -2706,6 +2720,8 @@ void InitConfig()
{
if (ini["MAIN"].has("TexturePack"))
strcpy_s(TPKfilename, ini["MAIN"]["TexturePack"].c_str());
if (ini["MAIN"].has("UseD3DDeviceTexture"))
bUseD3DDeviceTexture = std::stol(ini["MAIN"]["UseD3DDeviceTexture"]) != 0;
if (ini["MAIN"].has("Contrails"))
bContrails = std::stol(ini["MAIN"]["Contrails"]) != 0;
if (ini["MAIN"].has("UseCGStyle"))
Expand Down

0 comments on commit f6f216c

Please sign in to comment.