Random thought - if Dolphin is generating shaders, it must be compiling them at some point (1). 3DMigoto has code to catch shaders compiled from the game and is supposed to use them instead of decompiling shaders - the fact that it is still decompiling the shaders suggests that either:
- This functionality may has been broken at some point, which is very possible given that it is a very rarely used feature, and/or
- We may not be wrapping the correct D3DCompiler_xx.dll and missing the D3DCompile call, and/or
- Dolphin may be caching the shaders so they only get compiled once and the precompiled shader reused from then on, and we didn't catch the initial compile (2)
Fixing this would give us shaders closer to what Dolphin generates, which would help to match up the code you are seeing in the shaders to the code that generated it (3). This would also avoid decompiler issues like this alpha/early z test discard (4).
1: [url]https://github.com/dolphin-emu/dolphin/blob/master/Source/Core/VideoBackends/D3D/D3DShader.cpp#L149[/url]
2: [url]https://github.com/dolphin-emu/dolphin/blob/master/Source/Core/VideoBackends/D3D/PixelShaderCache.cpp[/url]
3: [url]https://github.com/dolphin-emu/dolphin/blob/master/Source/Core/VideoCommon/PixelShaderGen.cpp[/url]
4: [url]https://github.com/dolphin-emu/dolphin/blob/master/Source/Core/VideoCommon/PixelShaderGen.cpp#L1113[/url]
Random thought - if Dolphin is generating shaders, it must be compiling them at some point (1). 3DMigoto has code to catch shaders compiled from the game and is supposed to use them instead of decompiling shaders - the fact that it is still decompiling the shaders suggests that either:
- This functionality may has been broken at some point, which is very possible given that it is a very rarely used feature, and/or
- We may not be wrapping the correct D3DCompiler_xx.dll and missing the D3DCompile call, and/or
- Dolphin may be caching the shaders so they only get compiled once and the precompiled shader reused from then on, and we didn't catch the initial compile (2)
Fixing this would give us shaders closer to what Dolphin generates, which would help to match up the code you are seeing in the shaders to the code that generated it (3). This would also avoid decompiler issues like this alpha/early z test discard (4).
In current form 3Dmigoto will not see these original shaders. As a general idea, we never saw any game recompile their shaders on they fly, so I removed the d3d_compiler wrappers by default, as being added complexity for every install that wasn't useful.
The sub-projects are still live, just not shipped by default. I just updated d3d_compiler46 as a way to preload Batman, since they marked d3d11.dll as load-on-demand which is too late.
The way to use this now is as a one-off for a given fix, added in as needed (right-click subproject to build it). It's necessary to rename the original d3d_compiler like d3d_compiler46_org.dll, then add in the replacement. If it's not 46, the subproject will probably need some tweaking to bring it up to the new code base.
Alternatively, Dolphin may have a shader dump or logging feature to show what they generate.
In current form 3Dmigoto will not see these original shaders. As a general idea, we never saw any game recompile their shaders on they fly, so I removed the d3d_compiler wrappers by default, as being added complexity for every install that wasn't useful.
The sub-projects are still live, just not shipped by default. I just updated d3d_compiler46 as a way to preload Batman, since they marked d3d11.dll as load-on-demand which is too late.
The way to use this now is as a one-off for a given fix, added in as needed (right-click subproject to build it). It's necessary to rename the original d3d_compiler like d3d_compiler46_org.dll, then add in the replacement. If it's not 46, the subproject will probably need some tweaking to bring it up to the new code base.
Alternatively, Dolphin may have a shader dump or logging feature to show what they generate.
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
[quote=""]One thing worth noting that is a difference between the shaderhacker classes and 3Dmigoto- Since this is HLSL, you can modify the output variable directly.[/quote]
Interesting. I didn't know that. But well, I don't touch the ASM part (is it just for showing how it is in ASM, or would making changes there affect the shader?).
[quote=""]As DarkStarSword notes, try to put the code at the spot where you are trying to influence the result.[/quote]
Yep, that's what I usually do.
[quote=""]
BTW, the code you posted just above does not show this. The line commented out is:
[code] //if (r1.x != 0) discard;[/code]
And the surrounding code looks correct to me. Don't know why avoiding the discard would help, but it can be part of how Dolphin works.
[/quote]
You can see I put a line to change the aspect ratio of the effect. So I thought it was obvious that I commented that discard line, because it's needed to make the shader work. Sorry for not being clear about that. The unmodified shader just doesn't have the "r0.x=r0.x*4/3;", the comments and the discard line is uncommented.
About how Dolphin compiles its shaders, this is more or less how it does it (I don't know it in much detail): it does shader compilation while playing (which can produce stuttering except in the Ishiiruka builds, which have an async shader compilation option) and then it stores the compiled shaders in a cache folfer. The next time a game needs those shaders, it accesses the cache files. Using a different Dolphin build will wipe the cache and it will need to be generated again. By the way, the "per pixel lighting" option uses different shaders in games that make use of the option, like Zelda TP or Metroid Prime.
said:One thing worth noting that is a difference between the shaderhacker classes and 3Dmigoto- Since this is HLSL, you can modify the output variable directly.
Interesting. I didn't know that. But well, I don't touch the ASM part (is it just for showing how it is in ASM, or would making changes there affect the shader?).
said:As DarkStarSword notes, try to put the code at the spot where you are trying to influence the result.
Yep, that's what I usually do.
said:
BTW, the code you posted just above does not show this. The line commented out is:
//if (r1.x != 0) discard;
And the surrounding code looks correct to me. Don't know why avoiding the discard would help, but it can be part of how Dolphin works.
You can see I put a line to change the aspect ratio of the effect. So I thought it was obvious that I commented that discard line, because it's needed to make the shader work. Sorry for not being clear about that. The unmodified shader just doesn't have the "r0.x=r0.x*4/3;", the comments and the discard line is uncommented.
About how Dolphin compiles its shaders, this is more or less how it does it (I don't know it in much detail): it does shader compilation while playing (which can produce stuttering except in the Ishiiruka builds, which have an async shader compilation option) and then it stores the compiled shaders in a cache folfer. The next time a game needs those shaders, it accesses the cache files. Using a different Dolphin build will wipe the cache and it will need to be generated again. By the way, the "per pixel lighting" option uses different shaders in games that make use of the option, like Zelda TP or Metroid Prime.
I'm trying to disable a shader in Assassins Creed Unity (not 3D related just think this shader is ugly)
And when the shader is marked in hunting mode it's skipped and not rendered like I want it to be.
But when I export the shader and try disable it with "o0 = 0;" it's not skipped, it's only slightly darker.
Here is the shader in question:
http://www.pastebin.ca/3090803
As you can see I put "o0 = 0;" just above the "return;" am I doing this correctly? Or maybe the shader just isn't exported correctly?
I'm trying to disable a shader in Assassins Creed Unity (not 3D related just think this shader is ugly)
And when the shader is marked in hunting mode it's skipped and not rendered like I want it to be.
But when I export the shader and try disable it with "o0 = 0;" it's not skipped, it's only slightly darker.
[quote=""]
As you can see I put "o0 = 0;" just above the "return;" am I doing this correctly? Or maybe the shader just isn't exported correctly?[/quote]
If you want exactly the same effect as skipping the shader, there are two more reliable ways:
1- In the main method, put a "discard;" line at the start (I think there's one example of that in the file ). Example of the method of one of my shaders:
[code]
void main(
float4 v0 : SV_Position0,
float4 v1 : COLOR0,
float4 v2 : COLOR1,
float4 v3 : TEXCOORD0,
float4 v4 : TEXCOORD1,
uint v5 : SV_RenderTargetArrayIndex0,
out float4 o0 : SV_Target0)
{
float4 r0;
uint4 bitmask, uiDest;
float4 fDest;
discard;
r0.xyzw = max((int4)color[3].xyzw, int4(-1024,-1024,-1024,-1024));
r0.xyzw = min(int4(1023,1023,1023,1023), (int4)r0.xyzw);
r0.xyzw = (int4)r0.xyzw & int4(255,255,255,255);
r0.xyzw = (int4)r0.xyzw;
o0.xyzw = float4(0.00392156886,0.00392156886,0.00392156886,0.00392156886) * r0.xyzw;
return;
}
[/code]
Place that "discard" anywhere before any "rX" or "oX".
2- In the "d3dx.ini", put something like this with the hash of the vertex or pixel shader you want to disable:
[code]
[ShaderOverride1]
Hash=e803ab557d0d06d9
Handling=skip
[/code]
said:
As you can see I put "o0 = 0;" just above the "return;" am I doing this correctly? Or maybe the shader just isn't exported correctly?
If you want exactly the same effect as skipping the shader, there are two more reliable ways:
1- In the main method, put a "discard;" line at the start (I think there's one example of that in the file ). Example of the method of one of my shaders:
I found a better way to fix Zelda Ocarina of Time and with a lot less shader files. Fixing the disc menu of the Collector's Edition had an unexpected effect... it changed the aspect ratio! Now it works in 16:9 without the need of Dolphin's widescreen hack (and changing both the "x" and "y" axes gives the game more FOV, like a PC game (it isn't just zoom), but I guess it will break the disc menu). Now 16:9 corrected textures aren't needed (I restored/created all the 4:3 versions and they fit perfectly), fonts are perfect, the HUD is perfect (almost, I'll get to that now), the minimap is correct...
I need those 8 vertex shaders (all of them) to have the "x" axis corrected (multiplying by 0.75. I used one ini param to change the value in all shaders at the same time if I want). And in theory there is no problem with that. Only the minimap arrows needed partnering to not break other things and now its great.
But here's the problem... I need a different form of partnering (or something else). The skybox vertex shader also affects some things that need that "x" axis correction in the vertex shader, so partnering the vertex shader with the sky pixel shader fixes the sky but leaves the other things unfixed, with the need of that "*0.75" (because partnering makes the rest of pixel shaders use the default vertex shader values). The sky needs that x*0.75 on top the the xyz*115, but the rest needs just the x*0.75.
So basically there are 3 pixel shaders related to that vertex shader (sky, Navi and spiritual stones). The sky needs xyz*115 and x*0.75 but the other two need x*0.75.
Is there any way to accomplish this? I tried some things that didn't work, like using the d3dx.ini to assign different values to a variable depending on the pixel shader, and using that variable in the vertex shader.
I also need this for another vertex shader, to move the A button icon to the left.
Here are the current shaders if anyone wants to see them: https://www.dropbox.com/s/0s87zgcwn29hmsq/currentzeldaoot.7z?dl=0
Edit: also a pair of screenshots (rename the jpg one to jps):
[img]http://u.cubeupload.com/masterotaku/Dolphin1552.png[/img]
[img]http://u.cubeupload.com/masterotaku/Dolphin156.jpg[/img]
Edit: I can confirm that my fixes also work for Zelda Majora's Mask (everything except the minimap arrows fix), the VC version of OOT (I suppose also the VC Majora's Mask) and Zelda Master Quest. Dolphin's widescreen hack worked terribly with the VC version of OOT, but now the game looks fabulous with the fixes :). It also worked with more or less success with other games. It's like a I made a semi-universal widescreen hack :p.
I found a better way to fix Zelda Ocarina of Time and with a lot less shader files. Fixing the disc menu of the Collector's Edition had an unexpected effect... it changed the aspect ratio! Now it works in 16:9 without the need of Dolphin's widescreen hack (and changing both the "x" and "y" axes gives the game more FOV, like a PC game (it isn't just zoom), but I guess it will break the disc menu). Now 16:9 corrected textures aren't needed (I restored/created all the 4:3 versions and they fit perfectly), fonts are perfect, the HUD is perfect (almost, I'll get to that now), the minimap is correct...
I need those 8 vertex shaders (all of them) to have the "x" axis corrected (multiplying by 0.75. I used one ini param to change the value in all shaders at the same time if I want). And in theory there is no problem with that. Only the minimap arrows needed partnering to not break other things and now its great.
But here's the problem... I need a different form of partnering (or something else). The skybox vertex shader also affects some things that need that "x" axis correction in the vertex shader, so partnering the vertex shader with the sky pixel shader fixes the sky but leaves the other things unfixed, with the need of that "*0.75" (because partnering makes the rest of pixel shaders use the default vertex shader values). The sky needs that x*0.75 on top the the xyz*115, but the rest needs just the x*0.75.
So basically there are 3 pixel shaders related to that vertex shader (sky, Navi and spiritual stones). The sky needs xyz*115 and x*0.75 but the other two need x*0.75.
Is there any way to accomplish this? I tried some things that didn't work, like using the d3dx.ini to assign different values to a variable depending on the pixel shader, and using that variable in the vertex shader.
I also need this for another vertex shader, to move the A button icon to the left.
Edit: also a pair of screenshots (rename the jpg one to jps):
Edit: I can confirm that my fixes also work for Zelda Majora's Mask (everything except the minimap arrows fix), the VC version of OOT (I suppose also the VC Majora's Mask) and Zelda Master Quest. Dolphin's widescreen hack worked terribly with the VC version of OOT, but now the game looks fabulous with the fixes :). It also worked with more or less success with other games. It's like a I made a semi-universal widescreen hack :p.
[quote="masterotaku"]But here's the problem... I need a different form of partnering (or something else). The skybox vertex shader also affects some things that need that "x" axis correction in the vertex shader, so partnering the vertex shader with the sky pixel shader fixes the sky but leaves the other things unfixed, with the need of that "*0.75" (because partnering makes the rest of pixel shaders use the default vertex shader values). The sky needs that x*0.75 on top the the xyz*115, but the rest needs just the x*0.75.
So basically there are 3 pixel shaders related to that vertex shader (sky, Navi and spiritual stones). The sky needs xyz*115 and x*0.75 but the other two need x*0.75.
Is there any way to accomplish this? I tried some things that didn't work, like using the d3dx.ini to assign different values to a variable depending on the pixel shader, and using that variable in the vertex shader.[/quote]
You should be able to use the advanced form of partner shader filtering to do what you need, so long as each ShaderOverride section has a unique name, the correct hash and the same ini param with a different value set - the sections for the pixel shaders should each set the ini param to a different value, and the section for the vertex shader would set a default value that will be used if no pixel shader section matches. Obviously you should also remove the simple form of partner shader filtering for the shaders of interest if you haven't already. It would look something like this:
[code]
[ShaderOverrideVextexShaderSkyNaviSpiritualStones]
Hash = 7592a24e6fae0825
y = 0
[ShaderOverridePixelShaderSky]
Hash = b50a9fff61b7bf45
y = 1
[/code]
And then in the shader:
[code]
<snip>
float4 iniparams = IniParams.Load(0);
if (iniparams.y == 1) {
//This is needed for the sky. It still needs the *0.75 of further down.
v3.xyz = v3.xyz * 115;
}
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.z = dot(ctrmtx[r0.z].xyzw, v3.xyzw);
r1.y = dot(ctrmtx[r0.y].xyzw, v3.xyzw);
r1.w = 1;
//r0.x*0.75 for stones, xyz*115 for sky.
r0.x = dot(cproj[0].xyzw, r1.xyzw) * iniparams.x;
<snip>
[/code]
If you needed to get even more sophisticated and do different things for Navi or the Stones as well, you can expand this further by matching them as well:
[code]
[ShaderOverrideVextexShaderSkyNaviSpiritualStones]
Hash = 7592a24e6fae0825
y = 0
[ShaderOverridePixelShaderSky]
Hash = b50a9fff61b7bf45
y = 1
[ShaderOverridePixelShaderNavi]
Hash = fixme........
y = 2
[ShaderOverridePixelShaderSpiritualStones]
Hash = andme........
y = 3
[/code]
[code]
// partner filter is in IniParams[0].y:
float partner_shader = IniParams.Load(int2(0,0)).y;
if (partner_shader == 1) {
// Sky
} else if (partner_shader == 2) {
// Navi
} else if (partner_shader == 3) {
// Spiritual Stones
} else {
// Something else
}
[/code]
masterotaku said:But here's the problem... I need a different form of partnering (or something else). The skybox vertex shader also affects some things that need that "x" axis correction in the vertex shader, so partnering the vertex shader with the sky pixel shader fixes the sky but leaves the other things unfixed, with the need of that "*0.75" (because partnering makes the rest of pixel shaders use the default vertex shader values). The sky needs that x*0.75 on top the the xyz*115, but the rest needs just the x*0.75.
So basically there are 3 pixel shaders related to that vertex shader (sky, Navi and spiritual stones). The sky needs xyz*115 and x*0.75 but the other two need x*0.75.
Is there any way to accomplish this? I tried some things that didn't work, like using the d3dx.ini to assign different values to a variable depending on the pixel shader, and using that variable in the vertex shader.
You should be able to use the advanced form of partner shader filtering to do what you need, so long as each ShaderOverride section has a unique name, the correct hash and the same ini param with a different value set - the sections for the pixel shaders should each set the ini param to a different value, and the section for the vertex shader would set a default value that will be used if no pixel shader section matches. Obviously you should also remove the simple form of partner shader filtering for the shaders of interest if you haven't already. It would look something like this:
[ShaderOverrideVextexShaderSkyNaviSpiritualStones]
Hash = 7592a24e6fae0825
y = 0
[ShaderOverridePixelShaderSky]
Hash = b50a9fff61b7bf45
y = 1
And then in the shader:
<snip>
float4 iniparams = IniParams.Load(0);
if (iniparams.y == 1) {
//This is needed for the sky. It still needs the *0.75 of further down.
v3.xyz = v3.xyz * 115;
}
If you needed to get even more sophisticated and do different things for Navi or the Stones as well, you can expand this further by matching them as well:
[ShaderOverrideVextexShaderSkyNaviSpiritualStones]
Hash = 7592a24e6fae0825
y = 0
[ShaderOverridePixelShaderSky]
Hash = b50a9fff61b7bf45
y = 1
[ShaderOverridePixelShaderNavi]
Hash = fixme........
y = 2
[ShaderOverridePixelShaderSpiritualStones]
Hash = andme........
y = 3
// partner filter is in IniParams[0].y:
float partner_shader = IniParams.Load(int2(0,0)).y;
You are my hero! It worked for the sky and another thing (I was trying something similar to what you said, but it was wrong). Now there are only a pair of things to do that I'll fix this way too. Too bad that it's late and I have to enter the "sleep-work-be home" cycle again. Tomorrow or the day after that (if everything goes alright) the fix will be complete. And I hope you and more people will enjoy it :). But I also have to upload the updated texture pack with all 4:3 textures that are needed for this fix.
You are my hero! It worked for the sky and another thing (I was trying something similar to what you said, but it was wrong). Now there are only a pair of things to do that I'll fix this way too. Too bad that it's late and I have to enter the "sleep-work-be home" cycle again. Tomorrow or the day after that (if everything goes alright) the fix will be complete. And I hope you and more people will enjoy it :). But I also have to upload the updated texture pack with all 4:3 textures that are needed for this fix.
[quote=""]I'm trying to disable a shader in Assassins Creed Unity (not 3D related just think this shader is ugly)
And when the shader is marked in hunting mode it's skipped and not rendered like I want it to be.
But when I export the shader and try disable it with "o0 = 0;" it's not skipped, it's only slightly darker.
Here is the shader in question:
http://www.pastebin.ca/3090803
As you can see I put "o0 = 0;" just above the "return;" am I doing this correctly? Or maybe the shader just isn't exported correctly?[/quote]
Just to fill in a gap here- masterotaku's approach of using 'discard' is definitely better for a shader to be ignored. Using the ShaderOverride with skip is great if you have no logic, like "only discard if".
The other thing worth noting is that 'discard' is only available on SM4, SM5, and only for PixelShaders.
[url]https://msdn.microsoft.com/en-us/library/windows/desktop/hh446968(v=vs.85).aspx[/url]
I previously suggest using o0=0 as a more general approach. It works (mostly) in both VS and PS, and importantly in SM3. In ASM with HelixMod, we can either set outputs to zero, or delete the code in the shader. With further experience, the deleting the code is probably slightly more reliable.
In this example, the reason o0=0 did not work, is because there are multiple outputs. Every shader seems to be a unique little snowflake, and some need extra tweaks.
The output section is:
[code] out float4 o0 : SV_Target0,
out float4 o1 : SV_Target1,
out float4 o2 : SV_Target2,
out float4 o3 : SV_Target3,
out float4 o4 : SV_Target4[/code]
Note that it's not just a single output of o0. The other targets are different values, and probably you'd need to assign all 5 of them to 0 to get a fully blank output.
said:I'm trying to disable a shader in Assassins Creed Unity (not 3D related just think this shader is ugly)
And when the shader is marked in hunting mode it's skipped and not rendered like I want it to be.
But when I export the shader and try disable it with "o0 = 0;" it's not skipped, it's only slightly darker.
As you can see I put "o0 = 0;" just above the "return;" am I doing this correctly? Or maybe the shader just isn't exported correctly?
Just to fill in a gap here- masterotaku's approach of using 'discard' is definitely better for a shader to be ignored. Using the ShaderOverride with skip is great if you have no logic, like "only discard if".
The other thing worth noting is that 'discard' is only available on SM4, SM5, and only for PixelShaders.
I previously suggest using o0=0 as a more general approach. It works (mostly) in both VS and PS, and importantly in SM3. In ASM with HelixMod, we can either set outputs to zero, or delete the code in the shader. With further experience, the deleting the code is probably slightly more reliable.
In this example, the reason o0=0 did not work, is because there are multiple outputs. Every shader seems to be a unique little snowflake, and some need extra tweaks.
The output section is:
out float4 o0 : SV_Target0,
out float4 o1 : SV_Target1,
out float4 o2 : SV_Target2,
out float4 o3 : SV_Target3,
out float4 o4 : SV_Target4
Note that it's not just a single output of o0. The other targets are different values, and probably you'd need to assign all 5 of them to 0 to get a fully blank output.
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
[quote=""]
Note that it's not just a single output of o0. The other targets are different values, and probably you'd need to assign all 5 of them to 0 to get a fully blank output.
[/quote]
I tried that actually, but didn't seem to work either. The discard method works anyway so s'all good :)
said:
Note that it's not just a single output of o0. The other targets are different values, and probably you'd need to assign all 5 of them to 0 to get a fully blank output.
I tried that actually, but didn't seem to work either. The discard method works anyway so s'all good :)
1080 Ti - i7 5820k - 16Gb RAM - Win 10 version 1607 - ASUS VG236H (1920x1080@120Hz)
I think I might have found a bug in 3Dmigoto (or one of my shaders). In the current state of my Zelda OOT fixes (almost finished), all goes well in 3D. You know, I can reload shaders, disable them while I hold F11, etc. Everything is fine.
But something broke at some point. If I start the game (Zelda Collector's Edition) with 3D Vision disabled in the Nvidia Control Panel, the game starts but it displays a black screen. The game still has sound and I can boot Ocarina of time and play. Holding F11 makes the image appear (the key I use to temporarily disable the fixes), and if I press F10 to reload shaders, Dolphin crashes instantly.
A different game that contains Zelda OOT (the Zelda Master Quest disc) displays some icons at the start, that must be controlled by a different shader that I haven't dumped.
The Virtual Console version crashes after the N64 logo disappears (I can see it if I hold F11). What is funny is that the game doesn't crash if I keep holding F11. I can load the game, control Link, etc. As soon as I release F11, Dolphin crashes.
I'll be out today until night, so I don't have time to find the culprit right now. If anyone wants to look at it, here's 3Dmigoto + the shader fixes + the "d3d11_log.txt":
https://www.dropbox.com/s/qgl16evrvx7bap8/zeldabroken.7z?dl=0
I'll try to find out myself, but that will be about 13 hours from now :(.
I think I might have found a bug in 3Dmigoto (or one of my shaders). In the current state of my Zelda OOT fixes (almost finished), all goes well in 3D. You know, I can reload shaders, disable them while I hold F11, etc. Everything is fine.
But something broke at some point. If I start the game (Zelda Collector's Edition) with 3D Vision disabled in the Nvidia Control Panel, the game starts but it displays a black screen. The game still has sound and I can boot Ocarina of time and play. Holding F11 makes the image appear (the key I use to temporarily disable the fixes), and if I press F10 to reload shaders, Dolphin crashes instantly.
A different game that contains Zelda OOT (the Zelda Master Quest disc) displays some icons at the start, that must be controlled by a different shader that I haven't dumped.
The Virtual Console version crashes after the N64 logo disappears (I can see it if I hold F11). What is funny is that the game doesn't crash if I keep holding F11. I can load the game, control Link, etc. As soon as I release F11, Dolphin crashes.
@masterotaku: I took a quick look at the log file you have there, and it looks OK up until the time it crashes.
I'm confused on the use case though. Are you trying to use it in strictly 2D mode, or fixing the game in 3D. Any use of the 3D parts like StereoParams will fail if it's in 2D, because they cannot be created and thus don't exist. I could do a cleaner job of handling this case, but it hasn't come up before.
In general for a crash, you'll want to simplify the use case to try to narrow down the cause. So for example remove all the shaders from ShaderFixes and run with only the tool installed. If that crashes, try to run the game without the tool installed and make sure the game is still working. That sort of thing.
If it always crashes with 3D Vision disabled, that would suggest a bug in 3Dmigoto for the 2D only case.
@masterotaku: I took a quick look at the log file you have there, and it looks OK up until the time it crashes.
I'm confused on the use case though. Are you trying to use it in strictly 2D mode, or fixing the game in 3D. Any use of the 3D parts like StereoParams will fail if it's in 2D, because they cannot be created and thus don't exist. I could do a cleaner job of handling this case, but it hasn't come up before.
In general for a crash, you'll want to simplify the use case to try to narrow down the cause. So for example remove all the shaders from ShaderFixes and run with only the tool installed. If that crashes, try to run the game without the tool installed and make sure the game is still working. That sort of thing.
If it always crashes with 3D Vision disabled, that would suggest a bug in 3Dmigoto for the 2D only case.
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
[quote=""]
I'm confused on the use case though. Are you trying to use it in strictly 2D mode, or fixing the game in 3D.[/quote]
Both. Fixing the game for a perfect 16:9 should be for all users, and 3D users can benefit from the sky, moon and sun depth (by the way, at the end I can only multiply the sky coords by 11, because it affects some 2D backgrounds that start to disappear at further depth).
[quote=""]Any use of the 3D parts like StereoParams will fail if it's in 2D, because they cannot be created and thus don't exist. I could do a cleaner job of handling this case, but it hasn't come up before.
In general for a crash, you'll want to simplify the use case to try to narrow down the cause. So for example remove all the shaders from ShaderFixes and run with only the tool installed. If that crashes, try to run the game without the tool installed and make sure the game is still working. That sort of thing. [/quote]
I found out the problem: Dolphin doesn't read the iniparams in 2D mode (I mean with the 3D Vision option disabled in Dolphin). That caused for example the aspect ratio to be multiplied by 0 instead of 0.75, which made the image black. If instead of using the iniparam to multiply it I use 0.75 manually it works. But the big downside is that the conditions of some shaders to do a different thing for some pixel shaders if some iniparam is other than 0 don't work. The "else" is always applied in that case :(.
Consequences: when you look at the sun, the brightness only affects the 4:3 area. The Kokiri Forest sky is black outside of the 4:3 area. The transucent black border in the disc menu isn't moved to the border of the screen (this is a minor issue).
And unrelated to the iniparams, the black bars shader isn't discarded in 2D. Deleting the code or making the output 0 also doesn't work. Black bard that can only be seen in the 4:3 area are annoying.
I guess I should try making two separate fixes pack, trying to make sure both 3D and 2D users can benefit from everything I can do.
By the way, after not using the iniparams crashes only happen when reloading shaders in 2D.
said:
I'm confused on the use case though. Are you trying to use it in strictly 2D mode, or fixing the game in 3D.
Both. Fixing the game for a perfect 16:9 should be for all users, and 3D users can benefit from the sky, moon and sun depth (by the way, at the end I can only multiply the sky coords by 11, because it affects some 2D backgrounds that start to disappear at further depth).
said:Any use of the 3D parts like StereoParams will fail if it's in 2D, because they cannot be created and thus don't exist. I could do a cleaner job of handling this case, but it hasn't come up before.
In general for a crash, you'll want to simplify the use case to try to narrow down the cause. So for example remove all the shaders from ShaderFixes and run with only the tool installed. If that crashes, try to run the game without the tool installed and make sure the game is still working. That sort of thing.
I found out the problem: Dolphin doesn't read the iniparams in 2D mode (I mean with the 3D Vision option disabled in Dolphin). That caused for example the aspect ratio to be multiplied by 0 instead of 0.75, which made the image black. If instead of using the iniparam to multiply it I use 0.75 manually it works. But the big downside is that the conditions of some shaders to do a different thing for some pixel shaders if some iniparam is other than 0 don't work. The "else" is always applied in that case :(.
Consequences: when you look at the sun, the brightness only affects the 4:3 area. The Kokiri Forest sky is black outside of the 4:3 area. The transucent black border in the disc menu isn't moved to the border of the screen (this is a minor issue).
And unrelated to the iniparams, the black bars shader isn't discarded in 2D. Deleting the code or making the output 0 also doesn't work. Black bard that can only be seen in the 4:3 area are annoying.
I guess I should try making two separate fixes pack, trying to make sure both 3D and 2D users can benefit from everything I can do.
By the way, after not using the iniparams crashes only happen when reloading shaders in 2D.
[quote=""]I found out the problem: Dolphin doesn't read the iniparams in 2D mode (I mean with the 3D Vision option disabled in Dolphin). That caused for example the aspect ratio to be multiplied by 0 instead of 0.75, which made the image black. If instead of using the iniparam to multiply it I use 0.75 manually it works. But the big downside is that the conditions of some shaders to do a different thing for some pixel shaders if some iniparam is other than 0 don't work. The "else" is always applied in that case :(.[/quote]
I added this as an issue to the 3Dmigoto project, and will try to fix this fairly soon, so that iniParams works in 2D. There's no reason why iniParams shouldn't work here.
said:I found out the problem: Dolphin doesn't read the iniparams in 2D mode (I mean with the 3D Vision option disabled in Dolphin). That caused for example the aspect ratio to be multiplied by 0 instead of 0.75, which made the image black. If instead of using the iniparam to multiply it I use 0.75 manually it works. But the big downside is that the conditions of some shaders to do a different thing for some pixel shaders if some iniparam is other than 0 don't work. The "else" is always applied in that case :(.
I added this as an issue to the 3Dmigoto project, and will try to fix this fairly soon, so that iniParams works in 2D. There's no reason why iniParams shouldn't work here.
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
- This functionality may has been broken at some point, which is very possible given that it is a very rarely used feature, and/or
- We may not be wrapping the correct D3DCompiler_xx.dll and missing the D3DCompile call, and/or
- Dolphin may be caching the shaders so they only get compiled once and the precompiled shader reused from then on, and we didn't catch the initial compile (2)
Fixing this would give us shaders closer to what Dolphin generates, which would help to match up the code you are seeing in the shaders to the code that generated it (3). This would also avoid decompiler issues like this alpha/early z test discard (4).
1: https://github.com/dolphin-emu/dolphin/blob/master/Source/Core/VideoBackends/D3D/D3DShader.cpp#L149
2: https://github.com/dolphin-emu/dolphin/blob/master/Source/Core/VideoBackends/D3D/PixelShaderCache.cpp
3: https://github.com/dolphin-emu/dolphin/blob/master/Source/Core/VideoCommon/PixelShaderGen.cpp
4: https://github.com/dolphin-emu/dolphin/blob/master/Source/Core/VideoCommon/PixelShaderGen.cpp#L1113
2x Geforce GTX 980 in SLI provided by NVIDIA, i7 6700K 4GHz CPU, Asus 27" VG278HE 144Hz 3D Monitor, BenQ W1070 3D Projector, 120" Elite Screens YardMaster 2, 32GB Corsair DDR4 3200MHz RAM, Samsung 850 EVO 500G SSD, 4x750GB HDD in RAID5, Gigabyte Z170X-Gaming 7 Motherboard, Corsair Obsidian 750D Airflow Edition Case, Corsair RM850i PSU, HTC Vive, Win 10 64bit
Alienware M17x R4 w/ built in 3D, Intel i7 3740QM, GTX 680m 2GB, 16GB DDR3 1600MHz RAM, Win7 64bit, 1TB SSD, 1TB HDD, 750GB HDD
Pre-release 3D fixes, shadertool.py and other goodies: http://github.com/DarkStarSword/3d-fixes
Support me on Patreon: https://www.patreon.com/DarkStarSword or PayPal: https://www.paypal.me/DarkStarSword
The sub-projects are still live, just not shipped by default. I just updated d3d_compiler46 as a way to preload Batman, since they marked d3d11.dll as load-on-demand which is too late.
The way to use this now is as a one-off for a given fix, added in as needed (right-click subproject to build it). It's necessary to rename the original d3d_compiler like d3d_compiler46_org.dll, then add in the replacement. If it's not 46, the subproject will probably need some tweaking to bring it up to the new code base.
Alternatively, Dolphin may have a shader dump or logging feature to show what they generate.
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
Interesting. I didn't know that. But well, I don't touch the ASM part (is it just for showing how it is in ASM, or would making changes there affect the shader?).
Yep, that's what I usually do.
You can see I put a line to change the aspect ratio of the effect. So I thought it was obvious that I commented that discard line, because it's needed to make the shader work. Sorry for not being clear about that. The unmodified shader just doesn't have the "r0.x=r0.x*4/3;", the comments and the discard line is uncommented.
About how Dolphin compiles its shaders, this is more or less how it does it (I don't know it in much detail): it does shader compilation while playing (which can produce stuttering except in the Ishiiruka builds, which have an async shader compilation option) and then it stores the compiled shaders in a cache folfer. The next time a game needs those shaders, it accesses the cache files. Using a different Dolphin build will wipe the cache and it will need to be generated again. By the way, the "per pixel lighting" option uses different shaders in games that make use of the option, like Zelda TP or Metroid Prime.
CPU: Intel Core i7 7700K @ 4.9GHz
Motherboard: Gigabyte Aorus GA-Z270X-Gaming 5
RAM: GSKILL Ripjaws Z 16GB 3866MHz CL18
GPU: MSI GeForce RTX 2080Ti Gaming X Trio
Monitor: Asus PG278QR
Speakers: Logitech Z506
Donations account: masterotakusuko@gmail.com
And when the shader is marked in hunting mode it's skipped and not rendered like I want it to be.
But when I export the shader and try disable it with "o0 = 0;" it's not skipped, it's only slightly darker.
Here is the shader in question:
http://www.pastebin.ca/3090803
As you can see I put "o0 = 0;" just above the "return;" am I doing this correctly? Or maybe the shader just isn't exported correctly?
1080 Ti - i7 5820k - 16Gb RAM - Win 10 version 1607 - ASUS VG236H (1920x1080@120Hz)
If you want exactly the same effect as skipping the shader, there are two more reliable ways:
1- In the main method, put a "discard;" line at the start (I think there's one example of that in the file ). Example of the method of one of my shaders:
Place that "discard" anywhere before any "rX" or "oX".
2- In the "d3dx.ini", put something like this with the hash of the vertex or pixel shader you want to disable:
CPU: Intel Core i7 7700K @ 4.9GHz
Motherboard: Gigabyte Aorus GA-Z270X-Gaming 5
RAM: GSKILL Ripjaws Z 16GB 3866MHz CL18
GPU: MSI GeForce RTX 2080Ti Gaming X Trio
Monitor: Asus PG278QR
Speakers: Logitech Z506
Donations account: masterotakusuko@gmail.com
1080 Ti - i7 5820k - 16Gb RAM - Win 10 version 1607 - ASUS VG236H (1920x1080@120Hz)
I need those 8 vertex shaders (all of them) to have the "x" axis corrected (multiplying by 0.75. I used one ini param to change the value in all shaders at the same time if I want). And in theory there is no problem with that. Only the minimap arrows needed partnering to not break other things and now its great.
But here's the problem... I need a different form of partnering (or something else). The skybox vertex shader also affects some things that need that "x" axis correction in the vertex shader, so partnering the vertex shader with the sky pixel shader fixes the sky but leaves the other things unfixed, with the need of that "*0.75" (because partnering makes the rest of pixel shaders use the default vertex shader values). The sky needs that x*0.75 on top the the xyz*115, but the rest needs just the x*0.75.
So basically there are 3 pixel shaders related to that vertex shader (sky, Navi and spiritual stones). The sky needs xyz*115 and x*0.75 but the other two need x*0.75.
Is there any way to accomplish this? I tried some things that didn't work, like using the d3dx.ini to assign different values to a variable depending on the pixel shader, and using that variable in the vertex shader.
I also need this for another vertex shader, to move the A button icon to the left.
Here are the current shaders if anyone wants to see them: https://www.dropbox.com/s/0s87zgcwn29hmsq/currentzeldaoot.7z?dl=0
Edit: also a pair of screenshots (rename the jpg one to jps):
Edit: I can confirm that my fixes also work for Zelda Majora's Mask (everything except the minimap arrows fix), the VC version of OOT (I suppose also the VC Majora's Mask) and Zelda Master Quest. Dolphin's widescreen hack worked terribly with the VC version of OOT, but now the game looks fabulous with the fixes :). It also worked with more or less success with other games. It's like a I made a semi-universal widescreen hack :p.
CPU: Intel Core i7 7700K @ 4.9GHz
Motherboard: Gigabyte Aorus GA-Z270X-Gaming 5
RAM: GSKILL Ripjaws Z 16GB 3866MHz CL18
GPU: MSI GeForce RTX 2080Ti Gaming X Trio
Monitor: Asus PG278QR
Speakers: Logitech Z506
Donations account: masterotakusuko@gmail.com
You should be able to use the advanced form of partner shader filtering to do what you need, so long as each ShaderOverride section has a unique name, the correct hash and the same ini param with a different value set - the sections for the pixel shaders should each set the ini param to a different value, and the section for the vertex shader would set a default value that will be used if no pixel shader section matches. Obviously you should also remove the simple form of partner shader filtering for the shaders of interest if you haven't already. It would look something like this:
And then in the shader:
If you needed to get even more sophisticated and do different things for Navi or the Stones as well, you can expand this further by matching them as well:
2x Geforce GTX 980 in SLI provided by NVIDIA, i7 6700K 4GHz CPU, Asus 27" VG278HE 144Hz 3D Monitor, BenQ W1070 3D Projector, 120" Elite Screens YardMaster 2, 32GB Corsair DDR4 3200MHz RAM, Samsung 850 EVO 500G SSD, 4x750GB HDD in RAID5, Gigabyte Z170X-Gaming 7 Motherboard, Corsair Obsidian 750D Airflow Edition Case, Corsair RM850i PSU, HTC Vive, Win 10 64bit
Alienware M17x R4 w/ built in 3D, Intel i7 3740QM, GTX 680m 2GB, 16GB DDR3 1600MHz RAM, Win7 64bit, 1TB SSD, 1TB HDD, 750GB HDD
Pre-release 3D fixes, shadertool.py and other goodies: http://github.com/DarkStarSword/3d-fixes
Support me on Patreon: https://www.patreon.com/DarkStarSword or PayPal: https://www.paypal.me/DarkStarSword
CPU: Intel Core i7 7700K @ 4.9GHz
Motherboard: Gigabyte Aorus GA-Z270X-Gaming 5
RAM: GSKILL Ripjaws Z 16GB 3866MHz CL18
GPU: MSI GeForce RTX 2080Ti Gaming X Trio
Monitor: Asus PG278QR
Speakers: Logitech Z506
Donations account: masterotakusuko@gmail.com
Just to fill in a gap here- masterotaku's approach of using 'discard' is definitely better for a shader to be ignored. Using the ShaderOverride with skip is great if you have no logic, like "only discard if".
The other thing worth noting is that 'discard' is only available on SM4, SM5, and only for PixelShaders.
https://msdn.microsoft.com/en-us/library/windows/desktop/hh446968(v=vs.85).aspx
I previously suggest using o0=0 as a more general approach. It works (mostly) in both VS and PS, and importantly in SM3. In ASM with HelixMod, we can either set outputs to zero, or delete the code in the shader. With further experience, the deleting the code is probably slightly more reliable.
In this example, the reason o0=0 did not work, is because there are multiple outputs. Every shader seems to be a unique little snowflake, and some need extra tweaks.
The output section is:
Note that it's not just a single output of o0. The other targets are different values, and probably you'd need to assign all 5 of them to 0 to get a fully blank output.
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 tried that actually, but didn't seem to work either. The discard method works anyway so s'all good :)
1080 Ti - i7 5820k - 16Gb RAM - Win 10 version 1607 - ASUS VG236H (1920x1080@120Hz)
But something broke at some point. If I start the game (Zelda Collector's Edition) with 3D Vision disabled in the Nvidia Control Panel, the game starts but it displays a black screen. The game still has sound and I can boot Ocarina of time and play. Holding F11 makes the image appear (the key I use to temporarily disable the fixes), and if I press F10 to reload shaders, Dolphin crashes instantly.
A different game that contains Zelda OOT (the Zelda Master Quest disc) displays some icons at the start, that must be controlled by a different shader that I haven't dumped.
The Virtual Console version crashes after the N64 logo disappears (I can see it if I hold F11). What is funny is that the game doesn't crash if I keep holding F11. I can load the game, control Link, etc. As soon as I release F11, Dolphin crashes.
I'll be out today until night, so I don't have time to find the culprit right now. If anyone wants to look at it, here's 3Dmigoto + the shader fixes + the "d3d11_log.txt":
https://www.dropbox.com/s/qgl16evrvx7bap8/zeldabroken.7z?dl=0
I'll try to find out myself, but that will be about 13 hours from now :(.
CPU: Intel Core i7 7700K @ 4.9GHz
Motherboard: Gigabyte Aorus GA-Z270X-Gaming 5
RAM: GSKILL Ripjaws Z 16GB 3866MHz CL18
GPU: MSI GeForce RTX 2080Ti Gaming X Trio
Monitor: Asus PG278QR
Speakers: Logitech Z506
Donations account: masterotakusuko@gmail.com
I'm confused on the use case though. Are you trying to use it in strictly 2D mode, or fixing the game in 3D. Any use of the 3D parts like StereoParams will fail if it's in 2D, because they cannot be created and thus don't exist. I could do a cleaner job of handling this case, but it hasn't come up before.
In general for a crash, you'll want to simplify the use case to try to narrow down the cause. So for example remove all the shaders from ShaderFixes and run with only the tool installed. If that crashes, try to run the game without the tool installed and make sure the game is still working. That sort of thing.
If it always crashes with 3D Vision disabled, that would suggest a bug in 3Dmigoto for the 2D only case.
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
Both. Fixing the game for a perfect 16:9 should be for all users, and 3D users can benefit from the sky, moon and sun depth (by the way, at the end I can only multiply the sky coords by 11, because it affects some 2D backgrounds that start to disappear at further depth).
I found out the problem: Dolphin doesn't read the iniparams in 2D mode (I mean with the 3D Vision option disabled in Dolphin). That caused for example the aspect ratio to be multiplied by 0 instead of 0.75, which made the image black. If instead of using the iniparam to multiply it I use 0.75 manually it works. But the big downside is that the conditions of some shaders to do a different thing for some pixel shaders if some iniparam is other than 0 don't work. The "else" is always applied in that case :(.
Consequences: when you look at the sun, the brightness only affects the 4:3 area. The Kokiri Forest sky is black outside of the 4:3 area. The transucent black border in the disc menu isn't moved to the border of the screen (this is a minor issue).
And unrelated to the iniparams, the black bars shader isn't discarded in 2D. Deleting the code or making the output 0 also doesn't work. Black bard that can only be seen in the 4:3 area are annoying.
I guess I should try making two separate fixes pack, trying to make sure both 3D and 2D users can benefit from everything I can do.
By the way, after not using the iniparams crashes only happen when reloading shaders in 2D.
CPU: Intel Core i7 7700K @ 4.9GHz
Motherboard: Gigabyte Aorus GA-Z270X-Gaming 5
RAM: GSKILL Ripjaws Z 16GB 3866MHz CL18
GPU: MSI GeForce RTX 2080Ti Gaming X Trio
Monitor: Asus PG278QR
Speakers: Logitech Z506
Donations account: masterotakusuko@gmail.com
I added this as an issue to the 3Dmigoto project, and will try to fix this fairly soon, so that iniParams works in 2D. There's no reason why iniParams shouldn't work here.
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