Skip to content
Bo3b Johnson edited this page Feb 15, 2014 · 3 revisions
These are notes for experimenting with 3Dmigoto on AC3.

The latest version of the tool v0.52 is running, but is catching shader exceptions instead of fixing them. That means that some shaders are going to be marked 'bad', and not available for dumping. So it's running, but is probably not enough to complete all the fixes yet. The shaders that flicker can be marked, but are in the subset that are causing exceptions, so the HLSL is not generated. It is possible to examine the ASM though.

It should be possible to find and fix some broken shaders though.



For using the keyboard to find shaders, here is a complete d3dx.ini that I used to hunt shaders. Copy and paste into yours as a known working example.
;------------------------------------------------------------------------------------------------------
; Logging options. 
; Comment line or set value to 0 for no logging.
;------------------------------------------------------------------------------------------------------
[Logging]

; Log all API usage
calls=1

; Log Input key actions
input=1

; Log NVAPI convergence modifications
convergence=0
; Log NVAPI separation modifications
separation=0

; Super verbose massive log
debug=1


;------------------------------------------------------------------------------------------------------
; Chain load other wrapper DLLs instead of system DLLs.
;------------------------------------------------------------------------------------------------------
[System]

;proxy_d3d9=d3d9_helix.dll
;proxy_d3d11=d3d11_helix.dll


;------------------------------------------------------------------------------------------------------
; Settings to force display device to a specific mode.
; Uncomment a value to force the specific setting.
;------------------------------------------------------------------------------------------------------
[Device]

; overrides screen resolution.
width=1280
height=720

; overrides refresh rate set by game.
refresh_rate=120

; filters available video modes to those providing given refresh rates.
; some games don't explicitely set the refresh rate, but use the video mode.
; use this if setting refresh_rate doesn't work.
;filter_refresh_rate=24,59,60

; forces creation of full screen devices and swap chains. 
; use this for 3dtvplay if game won't active stereo mode.
; a value of 0 doesn't deactivate this option like on the others but
; forces the application into windowed mode.
;full_screen=1

; some games explicitely disable stereo, prohibiting any stereo attempts.
; settings this to 1 ignores all stereo disabling calls and also calls NvAPI_Stereo_Enable to force stereo on.
;force_stereo=1

; almost all DX11 games deactivate window message handling. 
; setting this to 1 reenables print screen handling, alt-tab key handling etc.
;allow_windowcommands=1


;------------------------------------------------------------------------------------------------------
; Settings for NVidia stereo driver.
;------------------------------------------------------------------------------------------------------
[Stereo]

; games which have their own stereo renderer disable the NVidia automatic 
; stereo mode and render themselves into stereo buffers (Crysis 3 for example). 
; Setting this to 1 disables the game stereo renderer and enables NVidia auto stereo mechanism.
automatic_mode=0

; games without predefined profiles can't save stereo settings. 
; enabling this options automatically creates a profile for unknown games.
create_profile=0

; sets the global surface creation heuristic for NVidia stero driver.
; 0 = NVAPI_STEREO_SURFACECREATEMODE_AUTO - use driver registry profile settings for surface creation mode. 
; 1 = NVAPI_STEREO_SURFACECREATEMODE_FORCESTEREO - Always create stereo surfaces.
; 2 = NVAPI_STEREO_SURFACECREATEMODE_FORCEMONO - Always create mono surfaces. 
;surface_createmode=1

; overrides surface creation mode for square surfaces.
;surface_square_createmode=1


;------------------------------------------------------------------------------------------------------
; Settings for GPU manipulations.
; Render settings override
;------------------------------------------------------------------------------------------------------
[Rendering]

; Setting this option disables scissor limits
rasterizer_disable_scissor=0

; GPU program manipulations.
;
; Shaders in game will be replaced by these custom shaders.
override_directory=ShaderFixes

; Automatically patched shaders will be written here if caching is enabled.
cache_directory=ShaderCache

; thread save data structure access. required on multithreaded rendering.
use_criticalsection=1

; cache all compiled .txt shaders into .bin. this removes loading stalls.
cache_shaders=0

; preload all patched shaders. there's a bug in NVidia auto stereoization if stero shaders
; are being loaded during the game on some HW/SW combinations, which turns off auto patching
; for those stereo shaders (results in partial mono rendering). this is a workaround for this case.
preload_shaders=0

