3Dmigoto icon indicating copy to clipboard operation
3Dmigoto copied to clipboard

failed to copy Marked shader to ShaderFixes

Open asilv12 opened this issue 3 years ago • 6 comments

I've only made a few hud toggles so I don't know if this is a common issue. I receive an error for the one shader that I want disabled; both ps and vs; all other shaders work. It saves this as a replace.txt. https://i.imgur.com/zITLnmy.png With version 1.3.16 when trying to mark the shader, a message states that it's decompiled and it's saved as a ps.txt and vs.txt https://i.imgur.com/Kf2lvKa.png

Any solution? Thank you.

asilv12 avatar Aug 17 '21 05:08 asilv12

I'm also dealing with this issue, normally I can make HUD toggles just fine, but right now with one specific game I'm also trying to mark a depth of field effect and I get this error. Did you ever find a solution?

ZachFett avatar Nov 02 '21 12:11 ZachFett

Your best bet is to edit the shaders as assembly (ps.txt / vs.txt). If you really want to use HLSL (_replace.txt) you will need to manually correct any instructions that the decompiler doesn't support.

DarkStarSword avatar Nov 02 '21 22:11 DarkStarSword

Oh, can you also please attach the shader to this bug report so we can use it to improve and regression test the HLSL decompiler in future (however, do not wait for that as the decompiler is very low priority given that the assembler is already near perfect).

DarkStarSword avatar Nov 02 '21 22:11 DarkStarSword

Sorry, I'm a complete noob and honestly didn't understand at all what your first reply meant, I just follow this guide when I make my HUD toggles in games.

Here's the shader file (which handles depth of field) that it keeps giving me though, if it helps. Tried fiddling with it a bit but couldn't get it to work when pressing the toggle key in-game. 77b3d27969596c56-ps_replace.txt

Also if you don't mind me asking here instead of making a new thread, since it's not an actual "issue", is there a way to have one of the shader txts always active (as in, always have that shader disabled in-game), and keep the other shader txt still on a toggle? That way I could remove depth of field no matter whether the HUD is toggled on or off.

If not that, is there perhaps a way to have two shader txts handled by two separate key toggles? Like, press "1" to toggle HUD and press "2" to toggle the DoF shader?

ZachFett avatar Nov 03 '21 10:11 ZachFett

No worries. HUD shaders are usually simple enough to work with the decompiler, but I guess this game is one of the exceptions. Normally that means you have to work with assembly instead of HLSL, but that is another language to learn with it's own difficulties, but since all you are trying to do is disable a shader as a whole might I suggest an alternative of skipping the shader from the d3dx.ini instead of editing the shader. Here's an example of how you might do this (excerpt from my DOAXVV mod*, this syntax requires the latest version of 3DMigoto to work):

[Constants]
; Declare variables and set defaults in the Constants section:
global $hud_visible = 1

[KeyToggleHUD1]
; Key section to toggle $hud_visible variable via the mouse back button. This is the cycle type,
; which unlike the toggle type will work regardless of whether the default is 1 or 0 above
Key = XBUTTON1
$hud_visible = 0, 1
type = cycle

[ShaderOverrideHUD1]
; When a shader with this hash is in use skip the draw call if $hud_visible is off:
hash = 77b3d27969596c56
if !$hud_visible
	handling = skip
endif

As you can probably guess, you can add as many named variables as you like to allow different shaders to be disabled by whatever keys (or other conditions) you like. Named variables can only be used from the d3dx.ini like the above, but you also have access to a virtually unlimited number of variables available to shaders via IniParams - the guide you are following uses the variable x in the d3dx.ini, which it accesses via float4 params = IniParams.Load(0); params.x in the shader, though I personally prefer to access it more concisely as IniParams[0].x. The next three variables in IniParams are referred to as y, z and w in the d3dx.ini, accessed as IniParams[0].y, IniParams[0].z and IniParams[0].w in the shader. If you need more than 4 variables you can use x1, y1, z1, w1, x2, y2, and so on, accessed as IniParams[1].x, IniParams[1].y and so in in the shader.

* This example and many others are in my 3d-fixes repository: https://github.com/DarkStarSword/3d-fixes/

DarkStarSword avatar Nov 03 '21 11:11 DarkStarSword

Thank you for the help, I'm glad to hear there's a way to have each shader toggled by separate keys! I tried using your example in my d3dx.ini, but I'm having issues getting the second shader to toggle, and when I boot up the game the HUD is already disabled and I can't toggle it back on, neither bound key is doing anything, actually. If I remove both Lens Flare sections the HUD works perfectly fine and can be toggled on and off.

This is what I've currently got:

[KeyToggleHUD] ; Key section to toggle $hud_visible variable via the mouse back button. This is the cycle type, ; which unlike the toggle type will work regardless of whether the default is 1 or 0 above Key = ] $hud_visible = 0, 1 type = cycle

[ShaderOverrideHUD] ; When a shader with this hash is in use skip the draw call if $hud_visible is off: hash = 7a5fc6d5478fe42e if !$hud_visible handling = skip endif

[KeyToggleLensFlare] ; Key section to toggle $hud_visible variable via the mouse back button. This is the cycle type, ; which unlike the toggle type will work regardless of whether the default is 1 or 0 above Key = [ $hud_visible = 0, 1 type = cycle

[ShaderOverrideLensFlare] ; When a shader with this hash is in use skip the draw call if $hud_visible is off: hash = 5f8d0c9aeee65b25 if !$hud_visible handling = skip endif

Did I do this wrong? I was thinking it might be the "hud_visible" lines, so I tried removing that from the Lens Flare sections and just kept "type = toggle", but no luck. I was also thinking it might be related to having "x = 1" under [Constants] like you mentioned, but I didn't quite understand how to change that to how you do it, with "IniParams[0].x"?

Sorry for taking up your time on this!

ZachFett avatar Nov 08 '21 13:11 ZachFett