How to fix/disable shaders in games(DLL,guide and fixes).
146 / 167
That does look too short, and does not seem to be a shadow shader. That's one of the problems with the "disabling shaders" method, in that little shaders like this that do some minor color processing make it look like they are doing something else. If this really is the only pixel shader that disabled shadows by stepping through you might want to, instead, go into the Dumps/AllShaders/PixelShaders directory and look in the headers for files with 'shadow' or 'light' or something in. If you zip up the dumps folder I'll have a look for you. Be aware though that shadows and lighting are the trickiest things because they are not really "things" like objects, but 'derived effects', which is why for the most part they can't be fixed completely in VS.
That does look too short, and does not seem to be a shadow shader. That's one of the problems with the "disabling shaders" method, in that little shaders like this that do some minor color processing make it look like they are doing something else. If this really is the only pixel shader that disabled shadows by stepping through you might want to, instead, go into the Dumps/AllShaders/PixelShaders directory and look in the headers for files with 'shadow' or 'light' or something in. If you zip up the dumps folder I'll have a look for you. Be aware though that shadows and lighting are the trickiest things because they are not really "things" like objects, but 'derived effects', which is why for the most part they can't be fixed completely in VS.
I am trying to use Helix DLL with Softth [url]http://www.kegetys.fi/SoftTH/[/url] (a dx9 dll which allow the use of a virtual screen over multiple physical screens) in DCS world (64b). But It did not works.
I call softth dll by using the “ProxyLib” variable in DX9Settings.ini
In this config, with the debug Helix dll I have the red text showing in game windows and I can dump shader.
But I cannot make modified shaders to be used ! Of course the modified vertex shaders are working without softth…
Is there a magic option to allow the use of the shaders with softth ?
My DX9Settings.ini (I must use overridemethod = 1 with DCS, otherwise the modified shaders are disabled)
[General]
ProxyLib = D:\jeux\DCS World\bin\d3d9_softth.dll
overridemethod = 1
PresetsKeysList = 0;1;2;20
Convergence = 0x3f000000
Separation = 0x41700000
[KEY0]
//mouse 4 = > low depth when hold
Key = 503
Presets = 0;
Type = 2
[PRES0]
UseSepSettings = true
SaveSepSettings = true
Convergence = 0x3f000000
Separation = 0x3c23d70a
[KEY1]
//F1 = > standard depth when pressed
Key = 112
Presets = 1;
Type = 1
…
(only mapping of keys/presets)
I am trying to use Helix DLL with Softth http://www.kegetys.fi/SoftTH/ (a dx9 dll which allow the use of a virtual screen over multiple physical screens) in DCS world (64b). But It did not works.
I call softth dll by using the “ProxyLib” variable in DX9Settings.ini
In this config, with the debug Helix dll I have the red text showing in game windows and I can dump shader.
But I cannot make modified shaders to be used ! Of course the modified vertex shaders are working without softth…
Is there a magic option to allow the use of the shaders with softth ?
My DX9Settings.ini (I must use overridemethod = 1 with DCS, otherwise the modified shaders are disabled)
Aaah found it.
NVIDIA can you please sticky this post so all your customers can have access to proper fixes for 3d vision since your developers are too inexperienced.
NVIDIA can you please sticky this post so all your customers can have access to proper fixes for 3d vision since your developers are too inexperienced.
[quote="lefuneste"]I am trying to use Helix DLL with Softth [url]http://www.kegetys.fi/SoftTH/[/url] (a dx9 dll which allow the use of a virtual screen over multiple physical screens) in DCS world (64b). But It did not works.
I call softth dll by using the “ProxyLib” variable in DX9Settings.ini
In this config, with the debug Helix dll I have the red text showing in game windows and I can dump shader.
But I cannot make modified shaders to be used ! Of course the modified vertex shaders are working without softth…
Is there a magic option to allow the use of the shaders with softth ?[/quote]Not sure why this wouldn't work for you. Seems like the SoftTH might be changing the directory that Helix uses/sees for shaderoverrides. Try dropping copies of ShaderOverride into other logical spots near the binary to see if they might get picked up.
Also, since you have the debug version, what does the Log.txt say?
lefuneste said:I am trying to use Helix DLL with Softth http://www.kegetys.fi/SoftTH/ (a dx9 dll which allow the use of a virtual screen over multiple physical screens) in DCS world (64b). But It did not works.
I call softth dll by using the “ProxyLib” variable in DX9Settings.ini
In this config, with the debug Helix dll I have the red text showing in game windows and I can dump shader.
But I cannot make modified shaders to be used ! Of course the modified vertex shaders are working without softth…
Is there a magic option to allow the use of the shaders with softth ?
Not sure why this wouldn't work for you. Seems like the SoftTH might be changing the directory that Helix uses/sees for shaderoverrides. Try dropping copies of ShaderOverride into other logical spots near the binary to see if they might get picked up.
Also, since you have the debug version, what does the Log.txt say?
Acer H5360 (1280x720@120Hz) - ASUS VG248QE with GSync mod - 3D Vision 1&2 - Driver 372.54
GTX 970 - i5-4670K@4.2GHz - 12GB RAM - Win7x64+evilKB2670838 - 4 Disk X25 RAID
SAGER NP9870-S - GTX 980 - i7-6700K - Win10 Pro 1607 Latest 3Dmigoto Release Bo3b's School for ShaderHackers
I though like you, so I put the “ShaderOverride” directory in each level of the path “D:\jeux\DCS World\bin”. It did not change a thing.
And the dumps of the shaders are in D:\jeux\DCS World\Dumps.
I do not know how to add the logs (with or without soffth) in the post. The modified shader is 54829A74.
I did not see major differences between the two log files:
the line lpStereoTex Init as a different value (0xCEAFDC0 or 0xCF477B0)
there are a lot of lines as below in both files:
luaL_loadfile cannot open PSscript.lua: No such file or directory
LuaL_loadfile cannot open VSscript.lua: No such file or directory
And I have the lines in both files also:
CreateVertexShader CRC: [b]0x54829A74 [/b]
pD3DXAssembleShaderFromFile
Shader overrode CRC: [b]0x54829A74 [/b]
seems that my shader should be modified...
I though like you, so I put the “ShaderOverride” directory in each level of the path “D:\jeux\DCS World\bin”. It did not change a thing.
And the dumps of the shaders are in D:\jeux\DCS World\Dumps.
I do not know how to add the logs (with or without soffth) in the post. The modified shader is 54829A74.
I did not see major differences between the two log files:
the line lpStereoTex Init as a different value (0xCEAFDC0 or 0xCF477B0)
there are a lot of lines as below in both files:
luaL_loadfile cannot open PSscript.lua: No such file or directory
LuaL_loadfile cannot open VSscript.lua: No such file or directory
And I have the lines in both files also:
CreateVertexShader CRC: 0x54829A74
pD3DXAssembleShaderFromFile
Shader overrode CRC: 0x54829A74
That all looks right to me.
The shader does seem to be override properly, and the Log says it was recompiled. BTW, the Lua error messages are OK, there is an auto-fix Lua script that runs if it's available. Since script it missing it reports that, but causes no problems.
Try changing the overridemethod to different values. I know that 0, 1, 2 are valid, maybe try 3, 4 too.
Anybody know what this feature does? When to use different values?
The shader does seem to be override properly, and the Log says it was recompiled. BTW, the Lua error messages are OK, there is an auto-fix Lua script that runs if it's available. Since script it missing it reports that, but causes no problems.
Try changing the overridemethod to different values. I know that 0, 1, 2 are valid, maybe try 3, 4 too.
Anybody know what this feature does? When to use different values?
Acer H5360 (1280x720@120Hz) - ASUS VG248QE with GSync mod - 3D Vision 1&2 - Driver 372.54
GTX 970 - i5-4670K@4.2GHz - 12GB RAM - Win7x64+evilKB2670838 - 4 Disk X25 RAID
SAGER NP9870-S - GTX 980 - i7-6700K - Win10 Pro 1607 Latest 3Dmigoto Release Bo3b's School for ShaderHackers
@lefuneste,
Did you do anything special to be able to dump shaders in Rise of Flight or Battle of Stalingrad? For some reason neither the dump shader key NP6, nor DumpAll = true in DX9Settings.Ini is working for me. The Dumps directory structure gets generated but never has anything in it? Did you have any of these issues? I wanted to fix Sun glare shader. I found the shader in question but can't for the life of me get the shader code dumped to edit.
I'm using your fix for BoS and a derivative of your Rise of Flight fix too (although my shader CRCs were different in ROF for some reason).
Did you do anything special to be able to dump shaders in Rise of Flight or Battle of Stalingrad? For some reason neither the dump shader key NP6, nor DumpAll = true in DX9Settings.Ini is working for me. The Dumps directory structure gets generated but never has anything in it? Did you have any of these issues? I wanted to fix Sun glare shader. I found the shader in question but can't for the life of me get the shader code dumped to edit.
I'm using your fix for BoS and a derivative of your Rise of Flight fix too (although my shader CRCs were different in ROF for some reason).
Hi, i am trying to fix shoguntotalwar 2, i have read all post and examples but i have a lot problems with the pixelsshaders, i have fix the vertexs, fire, smoke, blood, clouds, and river, road... of the campaign map and the game without shadows it is very nice now, but i would like to fix them about all for the rome totalwar 2, where the main shadow over the terrain do it unplayable
I have read all examples about all of mike because he comment it, and the lua.script from helix but i need help.
i would like a example about how to fix a shadow in shogun or some tips. The main problem it is that shadow are paint at screen depth, but the shadows are in stereo, when they are proyected over sea, river, or walls they are perfect but not over the terrain.
i would like some tip about when to apply vpos
dcl vPos.xy
mov r11.xy, vPos.xy
rcp r11.z, c210.x //viewport const W
rcp r11.w, c210.y //viewport const H
mul r11.xy, r11.xy, r11.zw //scale pos by width and height respectivey i.e. [0,1]
mul r11.zw, r11.zw, c220.ww //multiply by 0.5
add r10.xy, r11.xy, r11.zw
or i.e.
texldl r11, c200.z, s14
add r11.y, v1.w, -r11.y
mul r11.x, r11.x, r11.y
add r0.y, r0.y, -r11.x
or when apply inverse and double inverse ...
i have search words in pixelshaders with inv_view_projection matrix, gbuffers, shadow, lights, depth buffers and the doc of nvidia about deferred render
thanks for your work, bob, eqzitara, mike .... and of course helix
Hi, i am trying to fix shoguntotalwar 2, i have read all post and examples but i have a lot problems with the pixelsshaders, i have fix the vertexs, fire, smoke, blood, clouds, and river, road... of the campaign map and the game without shadows it is very nice now, but i would like to fix them about all for the rome totalwar 2, where the main shadow over the terrain do it unplayable
I have read all examples about all of mike because he comment it, and the lua.script from helix but i need help.
i would like a example about how to fix a shadow in shogun or some tips. The main problem it is that shadow are paint at screen depth, but the shadows are in stereo, when they are proyected over sea, river, or walls they are perfect but not over the terrain.
i would like some tip about when to apply vpos
dcl vPos.xy
mov r11.xy, vPos.xy
rcp r11.z, c210.x //viewport const W
rcp r11.w, c210.y //viewport const H
mul r11.xy, r11.xy, r11.zw //scale pos by width and height respectivey i.e. [0,1]
mul r11.zw, r11.zw, c220.ww //multiply by 0.5
add r10.xy, r11.xy, r11.zw
or i.e.
texldl r11, c200.z, s14
add r11.y, v1.w, -r11.y
mul r11.x, r11.x, r11.y
add r0.y, r0.y, -r11.x
or when apply inverse and double inverse ...
i have search words in pixelshaders with inv_view_projection matrix, gbuffers, shadow, lights, depth buffers and the doc of nvidia about deferred render
thanks for your work, bob, eqzitara, mike .... and of course helix
[quote="kankgeforce99"]Hi, i am trying to fix shoguntotalwar 2, i have read all post and examples but i have a lot problems with the pixelsshaders, i have fix the vertexs, fire, smoke, blood, clouds, and river, road... of the campaign map and the game without shadows it is very nice now, but i would like to fix them about all for the rome totalwar 2, where the main shadow over the terrain do it unplayable
I have read all examples about all of mike because he comment it, and the lua.script from helix but i need help.
i would like a example about how to fix a shadow in shogun or some tips. The main problem it is that shadow are paint at screen depth, but the shadows are in stereo, when they are proyected over sea, river, or walls they are perfect but not over the terrain.
i would like some tip about when to apply vpos
dcl vPos.xy
mov r11.xy, vPos.xy
rcp r11.z, c210.x //viewport const W
rcp r11.w, c210.y //viewport const H
mul r11.xy, r11.xy, r11.zw //scale pos by width and height respectivey i.e. [0,1]
mul r11.zw, r11.zw, c220.ww //multiply by 0.5
add r10.xy, r11.xy, r11.zw
or i.e.
texldl r11, c200.z, s14
add r11.y, v1.w, -r11.y
mul r11.x, r11.x, r11.y
add r0.y, r0.y, -r11.x
or when apply inverse and double inverse ...
i have search words in pixelshaders with inv_view_projection matrix, gbuffers, shadow, lights, depth buffers and the doc of nvidia about deferred render
thanks for your work, bob, eqzitara, mike .... and of course helix
[/quote]
Hi - it's great to see you getting involved in this :-) I don't think I've ever looked at this one, since I am now downloading the demo... Shadows (and lights) are tricky because each game does something a bit different, but there are two basic approaches (a) identify that the PS has created a World coord (somehow) and correct that through the matrix inversion process (b) identify some kind of transform from 'screen' space to 'light' or 'shadow' space and then you can directly correct the coordinate being transformed. The trick in each case is finding the coordinate to correct, making sure it is normalized properly, and applying the correct shift - so for example sometimes you need to multiply the shift by a half, or (as I found out for the lego games and for AVP, you need to scale by the FOV parameter in the Proj matrix).
With the approach (a) above, where the matrix inverse thing is done, there are two basic approaches that seem to be used to create the world coord (i) apply an inverse VPM or inverse View to some coordinate which puts it back in World Space (so it must be a world coordinate) (ii) 'build' a world coord by taking a normalized vector pointing from the view/eye/camera position, multiplied by the depth (usually obtained from a depth map) and adding it to the view/eye/camera position. So if you see a PS with a "CamPos" or "EyePos" in it, check to see if there is a line like: mad r1, v1, r0.x, c10 where r0.x comes from a depth map and c10 is the eyepos. This usually gives the xyz components so you need to set the w-component to "1" for a valid 4-coordinate.
With the approach (b) you need to check the PS header for something that is a matrix with 4 components (sometimes 3, I can't remember if that is valid) which will do the transformation, find it in the code, and pick out the x and z (usually) components that are being transformed. These might not be nice and regular like r0.x, r0.y, r0.z, r0.w, but could be a whole mixture of variables including texcoords - pick them out by looking at what the x-transform vector is and what the z-transform vector is and use the variable they operate on. If z does not work, try w.
To be clear: It can all be a bit trial and error to be honest.
One other important thing, the PS shadow fixes work only (I believe) on shadows that are 2D screen depth, so if shadows are 'wrong' but not 2D, you need to fix the VS to make them 2D, which sounds crazy but that's what you need to do. Shadows can very occasionally be fixed in VS - for older games with no deferred rendering usually - but it's not common.
There are some games I've not been able to work out - CryEngine is my biggest frustration right now, and I could not work out CoJ Gunslinger, or PayDay, so there are clearly other algorithms and subtleties as well that right now I can't help with - and Shogun 2 might be one of them...
Anyway, this is a bit of a ramble, PM me and I can maybe provide some examples from fixes I have done.
****EDIT Demo downloaded, turns out I have looked at it before for a couple of hours, but stopped. Now I think I know why - the game crashes 90% of the time when I start it and try overriding shaders. It's a mighty pain in the ass. I've tried a few DLLs they are all the same, not sure what to do about it...
kankgeforce99 said:Hi, i am trying to fix shoguntotalwar 2, i have read all post and examples but i have a lot problems with the pixelsshaders, i have fix the vertexs, fire, smoke, blood, clouds, and river, road... of the campaign map and the game without shadows it is very nice now, but i would like to fix them about all for the rome totalwar 2, where the main shadow over the terrain do it unplayable
I have read all examples about all of mike because he comment it, and the lua.script from helix but i need help.
i would like a example about how to fix a shadow in shogun or some tips. The main problem it is that shadow are paint at screen depth, but the shadows are in stereo, when they are proyected over sea, river, or walls they are perfect but not over the terrain.
i would like some tip about when to apply vpos
dcl vPos.xy
mov r11.xy, vPos.xy
rcp r11.z, c210.x //viewport const W
rcp r11.w, c210.y //viewport const H
mul r11.xy, r11.xy, r11.zw //scale pos by width and height respectivey i.e. [0,1]
mul r11.zw, r11.zw, c220.ww //multiply by 0.5
add r10.xy, r11.xy, r11.zw
or i.e.
texldl r11, c200.z, s14
add r11.y, v1.w, -r11.y
mul r11.x, r11.x, r11.y
add r0.y, r0.y, -r11.x
or when apply inverse and double inverse ...
i have search words in pixelshaders with inv_view_projection matrix, gbuffers, shadow, lights, depth buffers and the doc of nvidia about deferred render
thanks for your work, bob, eqzitara, mike .... and of course helix
Hi - it's great to see you getting involved in this :-) I don't think I've ever looked at this one, since I am now downloading the demo... Shadows (and lights) are tricky because each game does something a bit different, but there are two basic approaches (a) identify that the PS has created a World coord (somehow) and correct that through the matrix inversion process (b) identify some kind of transform from 'screen' space to 'light' or 'shadow' space and then you can directly correct the coordinate being transformed. The trick in each case is finding the coordinate to correct, making sure it is normalized properly, and applying the correct shift - so for example sometimes you need to multiply the shift by a half, or (as I found out for the lego games and for AVP, you need to scale by the FOV parameter in the Proj matrix).
With the approach (a) above, where the matrix inverse thing is done, there are two basic approaches that seem to be used to create the world coord (i) apply an inverse VPM or inverse View to some coordinate which puts it back in World Space (so it must be a world coordinate) (ii) 'build' a world coord by taking a normalized vector pointing from the view/eye/camera position, multiplied by the depth (usually obtained from a depth map) and adding it to the view/eye/camera position. So if you see a PS with a "CamPos" or "EyePos" in it, check to see if there is a line like: mad r1, v1, r0.x, c10 where r0.x comes from a depth map and c10 is the eyepos. This usually gives the xyz components so you need to set the w-component to "1" for a valid 4-coordinate.
With the approach (b) you need to check the PS header for something that is a matrix with 4 components (sometimes 3, I can't remember if that is valid) which will do the transformation, find it in the code, and pick out the x and z (usually) components that are being transformed. These might not be nice and regular like r0.x, r0.y, r0.z, r0.w, but could be a whole mixture of variables including texcoords - pick them out by looking at what the x-transform vector is and what the z-transform vector is and use the variable they operate on. If z does not work, try w.
To be clear: It can all be a bit trial and error to be honest.
One other important thing, the PS shadow fixes work only (I believe) on shadows that are 2D screen depth, so if shadows are 'wrong' but not 2D, you need to fix the VS to make them 2D, which sounds crazy but that's what you need to do. Shadows can very occasionally be fixed in VS - for older games with no deferred rendering usually - but it's not common.
There are some games I've not been able to work out - CryEngine is my biggest frustration right now, and I could not work out CoJ Gunslinger, or PayDay, so there are clearly other algorithms and subtleties as well that right now I can't help with - and Shogun 2 might be one of them...
Anyway, this is a bit of a ramble, PM me and I can maybe provide some examples from fixes I have done.
****EDIT Demo downloaded, turns out I have looked at it before for a couple of hours, but stopped. Now I think I know why - the game crashes 90% of the time when I start it and try overriding shaders. It's a mighty pain in the ass. I've tried a few DLLs they are all the same, not sure what to do about it...
[quote="BazzaLB"]@lefuneste,
Did you do anything special to be able to dump shaders in Rise of Flight or Battle of Stalingrad? [/quote]
I copy the dump structure to directory [b]Rise of Flight\bin_game\release\[/b] The dumped shaders should be there after (same problem for RoF and BoS)
a lot thanks mike , sg2 i have the steam version and no crash, but not tried the demo, i am using the dll version 686kb debug. in rome2 it is worse, only work the old versions of the dll 224kb, but in battle i can not see the red letters, only work the dump and save individual shader.
i have identified the shaders that when disable them, remove each shadow (vs and ps), but i dont how to find what ps correspond to a vs to pass a texcoord with the world coord.
"One other important thing, the PS shadow fixes work only (I believe) on shadows that are 2D screen depth, so if shadows are 'wrong' but not 2D, you need to fix the VS to make them 2D, which sounds crazy but that's what you need to do. Shadows can very occasionally be fixed in VS - for older games with no deferred rendering usually - but it's not common."
i see the shadows in napoleon or medieval and all are in stereo, in sg2 when using use high levels of convergence and depth i can see that are in stereo too, as ie in napoleon , but are not proyected well in the terrain, only in the sea and rivers, perhaps because have not ¿depth?, and the shadows in screen it is the effect that we see.
i will continue trying, now i know a little more about what to search, i was blind totally..
a lot thanks mike , sg2 i have the steam version and no crash, but not tried the demo, i am using the dll version 686kb debug. in rome2 it is worse, only work the old versions of the dll 224kb, but in battle i can not see the red letters, only work the dump and save individual shader.
i have identified the shaders that when disable them, remove each shadow (vs and ps), but i dont how to find what ps correspond to a vs to pass a texcoord with the world coord.
"One other important thing, the PS shadow fixes work only (I believe) on shadows that are 2D screen depth, so if shadows are 'wrong' but not 2D, you need to fix the VS to make them 2D, which sounds crazy but that's what you need to do. Shadows can very occasionally be fixed in VS - for older games with no deferred rendering usually - but it's not common."
i see the shadows in napoleon or medieval and all are in stereo, in sg2 when using use high levels of convergence and depth i can see that are in stereo too, as ie in napoleon , but are not proyected well in the terrain, only in the sea and rivers, perhaps because have not ¿depth?, and the shadows in screen it is the effect that we see.
i will continue trying, now i know a little more about what to search, i was blind totally..
@mike_ar69: Big thanks for your ramble there on how to approach shadows. This is something that has been escaping my grasp, and you have inspired me to take another look.
@mike_ar69: Big thanks for your ramble there on how to approach shadows. This is something that has been escaping my grasp, and you have inspired me to take another look.
Acer H5360 (1280x720@120Hz) - ASUS VG248QE with GSync mod - 3D Vision 1&2 - Driver 372.54
GTX 970 - i5-4670K@4.2GHz - 12GB RAM - Win7x64+evilKB2670838 - 4 Disk X25 RAID
SAGER NP9870-S - GTX 980 - i7-6700K - Win10 Pro 1607 Latest 3Dmigoto Release Bo3b's School for ShaderHackers
Hi all - so I managed to find a dll that did not crash the demo, but it was a major pain in the ass to work with since the game/dll did not pick up the nvapi properly so no fixes could be applied. I found a way to make it kick in and managed to work out shadows for the demo level. I expect the "approach" to work for the rest of the games, but I am not going to do it - I pass it on here for anyone else to pick up and complete the game:
[url]https://s3.amazonaws.com/Mike_Ar69/Shogun2_DemoShadows.zip[/url]
In this zip file are pixel shaders to fix shadows in the demo level, a vertex shader to fix clouds because they pissed me off, and a vertex shader to disable one particular shadow that is off the charts "wrong" in 3D - it's only a small ommission and you won't even notice it, but I welcome anyone to try and work out what the heck is going on with it. At one point I had it almost fixed, but then "lost" it somehow. Also in this zip are some screenshots so you can see the results. I did not fix anything else (other than the clouds).
Some advice on what I did:
1. As per my advice above, I looked in the PS dumps folder and found a number of shaders with things in like inv_view_proj and so on. There were also a lot with g_AmSplit of size 16 - suspicious shadow matrix variable that one.
2. I itertaed manually though the scene to find a pixel shader that seems to affect shadows, found one, looked at it
3. It was one with g_AmSplit and inv_view_proj in it - so that tells me these are the types of shaders that affect shadows.
4. The g_AmSplit matrix is the one mapping from world to 'shadow' view (that does not quite make sense but you get the point), and I identified that "r1" was the register being transformed.
5. Looking at the provenance of register r1 in the shader it was clear this was a WORLD coordinate
6. So the "forward proj" "shift" "inverse proj" method is applicable
7. As god fortune would have it, this game, and all shaders for shadows, have BOTH the VPM and IN_VPM in them which is a freaking winner...
8. So I used them to "correct" the r1 variable
An example file is below:
[code]
// Registers:
//
// Name Reg Size
// ----------------------- ----- ----
// g_amSplit c0 16 <--Used to sample shadow map at different points for different quality levels
// view_projection c16 4 <-- Very handy!
// inv_view_projection c20 4 <-- Likewise!
// ambient_cube_lr c24 2
// ambient_cube_tb c26 2
// ambient_cube_fb c28 2
// g_iSplitCount c30 1
// g_vSplitDepth c31 1
// g_fFadeRange c32 1
// camera_position c33 1
// screen_size c34 1
// g_texel_offset c35 1
// g_volume_fog_colour c36 1
// g_fog_distance_start c37 1
// g_fog_distance_strength c38 1
// g_fog_clear_distance c39 1
// light_direction c40 1
// light_colour c41 1
// sShadowBuffer s0 1
// gbuffer_normal_sampler s1 1
// gbuffer_colour_sampler s2 1
// depth_sampler s3 1
//
ps_3_0
def c42, 2, -1, -2, 1
def c43, -2, 3, 2000, 1000
def c44, 1, 0, -0, 0
def c45, -0, -1, -2, -3
def c220, 0, 0, 0.0625, 0
dcl_2d s13
dcl vPos.xy
dcl_2d s0
dcl_2d s1
dcl_2d s2
dcl_2d s3
add r0.xy, c35.x, vPos
rcp r1.x, c34.x
rcp r1.y, c34.y
mul r0.xy, r0, r1
texld r1, r0, s3
mad r1.zw, r1.x, c44.xyxy, c44.xyzx
mad r1.xy, r0, c42.xzzw, c42.ywzw
dp4 r0.z, r1, c23
rcp r0.z, r0.z
dp4 r2.x, r1, c20
dp4 r2.y, r1, c21
dp4 r2.z, r1, c22
mul r1.xyz, r0.z, r2
mad r2.xyz, r2, r0.z, -c33
dp3 r0.z, r2, r2
rsq r0.z, r0.z
rcp r0.z, r0.z
mov r1.w, c42.w <-- This line is important. This sets the w comp of r1 to "1" making it a 'point' in the affine scheme, and also helping to confirm that it is in fact a world coord
mov r10, r1 <-- I always create a copy and mess with that
dp4 r11.x, r10, c16 <--Am using the VPM here (because r1 is a world coord)
dp4 r11.y, r10, c17
dp4 r11.z, r10, c18
dp4 r11.w, r10, c19
texldl r24, c220.z, s13
add r24.y, r11.w, -r24.y
mul r24.x, r24.x, r24.y
add r11.x, r11.x, -r24.x
dp4 r10.x, r11, c20 <-- Use the inverse VPM here
dp4 r10.y, r11, c21
dp4 r10.z, r11, c22
dp4 r10.w, r11, c23
mov r1, r10
dp4 r0.w, r1, c19 <-- Note that I made sure I corrected r1 *before* this line
add r2, r0.w, -c31
cmp r2, r2, c44.x, c44.y
dp4 r2.x, r2, r2
mov r2.yw, c42
add r2.y, r2.y, c30.x
min r3.x, r2.y, r2.x
frc r2.x, r3.x
cmp r2.z, -r2.x, c44.y, c44.x
add r2.x, r3.x, -r2.x
cmp r2.z, r3.x, c44.y, r2.z
add r2.x, r2.z, r2.x
add r3, r2.x, c45
add r2.x, r2.x, -c30.x
mov r4.y, c44.y
cmp r5, -r3_abs.x, c0, r4.y
cmp r5, -r3_abs.y, c4, r5
cmp r5, -r3_abs.z, c8, r5
cmp r5, -r3_abs.w, c12, r5
dp4 r5.x, r1, r5 <-- This series of lines are the ones that 'transform' r1 to the shadow view
cmp r6, -r3_abs.x, c1, r4.y
cmp r6, -r3_abs.y, c5, r6
cmp r6, -r3_abs.z, c9, r6
cmp r6, -r3_abs.w, c13, r6
dp4 r5.y, r1, r6 <-- And Here
cmp r6, -r3_abs.x, c2, r4.y
cmp r6, -r3_abs.y, c6, r6
cmp r6, -r3_abs.z, c10, r6
cmp r6, -r3_abs.w, c14, r6
dp4 r5.z, r1, r6 <-- And Here
cmp r4, -r3_abs.x, c3, r4.y
cmp r4, -r3_abs.y, c7, r4
cmp r4, -r3_abs.z, c11, r4
cmp r3, -r3_abs.w, c15, r4
dp4 r5.w, r1, r3 <-- And Here
texldp r1, r5, s0 <-- Now see that r5 is used to sample the shadowmap buffer :-)
frc r1.y, c30.x
add r1.y, r2.y, -r1.y
add r3, r1.y, c45
cmp r3, -r3_abs, c44.x, c44.y
dp4 r1.y, c31, r3
add r1.z, r1.y, -c32.x
add r1.y, -r1.z, r1.y
add r0.w, r0.w, -r1.z
rcp r1.y, r1.y
mul_sat r0.w, r0.w, r1.y
mad r1.y, r0.w, c43.x, c43.y
mul r0.w, r0.w, r0.w
mad_sat r0.w, r1.y, r0.w, r1.x
cmp r0.w, r2.x, c42.w, r0.w
nrm r1.xyz, c40
texld r3, r0, s1
texld r4, r0, s2
mad r2.xyz, r3, c42.x, c42.y
nrm r3.xyz, r2
dp3 r0.x, r3, -r1
max r1.x, r0.x, c44.y
cmp r0.x, -r1.x, c44.y, r0.w
mul r1.xyz, r4, r1.x
mul r1.xyz, r1, c41
mul r0.xyw, r0.x, r1.xyzz
mov r1.xyz, c26
cmp r1.xyz, r3.y, r1, c27
mul r2.xyz, r3, r3
mul r1.xyz, r1, r2.y
mov r5.xyz, c24
cmp r3.xyw, r3.x, r5.xyzz, c25.xyzz
mov r5.xyz, c28
cmp r5.xyz, r3.z, r5, c29
mad r1.xyz, r2.x, r3.xyww, r1
mad r1.xyz, r2.z, r5, r1
mad r0.xyw, r1.xyzz, r4.xyzz, r0
mad r1.x, r4.w, c42.x, c42.y
lrp r2.xyz, r1_abs.x, r0.xyww, r4
add r0.xyw, -r2.xyzz, c36.xyzz
add r1.x, r2.w, -c38.x
mad r1.xy, r1.x, c43.z, c43.zwzw
mul r1.z, r1.x, c37.x
max r2.w, r1.z, c39.x
min r3.x, r1.y, r2.w
add r1.x, r1.x, -r3.x
add r0.z, r0.z, -r3.x
rcp r1.x, r1.x
mul_sat r0.z, r0.z, r1.x
mad oC0.xyz, r0.z, r0.xyww, r2
mov oC0.w, c42.w
[/code]
I corrected 25 shaders that all "look like" the above but there are another 225 or so with g_AmSplit in them, and these might need fixing for other levels, or for other shadow/lighting effects (maybe at night time, or who knows). So I leave that lot up to anyone who wants to work on it. I will note that not all of the shaders that have g_AmSPlit in them have the inv_view_proj or ViewProj matrices in them, so if they do need fixing you'll need to use the "VPM reuse" feature of the DLL (it is specified in the DX9Settings.ini file).
Good Luck :-)
PS - I had to use a DLL dated 2012, none of the 2013 dlls worked (all crashed on game load).
Hi all - so I managed to find a dll that did not crash the demo, but it was a major pain in the ass to work with since the game/dll did not pick up the nvapi properly so no fixes could be applied. I found a way to make it kick in and managed to work out shadows for the demo level. I expect the "approach" to work for the rest of the games, but I am not going to do it - I pass it on here for anyone else to pick up and complete the game: https://s3.amazonaws.com/Mike_Ar69/Shogun2_DemoShadows.zip
In this zip file are pixel shaders to fix shadows in the demo level, a vertex shader to fix clouds because they pissed me off, and a vertex shader to disable one particular shadow that is off the charts "wrong" in 3D - it's only a small ommission and you won't even notice it, but I welcome anyone to try and work out what the heck is going on with it. At one point I had it almost fixed, but then "lost" it somehow. Also in this zip are some screenshots so you can see the results. I did not fix anything else (other than the clouds).
Some advice on what I did:
1. As per my advice above, I looked in the PS dumps folder and found a number of shaders with things in like inv_view_proj and so on. There were also a lot with g_AmSplit of size 16 - suspicious shadow matrix variable that one.
2. I itertaed manually though the scene to find a pixel shader that seems to affect shadows, found one, looked at it
3. It was one with g_AmSplit and inv_view_proj in it - so that tells me these are the types of shaders that affect shadows.
4. The g_AmSplit matrix is the one mapping from world to 'shadow' view (that does not quite make sense but you get the point), and I identified that "r1" was the register being transformed.
5. Looking at the provenance of register r1 in the shader it was clear this was a WORLD coordinate
6. So the "forward proj" "shift" "inverse proj" method is applicable
7. As god fortune would have it, this game, and all shaders for shadows, have BOTH the VPM and IN_VPM in them which is a freaking winner...
8. So I used them to "correct" the r1 variable
I corrected 25 shaders that all "look like" the above but there are another 225 or so with g_AmSplit in them, and these might need fixing for other levels, or for other shadow/lighting effects (maybe at night time, or who knows). So I leave that lot up to anyone who wants to work on it. I will note that not all of the shaders that have g_AmSPlit in them have the inv_view_proj or ViewProj matrices in them, so if they do need fixing you'll need to use the "VPM reuse" feature of the DLL (it is specified in the DX9Settings.ini file).
Good Luck :-)
PS - I had to use a DLL dated 2012, none of the 2013 dlls worked (all crashed on game load).
Rig: Intel i7-8700K @4.7GHz, 16Gb Ram, SSD, GTX 1080Ti, Win10x64, Asus VG278
Co-founder/Web host of helixmod.blog.com
Donations for web hosting @ paypal -eqzitara@yahoo.com
or
https://www.patreon.com/user?u=791918
I call softth dll by using the “ProxyLib” variable in DX9Settings.ini
In this config, with the debug Helix dll I have the red text showing in game windows and I can dump shader.
But I cannot make modified shaders to be used ! Of course the modified vertex shaders are working without softth…
Is there a magic option to allow the use of the shaders with softth ?
My DX9Settings.ini (I must use overridemethod = 1 with DCS, otherwise the modified shaders are disabled)
[General]
ProxyLib = D:\jeux\DCS World\bin\d3d9_softth.dll
overridemethod = 1
PresetsKeysList = 0;1;2;20
Convergence = 0x3f000000
Separation = 0x41700000
[KEY0]
//mouse 4 = > low depth when hold
Key = 503
Presets = 0;
Type = 2
[PRES0]
UseSepSettings = true
SaveSepSettings = true
Convergence = 0x3f000000
Separation = 0x3c23d70a
[KEY1]
//F1 = > standard depth when pressed
Key = 112
Presets = 1;
Type = 1
…
(only mapping of keys/presets)
NVIDIA can you please sticky this post so all your customers can have access to proper fixes for 3d vision since your developers are too inexperienced.
Also, since you have the debug version, what does the Log.txt say?
Acer H5360 (1280x720@120Hz) - ASUS VG248QE with GSync mod - 3D Vision 1&2 - Driver 372.54
GTX 970 - i5-4670K@4.2GHz - 12GB RAM - Win7x64+evilKB2670838 - 4 Disk X25 RAID
SAGER NP9870-S - GTX 980 - i7-6700K - Win10 Pro 1607
Latest 3Dmigoto Release
Bo3b's School for ShaderHackers
And the dumps of the shaders are in D:\jeux\DCS World\Dumps.
I do not know how to add the logs (with or without soffth) in the post. The modified shader is 54829A74.
I did not see major differences between the two log files:
the line lpStereoTex Init as a different value (0xCEAFDC0 or 0xCF477B0)
there are a lot of lines as below in both files:
luaL_loadfile cannot open PSscript.lua: No such file or directory
LuaL_loadfile cannot open VSscript.lua: No such file or directory
And I have the lines in both files also:
CreateVertexShader CRC: 0x54829A74
pD3DXAssembleShaderFromFile
Shader overrode CRC: 0x54829A74
seems that my shader should be modified...
The shader does seem to be override properly, and the Log says it was recompiled. BTW, the Lua error messages are OK, there is an auto-fix Lua script that runs if it's available. Since script it missing it reports that, but causes no problems.
Try changing the overridemethod to different values. I know that 0, 1, 2 are valid, maybe try 3, 4 too.
Anybody know what this feature does? When to use different values?
Acer H5360 (1280x720@120Hz) - ASUS VG248QE with GSync mod - 3D Vision 1&2 - Driver 372.54
GTX 970 - i5-4670K@4.2GHz - 12GB RAM - Win7x64+evilKB2670838 - 4 Disk X25 RAID
SAGER NP9870-S - GTX 980 - i7-6700K - Win10 Pro 1607
Latest 3Dmigoto Release
Bo3b's School for ShaderHackers
Co-founder/Web host of helixmod.blog.com
Donations for web hosting @ paypal -eqzitara@yahoo.com
or
https://www.patreon.com/user?u=791918
Did you do anything special to be able to dump shaders in Rise of Flight or Battle of Stalingrad? For some reason neither the dump shader key NP6, nor DumpAll = true in DX9Settings.Ini is working for me. The Dumps directory structure gets generated but never has anything in it? Did you have any of these issues? I wanted to fix Sun glare shader. I found the shader in question but can't for the life of me get the shader code dumped to edit.
I'm using your fix for BoS and a derivative of your Rise of Flight fix too (although my shader CRCs were different in ROF for some reason).
I have read all examples about all of mike because he comment it, and the lua.script from helix but i need help.
i would like a example about how to fix a shadow in shogun or some tips. The main problem it is that shadow are paint at screen depth, but the shadows are in stereo, when they are proyected over sea, river, or walls they are perfect but not over the terrain.
i would like some tip about when to apply vpos
dcl vPos.xy
mov r11.xy, vPos.xy
rcp r11.z, c210.x //viewport const W
rcp r11.w, c210.y //viewport const H
mul r11.xy, r11.xy, r11.zw //scale pos by width and height respectivey i.e. [0,1]
mul r11.zw, r11.zw, c220.ww //multiply by 0.5
add r10.xy, r11.xy, r11.zw
or i.e.
texldl r11, c200.z, s14
add r11.y, v1.w, -r11.y
mul r11.x, r11.x, r11.y
add r0.y, r0.y, -r11.x
or when apply inverse and double inverse ...
i have search words in pixelshaders with inv_view_projection matrix, gbuffers, shadow, lights, depth buffers and the doc of nvidia about deferred render
thanks for your work, bob, eqzitara, mike .... and of course helix
Windows 7 64bit, i7, GTX680, 16GB, Benq 120hz
Hi - it's great to see you getting involved in this :-) I don't think I've ever looked at this one, since I am now downloading the demo... Shadows (and lights) are tricky because each game does something a bit different, but there are two basic approaches (a) identify that the PS has created a World coord (somehow) and correct that through the matrix inversion process (b) identify some kind of transform from 'screen' space to 'light' or 'shadow' space and then you can directly correct the coordinate being transformed. The trick in each case is finding the coordinate to correct, making sure it is normalized properly, and applying the correct shift - so for example sometimes you need to multiply the shift by a half, or (as I found out for the lego games and for AVP, you need to scale by the FOV parameter in the Proj matrix).
With the approach (a) above, where the matrix inverse thing is done, there are two basic approaches that seem to be used to create the world coord (i) apply an inverse VPM or inverse View to some coordinate which puts it back in World Space (so it must be a world coordinate) (ii) 'build' a world coord by taking a normalized vector pointing from the view/eye/camera position, multiplied by the depth (usually obtained from a depth map) and adding it to the view/eye/camera position. So if you see a PS with a "CamPos" or "EyePos" in it, check to see if there is a line like: mad r1, v1, r0.x, c10 where r0.x comes from a depth map and c10 is the eyepos. This usually gives the xyz components so you need to set the w-component to "1" for a valid 4-coordinate.
With the approach (b) you need to check the PS header for something that is a matrix with 4 components (sometimes 3, I can't remember if that is valid) which will do the transformation, find it in the code, and pick out the x and z (usually) components that are being transformed. These might not be nice and regular like r0.x, r0.y, r0.z, r0.w, but could be a whole mixture of variables including texcoords - pick them out by looking at what the x-transform vector is and what the z-transform vector is and use the variable they operate on. If z does not work, try w.
To be clear: It can all be a bit trial and error to be honest.
One other important thing, the PS shadow fixes work only (I believe) on shadows that are 2D screen depth, so if shadows are 'wrong' but not 2D, you need to fix the VS to make them 2D, which sounds crazy but that's what you need to do. Shadows can very occasionally be fixed in VS - for older games with no deferred rendering usually - but it's not common.
There are some games I've not been able to work out - CryEngine is my biggest frustration right now, and I could not work out CoJ Gunslinger, or PayDay, so there are clearly other algorithms and subtleties as well that right now I can't help with - and Shogun 2 might be one of them...
Anyway, this is a bit of a ramble, PM me and I can maybe provide some examples from fixes I have done.
****EDIT Demo downloaded, turns out I have looked at it before for a couple of hours, but stopped. Now I think I know why - the game crashes 90% of the time when I start it and try overriding shaders. It's a mighty pain in the ass. I've tried a few DLLs they are all the same, not sure what to do about it...
Rig: Intel i7-8700K @4.7GHz, 16Gb Ram, SSD, GTX 1080Ti, Win10x64, Asus VG278
I copy the dump structure to directory Rise of Flight\bin_game\release\ The dumped shaders should be there after (same problem for RoF and BoS)
i have identified the shaders that when disable them, remove each shadow (vs and ps), but i dont how to find what ps correspond to a vs to pass a texcoord with the world coord.
"One other important thing, the PS shadow fixes work only (I believe) on shadows that are 2D screen depth, so if shadows are 'wrong' but not 2D, you need to fix the VS to make them 2D, which sounds crazy but that's what you need to do. Shadows can very occasionally be fixed in VS - for older games with no deferred rendering usually - but it's not common."
i see the shadows in napoleon or medieval and all are in stereo, in sg2 when using use high levels of convergence and depth i can see that are in stereo too, as ie in napoleon , but are not proyected well in the terrain, only in the sea and rivers, perhaps because have not ¿depth?, and the shadows in screen it is the effect that we see.
i will continue trying, now i know a little more about what to search, i was blind totally..
Windows 7 64bit, i7, GTX680, 16GB, Benq 120hz
Acer H5360 (1280x720@120Hz) - ASUS VG248QE with GSync mod - 3D Vision 1&2 - Driver 372.54
GTX 970 - i5-4670K@4.2GHz - 12GB RAM - Win7x64+evilKB2670838 - 4 Disk X25 RAID
SAGER NP9870-S - GTX 980 - i7-6700K - Win10 Pro 1607
Latest 3Dmigoto Release
Bo3b's School for ShaderHackers
https://s3.amazonaws.com/Mike_Ar69/Shogun2_DemoShadows.zip
In this zip file are pixel shaders to fix shadows in the demo level, a vertex shader to fix clouds because they pissed me off, and a vertex shader to disable one particular shadow that is off the charts "wrong" in 3D - it's only a small ommission and you won't even notice it, but I welcome anyone to try and work out what the heck is going on with it. At one point I had it almost fixed, but then "lost" it somehow. Also in this zip are some screenshots so you can see the results. I did not fix anything else (other than the clouds).
Some advice on what I did:
1. As per my advice above, I looked in the PS dumps folder and found a number of shaders with things in like inv_view_proj and so on. There were also a lot with g_AmSplit of size 16 - suspicious shadow matrix variable that one.
2. I itertaed manually though the scene to find a pixel shader that seems to affect shadows, found one, looked at it
3. It was one with g_AmSplit and inv_view_proj in it - so that tells me these are the types of shaders that affect shadows.
4. The g_AmSplit matrix is the one mapping from world to 'shadow' view (that does not quite make sense but you get the point), and I identified that "r1" was the register being transformed.
5. Looking at the provenance of register r1 in the shader it was clear this was a WORLD coordinate
6. So the "forward proj" "shift" "inverse proj" method is applicable
7. As god fortune would have it, this game, and all shaders for shadows, have BOTH the VPM and IN_VPM in them which is a freaking winner...
8. So I used them to "correct" the r1 variable
An example file is below:
I corrected 25 shaders that all "look like" the above but there are another 225 or so with g_AmSplit in them, and these might need fixing for other levels, or for other shadow/lighting effects (maybe at night time, or who knows). So I leave that lot up to anyone who wants to work on it. I will note that not all of the shaders that have g_AmSPlit in them have the inv_view_proj or ViewProj matrices in them, so if they do need fixing you'll need to use the "VPM reuse" feature of the DLL (it is specified in the DX9Settings.ini file).
Good Luck :-)
PS - I had to use a DLL dated 2012, none of the 2013 dlls worked (all crashed on game load).
Rig: Intel i7-8700K @4.7GHz, 16Gb Ram, SSD, GTX 1080Ti, Win10x64, Asus VG278