(10-04-2015, 11:03 PM)Tino Wrote: [ -> ]@masterotaku: if you give more detail on the values you tweak i can see if a native modification framework can be added internally to make thos changes more user friendly.
OK. Here's the content of a vertex shader that controls some shadows in Zelda Majora's Mask, called "36825a742c3b0f39-vs_replace.txt":
Code:
//Zelda MM: shadow behind maks in walls, Skulltulas house.
cbuffer _Globals : register(b0)
{
 float4 cproj[4] : packoffset(c0);
 float4 cmtrl[4] : packoffset(c4);
 float4 clights[40] : packoffset(c8);
 float4 ctexmtx[24] : packoffset(c48);
 float4 ctrmtx[64] : packoffset(c72);
 float4 cnmtx[32] : packoffset(c136);
 float4 cpostmtx[64] : packoffset(c168);
 float4 cDepth : packoffset(c232);
 float4 cPLOffset[13] : packoffset(c233);
}
Texture2D<float4> StereoParams : register(t125);
Texture1D<float4> IniParams : register(t120);
void main(
 float4 v0 : COLOR0,
 float2 v1 : TEXCOORD0,
 float4 v2 : BLENDINDICES0,
 float4 v3 : POSITION0,
 out float4 o0 : SV_Position0,
 out float4 o1 : COLOR0,
 out float4 o2 : COLOR1,
 out float4 o3 : TEXCOORD0,
 out float4 o4 : TEXCOORD1)
{
 float4 r0,r1;
 uint4 bitmask, uiDest;
 float4 fDest;
 float4 iniparams = IniParams.Load(0);
Â
 r0.x = 255 * v2.x;
 r0.x = (int)r0.x;
 r0.yz = (int2)r0.xx + int2(1,2);
 r1.x = dot(ctrmtx[r0.x].xyzw, v3.xyzw);
 r1.y = dot(ctrmtx[r0.y].xyzw, v3.xyzw);
 r1.z = dot(ctrmtx[r0.z].xyzw, v3.xyzw);
 r1.w = 1;
 r0.x = dot(cproj[0].xyzw, r1.xyzw)*iniparams.x;
 r0.y = dot(cproj[1].xyzw, r1.xyzw)*iniparams.y;
 r0.z = dot(cproj[3].xyzw, r1.xyzw);
 r0.w = dot(cproj[2].xyzw, r1.xyzw);
 o3.xy = r1.xy;
 o4.w = r1.z;
 o0.xy = r0.zz * cDepth.zw + r0.xy;
 r0.x = cDepth.y * r0.w;
 r0.y = cDepth.x + -1;
 r0.x = r0.y * r0.z + r0.x;
 o0.z = -r0.x;
 o0.w = r0.z;
 o3.zw = r0.wz;
 o1.xyzw = v0.xyzw;
 o2.xyzw = v0.xyzw;
 o4.xyz = float3(0,0,0);
 return;
}
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.20789
//
// Â using 3Dmigoto v1.2.1 on Thu Sep 03 21:58:09 2015
//
//
// Buffer Definitions:
//
// cbuffer $Globals
// {
//
// Â float4 cproj[4]; Â Â Â Â Â Â Â Â Â // Offset: Â Â 0 Size: Â Â 64
// Â float4 cmtrl[4]; Â Â Â Â Â Â Â Â Â // Offset: Â 64 Size: Â Â 64 [unused]
// Â float4 clights[40]; Â Â Â Â Â Â Â Â // Offset: Â 128 Size: Â 640 [unused]
// Â float4 ctexmtx[24]; Â Â Â Â Â Â Â Â // Offset: Â 768 Size: Â 384 [unused]
// Â float4 ctrmtx[64]; Â Â Â Â Â Â Â Â // Offset: 1152 Size: Â 1024
// Â float4 cnmtx[32]; Â Â Â Â Â Â Â Â Â // Offset: 2176 Size: Â 512 [unused]
// Â float4 cpostmtx[64]; Â Â Â Â Â Â Â // Offset: 2688 Size: Â 1024 [unused]
// Â float4 cDepth; Â Â Â Â Â Â Â Â Â Â // Offset: 3712 Size: Â Â 16
// Â float4 cPLOffset[13]; Â Â Â Â Â Â Â // Offset: 3728 Size: Â 208 [unused]
//
// }
//
//
// Resource Bindings:
//
// Name                 Type  Format     Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// $Globals              cbuffer    NA      NA   0     1
//
//
//
// Input signature:
//
// Name         Index  Mask Register SysValue  Format  Used
// -------------------- ----- ------ -------- -------- ------- ------
// COLOR           0  xyzw     0   NONE  float  xyzw
// TEXCOORD         0  xy      1   NONE  float   Â
// BLENDINDICES       0  xyzw     2   NONE  float  x Â
// POSITION         0  xyzw     3   NONE  float  xyzw
//
//
// Output signature:
//
// Name         Index  Mask Register SysValue  Format  Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Position        0  xyzw     0    POS  float  xyzw
// COLOR           0  xyzw     1   NONE  float  xyzw
// COLOR           1  xyzw     2   NONE  float  xyzw
// TEXCOORD         0  xyzw     3   NONE  float  xyzw
// TEXCOORD         1  xyzw     4   NONE  float  xyzw
//
vs_5_0
dcl_globalFlags refactoringAllowed
dcl_constantbuffer cb0[233], dynamicIndexed
dcl_input v0.xyzw
dcl_input v2.x
dcl_input v3.xyzw
dcl_output_siv o0.xyzw, position
dcl_output o1.xyzw
dcl_output o2.xyzw
dcl_output o3.xyzw
dcl_output o4.xyzw
dcl_temps 2
mul r0.x, v2.x, l(255.000000)
ftoi r0.x, r0.x
iadd r0.yz, r0.xxxx, l(0, 1, 2, 0)
dp4 r1.x, cb0[r0.x + 72].xyzw, v3.xyzw
dp4 r1.y, cb0[r0.y + 72].xyzw, v3.xyzw
dp4 r1.z, cb0[r0.z + 72].xyzw, v3.xyzw
mov r1.w, l(1.000000)
dp4 r0.x, cb0[0].xyzw, r1.xyzw
dp4 r0.y, cb0[1].xyzw, r1.xyzw
dp4 r0.z, cb0[3].xyzw, r1.xyzw
dp4 r0.w, cb0[2].xyzw, r1.xyzw
mov o3.xy, r1.xyxx
mov o4.w, r1.z
mad o0.xy, r0.zzzz, cb0[232].zwzz, r0.xyxx
mul r0.x, r0.w, cb0[232].y
add r0.y, l(-1.000000), cb0[232].x
mad r0.x, r0.y, r0.z, r0.x
mov o0.z, -r0.x
mov o0.w, r0.z
mov o3.zw, r0.wwwz
mov o1.xyzw, v0.xyzw
mov o2.xyzw, v0.xyzw
mov o4.xyz, l(0,0,0,0)
ret
// Approximately 24 instruction slots used
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
The ASM code at the bottom doesn't need to be touched. Only the HLSL part.
The important (and almost only) lines that I modified for the aspect ratio correction are these:
Code:
r0.x = dot(cproj[0].xyzw, r1.xyzw)*iniparams.x;
r0.y = dot(cproj[1].xyzw, r1.xyzw)*iniparams.y;
"iniparams.x" and "iniparams.y" are variables that I defined in the "d3dx.ini" file that comes with 3Dmigoto. I use a variable so I can change its value in real time with a hotkey, for aspect ratio changes in real time. However, that makes it work only with 3D Vision.
If I put the value manually, like "r0.x = dot(cproj[0].xyzw, r1.xyzw)*0.75;" (correction from 4:3 to 16:9. Lower values for wider aspect ratios), it works for all users even if they don't have 3D Vision.
The thing is that all vertex shaders that I modified for aspect ratio mods needed exactly the same changes. The "r0.x = dot(cproj[0].xyzw, r1.xyzw);r0.y = dot(cproj[1].xyzw, r1.xyzw);r0.z = dot(cproj[3].xyzw, r1.xyzw);r0.w = dot(cproj[2].xyzw, r1.xyzw);" lines are always there. So if I had access to the source of the projection, I would be able to change all shaders at the same time.
Ideally, it would be like an improved widescreen hack that works with every game and leaves the HUD and menu elements with the correct aspect ratio. If it were done that way, I don't know if I would still need to make exceptions to some shaders (in some cases, some shaders needed to apply to the entire screen and not be corrected. Exceptions that do need 3D Vision to work because they use variables).