masterotaku said:STOP RIGHT THERE! I've noticed that the number you need is actually the FoV of the game (if it doesn't EVER change and it isn't user configurable, a static value should be fine). In the shaders fixed by the DarkStarSword Unity scripts, there are ways to calculate that. And I found something similar, so I'm going to try getting it 100% right. It's possible that this won't work, because I based it on an older Unity version. So back up your shaders and d3dx.ini first.
First, you need "inverse_unity_mvp.hlsl" and "matrix.hlsl" from my Yooka-Laylee fix. Place them in the "ShaderFixes" folder.
In "d3dx.ini" (yes, using the name of your vertex shader, thanks for posting it):
// ---- Created with 3Dmigoto v1.2.61 on Sat Jun 17 19:46:16 2017
cbuffer cb3 : register(b3)
{
float4 cb3[21];
}
cbuffer cb2 : register(b2)
{
float4 cb2[4];
}
// UnityPerCameraRare contains the projection & inverse projection matrices
// that we need to fix the shadows. The headers extracted from the asset files
// show which constant buffer is UnityPerCameraRare, and then we just grab the
// actual definition of the buffer from the Unity Cg source code, and replace
// references to it as necessary.
// Projection matrices of the camera. Note that this might be different from projection matrix
// that is set right now, e.g. while rendering shadows the matrices below are still the projection
// of original camera.
row_major uniform float4x4 unity_CameraProjection; // cb1[7] - cb1[10]
row_major uniform float4x4 unity_CameraInvProjection; // cb1[11] - cb1[14]
}
If it doesn't work, try going to the vertex shader and changing the axis "unity_CameraInvProjection" is using in the code. Instead of the "[1], [0], [2], [3]" order, change it to "[0], [3], [1], [2]".
If it works, it should be 100% correct at all FoV values.
EDIT: wow, I spent like half an hour posting this. Now I see your new post. I'll have to think about that one for a while.
That worked perfect!!! can we use this to fix the other shader?
It depends. If they are extremely similar vertex and pixel shaders, yes.
For example, that torch/lanterns shader is something I haven't seen before, so I have no idea for now.
Oh, and I think you should add these things to d3dx.ini just in case (they are in that file in the Yooka-Laylee fix, because you may need to know where you have to paste them. Green commented lines may look the wrong color here in the forums):
[code]
;;;;;;;;;;;;;;;;;;;;;;; DARKSTARSWORD'S UNITY 5 TEMPLATE ;;;;;;;;;;;;;;;;;;;;;;;
; Custom resource declarations
[Resource_UnityPerCameraRare]
max_copies_per_frame = 1
[Resource_CameraDepthTexture]
max_copies_per_frame = 1
[Resource_UnityPerCamera]
max_copies_per_frame = 1
[Resource_UnityPerDraw]
max_copies_per_frame = 1
[Resource_Inverse_MVP]
type = Buffer
format = R32G32B32A32_FLOAT
array = 4
;------------------------------------------------------------------------------------------------------
; Commands to run from the Present call at the start/end of each frame
;
; Useful to clear custom resources or ini params at the start of each frame, or
; to run a custom shader to do whatever you can dream up.
;------------------------------------------------------------------------------------------------------
[Present]
; Clear custom resources on the present call to ensure we don't use stale data:
Resource_UnityPerCameraRare = null
Resource_CameraDepthTexture = null
Resource_UnityPerCamera = null
Resource_UnityPerDraw = null
[/code]
And:
[code]
[CustomShader_Inverse_Unity_MVP]
max_executions_per_frame = 1
cs = ShaderFixes/inverse_unity_mvp.hlsl
cs-cb11 = Resource_UnityPerDraw
cs-u0 = Resource_Inverse_MVP
Dispatch = 1, 1, 1
post cs-cb11 = null
post cs-u0 = null
[/code]
I think they can help performance or be needed in some way.
It depends. If they are extremely similar vertex and pixel shaders, yes.
For example, that torch/lanterns shader is something I haven't seen before, so I have no idea for now.
Oh, and I think you should add these things to d3dx.ini just in case (they are in that file in the Yooka-Laylee fix, because you may need to know where you have to paste them. Green commented lines may look the wrong color here in the forums):
[Resource_Inverse_MVP]
type = Buffer
format = R32G32B32A32_FLOAT
array = 4
;------------------------------------------------------------------------------------------------------
; Commands to run from the Present call at the start/end of each frame
;
; Useful to clear custom resources or ini params at the start of each frame, or
; to run a custom shader to do whatever you can dream up.
;------------------------------------------------------------------------------------------------------
[Present]
; Clear custom resources on the present call to ensure we don't use stale data:
Resource_UnityPerCameraRare = null
Resource_CameraDepthTexture = null
Resource_UnityPerCamera = null
Resource_UnityPerDraw = null
// Projection matrices of the camera. Note that this might be different from projection matrix
// that is set right now, e.g. while rendering shadows the matrices below are still the projection
// of original camera.
row_major uniform float4x4 unity_CameraProjection; // cb1[7] - cb1[10]
row_major uniform float4x4 unity_CameraInvProjection; // cb1[11] - cb1[14]
}
uniform float4x4 _Object2World;
uniform float4x4 _World2Object;
uniform float4 unity_LODFade; // x is the fade value ranging within [0,1]. y is x quantized into 16 levels
uniform float4 unity_WorldTransformParams; // w is usually 1.0, or -1.0 for odd-negative scale transforms
}
Hi, Masterotaku I think I have the same lighting shader, but this one is of the same game "The Long Dark" but is from another older version. I have the original shader and the fixed shader fixed by DSS. Maybe you can use these shaders to fix the shader we are fighting...
This is the original VS: ca5cfc8e4d8b1ce5-vs_replace.txt
// ---- Created with 3Dmigoto v1.2.61 on Sun Jun 18 20:20:57 2017
cbuffer cb2 : register(b2)
{
float4 cb2[8];
}
// Replace definition with UnityPerDraw from Unity Cg source code:
// Note that matrix order is transposed between Cg and HLSL, so add row_major
// keywords to each float4x4 entry
cbuffer cb2 : register(b2)
{
// float4 cb2[8];
row_major uniform float4x4 _Object2World;
row_major uniform float4x4 _World2Object;
uniform float4 unity_LODFade; // x is the fade value ranging within [0,1]. y is x quantized into 16 levels
}
cbuffer cb1 : register(b1)
{
float4 cb1[6];
}
cbuffer cb0 : register(b0)
{
float4 cb0[7];
}
// Copied from the directional lighting shader using 3DMigoto
cbuffer UnityPerCameraRare : register(b13)
{
uniform float4 unity_CameraWorldClipPlanes[6];
// Projection matrices of the camera. Note that this might be different from projection matrix
// that is set right now, e.g. while rendering shadows the matrices below are still the projection
// of original camera.
row_major uniform float4x4 unity_CameraProjection;
row_major uniform float4x4 unity_CameraInvProjection;
}
if (!full_screen) {
// Looks like UNITY_MATRIX_IT_MV is 0, so we can't just do this:
// float4x4 projection = mul(UNITY_MATRIX_IT_MV, UNITY_MATRIX_MVP);
// fov = 1 / projection[0].x;
// Instead, we have to calculate this the long way:
// I already have an optimised version of this calculation in assembler for
// Unity 4 (the committed version is for column-major order, but the optimised
// row-major version was only slightly longer). I'm guessing the HLSL
// determinant() function won't be optimised because it can't make assumptions
// about the matrix (and that is a *large* amount of multiplications that could
// be eliminated), so we can probably do better, but for now this is clearer:
float det = 1 / determinant(UNITY_MATRIX_MV);
r0.x += separation * (depth - convergence) * fov;
} else {
// Can't determine the FOV from the values passed to this shader, so
// use the FOV copied from directional lighting shader with 3DMigoto.
// We could probably get away with using only this and scrapping the
// above code for games that always have directional lighting enabled.
@masterotaku here's my homework XD. cb3 it's new in VS I don't know what to do with it X(. I've made a new version of the shaders comparing with the old ones.
VS: 4c9936f7f1d28f6e-vs_replace.txt
// lights
// ---- Created with 3Dmigoto v1.2.61 on Sun Jun 18 23:18:31 2017
cbuffer cb3 : register(b3)
{
float4 cb3[21];
}
row_major uniform float4x4 _Object2World;
row_major uniform float4x4 _World2Object;
uniform float4 unity_LODFade; // x is the fade value ranging within [0,1]. y is x quantized into 16 levels
}
if (!full_screen) {
r0.x += separation * (depth - convergence);
r1.y = cb1[5].x * r1.y;
r2.xzw = float3(0.5,0.5,0.5) * r1.xwy;
o1.zw = r1.zw;
o1.xy = r2.xw + r2.zz;
r1.xyz = cb3[10].xyz * r0.yyy; //UNITY_MATRIX_MV?cb2 in old shader
r1.xyz = cb3[9].xyz * r0.xxx + r1.xyz; //UNITY_MATRIX_MV?cb2 in old shader
r0.xyz = cb3[11].xyz * r0.zzz + r1.xyz;//UNITY_MATRIX_MV?cb2 in old shader
r0.xyz = cb3[12].xyz * r0.www + r0.xyz;//UNITY_MATRIX_MV?cb2 in old shader
if (!full_screen) {
// Looks like UNITY_MATRIX_IT_MV is 0, so we can't just do this:
// float4x4 projection = mul(UNITY_MATRIX_IT_MV, UNITY_MATRIX_MVP);
// fov = 1 / projection[0].x;
// Instead, we have to calculate this the long way:
// I already have an optimised version of this calculation in assembler for
// Unity 4 (the committed version is for column-major order, but the optimised
// row-major version was only slightly longer). I'm guessing the HLSL
// determinant() function won't be optimised because it can't make assumptions
// about the matrix (and that is a *large* amount of multiplications that could
// be eliminated), so we can probably do better, but for now this is clearer:
float det = 1 / determinant(UNITY_MATRIX_MV);
r0.x += separation * (depth - convergence) * fov;
} else {
// Can't determine the FOV from the values passed to this shader, so
// use the FOV copied from directional lighting shader with 3DMigoto.
// We could probably get away with using only this and scrapping the
// above code for games that always have directional lighting enabled.
[quote="Punisher!|ITA"]Suddenly it does not work anymore. Game starts with BLACK SCREEN, no matter what. It's 3D related because it works without the fix.[/quote]
Use the uninstall.bat and download the last version of the fix, [url]https://drive.google.com/open?id=0B7-C-G8Te2HbMjBvNllFZnFmeUU[/url]
The game is working for me.
You can try this too:
In your Steam library, right click on "The Long Dark" and select "Properties"
Click "Set Launch Options"
In the box, type "-window-mode exclusive" without the ""
And in the folder of the game edit the file d3dx.ini: find full_screen=1 and replace it for ;full_screen=0
You can try this too:
In your Steam library, right click on "The Long Dark" and select "Properties"
Click "Set Launch Options"
In the box, type "-window-mode exclusive" without the ""
And in the folder of the game edit the file d3dx.ini: find full_screen=1 and replace it for ;full_screen=0
[quote="cicicleta"][quote="Punisher!|ITA"]Suddenly it does not work anymore. Game starts with BLACK SCREEN, no matter what. It's 3D related because it works without the fix.[/quote]
Use the uninstall.bat and download the last version of the fix, [url]https://drive.google.com/open?id=0B7-C-G8Te2HbMjBvNllFZnFmeUU[/url]
The game is working for me.
You can try this too:
In your Steam library, right click on "The Long Dark" and select "Properties"
Click "Set Launch Options"
In the box, type "-window-mode exclusive" without the ""
And in the folder of the game edit the file d3dx.ini: find full_screen=1 and replace it for ;full_screen=0[/quote]
It works perfectely now, thanks a lot!
You can try this too:
In your Steam library, right click on "The Long Dark" and select "Properties"
Click "Set Launch Options"
In the box, type "-window-mode exclusive" without the ""
And in the folder of the game edit the file d3dx.ini: find full_screen=1 and replace it for ;full_screen=0
That worked perfect!!! can we use this to fix the other shader?
For example, that torch/lanterns shader is something I haven't seen before, so I have no idea for now.
Oh, and I think you should add these things to d3dx.ini just in case (they are in that file in the Yooka-Laylee fix, because you may need to know where you have to paste them. Green commented lines may look the wrong color here in the forums):
And:
I think they can help performance or be needed in some way.
CPU: Intel Core i7 7700K @ 4.9GHz
Motherboard: Gigabyte Aorus GA-Z270X-Gaming 5
RAM: GSKILL Ripjaws Z 16GB 3866MHz CL18
GPU: Gainward Phoenix 1080 GLH
Monitor: Asus PG278QR
Speakers: Logitech Z506
Donations account: masterotakusuko@gmail.com
If so, maybe this will work in the vertex shader:
But I can't know because I don't have the game. Also the pixel shader doesn't use v5 for anything...
CPU: Intel Core i7 7700K @ 4.9GHz
Motherboard: Gigabyte Aorus GA-Z270X-Gaming 5
RAM: GSKILL Ripjaws Z 16GB 3866MHz CL18
GPU: Gainward Phoenix 1080 GLH
Monitor: Asus PG278QR
Speakers: Logitech Z506
Donations account: masterotakusuko@gmail.com
https://drive.google.com/open?id=0B7-C-G8Te2HbMHdTUmppSUZyUE0
and the other :e3fd8a725676603e-ps_replace.txt
PS:
d3dx.ini:
CPU: Intel Core i7 7700K @ 4.9GHz
Motherboard: Gigabyte Aorus GA-Z270X-Gaming 5
RAM: GSKILL Ripjaws Z 16GB 3866MHz CL18
GPU: Gainward Phoenix 1080 GLH
Monitor: Asus PG278QR
Speakers: Logitech Z506
Donations account: masterotakusuko@gmail.com
This is the original VS: ca5cfc8e4d8b1ce5-vs_replace.txt
This is the VS shader fixed by DSS
the PS original: adb8c8f1b20ba202-ps_replace.txt
and the fixed one by DSS
May the force be with you....
VS: 4c9936f7f1d28f6e-vs_replace.txt
PS e3fd8a725676603e-ps_replace.txt
d3dx.ini
https://drive.google.com/open?id=0B7-C-G8Te2HbRm9CMHAyZENxd2s
Use the uninstall.bat and download the last version of the fix, https://drive.google.com/open?id=0B7-C-G8Te2HbMjBvNllFZnFmeUU
The game is working for me.
You can try this too:
In your Steam library, right click on "The Long Dark" and select "Properties"
Click "Set Launch Options"
In the box, type "-window-mode exclusive" without the ""
And in the folder of the game edit the file d3dx.ini: find full_screen=1 and replace it for ;full_screen=0
It works perfectely now, thanks a lot!