mirror of
https://github.com/CookiePLMonster/SilentPatch.git
synced 2025-01-01 08:43:01 +05:00
Fixed flickering and alpha bugs in nvc shader.
This commit is contained in:
parent
b2c1a775e0
commit
c8f8be75f3
3 changed files with 201 additions and 142 deletions
|
@ -1,4 +1,5 @@
|
||||||
#include "StdAfxSA.h"
|
#include "StdAfxSA.h"
|
||||||
|
#include <limits>
|
||||||
|
|
||||||
#include "ScriptSA.h"
|
#include "ScriptSA.h"
|
||||||
#include "GeneralSA.h"
|
#include "GeneralSA.h"
|
||||||
|
@ -50,6 +51,8 @@ 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);
|
||||||
|
WRAPPER void _RwD3D9GetTransform(RwUInt32 state, void* matrix) { VARJMP(varRwD3D9GetTransform); }
|
||||||
|
|
||||||
RwCamera* RwCameraBeginUpdate(RwCamera* camera)
|
RwCamera* RwCameraBeginUpdate(RwCamera* camera)
|
||||||
{
|
{
|
||||||
|
@ -718,7 +721,8 @@ BOOL Initialise3D(void* pParam)
|
||||||
|
|
||||||
void SetShader(RxD3D9InstanceData* pInstData)
|
void SetShader(RxD3D9InstanceData* pInstData)
|
||||||
{
|
{
|
||||||
if ( bRenderNVC )
|
//GetAsyncKeyState(VK_F5) &&
|
||||||
|
if (bRenderNVC )
|
||||||
{
|
{
|
||||||
D3DMATRIX outMat;
|
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) };
|
||||||
|
@ -735,7 +739,15 @@ void SetShader(RxD3D9InstanceData* pInstData)
|
||||||
_rwD3D9VSSetActiveWorldMatrix(RwFrameGetLTM(RpAtomicGetFrame(pRenderedAtomic)));
|
_rwD3D9VSSetActiveWorldMatrix(RwFrameGetLTM(RpAtomicGetFrame(pRenderedAtomic)));
|
||||||
//_rwD3D9VSSetActiveWorldMatrix(RwFrameGetMatrix(RpAtomicGetFrame(pRenderedAtomic)));
|
//_rwD3D9VSSetActiveWorldMatrix(RwFrameGetMatrix(RpAtomicGetFrame(pRenderedAtomic)));
|
||||||
_rwD3D9VSGetComposedTransformMatrix(&outMat);
|
_rwD3D9VSGetComposedTransformMatrix(&outMat);
|
||||||
|
|
||||||
|
D3DMATRIX worldMat, viewMat, projMat;
|
||||||
|
_RwD3D9GetTransform(D3DTS_WORLD, &worldMat);
|
||||||
|
_RwD3D9GetTransform(D3DTS_VIEW, &viewMat);
|
||||||
|
_RwD3D9GetTransform(D3DTS_PROJECTION, &projMat);
|
||||||
|
RwD3D9SetVertexShaderConstant(6, &worldMat, 4);
|
||||||
|
RwD3D9SetVertexShaderConstant(10, &viewMat, 4);
|
||||||
|
RwD3D9SetVertexShaderConstant(14, &projMat, 4);
|
||||||
|
|
||||||
RwD3D9SetVertexShaderConstant(0, &outMat, 4);
|
RwD3D9SetVertexShaderConstant(0, &outMat, 4);
|
||||||
RwD3D9SetVertexShaderConstant(4, fEnvVars, 1);
|
RwD3D9SetVertexShaderConstant(4, fEnvVars, 1);
|
||||||
RwD3D9SetVertexShaderConstant(5, AmbientLight, 1);
|
RwD3D9SetVertexShaderConstant(5, AmbientLight, 1);
|
||||||
|
|
|
@ -16,16 +16,20 @@ struct VS_OUTPUT
|
||||||
float4x4 viewProjMatrix : register(c0);
|
float4x4 viewProjMatrix : register(c0);
|
||||||
float2 fEnvVars : register(c4);
|
float2 fEnvVars : register(c4);
|
||||||
float4 AmbientLight : register(c5);
|
float4 AmbientLight : register(c5);
|
||||||
|
float4x4 world : register(c6);
|
||||||
|
float4x4 view : 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(In.Position, viewProjMatrix);
|
||||||
|
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.rgb = (In.DayColor.rgb * (1.0-fEnvVars[0]) + In.NightColor.rgb * fEnvVars[0]) + AmbientLight.rgb;
|
||||||
Out.Color.a = In.DayColor.a * fEnvVars[1];
|
Out.Color.a = In.DayColor.a * (256.0/128.0) * fEnvVars[1];
|
||||||
//Out.Color.rgb = In.DayColor.rgb + AmbientLight.rgb;
|
//Out.Color.rgb = In.DayColor.rgb + AmbientLight.rgb;
|
||||||
Out.Color = saturate(Out.Color);
|
Out.Color = saturate(Out.Color);
|
||||||
|
|
||||||
|
|
|
@ -1,138 +1,181 @@
|
||||||
#if 0
|
#if 0
|
||||||
//
|
//
|
||||||
// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111
|
// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384
|
||||||
//
|
//
|
||||||
// fxc /T vs_2_0 /E NVC_vertex_shader /Fh ..\SilentPatch\nvc.h
|
// Parameters:
|
||||||
// ..\SilentPatch\nvc.fx
|
//
|
||||||
//
|
// float4 AmbientLight;
|
||||||
//
|
// float2 fEnvVars;
|
||||||
// Parameters:
|
// float4x4 proj;
|
||||||
//
|
// float4x4 view;
|
||||||
// float4 AmbientLight;
|
// float4x4 world;
|
||||||
// float2 fEnvVars;
|
//
|
||||||
// float4x4 viewProjMatrix;
|
//
|
||||||
//
|
// Registers:
|
||||||
//
|
//
|
||||||
// Registers:
|
// Name Reg Size
|
||||||
//
|
// ------------ ----- ----
|
||||||
// Name Reg Size
|
// fEnvVars c4 1
|
||||||
// -------------- ----- ----
|
// AmbientLight c5 1
|
||||||
// viewProjMatrix c0 4
|
// world c6 4
|
||||||
// fEnvVars c4 1
|
// view c10 4
|
||||||
// AmbientLight c5 1
|
// proj c14 4
|
||||||
//
|
//
|
||||||
|
|
||||||
vs_2_0
|
vs_2_0
|
||||||
def c6, 1, 0, 0, 0
|
def c0, 1, 0, 0, 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
|
||||||
dp4 oPos.x, v0, c0
|
mul r0, v0.y, c7
|
||||||
dp4 oPos.y, v0, c1
|
mad r0, c6, v0.x, r0
|
||||||
dp4 oPos.z, v0, c2
|
mad r0, c8, v0.z, r0
|
||||||
dp4 oPos.w, v0, c3
|
mad r0, c9, v0.w, r0
|
||||||
mov r0.x, c6.x
|
mul r1, r0.y, c11
|
||||||
add r0.x, r0.x, -c4.x
|
mad r1, c10, r0.x, r1
|
||||||
mul r0.yzw, v2.xxyz, c4.x
|
mad r1, c12, r0.z, r1
|
||||||
mad r0.xyz, v3, r0.x, r0.yzww
|
mad r0, c13, r0.w, r1
|
||||||
add r0.xyz, r0, c5
|
mul r1, r0.y, c15
|
||||||
mul r0.w, v3.w, c4.y
|
mad r1, c14, r0.x, r1
|
||||||
max r0, r0, c6.y
|
mad r1, c16, r0.z, r1
|
||||||
min oD0, r0, c6.x
|
mad oPos, c17, r0.w, r1
|
||||||
mov oT0.xy, v1
|
mov r0.x, c0.x
|
||||||
|
add r0.x, r0.x, -c4.x
|
||||||
// approximately 13 instruction slots used
|
mul r0.yzw, v2.xxyz, c4.x
|
||||||
#endif
|
mad r0.xyz, v3, r0.x, r0.yzww
|
||||||
|
add r0.xyz, r0, c5
|
||||||
const BYTE g_vs20_NVC_vertex_shader[] =
|
mul r0.w, v3.w, c4.y
|
||||||
{
|
max r0, r0, c0.y
|
||||||
0, 2, 254, 255, 254, 255,
|
min oD0, r0, c0.x
|
||||||
60, 0, 67, 84, 65, 66,
|
mov oT0.xy, v1
|
||||||
28, 0, 0, 0, 187, 0,
|
|
||||||
0, 0, 0, 2, 254, 255,
|
// approximately 21 instruction slots used
|
||||||
3, 0, 0, 0, 28, 0,
|
#endif
|
||||||
0, 0, 0, 1, 0, 0,
|
|
||||||
180, 0, 0, 0, 88, 0,
|
const BYTE g_vs20_NVC_vertex_shader[] =
|
||||||
0, 0, 2, 0, 5, 0,
|
{
|
||||||
1, 0, 22, 0, 104, 0,
|
0, 2, 254, 255, 254, 255,
|
||||||
0, 0, 0, 0, 0, 0,
|
71, 0, 67, 84, 65, 66,
|
||||||
120, 0, 0, 0, 2, 0,
|
28, 0, 0, 0, 230, 0,
|
||||||
4, 0, 1, 0, 18, 0,
|
0, 0, 0, 2, 254, 255,
|
||||||
132, 0, 0, 0, 0, 0,
|
5, 0, 0, 0, 28, 0,
|
||||||
0, 0, 148, 0, 0, 0,
|
0, 0, 0, 1, 0, 0,
|
||||||
2, 0, 0, 0, 4, 0,
|
223, 0, 0, 0, 128, 0,
|
||||||
2, 0, 164, 0, 0, 0,
|
0, 0, 2, 0, 5, 0,
|
||||||
0, 0, 0, 0, 65, 109,
|
1, 0, 22, 0, 144, 0,
|
||||||
98, 105, 101, 110, 116, 76,
|
0, 0, 0, 0, 0, 0,
|
||||||
105, 103, 104, 116, 0, 171,
|
160, 0, 0, 0, 2, 0,
|
||||||
171, 171, 1, 0, 3, 0,
|
4, 0, 1, 0, 18, 0,
|
||||||
1, 0, 4, 0, 1, 0,
|
172, 0, 0, 0, 0, 0,
|
||||||
0, 0, 0, 0, 0, 0,
|
0, 0, 188, 0, 0, 0,
|
||||||
102, 69, 110, 118, 86, 97,
|
2, 0, 14, 0, 4, 0,
|
||||||
114, 115, 0, 171, 171, 171,
|
58, 0, 196, 0, 0, 0,
|
||||||
1, 0, 3, 0, 1, 0,
|
0, 0, 0, 0, 212, 0,
|
||||||
2, 0, 1, 0, 0, 0,
|
0, 0, 2, 0, 10, 0,
|
||||||
0, 0, 0, 0, 118, 105,
|
4, 0, 42, 0, 196, 0,
|
||||||
101, 119, 80, 114, 111, 106,
|
0, 0, 0, 0, 0, 0,
|
||||||
77, 97, 116, 114, 105, 120,
|
217, 0, 0, 0, 2, 0,
|
||||||
0, 171, 3, 0, 3, 0,
|
6, 0, 4, 0, 26, 0,
|
||||||
4, 0, 4, 0, 1, 0,
|
196, 0, 0, 0, 0, 0,
|
||||||
0, 0, 0, 0, 0, 0,
|
0, 0, 65, 109, 98, 105,
|
||||||
118, 115, 95, 50, 95, 48,
|
101, 110, 116, 76, 105, 103,
|
||||||
0, 77, 105, 99, 114, 111,
|
104, 116, 0, 171, 171, 171,
|
||||||
115, 111, 102, 116, 32, 40,
|
1, 0, 3, 0, 1, 0,
|
||||||
82, 41, 32, 72, 76, 83,
|
4, 0, 1, 0, 0, 0,
|
||||||
76, 32, 83, 104, 97, 100,
|
0, 0, 0, 0, 102, 69,
|
||||||
101, 114, 32, 67, 111, 109,
|
110, 118, 86, 97, 114, 115,
|
||||||
112, 105, 108, 101, 114, 32,
|
0, 171, 171, 171, 1, 0,
|
||||||
57, 46, 50, 57, 46, 57,
|
3, 0, 1, 0, 2, 0,
|
||||||
53, 50, 46, 51, 49, 49,
|
1, 0, 0, 0, 0, 0,
|
||||||
49, 0, 81, 0, 0, 5,
|
0, 0, 112, 114, 111, 106,
|
||||||
6, 0, 15, 160, 0, 0,
|
0, 171, 171, 171, 3, 0,
|
||||||
128, 63, 0, 0, 0, 0,
|
3, 0, 4, 0, 4, 0,
|
||||||
0, 0, 0, 0, 0, 0,
|
1, 0, 0, 0, 0, 0,
|
||||||
0, 0, 31, 0, 0, 2,
|
0, 0, 118, 105, 101, 119,
|
||||||
0, 0, 0, 128, 0, 0,
|
0, 119, 111, 114, 108, 100,
|
||||||
15, 144, 31, 0, 0, 2,
|
0, 118, 115, 95, 50, 95,
|
||||||
5, 0, 0, 128, 1, 0,
|
48, 0, 77, 105, 99, 114,
|
||||||
15, 144, 31, 0, 0, 2,
|
111, 115, 111, 102, 116, 32,
|
||||||
10, 0, 0, 128, 2, 0,
|
40, 82, 41, 32, 72, 76,
|
||||||
15, 144, 31, 0, 0, 2,
|
83, 76, 32, 83, 104, 97,
|
||||||
10, 0, 1, 128, 3, 0,
|
100, 101, 114, 32, 67, 111,
|
||||||
15, 144, 9, 0, 0, 3,
|
109, 112, 105, 108, 101, 114,
|
||||||
0, 0, 1, 192, 0, 0,
|
32, 54, 46, 51, 46, 57,
|
||||||
228, 144, 0, 0, 228, 160,
|
54, 48, 48, 46, 49, 54,
|
||||||
9, 0, 0, 3, 0, 0,
|
51, 56, 52, 0, 81, 0,
|
||||||
2, 192, 0, 0, 228, 144,
|
0, 5, 0, 0, 15, 160,
|
||||||
1, 0, 228, 160, 9, 0,
|
0, 0, 128, 63, 0, 0,
|
||||||
0, 3, 0, 0, 4, 192,
|
0, 0, 0, 0, 0, 0,
|
||||||
0, 0, 228, 144, 2, 0,
|
0, 0, 0, 0, 31, 0,
|
||||||
228, 160, 9, 0, 0, 3,
|
0, 2, 0, 0, 0, 128,
|
||||||
0, 0, 8, 192, 0, 0,
|
0, 0, 15, 144, 31, 0,
|
||||||
228, 144, 3, 0, 228, 160,
|
0, 2, 5, 0, 0, 128,
|
||||||
1, 0, 0, 2, 0, 0,
|
1, 0, 15, 144, 31, 0,
|
||||||
1, 128, 6, 0, 0, 160,
|
0, 2, 10, 0, 0, 128,
|
||||||
2, 0, 0, 3, 0, 0,
|
2, 0, 15, 144, 31, 0,
|
||||||
1, 128, 0, 0, 0, 128,
|
0, 2, 10, 0, 1, 128,
|
||||||
4, 0, 0, 161, 5, 0,
|
3, 0, 15, 144, 5, 0,
|
||||||
0, 3, 0, 0, 14, 128,
|
0, 3, 0, 0, 15, 128,
|
||||||
2, 0, 144, 144, 4, 0,
|
0, 0, 85, 144, 7, 0,
|
||||||
0, 160, 4, 0, 0, 4,
|
228, 160, 4, 0, 0, 4,
|
||||||
0, 0, 7, 128, 3, 0,
|
0, 0, 15, 128, 6, 0,
|
||||||
228, 144, 0, 0, 0, 128,
|
228, 160, 0, 0, 0, 144,
|
||||||
0, 0, 249, 128, 2, 0,
|
0, 0, 228, 128, 4, 0,
|
||||||
0, 3, 0, 0, 7, 128,
|
0, 4, 0, 0, 15, 128,
|
||||||
0, 0, 228, 128, 5, 0,
|
8, 0, 228, 160, 0, 0,
|
||||||
228, 160, 5, 0, 0, 3,
|
170, 144, 0, 0, 228, 128,
|
||||||
0, 0, 8, 128, 3, 0,
|
4, 0, 0, 4, 0, 0,
|
||||||
255, 144, 4, 0, 85, 160,
|
15, 128, 9, 0, 228, 160,
|
||||||
11, 0, 0, 3, 0, 0,
|
0, 0, 255, 144, 0, 0,
|
||||||
15, 128, 0, 0, 228, 128,
|
228, 128, 5, 0, 0, 3,
|
||||||
6, 0, 85, 160, 10, 0,
|
1, 0, 15, 128, 0, 0,
|
||||||
0, 3, 0, 0, 15, 208,
|
85, 128, 11, 0, 228, 160,
|
||||||
0, 0, 228, 128, 6, 0,
|
4, 0, 0, 4, 1, 0,
|
||||||
0, 160, 1, 0, 0, 2,
|
15, 128, 10, 0, 228, 160,
|
||||||
0, 0, 3, 224, 1, 0,
|
0, 0, 0, 128, 1, 0,
|
||||||
228, 144, 255, 255, 0, 0
|
228, 128, 4, 0, 0, 4,
|
||||||
};
|
1, 0, 15, 128, 12, 0,
|
||||||
|
228, 160, 0, 0, 170, 128,
|
||||||
|
1, 0, 228, 128, 4, 0,
|
||||||
|
0, 4, 0, 0, 15, 128,
|
||||||
|
13, 0, 228, 160, 0, 0,
|
||||||
|
255, 128, 1, 0, 228, 128,
|
||||||
|
5, 0, 0, 3, 1, 0,
|
||||||
|
15, 128, 0, 0, 85, 128,
|
||||||
|
15, 0, 228, 160, 4, 0,
|
||||||
|
0, 4, 1, 0, 15, 128,
|
||||||
|
14, 0, 228, 160, 0, 0,
|
||||||
|
0, 128, 1, 0, 228, 128,
|
||||||
|
4, 0, 0, 4, 1, 0,
|
||||||
|
15, 128, 16, 0, 228, 160,
|
||||||
|
0, 0, 170, 128, 1, 0,
|
||||||
|
228, 128, 4, 0, 0, 4,
|
||||||
|
0, 0, 15, 192, 17, 0,
|
||||||
|
228, 160, 0, 0, 255, 128,
|
||||||
|
1, 0, 228, 128, 1, 0,
|
||||||
|
0, 2, 0, 0, 1, 128,
|
||||||
|
0, 0, 0, 160, 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, 0, 228, 128, 0, 0,
|
||||||
|
85, 160, 10, 0, 0, 3,
|
||||||
|
0, 0, 15, 208, 0, 0,
|
||||||
|
228, 128, 0, 0, 0, 160,
|
||||||
|
1, 0, 0, 2, 0, 0,
|
||||||
|
3, 224, 1, 0, 228, 144,
|
||||||
|
255, 255, 0, 0
|
||||||
|
};
|
||||||
|
|
Loading…
Reference in a new issue