;------------------------------------------------------------------------------------------------------
; Automatic shader fixes. Those settings here apply only on newly read shaders.
; All existing *_replace.txt or *_replace.bin files are not tampered with.
; If you change settings here, the best workflow is to delete all shaders in
; the shader cache directory and let them be fixed again.

; Stereoize all shader parameters with position semantic.
fix_sv_position=0

; Pixel depth evaluation.
;fix_ZRepair_DepthTexture1=SceneDepthTexture.x
;fix_ZRepair_Dependencies1=MinZ_MaxZRatio
;fix_ZRepair_ZPosCalc1=zTex * MinZ_MaxZRatio.z - MinZ_MaxZRatio.w
;fix_ZRepair_DepthTexture2=SceneDepthTexture.x
;fix_ZRepair_Dependencies2=
;fix_ZRepair_ZPosCalc2=zTex
;fix_ZRepair_PositionTexture=PositionTexture
;fix_ZRepair_PositionCalc=1024 * %s

; Inject depth texture if other depth sources are unavailable.
;fix_ZRepair_DepthTextureHash=8a19f087b004598f

; Correct inverse transformations in pixel shaders using evaluated depth.
;fix_InvTransform=ScreenToLight,InverseTranslatedViewProjectionMatrix

; Back projection coordinate fix. 
; 
; Available variables in expressions:
; stereoParams.x = Separation value in range [0..1] or [-0..-1] dependent on active eye
; stereoParams.y = Convergence value in w coordinates (1/z)
; stereoParams.z = -1/1 for left/right eye
; stereoParams.w = Separation value without eye separation
; stereoTune.x = tune value 1 (default is 1)
; stereoTune.y = tune value 2 (default is 1)
; stereoTune.z = tune value 3 (default is 1)
; stereoTune.w = tune value 4 (default is 1)
; stereoScreenRes.x = Primary swap chain backbuffer horizontal resolution
; stereoScreenRes.y = Primary swap chain backbuffer vertical resolution
; zpos = current pixel z position in pixel shader
; wpos = current pixel w position in pixel shader

; Send inverse transformations from vertex shaders to pixel shaders.
;fix_BackProjectionTransform1=ScreenToTranslatedWorldMatrix._m00,ScreenToTranslatedWorldMatrix._m02,ScreenToTranslatedWorldMatrix._m01
;fix_BackProjectionTransform2=ScreenToWorld._m00,ScreenToWorld._m02,ScreenToWorld._m01

; Position variables to correct in pixel shaders.
;fix_ObjectPosition1=PointPositionAndInverseRadius
;fix_ObjectPosition1Multiplier=1, (stereoScreenRes.x/stereoScreenRes.y)*0.5, -0.5
;fix_ObjectPosition2=SpotPositionAndInverseRadius
;fix_ObjectPosition2Multiplier=1, (stereoScreenRes.x/stereoScreenRes.y)*0.5, -0.5

; Matrix multiplications to correct in pixel shaders.
;fix_MatrixOperand1=TranslatedWorldToShadowMatrix
;fix_MatrixOperand1Multiplier=1, (stereoScreenRes.x/stereoScreenRes.y)*0.5 - viewDirection.z*0.05 + (0.02791946-stereoParams.x/stereoParams.w), 0

; autofix shader option: recompiles all vertex shaders. fixes minor differences in deferred rendering.
recompile_all_vs=0
 
;------------------------------------------------------------------------------------------------------
; Analyzation options.
;
; stores all autofixed shaders. this is convenient for caching.
export_fixed=0

; store a copy of all shaders sent to DX11 as ASM text files.
export_shaders=1

; store shaders as HLSL code.
export_hlsl=1

; store a copy of the original shaders as binary files.
export_binary=1

; stores a ShaderUsage.txt file on any marking button press.
dump_usage=1

;------------------------------------------------------------------------------------------------------
; Shader isolation options. 

; XInputDevice activates a XBOX360 controller for input.
;XInputDevice=0

; Use a DirectX input device for input.
Input=Keyboard

; Highlight mode of currently selected shader / rendertarget.
; "skip" = skip shader. don't render anything using the currently selected shader.
; "original" = fall back to original shader if the currently selected shader was patched.
; "mono" = disable stereo for the selected shader / rendertarget.
; "zero" = shader output is all zero. NOTE: this has a big performance impact.
marking_mode=skip

