mirror of
https://github.com/CookiePLMonster/SilentPatch.git
synced 2025-01-31 15:07:28 +05:00
Cleaned shader code up
Matched RwD3D9GetTransform in 1.01 and 3.0 EXEs
This commit is contained in:
parent
80f652762a
commit
49ddc29312
3 changed files with 3128 additions and 3133 deletions
|
@ -37,10 +37,6 @@ static void* varRwD3D9CreateVertexShader = AddressByVersion<void*>(0x7FAC60, 0x7
|
||||||
WRAPPER RwBool RwD3D9CreateVertexShader(const RwUInt32 *function, void **shader) { VARJMP(varRwD3D9CreateVertexShader); }
|
WRAPPER RwBool RwD3D9CreateVertexShader(const RwUInt32 *function, void **shader) { VARJMP(varRwD3D9CreateVertexShader); }
|
||||||
static void* varRwD3D9DeleteVertexShader = AddressByVersion<void*>(0x7FAC90, 0x7FB590, 0x834C50);
|
static void* varRwD3D9DeleteVertexShader = AddressByVersion<void*>(0x7FAC90, 0x7FB590, 0x834C50);
|
||||||
WRAPPER void RwD3D9DeleteVertexShader(void *shader) { VARJMP(varRwD3D9DeleteVertexShader); }
|
WRAPPER void RwD3D9DeleteVertexShader(void *shader) { VARJMP(varRwD3D9DeleteVertexShader); }
|
||||||
static void* var_rwD3D9VSGetComposedTransformMatrix = AddressByVersion<void*>(0x7646E0, 0x764FF0, 0x79E6A0);
|
|
||||||
WRAPPER void _rwD3D9VSGetComposedTransformMatrix(void *transformMatrix) { VARJMP(var_rwD3D9VSGetComposedTransformMatrix); }
|
|
||||||
static void* var_rwD3D9VSSetActiveWorldMatrix = AddressByVersion<void*>(0x764650, 0x764F60, 0x79E610);
|
|
||||||
WRAPPER void _rwD3D9VSSetActiveWorldMatrix(const RwMatrix *worldMatrix) { VARJMP(var_rwD3D9VSSetActiveWorldMatrix); }
|
|
||||||
static void* var_rwD3D9SetVertexShaderConstant = AddressByVersion<void*>(0x7FACA0, 0x7FB5A0, 0x834C60);
|
static void* var_rwD3D9SetVertexShaderConstant = AddressByVersion<void*>(0x7FACA0, 0x7FB5A0, 0x834C60);
|
||||||
WRAPPER void _rwD3D9SetVertexShaderConstant(RwUInt32 registerAddress,
|
WRAPPER void _rwD3D9SetVertexShaderConstant(RwUInt32 registerAddress,
|
||||||
const void *constantData,
|
const void *constantData,
|
||||||
|
@ -51,7 +47,7 @@ WRAPPER RwBool _rpD3D9VertexDeclarationInstColor(RwUInt8 *mem,
|
||||||
RwInt32 numVerts,
|
RwInt32 numVerts,
|
||||||
RwUInt32 stride) { VARJMP(var_rpD3D9VertexDeclarationInstColor); }
|
RwUInt32 stride) { VARJMP(var_rpD3D9VertexDeclarationInstColor); }
|
||||||
|
|
||||||
static void* varRwD3D9GetTransform = AddressByVersion<void*>(0x007FA4F0, 0x007FA4F0, 0x007FA4F0);
|
static void* varRwD3D9GetTransform = AddressByVersion<void*>(0x7FA4F0, 0x7FADF0, 0x8344B0);
|
||||||
WRAPPER void _RwD3D9GetTransform(RwUInt32 state, void* matrix) { VARJMP(varRwD3D9GetTransform); }
|
WRAPPER void _RwD3D9GetTransform(RwUInt32 state, void* matrix) { VARJMP(varRwD3D9GetTransform); }
|
||||||
|
|
||||||
RwCamera* RwCameraBeginUpdate(RwCamera* camera)
|
RwCamera* RwCameraBeginUpdate(RwCamera* camera)
|
||||||
|
@ -721,10 +717,8 @@ BOOL Initialise3D(void* pParam)
|
||||||
|
|
||||||
void SetShader(RxD3D9InstanceData* pInstData)
|
void SetShader(RxD3D9InstanceData* pInstData)
|
||||||
{
|
{
|
||||||
//GetAsyncKeyState(VK_F5) &&
|
|
||||||
if (bRenderNVC )
|
if (bRenderNVC )
|
||||||
{
|
{
|
||||||
D3DMATRIX outMat;
|
|
||||||
float fEnvVars[2] = { m_fDNBalanceParam, RpMaterialGetColor(pInstData->material)->alpha * (1.0f/255.0f) };
|
float fEnvVars[2] = { m_fDNBalanceParam, RpMaterialGetColor(pInstData->material)->alpha * (1.0f/255.0f) };
|
||||||
RwRGBAReal* AmbientLight = RpLightGetColor(pAmbient);
|
RwRGBAReal* AmbientLight = RpLightGetColor(pAmbient);
|
||||||
|
|
||||||
|
@ -736,21 +730,20 @@ void SetShader(RxD3D9InstanceData* pInstData)
|
||||||
|
|
||||||
RwD3D9SetVertexShader(pNVCShader);
|
RwD3D9SetVertexShader(pNVCShader);
|
||||||
|
|
||||||
_rwD3D9VSSetActiveWorldMatrix(RwFrameGetLTM(RpAtomicGetFrame(pRenderedAtomic)));
|
//_rwD3D9VSSetActiveWorldMatrix(RwFrameGetLTM(RpAtomicGetFrame(pRenderedAtomic)));
|
||||||
//_rwD3D9VSSetActiveWorldMatrix(RwFrameGetMatrix(RpAtomicGetFrame(pRenderedAtomic)));
|
//_rwD3D9VSSetActiveWorldMatrix(RwFrameGetMatrix(RpAtomicGetFrame(pRenderedAtomic)));
|
||||||
_rwD3D9VSGetComposedTransformMatrix(&outMat);
|
//_rwD3D9VSGetComposedTransformMatrix(&outMat);
|
||||||
|
|
||||||
D3DMATRIX worldMat, viewMat, projMat;
|
D3DMATRIX worldMat, viewMat, projMat;
|
||||||
_RwD3D9GetTransform(D3DTS_WORLD, &worldMat);
|
_RwD3D9GetTransform(D3DTS_WORLD, &worldMat);
|
||||||
_RwD3D9GetTransform(D3DTS_VIEW, &viewMat);
|
_RwD3D9GetTransform(D3DTS_VIEW, &viewMat);
|
||||||
_RwD3D9GetTransform(D3DTS_PROJECTION, &projMat);
|
_RwD3D9GetTransform(D3DTS_PROJECTION, &projMat);
|
||||||
RwD3D9SetVertexShaderConstant(6, &worldMat, 4);
|
RwD3D9SetVertexShaderConstant(2, &worldMat, 4);
|
||||||
RwD3D9SetVertexShaderConstant(10, &viewMat, 4);
|
RwD3D9SetVertexShaderConstant(6, &viewMat, 4);
|
||||||
RwD3D9SetVertexShaderConstant(14, &projMat, 4);
|
RwD3D9SetVertexShaderConstant(10, &projMat, 4);
|
||||||
|
|
||||||
RwD3D9SetVertexShaderConstant(0, &outMat, 4);
|
RwD3D9SetVertexShaderConstant(0, fEnvVars, 1);
|
||||||
RwD3D9SetVertexShaderConstant(4, fEnvVars, 1);
|
RwD3D9SetVertexShaderConstant(1, AmbientLight, 1);
|
||||||
RwD3D9SetVertexShaderConstant(5, AmbientLight, 1);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
RwD3D9SetVertexShader(pInstData->vertexShader);
|
RwD3D9SetVertexShader(pInstData->vertexShader);
|
||||||
|
|
|
@ -13,24 +13,22 @@ struct VS_OUTPUT
|
||||||
float4 Color : COLOR0;
|
float4 Color : COLOR0;
|
||||||
};
|
};
|
||||||
|
|
||||||
float4x4 viewProjMatrix : register(c0);
|
float2 fEnvVars : register(c0);
|
||||||
float2 fEnvVars : register(c4);
|
float4 AmbientLight : register(c1);
|
||||||
float4 AmbientLight : register(c5);
|
float4x4 world : register(c2);
|
||||||
float4x4 world : register(c6);
|
float4x4 view : register(c6);
|
||||||
float4x4 view : register(c10);
|
float4x4 proj : register(c10);
|
||||||
float4x4 proj : register(c14);
|
|
||||||
|
|
||||||
VS_OUTPUT NVC_vertex_shader( in VS_INPUT In )
|
VS_OUTPUT NVC_vertex_shader( in VS_INPUT In )
|
||||||
{
|
{
|
||||||
VS_OUTPUT Out;
|
VS_OUTPUT Out;
|
||||||
|
|
||||||
// Out.Position = mul(In.Position, viewProjMatrix);
|
|
||||||
Out.Position = mul(proj, mul(view, mul(world, In.Position)));
|
Out.Position = mul(proj, mul(view, mul(world, In.Position)));
|
||||||
Out.Texture = In.Texture;
|
Out.Texture = In.Texture;
|
||||||
|
|
||||||
Out.Color.rgb = (In.DayColor.rgb * (1.0-fEnvVars[0]) + In.NightColor.rgb * fEnvVars[0]) + AmbientLight.rgb;
|
Out.Color = lerp(In.DayColor, In.NightColor, fEnvVars[0]);
|
||||||
Out.Color.a = In.DayColor.a * (255.0/128.0) * fEnvVars[1];
|
Out.Color.rgb += AmbientLight.rgb;
|
||||||
//Out.Color.rgb = In.DayColor.rgb + AmbientLight.rgb;
|
Out.Color.a *= (255.0/128.0) * fEnvVars[1];
|
||||||
Out.Color = saturate(Out.Color);
|
Out.Color = saturate(Out.Color);
|
||||||
|
|
||||||
return Out;
|
return Out;
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
#if 0
|
#if 0
|
||||||
//
|
//
|
||||||
// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384
|
// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111
|
||||||
|
//
|
||||||
|
// fxc /T vs_2_0 /E NVC_vertex_shader /Fh ..\SilentPatch\nvc.h
|
||||||
|
// ..\SilentPatch\nvc.fx
|
||||||
|
//
|
||||||
//
|
//
|
||||||
// Parameters:
|
// Parameters:
|
||||||
//
|
//
|
||||||
|
@ -15,39 +19,39 @@
|
||||||
//
|
//
|
||||||
// Name Reg Size
|
// Name Reg Size
|
||||||
// ------------ ----- ----
|
// ------------ ----- ----
|
||||||
// fEnvVars c4 1
|
// fEnvVars c0 1
|
||||||
// AmbientLight c5 1
|
// AmbientLight c1 1
|
||||||
// world c6 4
|
// world c2 4
|
||||||
// view c10 4
|
// view c6 4
|
||||||
// proj c14 4
|
// proj c10 4
|
||||||
//
|
//
|
||||||
|
|
||||||
vs_2_0
|
vs_2_0
|
||||||
def c0, 1, 0, 0, 0
|
def c14, 1.9921875, 0, 1, 0
|
||||||
dcl_position v0
|
dcl_position v0
|
||||||
dcl_texcoord v1
|
dcl_texcoord v1
|
||||||
dcl_color v2
|
dcl_color v2
|
||||||
dcl_color1 v3
|
dcl_color1 v3
|
||||||
mul r0, v0.y, c7
|
mul r0, v0.y, c3
|
||||||
mad r0, c6, v0.x, r0
|
mad r0, c2, v0.x, r0
|
||||||
mad r0, c8, v0.z, r0
|
mad r0, c4, v0.z, r0
|
||||||
mad r0, c9, v0.w, r0
|
mad r0, c5, v0.w, r0
|
||||||
|
mul r1, r0.y, c7
|
||||||
|
mad r1, c6, r0.x, r1
|
||||||
|
mad r1, c8, r0.z, r1
|
||||||
|
mad r0, c9, r0.w, r1
|
||||||
mul r1, r0.y, c11
|
mul r1, r0.y, c11
|
||||||
mad r1, c10, r0.x, r1
|
mad r1, c10, r0.x, r1
|
||||||
mad r1, c12, r0.z, r1
|
mad r1, c12, r0.z, r1
|
||||||
mad r0, c13, r0.w, r1
|
mad oPos, c13, r0.w, r1
|
||||||
mul r1, r0.y, c15
|
mov r0, v3
|
||||||
mad r1, c14, r0.x, r1
|
add r0, -r0, v2
|
||||||
mad r1, c16, r0.z, r1
|
mad r0, c0.x, r0, v3
|
||||||
mad oPos, c17, r0.w, r1
|
mul r0.w, r0.w, c0.y
|
||||||
mov r0.x, c0.x
|
add r1.xyz, r0, c1
|
||||||
add r0.x, r0.x, -c4.x
|
mul r1.w, r0.w, c14.x
|
||||||
mul r0.yzw, v2.xxyz, c4.x
|
max r0, r1, c14.y
|
||||||
mad r0.xyz, v3, r0.x, r0.yzww
|
min oD0, r0, c14.z
|
||||||
add r0.xyz, r0, c5
|
|
||||||
mul r0.w, v3.w, c4.y
|
|
||||||
max r0, r0, c0.y
|
|
||||||
min oD0, r0, c0.x
|
|
||||||
mov oT0.xy, v1
|
mov oT0.xy, v1
|
||||||
|
|
||||||
// approximately 21 instruction slots used
|
// approximately 21 instruction slots used
|
||||||
|
@ -62,21 +66,21 @@ const BYTE g_vs20_NVC_vertex_shader[] =
|
||||||
5, 0, 0, 0, 28, 0,
|
5, 0, 0, 0, 28, 0,
|
||||||
0, 0, 0, 1, 0, 0,
|
0, 0, 0, 1, 0, 0,
|
||||||
223, 0, 0, 0, 128, 0,
|
223, 0, 0, 0, 128, 0,
|
||||||
0, 0, 2, 0, 5, 0,
|
0, 0, 2, 0, 1, 0,
|
||||||
1, 0, 22, 0, 144, 0,
|
1, 0, 6, 0, 144, 0,
|
||||||
0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0,
|
||||||
160, 0, 0, 0, 2, 0,
|
160, 0, 0, 0, 2, 0,
|
||||||
4, 0, 1, 0, 18, 0,
|
0, 0, 1, 0, 2, 0,
|
||||||
172, 0, 0, 0, 0, 0,
|
172, 0, 0, 0, 0, 0,
|
||||||
0, 0, 188, 0, 0, 0,
|
0, 0, 188, 0, 0, 0,
|
||||||
2, 0, 14, 0, 4, 0,
|
2, 0, 10, 0, 4, 0,
|
||||||
58, 0, 196, 0, 0, 0,
|
42, 0, 196, 0, 0, 0,
|
||||||
0, 0, 0, 0, 212, 0,
|
0, 0, 0, 0, 212, 0,
|
||||||
0, 0, 2, 0, 10, 0,
|
0, 0, 2, 0, 6, 0,
|
||||||
4, 0, 42, 0, 196, 0,
|
4, 0, 26, 0, 196, 0,
|
||||||
0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0,
|
||||||
217, 0, 0, 0, 2, 0,
|
217, 0, 0, 0, 2, 0,
|
||||||
6, 0, 4, 0, 26, 0,
|
2, 0, 4, 0, 10, 0,
|
||||||
196, 0, 0, 0, 0, 0,
|
196, 0, 0, 0, 0, 0,
|
||||||
0, 0, 65, 109, 98, 105,
|
0, 0, 65, 109, 98, 105,
|
||||||
101, 110, 116, 76, 105, 103,
|
101, 110, 116, 76, 105, 103,
|
||||||
|
@ -101,12 +105,12 @@ const BYTE g_vs20_NVC_vertex_shader[] =
|
||||||
83, 76, 32, 83, 104, 97,
|
83, 76, 32, 83, 104, 97,
|
||||||
100, 101, 114, 32, 67, 111,
|
100, 101, 114, 32, 67, 111,
|
||||||
109, 112, 105, 108, 101, 114,
|
109, 112, 105, 108, 101, 114,
|
||||||
32, 54, 46, 51, 46, 57,
|
32, 57, 46, 50, 57, 46,
|
||||||
54, 48, 48, 46, 49, 54,
|
57, 53, 50, 46, 51, 49,
|
||||||
51, 56, 52, 0, 81, 0,
|
49, 49, 0, 171, 81, 0,
|
||||||
0, 5, 0, 0, 15, 160,
|
0, 5, 14, 0, 15, 160,
|
||||||
0, 0, 128, 63, 0, 0,
|
0, 0, 255, 63, 0, 0,
|
||||||
0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 128, 63,
|
||||||
0, 0, 0, 0, 31, 0,
|
0, 0, 0, 0, 31, 0,
|
||||||
0, 2, 0, 0, 0, 128,
|
0, 2, 0, 0, 0, 128,
|
||||||
0, 0, 15, 144, 31, 0,
|
0, 0, 15, 144, 31, 0,
|
||||||
|
@ -117,64 +121,64 @@ const BYTE g_vs20_NVC_vertex_shader[] =
|
||||||
0, 2, 10, 0, 1, 128,
|
0, 2, 10, 0, 1, 128,
|
||||||
3, 0, 15, 144, 5, 0,
|
3, 0, 15, 144, 5, 0,
|
||||||
0, 3, 0, 0, 15, 128,
|
0, 3, 0, 0, 15, 128,
|
||||||
0, 0, 85, 144, 7, 0,
|
0, 0, 85, 144, 3, 0,
|
||||||
228, 160, 4, 0, 0, 4,
|
228, 160, 4, 0, 0, 4,
|
||||||
0, 0, 15, 128, 6, 0,
|
0, 0, 15, 128, 2, 0,
|
||||||
228, 160, 0, 0, 0, 144,
|
228, 160, 0, 0, 0, 144,
|
||||||
0, 0, 228, 128, 4, 0,
|
0, 0, 228, 128, 4, 0,
|
||||||
0, 4, 0, 0, 15, 128,
|
0, 4, 0, 0, 15, 128,
|
||||||
8, 0, 228, 160, 0, 0,
|
4, 0, 228, 160, 0, 0,
|
||||||
170, 144, 0, 0, 228, 128,
|
170, 144, 0, 0, 228, 128,
|
||||||
4, 0, 0, 4, 0, 0,
|
4, 0, 0, 4, 0, 0,
|
||||||
15, 128, 9, 0, 228, 160,
|
15, 128, 5, 0, 228, 160,
|
||||||
0, 0, 255, 144, 0, 0,
|
0, 0, 255, 144, 0, 0,
|
||||||
228, 128, 5, 0, 0, 3,
|
228, 128, 5, 0, 0, 3,
|
||||||
1, 0, 15, 128, 0, 0,
|
1, 0, 15, 128, 0, 0,
|
||||||
85, 128, 11, 0, 228, 160,
|
85, 128, 7, 0, 228, 160,
|
||||||
4, 0, 0, 4, 1, 0,
|
4, 0, 0, 4, 1, 0,
|
||||||
15, 128, 10, 0, 228, 160,
|
15, 128, 6, 0, 228, 160,
|
||||||
0, 0, 0, 128, 1, 0,
|
0, 0, 0, 128, 1, 0,
|
||||||
228, 128, 4, 0, 0, 4,
|
228, 128, 4, 0, 0, 4,
|
||||||
1, 0, 15, 128, 12, 0,
|
1, 0, 15, 128, 8, 0,
|
||||||
228, 160, 0, 0, 170, 128,
|
228, 160, 0, 0, 170, 128,
|
||||||
1, 0, 228, 128, 4, 0,
|
1, 0, 228, 128, 4, 0,
|
||||||
0, 4, 0, 0, 15, 128,
|
0, 4, 0, 0, 15, 128,
|
||||||
13, 0, 228, 160, 0, 0,
|
9, 0, 228, 160, 0, 0,
|
||||||
255, 128, 1, 0, 228, 128,
|
255, 128, 1, 0, 228, 128,
|
||||||
5, 0, 0, 3, 1, 0,
|
5, 0, 0, 3, 1, 0,
|
||||||
15, 128, 0, 0, 85, 128,
|
15, 128, 0, 0, 85, 128,
|
||||||
15, 0, 228, 160, 4, 0,
|
11, 0, 228, 160, 4, 0,
|
||||||
0, 4, 1, 0, 15, 128,
|
0, 4, 1, 0, 15, 128,
|
||||||
14, 0, 228, 160, 0, 0,
|
10, 0, 228, 160, 0, 0,
|
||||||
0, 128, 1, 0, 228, 128,
|
0, 128, 1, 0, 228, 128,
|
||||||
4, 0, 0, 4, 1, 0,
|
4, 0, 0, 4, 1, 0,
|
||||||
15, 128, 16, 0, 228, 160,
|
15, 128, 12, 0, 228, 160,
|
||||||
0, 0, 170, 128, 1, 0,
|
0, 0, 170, 128, 1, 0,
|
||||||
228, 128, 4, 0, 0, 4,
|
228, 128, 4, 0, 0, 4,
|
||||||
0, 0, 15, 192, 17, 0,
|
0, 0, 15, 192, 13, 0,
|
||||||
228, 160, 0, 0, 255, 128,
|
228, 160, 0, 0, 255, 128,
|
||||||
1, 0, 228, 128, 1, 0,
|
1, 0, 228, 128, 1, 0,
|
||||||
0, 2, 0, 0, 1, 128,
|
0, 2, 0, 0, 15, 128,
|
||||||
0, 0, 0, 160, 2, 0,
|
3, 0, 228, 144, 2, 0,
|
||||||
0, 3, 0, 0, 1, 128,
|
|
||||||
0, 0, 0, 128, 4, 0,
|
|
||||||
0, 161, 5, 0, 0, 3,
|
|
||||||
0, 0, 14, 128, 2, 0,
|
|
||||||
144, 144, 4, 0, 0, 160,
|
|
||||||
4, 0, 0, 4, 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, 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, 3, 0, 0, 15, 128,
|
||||||
0, 0, 228, 128, 0, 0,
|
0, 0, 228, 129, 2, 0,
|
||||||
|
228, 144, 4, 0, 0, 4,
|
||||||
|
0, 0, 15, 128, 0, 0,
|
||||||
|
0, 160, 0, 0, 228, 128,
|
||||||
|
3, 0, 228, 144, 5, 0,
|
||||||
|
0, 3, 0, 0, 8, 128,
|
||||||
|
0, 0, 255, 128, 0, 0,
|
||||||
|
85, 160, 2, 0, 0, 3,
|
||||||
|
1, 0, 7, 128, 0, 0,
|
||||||
|
228, 128, 1, 0, 228, 160,
|
||||||
|
5, 0, 0, 3, 1, 0,
|
||||||
|
8, 128, 0, 0, 255, 128,
|
||||||
|
14, 0, 0, 160, 11, 0,
|
||||||
|
0, 3, 0, 0, 15, 128,
|
||||||
|
1, 0, 228, 128, 14, 0,
|
||||||
85, 160, 10, 0, 0, 3,
|
85, 160, 10, 0, 0, 3,
|
||||||
0, 0, 15, 208, 0, 0,
|
0, 0, 15, 208, 0, 0,
|
||||||
228, 128, 0, 0, 0, 160,
|
228, 128, 14, 0, 170, 160,
|
||||||
1, 0, 0, 2, 0, 0,
|
1, 0, 0, 2, 0, 0,
|
||||||
3, 224, 1, 0, 228, 144,
|
3, 224, 1, 0, 228, 144,
|
||||||
255, 255, 0, 0
|
255, 255, 0, 0
|
||||||
|
|
Loading…
Reference in a new issue