From 99ca045beec997096c2d219399e8ac8dc6430445 Mon Sep 17 00:00:00 2001 From: Silent Date: Thu, 19 Jun 2014 00:57:22 +0200 Subject: [PATCH] Rustler prop fix Unwoking attempt to fix shader fighting issues Dirt now works properly with ImVehFt --- SilentPatch/dllmain.cpp | 33 ++++++++++++++++++++++++++------ SilentPatch/nvc.fx | 3 ++- SilentPatch/nvc.h | 42 ++++++++++++++++++++--------------------- 3 files changed, 50 insertions(+), 28 deletions(-) diff --git a/SilentPatch/dllmain.cpp b/SilentPatch/dllmain.cpp index 0719b62..c151b42 100644 --- a/SilentPatch/dllmain.cpp +++ b/SilentPatch/dllmain.cpp @@ -1300,18 +1300,30 @@ void __declspec(naked) CacheCRC32() void __declspec(naked) PlaneAtomicRendererSetup() { static const char aStaticProp[] = "static_prop"; + static const char aMovingProp[] = "moving_prop"; _asm { mov eax, [esi+4] push eax call GetFrameNodeName + //push eax + mov [esp+8+8], eax push 11 push offset aStaticProp push eax call strncmp add esp, 10h test eax, eax + jz PlaneAtomicRendererSetup_Alpha + push 11 + push offset aMovingProp + push [esp+12+8] + call strncmp + add esp, 0Ch + test eax, eax jnz PlaneAtomicRendererSetup_NoAlpha + +PlaneAtomicRendererSetup_Alpha: push 734370h jmp PlaneAtomicRendererSetup_Return @@ -1723,6 +1735,12 @@ void SetShader(RxD3D9InstanceData* pInstData) float fEnvVars[2] = { *(float*)0x8D12C0, RpMaterialGetColor(pInstData->material)->alpha * (1.0f/255.0f) }; RwRGBAReal* AmbientLight = RpLightGetColor(*(RpLight**)0xC886E8); + // Normalise the balance + if ( fEnvVars[0] < 0.0f ) + fEnvVars[0] = 0.0f; + else if ( fEnvVars[0] > 1.0f ) + fEnvVars[0] = 1.0f; + RwD3D9SetVertexShader(pNVCShader); _rwD3D9VSSetActiveWorldMatrix(RwFrameGetLTM(RpAtomicGetFrame(pRenderedAtomic))); @@ -2168,8 +2186,17 @@ BOOL InjectDelayedPatches_10() // ImVehFt conflicts if ( GetModuleHandle("ImVehFt.asi") == nullptr ) { + // Lights InjectHook(0x4C830C, LightMaterialsFix, PATCH_CALL); + + // Flying components InjectMethodVP(0x59F180, CObject::Render, PATCH_JUMP); + + // Cars getting dirty + // Only 1.0 and Steam + InjectMethodVP(0x4C9648, CVehicleModelInfo::FindEditableMaterialList, PATCH_CALL); + Patch(0x4C964D, 0x0FEBCE8B); + Patch(0x5D5DC2, 32); // 1.0 ONLY } return FALSE; @@ -2259,12 +2286,6 @@ __forceinline void Patch_SA_10() InjectHook(0x5D9B44, DarkVehiclesFix3, PATCH_JUMP); InjectHook(0x5D9CB2, DarkVehiclesFix4, PATCH_JUMP); - // Cars getting dirty - // Only 1.0 and Steam - InjectMethodVP(0x4C9648, CVehicleModelInfo::FindEditableMaterialList, PATCH_CALL); - Patch(0x4C964D, 0x0FEBCE8B); - Patch(0x5D5DC2, 32); // 1.0 ONLY - // Bindable NUM5 // Only 1.0 and Steam Nop(0x57DC55, 2); diff --git a/SilentPatch/nvc.fx b/SilentPatch/nvc.fx index 123f2d8..f052433 100644 --- a/SilentPatch/nvc.fx +++ b/SilentPatch/nvc.fx @@ -25,7 +25,8 @@ VS_OUTPUT NVC_vertex_shader( in VS_INPUT In ) Out.Texture = In.Texture; Out.Color.rgb = (In.DayColor.rgb * (1.0-fEnvVars[0]) + In.NightColor.rgb * fEnvVars[0]) + AmbientLight.rgb; - Out.Color.a = fEnvVars[1]; + Out.Color.a = In.DayColor.a * fEnvVars[1]; + //Out.Color.rgb = In.DayColor.rgb + AmbientLight.rgb; Out.Color = saturate(Out.Color); return Out; diff --git a/SilentPatch/nvc.h b/SilentPatch/nvc.h index c085f9a..d96acee 100644 --- a/SilentPatch/nvc.h +++ b/SilentPatch/nvc.h @@ -32,14 +32,14 @@ dp4 oPos.y, v0, c1 dp4 oPos.z, v0, c2 dp4 oPos.w, v0, c3 - mov r0.xy, c6 + mov r0.x, c6.x add r0.x, r0.x, -c4.x - mul r1.xyz, v2, c4.x - mad r0.xzw, v3.xyyz, r0.x, r1.xyyz - add r0.xzw, r0, c5.xyyz - max r1.xyz, r0.xzww, c6.y - max r1.w, r0.y, c4.y - min oD0, r1, c6.x + mul r0.yzw, v2.xxyz, c4.x + mad r0.xyz, v3, r0.x, r0.yzww + add r0.xyz, r0, c5 + mul r0.w, v3.w, c4.y + max r0, r0, c6.y + min oD0, r0, c6.x mov oT0.xy, v1 // approximately 13 instruction slots used @@ -112,26 +112,26 @@ const BYTE g_vs20_NVC_vertex_shader[] = 0, 0, 8, 192, 0, 0, 228, 144, 3, 0, 228, 160, 1, 0, 0, 2, 0, 0, - 3, 128, 6, 0, 228, 160, + 1, 128, 6, 0, 0, 160, 2, 0, 0, 3, 0, 0, 1, 128, 0, 0, 0, 128, 4, 0, 0, 161, 5, 0, - 0, 3, 1, 0, 7, 128, - 2, 0, 228, 144, 4, 0, + 0, 3, 0, 0, 14, 128, + 2, 0, 144, 144, 4, 0, 0, 160, 4, 0, 0, 4, - 0, 0, 13, 128, 3, 0, - 148, 144, 0, 0, 0, 128, - 1, 0, 148, 128, 2, 0, - 0, 3, 0, 0, 13, 128, + 0, 0, 7, 128, 3, 0, + 228, 144, 0, 0, 0, 128, + 0, 0, 249, 128, 2, 0, + 0, 3, 0, 0, 7, 128, 0, 0, 228, 128, 5, 0, - 148, 160, 11, 0, 0, 3, - 1, 0, 7, 128, 0, 0, - 248, 128, 6, 0, 85, 160, - 11, 0, 0, 3, 1, 0, - 8, 128, 0, 0, 85, 128, - 4, 0, 85, 160, 10, 0, + 228, 160, 5, 0, 0, 3, + 0, 0, 8, 128, 3, 0, + 255, 144, 4, 0, 85, 160, + 11, 0, 0, 3, 0, 0, + 15, 128, 0, 0, 228, 128, + 6, 0, 85, 160, 10, 0, 0, 3, 0, 0, 15, 208, - 1, 0, 228, 128, 6, 0, + 0, 0, 228, 128, 6, 0, 0, 160, 1, 0, 0, 2, 0, 0, 3, 224, 1, 0, 228, 144, 255, 255, 0, 0