; rotate through all VISIBLE pixel shaders at the current scene.
;next_pixelshader=RIGHT_SHOULDER
;previous_pixelshader=LEFT_SHOULDER
;mark_pixelshader=A

; rotate through all VISIBLE vertex shaders at the current scene.
;next_vertexshader=RightTrigger
;previous_vertexshader=LeftTrigger
;mark_vertexshader=B

; rotate through all USED index buffers at the current scene.
;next_indexbuffer=Y
;previous_indexbuffer=X
;mark_indexbuffer=START

; rotate through all USED render targets at the current scene.
;next_rendertarget=DPAD_UP
;previous_rendertarget=DPAD_DOWN
;mark_rendertarget=LEFT_THUMB

; additional screenshot button
;take_screenshot=BACK

; tunable parameter to use in modified shaders as variable (StereoParams.w)
; enabling tuning results in a small performance hit because the parameter texture
; has to be updated frequently. 
;tune_enable=0
;tune_up=DPAD_RIGHT
;tune_down=DPAD_LEFT

; tune values in stereo texture.
;tune2_up=DPAD_UP
;tune2_down=DPAD_DOWN
;tune3_up=X
;tune3_down=Y

; default parameter value is 1 and the value is incremented and decremented using
; the following step size.
;tune_step=0.05

;------------------------------------------------------------------------------------------------------
; Example keyboard shortcut configuration using keypad
next_pixelshader=Num 2
previous_pixelshader=Num 1
mark_pixelshader=Num 3
next_vertexshader=Num 5
previous_vertexshader=Num 4
mark_vertexshader=Num 6
;next_indexbuffer=Next Track
;previous_indexbuffer=Prev Track
;mark_indexbuffer=Media Stop
;next_rendertarget=Page Down
;previous_rendertarget=Page Up
;mark_rendertarget=Home
take_screenshot=Prnt Scrn
;tune_up=Insert
;tune_down=Delete


;------------------------------------------------------------------------------------------------------
; texture / render target manipulations
;------------------------------------------------------------------------------------------------------
;[TextureOverride1]
;Hash=c3e55ebdb0d20c35
; NVidia stores surface creation mode heuristics in the game profile. setting
; this option overrides the creation mode for a given texture / buffer.
; 0 = NVAPI_STEREO_SURFACECREATEMODE_AUTO - use driver registry profile settings. 
; 1 = NVAPI_STEREO_SURFACECREATEMODE_FORCESTEREO - create stereo surface.
; 2 = NVAPI_STEREO_SURFACECREATEMODE_FORCEMONO - create mono surface.
;StereoMode=2
; advanced option: use this to only override specific iterations of this texture.
;Iteration=1,3,5

;[TextureOverride2]
;...

;------------------------------------------------------------------------------------------------------
; Shader manipulations without patches.
;------------------------------------------------------------------------------------------------------
;[ShaderOverride1]
;Hash=7ca36f0ff0ee6ea9
; Custom stereo separation value while rendering objects using this shader.
;Separation=0
; don't draw anything using this shader.
;Handling=skip
; advanced option: use this to override only specific render iterations.
;Iteration=1,3,5
; advanced option: use this to override only if this shader is used rendering the given index buffer.
;IndexBufferFilter=b3e56ebcb0d20c32


;------------------------------------------------------------------------------------------------------
; Custom stereo settings override
;------------------------------------------------------------------------------------------------------
;[OverrideSettings]

; Example of settings override by mouse button configuration
;Input=Mouse
;Action=Button 1
;Convergence=5.0
;Separation=10

; Example of settings override by keyboard configuration
;Input=Keyboard
;Action=Ctrl
;Convergence=5.0
;Separation=10

; Example of settings override by XBOX360 joypad button presses
;XInputDevice=0
;Action=LeftTrigger
;Convergence=5.0
;Separation=10

; Example of settings override by generic joystick/joypad configuration
;Input=WingMan Cordless Gamepad
;DeviceNr=0
;Action=Button9
;Convergence=5.0
;Separation=10


;------------------------------------------------------------------------------------------------------
; Example of settings override by mouse button configuration
; Mapping of from game provided hard coded convergence values to custom values
; Those are values for L.A. Noir
; Example of settings override by mouse button configuration
;------------------------------------------------------------------------------------------------------
;[ConvergenceMap]

;Map1=from 3e99999a to 0.3
;Map2=from 3f800000 to 1.0
;Map3=from 3f666666 to 0.9