3Dmigoto now open-source...
  32 / 143    
Thanks, bo3b! By the way, the memory leak only happens when hunting mode is enabled (I see you opened an issue in Github about this). With it disabled, I used alt+enter multiple times and VRAM remained steady. I've released the fixes for Zelda OOT here: https://forums.dolphin-emu.org/Thread-zelda-collector-s-edition-hd-texture-pack-v0-4-patch-2-new-dds-link-and-ar-fix If the iniparams issue gets fixed someday, 2 fixes packs will be needed instead of 4.
Thanks, bo3b!

By the way, the memory leak only happens when hunting mode is enabled (I see you opened an issue in Github about this). With it disabled, I used alt+enter multiple times and VRAM remained steady.

I've released the fixes for Zelda OOT here: https://forums.dolphin-emu.org/Thread-zelda-collector-s-edition-hd-texture-pack-v0-4-patch-2-new-dds-link-and-ar-fix

If the iniparams issue gets fixed someday, 2 fixes packs will be needed instead of 4.

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

Posted 08/10/2015 02:12 PM   
Totally not related to Dolphin but related to the memory leak on alt+tabbing: - I saw this thing a while back on Dragon Age: Inquisition as well. If you alt+tab (while shader hunting=1) around 4-5 times and also monitor the RAM usage you will see that at some point your whole RAM is used (in my case 16GB) and stars dumping stuff on the HDD. At some point it will silently crash the game... Now I haven't checked this thing lately and I can't remember if you found the issue there or not... but I just remembered this and maybe it helps you identify the issue easier?:)
Totally not related to Dolphin but related to the memory leak on alt+tabbing:
- I saw this thing a while back on Dragon Age: Inquisition as well. If you alt+tab (while shader hunting=1) around 4-5 times and also monitor the RAM usage you will see that at some point your whole RAM is used (in my case 16GB) and stars dumping stuff on the HDD. At some point it will silently crash the game...

Now I haven't checked this thing lately and I can't remember if you found the issue there or not... but I just remembered this and maybe it helps you identify the issue easier?:)

1x Palit RTX 2080Ti Pro Gaming OC(watercooled and overclocked to hell)
3x 3D Vision Ready Asus VG278HE monitors (5760x1080).
Intel i9 9900K (overclocked to 5.3 and watercooled ofc).
Asus Maximus XI Hero Mobo.
16 GB Team Group T-Force Dark Pro DDR4 @ 3600.
Lots of Disks:
- Raid 0 - 256GB Sandisk Extreme SSD.
- Raid 0 - WD Black - 2TB.
- SanDisk SSD PLUS 480 GB.
- Intel 760p 256GB M.2 PCIe NVMe SSD.
Creative Sound Blaster Z.
Windows 10 x64 Pro.
etc


My website with my fixes and OpenGL to 3D Vision wrapper:
http://3dsurroundgaming.com

(If you like some of the stuff that I've done and want to donate something, you can do it with PayPal at tavyhome@gmail.com)

Posted 08/10/2015 03:22 PM   
[quote=""]Totally not related to Dolphin but related to the memory leak on alt+tabbing: - I saw this thing a while back on Dragon Age: Inquisition as well. If you alt+tab (while shader hunting=1) around 4-5 times and also monitor the RAM usage you will see that at some point your whole RAM is used (in my case 16GB) and stars dumping stuff on the HDD. At some point it will silently crash the game...[/quote] In my case Shadow Warrior and Dolphin filled my VRAM, and after a few more alt+tabbing, they crash, or make the Nvidia drivers crash, or Windows complained about the lack of memory, but the system RAM usage was normal. By the way, with 3Dmigoto in 2D, not only constants don't work. Shader partnering also doesn't work, for example. It made the vertex shader not apply to anything, instead of applying to the defined pixel shader. This gets in my way of fixing precisely a game with 2D backgrounds that should be played in 2D.
said:Totally not related to Dolphin but related to the memory leak on alt+tabbing:
- I saw this thing a while back on Dragon Age: Inquisition as well. If you alt+tab (while shader hunting=1) around 4-5 times and also monitor the RAM usage you will see that at some point your whole RAM is used (in my case 16GB) and stars dumping stuff on the HDD. At some point it will silently crash the game...


In my case Shadow Warrior and Dolphin filled my VRAM, and after a few more alt+tabbing, they crash, or make the Nvidia drivers crash, or Windows complained about the lack of memory, but the system RAM usage was normal.

By the way, with 3Dmigoto in 2D, not only constants don't work. Shader partnering also doesn't work, for example. It made the vertex shader not apply to anything, instead of applying to the defined pixel shader. This gets in my way of fixing precisely a game with 2D backgrounds that should be played 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

Posted 08/10/2015 10:17 PM   
Just posted an update to 3Dmigoto for version 1.2.1. [url]https://github.com/bo3b/3Dmigoto/releases[/url] This version primarily includes a new hash calculation for textures and buffers. If you want to use TextureOverrides, the hash calculation is now completely different and so the hashes themselves will be different. Old fixes using those will not directly work with this new version, which is why we are bumping to 1.2, it's an incompatible change. I think there are only 2 or 3 fixes using this, including FarCry4, Crysis2&3. If it's too inconvenient, it's always OK to use the older version. The new hash is only 32 bits instead of 64, so a bit easier to manage. The hash function for shaders themselves did not change, as there was no advantage there, and plenty of shaders already out there. This will make it easy to tell the difference between hashes, as textures will be shorter. The reason to do this change was to improve the performance of the texture override function, as it was using 2.4% or so of the CPU, almost all in the hash calculation itself. This change uses a hardware based crc32c function that is in all modern processors, and so it's some 30x faster than the old one. With this change, we are now back to using 0.8% of the CPU for 3Dmigoto as measured with performance tools.
Just posted an update to 3Dmigoto for version 1.2.1. https://github.com/bo3b/3Dmigoto/releases


This version primarily includes a new hash calculation for textures and buffers. If you want to use TextureOverrides, the hash calculation is now completely different and so the hashes themselves will be different.

Old fixes using those will not directly work with this new version, which is why we are bumping to 1.2, it's an incompatible change. I think there are only 2 or 3 fixes using this, including FarCry4, Crysis2&3. If it's too inconvenient, it's always OK to use the older version.

The new hash is only 32 bits instead of 64, so a bit easier to manage. The hash function for shaders themselves did not change, as there was no advantage there, and plenty of shaders already out there. This will make it easy to tell the difference between hashes, as textures will be shorter.

The reason to do this change was to improve the performance of the texture override function, as it was using 2.4% or so of the CPU, almost all in the hash calculation itself. This change uses a hardware based crc32c function that is in all modern processors, and so it's some 30x faster than the old one.


With this change, we are now back to using 0.8% of the CPU for 3Dmigoto as measured with performance tools.

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

Posted 08/18/2015 09:20 AM   
Looks like I have to add support for this eventually. Did you consider making it backwards compatible. Basically detect if textureObveride uses old or new hashes and either do the efficient new texture hashing or de old one depending on d3dx.ini. As you mentioned it only affects a few game fixes so not sure if it matters.
Looks like I have to add support for this eventually. Did you consider making it backwards compatible.

Basically detect if textureObveride uses old or new hashes and either do the efficient new texture hashing or de old one depending on d3dx.ini.

As you mentioned it only affects a few game fixes so not sure if it matters.

Thanks to everybody using my assembler it warms my heart.
To have a critical piece of code that everyone can enjoy!
What more can you ask for?

donations: ulfjalmbrant@hotmail.com

Posted 08/18/2015 10:07 AM   
Yes, we considered it, but DarkStarSword and I thought now was a good time to make a clean break there because only a couple of games are using it. If someone decides to revisit those games, it won't be a large burden to replace the TextureOverride. So, I wouldn't worry about the old version, and just go with the new version. The crc32c library code is in the project, and I did not modify the project, so you should be able to just grab those code files and call them. It's basically changing the call from fnv_64_buf for Texture2D, Texture3D, and Buffer to use the append_hw call. You might want to use the superset version of CalcTexture2DDescHash from HackerDevice.cpp, as that includes the code to include the pDesc. Please look for example at CreateTexture2D to be able to exactly match the new texture hash for these. It should be simpler than it was before.
Yes, we considered it, but DarkStarSword and I thought now was a good time to make a clean break there because only a couple of games are using it. If someone decides to revisit those games, it won't be a large burden to replace the TextureOverride.

So, I wouldn't worry about the old version, and just go with the new version. The crc32c library code is in the project, and I did not modify the project, so you should be able to just grab those code files and call them.

It's basically changing the call from fnv_64_buf for Texture2D, Texture3D, and Buffer to use the append_hw call. You might want to use the superset version of CalcTexture2DDescHash from HackerDevice.cpp, as that includes the code to include the pDesc.

Please look for example at CreateTexture2D to be able to exactly match the new texture hash for these. It should be simpler than it was before.

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

Posted 08/18/2015 10:15 PM   
I'm having an issue with a game I'm looking at. I have a number of shaders (4 so far) that get blanked out simply by being in the ShaderFixes directory. When I look in the D3d11 log for the associated shader, it only shows "D:\Origin Games\BFH\wrapper1349(116,3-14): warning X3557: loop only executes for 0 iteration(s), forcing loop to unroll". I'm using the latest 3Dmigoto version (1.2.3) and I tried with hunting off, but no dice. I'm wondering if there's anything else I can try to fix this issue?
I'm having an issue with a game I'm looking at. I have a number of shaders (4 so far) that get blanked out simply by being in the ShaderFixes directory. When I look in the D3d11 log for the associated shader, it only shows "D:\Origin Games\BFH\wrapper1349(116,3-14): warning X3557: loop only executes for 0 iteration(s), forcing loop to unroll". I'm using the latest 3Dmigoto version (1.2.3) and I tried with hunting off, but no dice. I'm wondering if there's anything else I can try to fix this issue?

Dual boot Win 7 x64 & Win 10 (1809) | Geforce Drivers 417.35

Posted 10/12/2015 05:20 PM   
4everAwake..look the wip i send you. The shader for reflection has a manual fix (replace one line) and also in the star wars battlefront we found a similar issue that need manually remove one line (you can look the thread) Upload the shaders here...i think will be similar issue to the previous one i mentioned. Its an specific issue with the wrapper.
4everAwake..look the wip i send you. The shader for reflection has a manual fix (replace one line) and also in the star wars battlefront we found a similar issue that need manually remove one line (you can look the thread)

Upload the shaders here...i think will be similar issue to the previous one i mentioned. Its an specific issue with the wrapper.

MY WEB

Helix Mod - Making 3D Better

My 3D Screenshot Gallery

Like my fixes? you can donate to Paypal: dhr.donation@gmail.com

Posted 10/12/2015 05:50 PM   
Introducing 3DMigoto 1.2.4 with support for copying resources arbitrarily between shaders: https://github.com/bo3b/3Dmigoto/releases/tag/1.2.4 Currently supports copying: - Constant Buffers (<type>s-cb<slot>) - Vertex Buffers (vb<slot>) - Index Buffers (ib) - Stream Output Buffers (so<slot>) - Textures (<type>s-t<slot>) - Render Targets (o<slot>) - Depth Targets (oD) (Unordered Access Views and sampler states not yet supported) I haven't fully documented this in the d3dx.ini yet, but here's a few examples to get you started. Copy constant buffer 1 from the pixel shader to the vertex shader as constant buffer 13 (used in Mad Max to get access to the depth of a light to fix bloom): [code] [ShaderOverrideBloomVS] ; The vertex shader doesn't have access to the light depth, which we need to ; correct the bloom position accurately. The pixel shader does have the depth ; which it uses to calculate the bloom opacity. Bind the relevant constant ; buffer from the pixel shader to the vertex shader so we can get the correct ; depth and fix the position. Hash=e9849e745227d124 vs-cb13 = ps-cb1 [/code] - https://github.com/DarkStarSword/3d-fixes/commit/565daab56d5b4d52aa6aaa9e1b45cf37d03e2492 Copy a constant buffer from one shader to another, using an intermediate resource (used to fix specular highlights and environmental reflections in Unity 5 games): [code] ; Define an intermediate resource to copy between different shaders. Custom ; resources like this start with "Resource": [ResourceUnityPerCameraRare] ; Copy constant buffer 1 from the directional lighting shader into the ; intermediate resource: [ShaderOverrideDirectional] Hash = b78925705424e647 ResourceUnityPerCameraRare = vs-cb1 ; Copy (actually reference) the intermediate resource into the physical ; lighting shader as constant buffer 13: [ShaderOverridePhysical] Hash = ca5cfc8e4d8b1ce5 vs-cb13 = ResourceUnityPerCameraRare [/code] - https://github.com/DarkStarSword/3d-fixes/commit/cacec95fe30661194ef014e1b386bb346dc10118 Copy the currently active depth buffer into a vertex shader (e.g. for automatically adjusting a crosshair depth) - this replaces the experimental depth_input feature, which has been removed: [code] [ShaderOverrideCrosshair] Hash = 07e0f4c1eb997ee1 vs-t110 = oD [/code] Copy a vertex buffer into the shader as a constant buffer (Might be able to look up the position of other vertices?): [code] [ShaderOverrideClippedLight] Hash = 1234 vs-cb12 = vb0 [/code] Copy an active render target into the shader as a texture: [code] [ShaderOverrideClippedTransparency] Hash = abcd ps-t108 = o0 [/code] There's also keywords to control some advanced features. For example, 3DMigoto will try to guess whether it should do a full copy of a resource, or only a lightweight reference, but maybe you want to override this: [code] [ResourceTempStorage] [ShaderOverrideFoo] Hash = foo ; Assigning *to* a temporary resource defaults to copying, but maybe we ; actually want a reference either to get any updates the game makes to the ; original texture, or because we know the resource won't change before we need ; to use it: ResourceTempStorage = reference ps-t0 [ShaderOverrideBar] Hash = bar ; Assigning *from* a temporary resource defaults to reference, but perhaps the ; temporary resource doesn't have the right bind flags for what we are ; assigning it to, or we want it leave it assigned in this slot while ; preventing it from getting updated if the game changes the original: ps-t110 = copy ResourceTempStorage [/code] By default, if you try to copy something that wasn't bound, 3DMigoto will unbind the destination as well. But, perhaps the resource you are copying is only bound some of the time, and if it is not bound you want to leave whatever was previously bound in the destination alone: [code] [ShaderOverrideBaz] Hash = baz ps-t50 = o2 unless_null [/code] Or, perhaps you just want to unbind something from the pipeline for some reason (like influencing driver heuristics?): [code] [ShaderOverrideRubbish] Hash = rubbish o0 = null [/code] All this code is very new and there might still be bugs or memory leaks. If you can think of something this might be useful for, please give it a try and see what happens :)
Introducing 3DMigoto 1.2.4 with support for copying resources arbitrarily between shaders:
https://github.com/bo3b/3Dmigoto/releases/tag/1.2.4

Currently supports copying:
- Constant Buffers (<type>s-cb<slot>)
- Vertex Buffers (vb<slot>)
- Index Buffers (ib)
- Stream Output Buffers (so<slot>)
- Textures (<type>s-t<slot>)
- Render Targets (o<slot>)
- Depth Targets (oD)

(Unordered Access Views and sampler states not yet supported)

I haven't fully documented this in the d3dx.ini yet, but here's a few examples to get you started.

Copy constant buffer 1 from the pixel shader to the vertex shader as constant buffer 13 (used in Mad Max to get access to the depth of a light to fix bloom):
[ShaderOverrideBloomVS]
; The vertex shader doesn't have access to the light depth, which we need to
; correct the bloom position accurately. The pixel shader does have the depth
; which it uses to calculate the bloom opacity. Bind the relevant constant
; buffer from the pixel shader to the vertex shader so we can get the correct
; depth and fix the position.
Hash=e9849e745227d124
vs-cb13 = ps-cb1

- https://github.com/DarkStarSword/3d-fixes/commit/565daab56d5b4d52aa6aaa9e1b45cf37d03e2492

Copy a constant buffer from one shader to another, using an intermediate resource (used to fix specular highlights and environmental reflections in Unity 5 games):
; Define an intermediate resource to copy between different shaders. Custom
; resources like this start with "Resource":
[ResourceUnityPerCameraRare]

; Copy constant buffer 1 from the directional lighting shader into the
; intermediate resource:
[ShaderOverrideDirectional]
Hash = b78925705424e647
ResourceUnityPerCameraRare = vs-cb1

; Copy (actually reference) the intermediate resource into the physical
; lighting shader as constant buffer 13:
[ShaderOverridePhysical]
Hash = ca5cfc8e4d8b1ce5
vs-cb13 = ResourceUnityPerCameraRare

- https://github.com/DarkStarSword/3d-fixes/commit/cacec95fe30661194ef014e1b386bb346dc10118

Copy the currently active depth buffer into a vertex shader (e.g. for automatically adjusting a crosshair depth) - this replaces the experimental depth_input feature, which has been removed:
[ShaderOverrideCrosshair]
Hash = 07e0f4c1eb997ee1
vs-t110 = oD


Copy a vertex buffer into the shader as a constant buffer (Might be able to look up the position of other vertices?):
[ShaderOverrideClippedLight]
Hash = 1234
vs-cb12 = vb0


Copy an active render target into the shader as a texture:
[ShaderOverrideClippedTransparency]
Hash = abcd
ps-t108 = o0


There's also keywords to control some advanced features. For example, 3DMigoto will try to guess whether it should do a full copy of a resource, or only a lightweight reference, but maybe you want to override this:
[ResourceTempStorage]
[ShaderOverrideFoo]
Hash = foo
; Assigning *to* a temporary resource defaults to copying, but maybe we
; actually want a reference either to get any updates the game makes to the
; original texture, or because we know the resource won't change before we need
; to use it:
ResourceTempStorage = reference ps-t0

[ShaderOverrideBar]
Hash = bar
; Assigning *from* a temporary resource defaults to reference, but perhaps the
; temporary resource doesn't have the right bind flags for what we are
; assigning it to, or we want it leave it assigned in this slot while
; preventing it from getting updated if the game changes the original:
ps-t110 = copy ResourceTempStorage


By default, if you try to copy something that wasn't bound, 3DMigoto will unbind the destination as well. But, perhaps the resource you are copying is only bound some of the time, and if it is not bound you want to leave whatever was previously bound in the destination alone:
[ShaderOverrideBaz]
Hash = baz
ps-t50 = o2 unless_null


Or, perhaps you just want to unbind something from the pipeline for some reason (like influencing driver heuristics?):
[ShaderOverrideRubbish]
Hash = rubbish
o0 = null


All this code is very new and there might still be bugs or memory leaks. If you can think of something this might be useful for, please give it a try and see what happens :)

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

Posted 10/12/2015 07:59 PM   
[quote="DarkStarSword"] Copy the currently active depth buffer into a vertex shader (e.g. for automatically adjusting a crosshair depth) - this replaces the experimental depth_input feature, which has been removed: [code] [ShaderOverrideCrosshair] Hash = 07e0f4c1eb997ee1 vs-t110 = oD [/code] [/quote] Can you extend a little more this feature....how to use in a shader and what's all the info. With this we can implement dynamics crosshair...yeaaah!!
DarkStarSword said:
Copy the currently active depth buffer into a vertex shader (e.g. for automatically adjusting a crosshair depth) - this replaces the experimental depth_input feature, which has been removed:
[ShaderOverrideCrosshair]
Hash = 07e0f4c1eb997ee1
vs-t110 = oD


Can you extend a little more this feature....how to use in a shader and what's all the info.
With this we can implement dynamics crosshair...yeaaah!!

MY WEB

Helix Mod - Making 3D Better

My 3D Screenshot Gallery

Like my fixes? you can donate to Paypal: dhr.donation@gmail.com

Posted 10/12/2015 08:28 PM   
There's a few pieces you need to get an auto crosshair working, and you will need to adjust it for each game. [size="L"][center][b][color="green"]Step 1: Copy the depth buffer[/color][/b][/center][/size] Firstly, you will need to get access to the depth buffer in the crosshair's vertex shader, which you can use the new resource copying feature for. [size="M"][b][color="green"]Option 1: Simple[/color][/b][/size] If the game leaves the depth buffer assigned while it is drawing UI elements, you can simply do this to copy it to texture 110 in the vertex shader: [code] [ShaderOverrideCrosshair] Hash = ... vs-t110 = oD [/code] This may or may not work in a given game. You can use frame analysis to dump out the depth buffer for this shader to check, or just try it and see. There may also be some other problems with this method in terms of performance or vram usage as this will cause a full copy every time this shader is encountered. This is likely to happen multiple times in a frame, and if you are adjusting the entire UI you may end up with copies performed for each UI element (eating performance), and copies hanging around for each unique UI shader (consuming vram). Resource renaming (a hardware feature to trade off vram for performance) may also cause more vram to be consumed than we would naively expect. This should be fairly well contained though - if you see ram or vram usage continue to increase without limit while using this feature let me know as that may signify be a bug (which is entirely possible as this is all very new code). [size="M"][b][color="green"]Option 2: Reduced copies, better performance, less vram usage[/color][/b][/size] You can limit the number of copies to once per frame for a given resource to eliminate these issues, though it uses slightly different code: [code] [ResourceDepthBuffer] max_copies_per_frame=1 [ShaderOverrideCrosshair] Hash = ... ; Since we are limiting the number of copies, use the 'unless_null' keyword to ; make sure we don't end up with a blank buffer if some draw call doesn't have ; a depth buffer bound: ResourceDepthBuffer = oD unless_null vs-t110 = ResourceDepthBuffer [/code] The idea there is that a depth buffer will only be copied to ResourceDepthBuffer the first time a UI shader is encountered in a frame, eliminating excess copies and reducing the performance overhead. Using an intermediate resource means we can get this benefit even if multiple UI shaders are used. The "copy" of the temporary resource to a texture happens by reference (by default), so there is no overhead there. Edit: Supported in 3DMigoto 1.2.5. Added 'unless_null' keyword. [size="M"][b][color="green"]Option 3: Copy from another shader (may make step 5 easier)[/color][/b][/size] If the depth buffer is not assigned when the UI shader is drawn you can't just copy it directly and will need to copy it from a separate shader. This should not be too difficult as the depth buffer is typically available all over the place. You might even be able to find a version that has been pre-scaled to world coordinates (a "W-buffer"), which will make step 5 trivial. e.g. you might copy it out of a shadow shader: [code] [ResourceDepthBuffer] [ShaderOverrideShadow] Hash = ... ; There's a good chance that copying by reference will work as we are copying a ; texture for use in a texture slot (same type of binding), and if it works this ; will save us the copy and extra storage: ResourceDepthBuffer = reference ps-t0 ; But if it doesn't work (maybe the game overwrites the texture afterwards), ; use a full copy instead, which is the default when copying to a temporary ; resource so we don't need to explicitly say so: ;ResourceDepthBuffer = ps-t0 [ShaderOverrideCrosshair] Hash = ... vs-t110 = ResourceDepthBuffer [/code] or perhaps you have found (using frame analysis) a shader run once at the start of post processing that renders the depth buffer to a render target (seems to be fairly common): [code] [ResourceDepthBuffer] [ShaderOverridePostProcessingDepthBuffer] Hash = ... ; Unlike the above we almost certainly need to do a full copy here as we are ; copying a render target for use in a texture, which are different types of ; bindings (unless the game created the texture with both bind flags, which is ; unlikely). This is the default behaviour when copying to a temporary ; resource, so we don't need to explicitly say so: ; ; Since we are copying a render target we want to wait until after the draw ; call has finished before we copy it, which requires the "post" keyword ; introduced in 3DMigoto 1.2.5: post ResourceDepthBuffer = o0 [ShaderOverrideCrosshair] Hash = ... vs-t110 = ResourceDepthBuffer [/code] Edit: Added post keyword in 3DMigoto 1.2.5 to copy render targets after the draw call [size="L"][center][b][color="green"]Step 2: Declare the copied depth buffer[/color][/b][/center][/size] Once you have the depth buffer copied into the vertex shader you need to add this declaration to the top, adjusting register(t110) to match whichever texture slot you copied the depth buffer to: [code] // Depth buffer copied to this input with 3Dmigoto: Texture2D<float> DepthBuffer : register(t110); [/code] Note that if you copied the resource from another texture (as opposed to a depth buffer) you should use the same declaration as the shader you copied it from (except for the register number). If you copied it from another render target you may also need to change float to float4 to match the oN register in the original pixel shader. If either of these mean using a float2/float3/float4 you may also need to adjust which channel the depth is read from where it is used below. [size="L"][center][b][color="green"]Step 3: Copy and paste the auto crosshair code[/color][/b][/center][/size] Then, you will want to paste this code into the shader before the main() function. You will need to change some things (either near & far, or the scaling applied in world_z_from_depth_buffer), but we will come back to that: [code] static const float near = 0.1; static const float far = 40000; float world_z_from_depth_buffer(float x, float y) { uint width, height; float z; DepthBuffer.GetDimensions(width, height); x = min(max((x / 2 + 0.5) * width, 0), width - 1); y = min(max((-y / 2 + 0.5) * height, 0), height - 1); z = DepthBuffer.Load(int3(x, y, 0)); if (z == 1) return 0; // Derive world Z from depth buffer. This is a kluge since I don't know // the correct scaling, and the Z buffer seems to be (1 - what I expected). // Might be able to determine the correct way to scale it from other shaders. return far*near/(((1-z)*near) + (far*z)); } float adjust_from_depth_buffer(float x, float y) { float4 stereo = StereoParams.Load(0); float separation = stereo.x; float convergence = stereo.y; float old_offset, offset, w, sampled_w, distance; uint i; // Stereo cursor: To improve the accuracy of the stereo cursor, we // sample a number of points on the depth buffer, starting at the near // clipping plane and working towards original x + separation. // // You can think of this as a line in three dimensional space that // starts at each eye and stretches out towards infinity. We sample 255 // points along this line (evenly spaced in the X axis) and compare // with the depth buffer to find where the line is first intersected. // // Note: The reason for sampling 255 points came from a restriction in // DX9/SM3 where loops had to run a constant number of iterations and // there was no way to set that number from within the shader itself. // I'm not sure if the same restriction applies in DX11 with SM4/5 - if // it doesn't, we could change this to check each pixel instead for // better accuracy. // // Based on DarkStarSword's stereo crosshair code originally developed // for Miasmata, adapted to Unity, then translated to HLSL. offset = (near - convergence) * separation; // Z = X offset from center distance = separation - offset; // Total distance to cover (separation - starting X offset) old_offset = offset; for (i = 0; i < 255; i++) { offset += distance / 255.0; // Calculate depth for this point on the line: w = (separation * convergence) / (separation - offset); sampled_w = world_z_from_depth_buffer(x + offset, y); if (sampled_w == 0) return 0; // If the sampled depth is closer than the calculated depth, // we have found something that intersects the line, so exit // the loop and return the last point that was not intersected: if (w > sampled_w) break; old_offset = offset; } return old_offset; } [/code] [size="L"][center][b][color="green"]Step 4: Hook up the auto crosshair code[/color][/b][/center][/size] [size="M"][b][color="green"]Option 1: Adjust based on the center of the screen[/color][/b][/size] Then, somewhere in the body of the code you call this function and pass it the coordinates on the depth buffer you want to check. For example, if you are adjusting a crosshair you probably want to sample around the center of the screen (0,0): [code] o0.x += adjust_from_depth_buffer(0, 0); [/code] This assumes that o0.w == 1 and the UI element was being displayed at screen depth originally. If that is not the case, you would need to change the adjustment to compensate (e.g. by multiplying by o0.w, and/or subtracting the nvidia formula and/or normalising the coordinate so that it is at depth==1 or depth==convergence) - standard UI adjustment stuff. [size="M"][b][color="green"]Option 2: Adjust each UI element separately[/color][/b][/size] I've generally found it's simpler to adjust the whole UI to the crosshair depth, or better to only adjust the crosshair, but if you wanted to experiment with automatically adjust the entire UI you could do something like this to adjust each vertex individually. The result looks very similar to how the UI appears in compatibility mode, with the UI distorted over the geometry, so I don't necessarily recommend this: [code] o0.x += adjust_from_depth_buffer(o0.x, o0.y); [/code] You might also experiment with finding a consistent point to sample for a given UI element. You might be able to multiply a point at the origin (or some fixed offset) by the MVP matrix passed to the shader to find a point that will be consistent for all corners, or perhaps you could copy a vertex buffer in to look up the coordinates of other vertices (I haven't tried this yet). [size="L"][center][b][color="green"]Step 5: Figure out the right scaling[/color][/b][/center][/size] Finally, you will need to figure out the correct way to scale a value from the depth buffer to world Z for this particular game, and the right answer here will vary depending on the game. [size="M"][b][color="green"]Option 1: Adjust near + far clipping planes[/color][/b][/size] A simple way that might work is to find or guess the values of the near and far clipping planes and adjust the definitions at the top of the code. You might be able to find these in a constant buffer somewhere and use them directly or dump them out using frame analysis to find their values and hardcode them (which will only work if they don't change during the game - check a few levels & cutscenes to make sure they are ok). You can also use the convergence to guess these - find something in the game that clips through the camera (or failing that is as close to the camera as possible), then adjust the convergence to put the point it clips at screen depth. At that point the convergence will be an upper bound for the near clipping plane. Then, find something far away (like a mountain, but probably not the sky box) and adjust convergence until that is at screen depth, which will give you a lower bound for the far clipping plane. Plug those values into the code, then use trial and error to tune them until the crosshair rests on whatever you are aiming at. If this is totally not working it may be that the game is fundamentally scaling their depth buffer differently (e.g. linear vs exponential), and the formula in world_z_from_depth_buffer() may need to be adjusted (the above one works in Witcher 3 and Mad Max). [size="M"][b][color="green"]Option 2: Do what the game does[/color][/b][/size] A better way is to look at other places the game uses the depth buffer to calculate a world coordinate (such as in most deferred lighting shaders) and replace the "return far*near/..." line in the world_z_from_depth_buffer() function with code that does the same scaling as the game. You may find you also need to some values which may or may not already be available in the crosshair shader - if they aren't you can copy them in, or use frame analysis to dump them out and hardcode them (which will only work if they don't change during the game). [size="M"][b][color="green"]Option 3: Revisit step 1[/color][/b][/size] The game may have a pre-scaled copy of the depth buffer available somewhere (a "W-buffer"), allowing you to use it's values directly with no scaling whatsoever. This won't be available if you copied a depth buffer from oD, so you may wish to go back to step 1 and look for alternative sources of depth information. e.g. in The Witcher 3 the first shader run during post-processing scales the Z-buffer into a W-buffer, so using it allows us to skip scaling it ourselves: [code] [ResourceWBuffer] [ShaderOverrideHBAODepthPass] Hash = 170486ed36efcc9e ; This shader converts the Z buffer into a W buffer. Save it off for later use ; in HUD shaders: post ResourceWBuffer = o0 [/code]
There's a few pieces you need to get an auto crosshair working, and you will need to adjust it for each game.

Step 1: Copy the depth buffer

Firstly, you will need to get access to the depth buffer in the crosshair's vertex shader, which you can use the new resource copying feature for.

Option 1: Simple
If the game leaves the depth buffer assigned while it is drawing UI elements, you can simply do this to copy it to texture 110 in the vertex shader:
[ShaderOverrideCrosshair]
Hash = ...
vs-t110 = oD


This may or may not work in a given game. You can use frame analysis to dump out the depth buffer for this shader to check, or just try it and see.

There may also be some other problems with this method in terms of performance or vram usage as this will cause a full copy every time this shader is encountered. This is likely to happen multiple times in a frame, and if you are adjusting the entire UI you may end up with copies performed for each UI element (eating performance), and copies hanging around for each unique UI shader (consuming vram). Resource renaming (a hardware feature to trade off vram for performance) may also cause more vram to be consumed than we would naively expect. This should be fairly well contained though - if you see ram or vram usage continue to increase without limit while using this feature let me know as that may signify be a bug (which is entirely possible as this is all very new code).

Option 2: Reduced copies, better performance, less vram usage
You can limit the number of copies to once per frame for a given resource to eliminate these issues, though it uses slightly different code:
[ResourceDepthBuffer]
max_copies_per_frame=1

[ShaderOverrideCrosshair]
Hash = ...
; Since we are limiting the number of copies, use the 'unless_null' keyword to
; make sure we don't end up with a blank buffer if some draw call doesn't have
; a depth buffer bound:
ResourceDepthBuffer = oD unless_null
vs-t110 = ResourceDepthBuffer

The idea there is that a depth buffer will only be copied to ResourceDepthBuffer the first time a UI shader is encountered in a frame, eliminating excess copies and reducing the performance overhead. Using an intermediate resource means we can get this benefit even if multiple UI shaders are used. The "copy" of the temporary resource to a texture happens by reference (by default), so there is no overhead there.

Edit: Supported in 3DMigoto 1.2.5. Added 'unless_null' keyword.

Option 3: Copy from another shader (may make step 5 easier)
If the depth buffer is not assigned when the UI shader is drawn you can't just copy it directly and will need to copy it from a separate shader. This should not be too difficult as the depth buffer is typically available all over the place. You might even be able to find a version that has been pre-scaled to world coordinates (a "W-buffer"), which will make step 5 trivial.

e.g. you might copy it out of a shadow shader:
[ResourceDepthBuffer]
[ShaderOverrideShadow]
Hash = ...
; There's a good chance that copying by reference will work as we are copying a
; texture for use in a texture slot (same type of binding), and if it works this
; will save us the copy and extra storage:
ResourceDepthBuffer = reference ps-t0
; But if it doesn't work (maybe the game overwrites the texture afterwards),
; use a full copy instead, which is the default when copying to a temporary
; resource so we don't need to explicitly say so:
;ResourceDepthBuffer = ps-t0

[ShaderOverrideCrosshair]
Hash = ...
vs-t110 = ResourceDepthBuffer


or perhaps you have found (using frame analysis) a shader run once at the start of post processing that renders the depth buffer to a render target (seems to be fairly common):
[ResourceDepthBuffer]
[ShaderOverridePostProcessingDepthBuffer]
Hash = ...
; Unlike the above we almost certainly need to do a full copy here as we are
; copying a render target for use in a texture, which are different types of
; bindings (unless the game created the texture with both bind flags, which is
; unlikely). This is the default behaviour when copying to a temporary
; resource, so we don't need to explicitly say so:
;
; Since we are copying a render target we want to wait until after the draw
; call has finished before we copy it, which requires the "post" keyword
; introduced in 3DMigoto 1.2.5:
post ResourceDepthBuffer = o0

[ShaderOverrideCrosshair]
Hash = ...
vs-t110 = ResourceDepthBuffer

Edit: Added post keyword in 3DMigoto 1.2.5 to copy render targets after the draw call

Step 2: Declare the copied depth buffer

Once you have the depth buffer copied into the vertex shader you need to add this declaration to the top, adjusting register(t110) to match whichever texture slot you copied the depth buffer to:
// Depth buffer copied to this input with 3Dmigoto:
Texture2D<float> DepthBuffer : register(t110);

Note that if you copied the resource from another texture (as opposed to a depth buffer) you should use the same declaration as the shader you copied it from (except for the register number). If you copied it from another render target you may also need to change float to float4 to match the oN register in the original pixel shader. If either of these mean using a float2/float3/float4 you may also need to adjust which channel the depth is read from where it is used below.

Step 3: Copy and paste the auto crosshair code

Then, you will want to paste this code into the shader before the main() function. You will need to change some things (either near & far, or the scaling applied in world_z_from_depth_buffer), but we will come back to that:
static const float near = 0.1;
static const float far = 40000;

float world_z_from_depth_buffer(float x, float y)
{
uint width, height;
float z;

DepthBuffer.GetDimensions(width, height);

x = min(max((x / 2 + 0.5) * width, 0), width - 1);
y = min(max((-y / 2 + 0.5) * height, 0), height - 1);
z = DepthBuffer.Load(int3(x, y, 0));
if (z == 1)
return 0;

// Derive world Z from depth buffer. This is a kluge since I don't know
// the correct scaling, and the Z buffer seems to be (1 - what I expected).
// Might be able to determine the correct way to scale it from other shaders.
return far*near/(((1-z)*near) + (far*z));
}

float adjust_from_depth_buffer(float x, float y)
{
float4 stereo = StereoParams.Load(0);
float separation = stereo.x; float convergence = stereo.y;
float old_offset, offset, w, sampled_w, distance;
uint i;

// Stereo cursor: To improve the accuracy of the stereo cursor, we
// sample a number of points on the depth buffer, starting at the near
// clipping plane and working towards original x + separation.
//
// You can think of this as a line in three dimensional space that
// starts at each eye and stretches out towards infinity. We sample 255
// points along this line (evenly spaced in the X axis) and compare
// with the depth buffer to find where the line is first intersected.
//
// Note: The reason for sampling 255 points came from a restriction in
// DX9/SM3 where loops had to run a constant number of iterations and
// there was no way to set that number from within the shader itself.
// I'm not sure if the same restriction applies in DX11 with SM4/5 - if
// it doesn't, we could change this to check each pixel instead for
// better accuracy.
//
// Based on DarkStarSword's stereo crosshair code originally developed
// for Miasmata, adapted to Unity, then translated to HLSL.

offset = (near - convergence) * separation; // Z = X offset from center
distance = separation - offset; // Total distance to cover (separation - starting X offset)

old_offset = offset;
for (i = 0; i < 255; i++) {
offset += distance / 255.0;

// Calculate depth for this point on the line:
w = (separation * convergence) / (separation - offset);

sampled_w = world_z_from_depth_buffer(x + offset, y);
if (sampled_w == 0)
return 0;

// If the sampled depth is closer than the calculated depth,
// we have found something that intersects the line, so exit
// the loop and return the last point that was not intersected:
if (w > sampled_w)
break;

old_offset = offset;
}

return old_offset;
}


Step 4: Hook up the auto crosshair code

Option 1: Adjust based on the center of the screen
Then, somewhere in the body of the code you call this function and pass it the coordinates on the depth buffer you want to check. For example, if you are adjusting a crosshair you probably want to sample around the center of the screen (0,0):
o0.x += adjust_from_depth_buffer(0, 0);

This assumes that o0.w == 1 and the UI element was being displayed at screen depth originally. If that is not the case, you would need to change the adjustment to compensate (e.g. by multiplying by o0.w, and/or subtracting the nvidia formula and/or normalising the coordinate so that it is at depth==1 or depth==convergence) - standard UI adjustment stuff.

Option 2: Adjust each UI element separately
I've generally found it's simpler to adjust the whole UI to the crosshair depth, or better to only adjust the crosshair, but if you wanted to experiment with automatically adjust the entire UI you could do something like this to adjust each vertex individually. The result looks very similar to how the UI appears in compatibility mode, with the UI distorted over the geometry, so I don't necessarily recommend this:
o0.x += adjust_from_depth_buffer(o0.x, o0.y);

You might also experiment with finding a consistent point to sample for a given UI element. You might be able to multiply a point at the origin (or some fixed offset) by the MVP matrix passed to the shader to find a point that will be consistent for all corners, or perhaps you could copy a vertex buffer in to look up the coordinates of other vertices (I haven't tried this yet).


Step 5: Figure out the right scaling

Finally, you will need to figure out the correct way to scale a value from the depth buffer to world Z for this particular game, and the right answer here will vary depending on the game.

Option 1: Adjust near + far clipping planes
A simple way that might work is to find or guess the values of the near and far clipping planes and adjust the definitions at the top of the code. You might be able to find these in a constant buffer somewhere and use them directly or dump them out using frame analysis to find their values and hardcode them (which will only work if they don't change during the game - check a few levels & cutscenes to make sure they are ok).

You can also use the convergence to guess these - find something in the game that clips through the camera (or failing that is as close to the camera as possible), then adjust the convergence to put the point it clips at screen depth. At that point the convergence will be an upper bound for the near clipping plane. Then, find something far away (like a mountain, but probably not the sky box) and adjust convergence until that is at screen depth, which will give you a lower bound for the far clipping plane. Plug those values into the code, then use trial and error to tune them until the crosshair rests on whatever you are aiming at.

If this is totally not working it may be that the game is fundamentally scaling their depth buffer differently (e.g. linear vs exponential), and the formula in world_z_from_depth_buffer() may need to be adjusted (the above one works in Witcher 3 and Mad Max).

Option 2: Do what the game does
A better way is to look at other places the game uses the depth buffer to calculate a world coordinate (such as in most deferred lighting shaders) and replace the "return far*near/..." line in the world_z_from_depth_buffer() function with code that does the same scaling as the game. You may find you also need to some values which may or may not already be available in the crosshair shader - if they aren't you can copy them in, or use frame analysis to dump them out and hardcode them (which will only work if they don't change during the game).

Option 3: Revisit step 1
The game may have a pre-scaled copy of the depth buffer available somewhere (a "W-buffer"), allowing you to use it's values directly with no scaling whatsoever. This won't be available if you copied a depth buffer from oD, so you may wish to go back to step 1 and look for alternative sources of depth information.

e.g. in The Witcher 3 the first shader run during post-processing scales the Z-buffer into a W-buffer, so using it allows us to skip scaling it ourselves:
[ResourceWBuffer]
[ShaderOverrideHBAODepthPass]
Hash = 170486ed36efcc9e
; This shader converts the Z buffer into a W buffer. Save it off for later use
; in HUD shaders:
post ResourceWBuffer = o0

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

Posted 10/13/2015 02:53 AM   
Thanks DarkStarSword!! great info....i will have to read 2 or 3 more times..jejeje
Thanks DarkStarSword!! great info....i will have to read 2 or 3 more times..jejeje

MY WEB

Helix Mod - Making 3D Better

My 3D Screenshot Gallery

Like my fixes? you can donate to Paypal: dhr.donation@gmail.com

Posted 10/13/2015 08:10 PM   
[quote="DHR"]4everAwake..look the wip i send you. The shader for reflection has a manual fix (replace one line) and also in the star wars battlefront we found a similar issue that need manually remove one line (you can look the thread) Upload the shaders here...i think will be similar issue to the previous one i mentioned. Its an specific issue with the wrapper.[/quote] I looked at the example in the Battlefront thread. I know there's a line you have to disable, but I was unable to determine which line it is with this shader: [code] cbuffer _Globals : register(b0) { float3 g_cameraPos : packoffset(c0); float2 g_invScreenSize : packoffset(c1); float4x4 g_invViewProjMatrix : packoffset(c2); float4 g_cloudOffsetAndScale : packoffset(c6); float4 g_cloudCoverageExponentAndFade : packoffset(c7); float3 g_lightDir : packoffset(c8); float4 g_keyColor : packoffset(c9); float4 g_keyTranslucencyParams : packoffset(c10); float4 g_subParams : packoffset(c11); float4 g_envmapParams : packoffset(c12); float g_skyEnvmap8BitTexInvScale : packoffset(c13); float g_colorScale : packoffset(c13.y); float4 g_envmapsMipmapCount : packoffset(c14); } SamplerState g_cloudShadowSampler_s : register(s0); SamplerState g_skyEnvmapSampler_s : register(s1); SamplerState g_customSampler_s : register(s2); SamplerState g_ssaoSampler_s : register(s3); Texture2D<float4> g_cloudShadowTexture : register(t0); TextureCube<float4> g_skyEnvmap : register(t1); TextureCube<float4> g_customEnvmap : register(t2); Texture2D<float4> g_ssaoTexture : register(t3); Texture2DMS<float4,2> g_depthTexture : register(t4); Texture2DMS<float4,2> g_gbufferTexture0 : register(t5); Texture2DMS<float4,2> g_gbufferTexture1 : register(t6); Texture2DMS<float4,2> g_gbufferTexture2 : register(t7); Texture2DMS<float4,2> g_gbufferTexture3 : register(t8); Texture2DMS<float4,2> g_gbufferTexture4 : register(t9); Texture2DMS<float4,2> g_gbufferTexture5 : register(t10); Texture2DMS<float4> g_shadowAccumTexture : register(t11); Texture2D<float> g_msaaClassifyTexture : register(t12); Texture2D<float4> StereoParams : register(t125); Texture1D<float4> IniParams : register(t120); void main( float4 v0 : SV_Position0, out float4 o0 : SV_Target0, out float4 o1 : SV_Target1) { const float4 icb[] = { { 0.250000, 0, 0, 0}, { -0.250000, 0, 0, 0} }; float4 r0,r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11,r12,r13,r14,r15,r16,r17,r18,r19,r20,r21,r22,r23,r24; uint4 bitmask, uiDest; float4 fDest; r0.xy = (int2)v0.xy; r1.xy = g_invScreenSize.xy * v0.xy; r0.zw = float2(0,0); r1.z = g_msaaClassifyTexture.Load(r0.xyw).x; r1.z = 0 < r1.z; r1.zw = r1.zz ? float2(2.80259693e-045,0.499999493) : float2(1.40129846e-045,0.999998987); r2.x = 1 + -g_envmapParams.w; r2.yz = trunc(g_envmapsMipmapCount.xy); r3.w = 1; r4.xyz = float3(0,0,0); r5.xyz = float3(0,0,0); r2.w = 0; while (true) { r4.w = (int)r2.w >= (int)r1.z; if (r4.w != 0) break; r6.xy = icb[r2.w+0].xx * g_invScreenSize.xy + r1.xy; r7.xyzw = g_gbufferTexture0.Load(r0.xy, r2.w).xyzw; r8.xyzw = g_gbufferTexture1.Load(r0.xy, r2.w).xyzw; r9.xyzw = g_gbufferTexture2.Load(r0.xy, r2.w).yxzw; r10.xyz = g_gbufferTexture3.Load(r0.xy, r2.w).xyz; r3.z = g_depthTexture.Load(r0.xy, r2.w).x; r4.w = 255 * r9.w; r4.w = round(r4.w); r4.w = (int)r4.w; r11.xyzw = r8.xyzw * r8.xyzw; r12.xyzw = (int4)r4.wwww == int4(1,5,6,4); if (r12.x != 0) { r13.xyz = r11.www * r11.xyz; } else { r13.xyz = r11.www; } r5.w = 0 < r13.x; r5.w = r5.w ? r7.w : 0; r6.z = (int)r12.z | (int)r12.y; r6.w = (int)r9.x & (int)r6.z; r7.w = log2(abs(r9.y)); r7.w = g_envmapParams.z * r7.w; r7.w = exp2(r7.w); r7.xyz = r7.xyz * float3(2,2,2) + float3(-1,-1,-1); r8.w = dot(r7.xyz, r7.xyz); r8.w = rsqrt(r8.w); r7.xyz = r8.www * r7.xyz; r6.xy = r6.xy * float2(2,2) + float2(-1,-1); r3.xy = float2(1,-1) * r6.xy; r14.x = dot(r3.xyzw, g_invViewProjMatrix._m00_m10_m20_m30); r14.y = dot(r3.xyzw, g_invViewProjMatrix._m01_m11_m21_m31); r14.z = dot(r3.xyzw, g_invViewProjMatrix._m02_m12_m22_m32); r3.x = dot(r3.xyzw, g_invViewProjMatrix._m03_m13_m23_m33); r3.x = 1 / r3.x; r14.xzw = r14.xzy * r3.xxx; r3.y = dot(-r14.xzw, -r14.xzw); r3.y = rsqrt(r3.y); r15.xyz = -r14.xwz * r3.yyy; r3.z = g_shadowAccumTexture.Load(r0.xy, r2.w).x; r3.x = r14.y * r3.x + g_cameraPos.y; r6.xy = g_lightDir.xz * r3.xx; r6.xy = r6.xy * g_cloudOffsetAndScale.ww + r14.xz; r6.xy = r6.xy * g_cloudOffsetAndScale.zz + g_cloudOffsetAndScale.xy; r3.x = g_cloudShadowTexture.SampleLevel(g_cloudShadowSampler_s, r6.xy, 0).x; r3.x = saturate(g_cloudCoverageExponentAndFade.x + r3.x); r3.x = log2(r3.x); r3.x = g_cloudCoverageExponentAndFade.y * r3.x; r3.x = exp2(r3.x); r6.x = dot(r14.xzw, r14.xzw); r6.x = sqrt(r6.x); r6.x = -g_cloudCoverageExponentAndFade.z + r6.x; r6.x = saturate(g_cloudCoverageExponentAndFade.w * r6.x); r6.x = r6.x * r6.x; r6.y = 1 + -r3.x; r3.x = r6.x * r6.y + r3.x; r3.x = r3.z * r3.x; r3.z = dot(r7.xyz, g_lightDir.xyz); r6.x = saturate(r3.z); r16.xyz = g_keyColor.xyz * r6.xxx; r17.xyz = r16.xyz * r3.xxx; if (r12.w != 0) { r18.xyzw = g_gbufferTexture4.Load(r0.xy, r2.w).xyzw; r19.xyzw = g_gbufferTexture5.Load(r0.xy, r2.w).xyzw; r6.y = r5.w * 12 + 1; r6.y = exp2(r6.y); r12.yw = r6.yy * float2(1.44299996,1.44299996) + float2(1.44299996,9.44299984); r18.xyz = r18.xyz * float3(2,2,2) + float3(-1,-1,-1); r6.y = dot(r18.xyz, r18.xyz); r6.y = rsqrt(r6.y); r18.xyz = r18.xyz * r6.yyy; r6.y = 65535 * r18.w; r6.y = round(r6.y); r8.w = 0.00390625 * r6.y; r8.w = trunc(r8.w); r6.y = r6.y * 0.00390625 + -r8.w; r6.y = 256 * r6.y; r6.y = round(r6.y); r19.xyz = r19.xyz * r19.xyz; r8.w = r19.w * 12 + 1; r8.w = exp2(r8.w); r20.xy = r8.ww * float2(1.44299996,1.44299996) + float2(1.44299996,9.44299984); r3.z = saturate(r3.z * 0.699999988 + 0.300000012); r21.xyz = -r14.xwz * r3.yyy + g_lightDir.xyz; r8.w = dot(r21.xyz, r21.xyz); r8.w = rsqrt(r8.w); r21.xyz = r21.xyz * r8.www; r8.w = dot(r15.xyz, r18.xyz); r8.w = r8.w + r8.w; r22.xyz = r18.xyz * -r8.www + r15.xyz; r20.zw = r6.yy * float2(0.000392156886,0.000392156886) + float2(0.299999982,0.0699999928); r22.xyz = -r20.zzz * r18.xyz + r22.xyz; r23.xyz = r18.xyz * r15.yzx; r23.xyz = r15.xyz * r18.yzx + -r23.xyz; r24.xyz = r23.xyz * r18.yzx; r23.xyz = r23.zxy * r18.zxy + -r24.xyz; r8.w = dot(r21.xyz, r18.xyz); r9.y = r20.w + -r8.w; r9.y = -r9.y * r9.y + 1; r9.y = max(0, r9.y); r9.y = log2(r9.y); r9.y = r12.y * r9.y; r9.y = exp2(r9.y); r9.y = r12.w * r9.y; r9.y = 0.125 * r9.y; r10.w = dot(g_lightDir.xyz, r15.xyz); r10.w = 1 + -r10.w; r11.w = r10.w * r10.w; r11.w = r11.w * r11.w; r10.w = r11.w * r10.w; r10.w = r10.w * 0.150000006 + 1; r9.y = r10.w * r9.y; r21.xyz = g_lightDir.xyz + -r22.xyz; r10.w = dot(r21.xyz, r21.xyz); r10.w = rsqrt(r10.w); r21.xyz = r21.xyz * r10.www; r10.w = dot(r21.xyz, r18.xyz); r10.w = -0.150000006 + r10.w; r10.w = -r10.w * r10.w + 1; r10.w = max(0, r10.w); r10.w = log2(r10.w); r10.w = r20.x * r10.w; r10.w = exp2(r10.w); r11.w = 0.125 * r20.y; r10.w = r11.w * r10.w; r12.y = saturate(dot(r23.xyz, g_lightDir.xyz)); r12.y = r12.y * r12.y; r10.w = r12.y * r10.w; r6.y = r6.y * 0.000392156886 + r8.w; r6.y = 0.13000001 + r6.y; r6.y = -r6.y * r6.y + 1; r6.y = max(0, r6.y); r6.y = log2(r6.y); r6.y = r20.x * r6.y; r6.y = exp2(r6.y); r6.y = r6.y * r11.w; r8.w = saturate(dot(r7.xyz, r15.xyz)); r8.w = r8.w * r8.w; r8.w = r8.w * r8.w; r6.y = r6.y * r8.w + r10.w; r8.w = r9.y * r3.z; r18.xyz = g_keyColor.xyz * r8.www; r18.xyz = g_keyColor.www * r18.xyz; r18.xyz = r18.xyz * r3.xxx; r3.z = r6.y * r3.z; r20.xyz = g_keyColor.xyz * r3.zzz; r20.xyz = g_keyColor.www * r20.xyz; r20.xyz = r20.xyz * r3.xxx; r19.xyz = r20.xyz * r19.xyz; r18.xyz = r18.xyz * r11.xyz + r19.xyz; } else { r17.xyz = r17.xyz * r13.xyz; if (r6.z != 0) { r3.z = -r5.w * 0.746999979 + 0.837000012; r3.z = r3.z * r3.z; r19.xyz = -r14.xwz * r3.yyy + g_lightDir.xyz; r6.y = dot(r19.xyz, r19.xyz); r6.y = rsqrt(r6.y); r19.xyz = r19.xyz * r6.yyy; r6.y = saturate(dot(r15.xyz, r19.xyz)); r6.z = saturate(dot(r7.xyz, r19.xyz)); r8.w = saturate(dot(r7.xyz, r15.xyz)); r9.y = saturate(r6.w); r19.xyz = r8.xyz * r8.xyz + float3(-0.0799999982,-0.0799999982,-0.0799999982); r19.xyz = r9.yyy * r19.xyz + float3(0.0799999982,0.0799999982,0.0799999982); r6.z = r6.z * r6.z; r9.y = r3.z * r3.z; r10.w = r3.z * r3.z + -1; r10.w = r6.z * r10.w + 1; r10.w = r10.w * r10.w; r10.w = 3.14159274 * r10.w; r9.y = r9.y / r10.w; r20.xyz = float3(1,1,1) + -r19.xyz; r6.y = 1.00100005 + -r6.y; r10.w = r6.y * r6.y; r10.w = r10.w * r10.w; r6.y = r10.w * r6.y; r19.xyz = r20.xyz * r6.yyy + r19.xyz; r10.w = 0.797884583 * r3.z; r3.z = -r3.z * 0.797884583 + 1; r11.w = r6.x * r3.z + r10.w; r3.z = r8.w * r3.z + r10.w; r3.z = r11.w * r3.z; r3.z = 1 / r3.z; r19.xyz = r19.xyz * r9.yyy; r19.xyz = r19.xyz * r3.zzz; r19.xyz = float3(0.785398185,0.785398185,0.785398185) * r19.xyz; if (r12.z != 0) { r3.z = r6.z * -0.999934375 + 1; r3.z = r3.z * r3.z; r3.z = 3.14159274 * r3.z; r3.z = 6.56100965e-005 / r3.z; r6.y = r6.y * 0.920000017 + 0.0799999982; r6.z = r6.x * 0.993537128 + 0.0064628697; r8.w = r8.w * 0.993537128 + 0.0064628697; r6.z = r8.w * r6.z; r6.z = 1 / r6.z; r3.z = r6.y * r3.z; r3.z = r3.z * r6.z; r19.xyz = r3.zzz * float3(0.785398185,0.785398185,0.785398185) + r19.xyz; } } else { r3.z = -r5.w * 0.746999979 + 0.837000012; r3.z = r3.z * r3.z; r14.xyz = -r14.xwz * r3.yyy + g_lightDir.xyz; r3.y = dot(r14.xyz, r14.xyz); r3.y = rsqrt(r3.y); r14.xyz = r14.xyz * r3.yyy; r3.y = saturate(dot(r15.xyz, r14.xyz)); r6.y = saturate(dot(r7.xyz, r14.xyz)); r6.z = saturate(dot(r7.xyz, r15.xyz)); r6.y = r6.y * r6.y; r8.w = r3.z * r3.z; r9.y = r3.z * r3.z + -1; r6.y = r6.y * r9.y + 1; r6.y = r6.y * r6.y; r6.y = 3.14159274 * r6.y; r6.y = r8.w / r6.y; r3.y = 1.00100005 + -r3.y; r8.w = r3.y * r3.y; r8.w = r8.w * r8.w; r3.y = r8.w * r3.y; r3.y = r3.y * 0.920000017 + 0.0799999982; r8.w = 0.797884583 * r3.z; r3.z = -r3.z * 0.797884583 + 1; r6.x = r6.x * r3.z + r8.w; r3.z = r6.z * r3.z + r8.w; r3.yz = r6.yx * r3.yz; r3.z = 1 / r3.z; r3.y = r3.y * r3.z; r19.xyz = float3(0.785398185,0.785398185,0.785398185) * r3.yyy; } r6.xyz = r19.xyz * r17.xyz; r18.xyz = g_keyColor.www * r6.xyz; } r3.y = dot(-r15.xyz, r7.xyz); r3.y = r3.y + r3.y; r6.xyz = r7.xyz * -r3.yyy + -r15.xyz; r14.xyz = r16.xyz * r3.xxx + r10.xyz; r16.xyzw = r9.zzzz == float4(0,0.00392200006,0.00784299988,0.0117650004); r16.xyzw = r16.xyzw ? g_envmapParams.xxxx : 0; r3.y = r3.x * r2.x + g_envmapParams.w; r3.y = r3.y * r7.w; r3.z = dot(r7.xyz, r15.xyz); r8.w = r5.w * r5.w; r8.w = r8.w * r5.w; r9.yz = r5.ww * float2(0.649999976,0.0399999991) + float2(0.349999994,0.0399999991); r12.yw = r8.ww * float2(0.399999976,0.899999976) + float2(0.300000012,0.100000001); r17.xyz = r9.yyy * r11.xyz; r8.xyz = -r8.xyz * r8.xyz + float3(1,1,1); r8.xyz = r5.www * r8.xyz + r11.xyz; r3.z = 1 + -r3.z; r3.z = r3.z * r3.z; r3.z = r3.z * r3.z; r3.z = min(1, r3.z); r8.w = r12.w + -r9.z; r8.w = r3.z * r8.w + r9.z; r8.xyz = r12.yyy * r8.xyz + -r17.xyz; r8.xyz = r3.zzz * r8.xyz + r17.xyz; r8.xyz = r8.xyz + -r8.www; r8.xyz = r6.www * r8.xyz + r8.www; r8.xyz = r13.xyz * r8.xyz; r8.xyz = r12.xxx ? float3(1,1,1) : r8.xyz; r9.yz = (int2)r4.ww != int2(4,1); if (r9.y != 0) { r3.z = 1 + -r5.w; r3.z = log2(r3.z); r12.xy = r3.zz + r2.yz; r12.xy = float2(-1,-1) + r12.xy; r12.xy = max(float2(0,0), r12.xy); r17.xyzw = g_customEnvmap.SampleLevel(g_customSampler_s, r6.xyz, r12.y).xyzw; r3.z = dot(r16.xyzw, r17.xyzw); r12.xyw = g_skyEnvmap.SampleLevel(g_skyEnvmapSampler_s, r6.xyz, r12.x).xyz; r12.xyw = r12.xyw * r8.xyz; r12.xyw = r12.xyw * r3.yyy; r18.xyz = r12.xyw * g_skyEnvmap8BitTexInvScale + r18.xyz; } else { r3.z = 0; } r8.xyz = r8.xyz * r3.zzz; r10.xyz = g_envmapParams.yyy + r10.xyz; r8.xyz = r10.xyz * r8.xyz; r3.z = 1 + -r7.w; r8.xyz = r8.xyz * r3.zzz + r18.xyz; if (r12.z != 0) { r5.w = dot(r7.xyz, r15.xyz); r5.w = 1 + -r5.w; r5.w = r5.w * r5.w; r5.w = r5.w * r5.w; r5.w = min(1, r5.w); r5.w = r5.w * 0.920000017 + 0.0799999982; r12.xyz = r13.xyz * r5.www; r17.xyz = -r13.xyz * r5.www + float3(1,1,1); r18.xyzw = g_customEnvmap.SampleLevel(g_customSampler_s, r6.xyz, 0).xyzw; r5.w = dot(r16.xyzw, r18.xyzw); r6.xyz = g_skyEnvmap.SampleLevel(g_skyEnvmapSampler_s, r6.xyz, 0).xyz; r6.xyz = r12.xyz * r6.xyz; r6.xyz = r6.xyz * r3.yyy; r6.xyz = g_skyEnvmap8BitTexInvScale * r6.xyz; r6.xyz = r8.xyz * r17.xyz + r6.xyz; r12.xyz = r12.xyz * r5.www; r10.xyz = r12.xyz * r10.xyz; r8.xyz = r10.xyz * r3.zzz + r6.xyz; } r3.y = (int)r4.w >= 7; if (r3.y != 0) { r3.y = saturate(-0.0274509806 + r9.w); r9.x = saturate(r9.x); r6.x = 1 + -r9.x; r6.y = 1 + -r3.y; r7.xyz = r7.xyz * g_keyTranslucencyParams.www + g_lightDir.xyz; r3.y = saturate(dot(r15.xyz, -r7.xyz)); r6.xy = g_keyTranslucencyParams.yy * r6.xy; r6.xy = float2(-1.44269502,-1.44269502) * r6.xy; r6.xy = exp2(r6.xy); r3.y = r3.y * g_keyTranslucencyParams.z + g_keyTranslucencyParams.x; r3.y = dot(r3.yy, r6.xy); r3.x = r3.y * r3.x; r14.xyz = r3.xxx * g_keyColor.xyz + r14.xyz; } r3.x = r9.y ? r9.z : 0; if (r3.x != 0) { r3.x = saturate(1 + -r6.w); r11.xyz = r11.xyz * r3.xxx; r13.xyz = float3(1,1,1); } r3.xyz = r11.xyz * r14.xyz + r5.xyz; r6.xyz = r13.xyz * r8.xyz; r4.xyz = r13.xyz * r8.xyz + r4.xyz; r4.w = (int)r4.w == 2; r4.w = r4.w ? 0 : 1; r5.xyz = r6.xyz * r4.www + r3.xyz; r2.w = (int)r2.w + 1; } r0.xyzw = g_ssaoTexture.Gather(g_ssaoSampler_s, r1.xy).xyzw; r0.x = min(r0.x, r0.y); r0.x = min(r0.x, r0.z); o0.w = min(r0.x, r0.w); o0.xyz = r5.xyz * r1.www; o1.xyz = r4.xyz * r1.www; o1.w = 1; return; } /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.20546 // // using 3Dmigoto v1.2.3 on Wed Oct 14 10:35:16 2015 // // // Buffer Definitions: // // cbuffer $Globals // { // // float3 g_cameraPos; // Offset: 0 Size: 12 // float2 g_invScreenSize; // Offset: 16 Size: 8 // float4x4 g_invViewProjMatrix; // Offset: 32 Size: 64 // float4 g_cloudOffsetAndScale; // Offset: 96 Size: 16 // float4 g_cloudCoverageExponentAndFade;// Offset: 112 Size: 16 // float3 g_lightDir; // Offset: 128 Size: 12 // float4 g_keyColor; // Offset: 144 Size: 16 // float4 g_keyTranslucencyParams; // Offset: 160 Size: 16 // float4 g_subParams; // Offset: 176 Size: 16 [unused] // float4 g_envmapParams; // Offset: 192 Size: 16 // float g_skyEnvmap8BitTexInvScale; // Offset: 208 Size: 4 // float g_colorScale; // Offset: 212 Size: 4 [unused] // float4 g_envmapsMipmapCount; // Offset: 224 Size: 16 // // } // // // Resource Bindings: // // Name Type Format Dim Slot Elements // ------------------------------ ---------- ------- ----------- ---- -------- // g_cloudShadowSampler sampler NA NA 0 1 // g_skyEnvmapSampler sampler NA NA 1 1 // g_customSampler sampler NA NA 2 1 // g_ssaoSampler sampler NA NA 3 1 // g_cloudShadowTexture texture float4 2d 0 1 // g_skyEnvmap texture float4 cube 1 1 // g_customEnvmap texture float4 cube 2 1 // g_ssaoTexture texture float4 2d 3 1 // g_depthTexture texture float4 2dMS2 4 1 // g_gbufferTexture0 texture float4 2dMS2 5 1 // g_gbufferTexture1 texture float4 2dMS2 6 1 // g_gbufferTexture2 texture float4 2dMS2 7 1 // g_gbufferTexture3 texture float4 2dMS2 8 1 // g_gbufferTexture4 texture float4 2dMS2 9 1 // g_gbufferTexture5 texture float4 2dMS2 10 1 // g_shadowAccumTexture texture float4 2dMS 11 1 // g_msaaClassifyTexture texture float 2d 12 1 // $Globals cbuffer NA NA 0 1 // // // // Input signature: // // Name Index Mask Register SysValue Format Used // -------------------- ----- ------ -------- -------- ------- ------ // SV_Position 0 xyzw 0 POS float xy // // // Output signature: // // Name Index Mask Register SysValue Format Used // -------------------- ----- ------ -------- -------- ------- ------ // SV_Target 0 xyzw 0 TARGET float xyzw // SV_Target 1 xyzw 1 TARGET float xyzw // ps_5_0 dcl_globalFlags refactoringAllowed dcl_immediateConstantBuffer { { 0.250000, 0, 0, 0}, { -0.250000, 0, 0, 0} } dcl_constantbuffer cb0[15], immediateIndexed dcl_sampler s0, mode_default dcl_sampler s1, mode_default dcl_sampler s2, mode_default dcl_sampler s3, mode_default dcl_resource_texture2d (float,float,float,float) t0 dcl_resource_texturecube (float,float,float,float) t1 dcl_resource_texturecube (float,float,float,float) t2 dcl_resource_texture2d (float,float,float,float) t3 dcl_resource_texture2dms(2) (float,float,float,float) t4 dcl_resource_texture2dms(2) (float,float,float,float) t5 dcl_resource_texture2dms(2) (float,float,float,float) t6 dcl_resource_texture2dms(2) (float,float,float,float) t7 dcl_resource_texture2dms(2) (float,float,float,float) t8 dcl_resource_texture2dms(2) (float,float,float,float) t9 dcl_resource_texture2dms(2) (float,float,float,float) t10 dcl_resource_texture2dms(0) (float,float,float,float) t11 dcl_resource_texture2d (float,float,float,float) t12 dcl_input_ps_siv linear noperspective v0.xy, position dcl_output o0.xyzw dcl_output o1.xyzw dcl_temps 25 ftoi r0.xy, v0.xyxx mul r1.xy, v0.xyxx, cb0[1].xyxx mov r0.zw, l(0,0,0,0) ld_indexable(texture2d)(float,float,float,float) r1.z, r0.xyww, t12.yzxw lt r1.z, l(0.000000), r1.z movc r1.zw, r1.zzzz, l(0,0,2,0.499999), l(0,0,1,0.999999) add r2.x, -cb0[12].w, l(1.000000) round_z r2.yz, cb0[14].xxyx mov r3.w, l(1.000000) mov r4.xyz, l(0,0,0,0) mov r5.xyz, l(0,0,0,0) mov r2.w, l(0) loop ige r4.w, r2.w, r1.z breakc_nz r4.w mad r6.xy, icb[r2.w + 0].xxxx, cb0[1].xyxx, r1.xyxx ldms_indexable(texture2dms)(float,float,float,float) r7.xyzw, r0.xyww, t5.xyzw, r2.w ldms_indexable(texture2dms)(float,float,float,float) r8.xyzw, r0.xyww, t6.xyzw, r2.w ldms_indexable(texture2dms)(float,float,float,float) r9.xyzw, r0.xyww, t7.yxzw, r2.w ldms_indexable(texture2dms)(float,float,float,float) r10.xyz, r0.xyww, t8.xyzw, r2.w ldms_indexable(texture2dms)(float,float,float,float) r3.z, r0.xyww, t4.yzxw, r2.w mul r4.w, r9.w, l(255.000000) round_ne r4.w, r4.w ftoi r4.w, r4.w mul r11.xyzw, r8.xyzw, r8.xyzw ieq r12.xyzw, r4.wwww, l(1, 5, 6, 4) if_nz r12.x mul r13.xyz, r11.xyzx, r11.wwww else mov r13.xyz, r11.wwww endif lt r5.w, l(0.000000), r13.x and r5.w, r7.w, r5.w or r6.z, r12.z, r12.y and r6.w, r9.x, r6.z log r7.w, |r9.y| mul r7.w, r7.w, cb0[12].z exp r7.w, r7.w mad r7.xyz, r7.xyzx, l(2.000000, 2.000000, 2.000000, 0.000000), l(-1.000000, -1.000000, -1.000000, 0.000000) dp3 r8.w, r7.xyzx, r7.xyzx rsq r8.w, r8.w mul r7.xyz, r7.xyzx, r8.wwww mad r6.xy, r6.xyxx, l(2.000000, 2.000000, 0.000000, 0.000000), l(-1.000000, -1.000000, 0.000000, 0.000000) mul r3.xy, r6.xyxx, l(1.000000, -1.000000, 0.000000, 0.000000) dp4 r14.x, r3.xyzw, cb0[2].xyzw dp4 r14.y, r3.xyzw, cb0[3].xyzw dp4 r14.z, r3.xyzw, cb0[4].xyzw dp4 r3.x, r3.xyzw, cb0[5].xyzw div r3.x, l(1.000000, 1.000000, 1.000000, 1.000000), r3.x mul r14.xzw, r3.xxxx, r14.xxzy dp3 r3.y, -r14.xzwx, -r14.xzwx rsq r3.y, r3.y mul r15.xyz, r3.yyyy, -r14.xwzx ldms_indexable(texture2dms)(float,float,float,float) r3.z, r0.xyww, t11.yzxw, r2.w mad r3.x, r14.y, r3.x, cb0[0].y mul r6.xy, r3.xxxx, cb0[8].xzxx mad r6.xy, r6.xyxx, cb0[6].wwww, r14.xzxx mad r6.xy, r6.xyxx, cb0[6].zzzz, cb0[6].xyxx sample_l_indexable(texture2d)(float,float,float,float) r3.x, r6.xyxx, t0.xyzw, s0, l(0.000000) add_sat r3.x, r3.x, cb0[7].x log r3.x, r3.x mul r3.x, r3.x, cb0[7].y exp r3.x, r3.x dp3 r6.x, r14.xzwx, r14.xzwx sqrt r6.x, r6.x add r6.x, r6.x, -cb0[7].z mul_sat r6.x, r6.x, cb0[7].w mul r6.x, r6.x, r6.x add r6.y, -r3.x, l(1.000000) mad r3.x, r6.x, r6.y, r3.x mul r3.x, r3.x, r3.z dp3 r3.z, r7.xyzx, cb0[8].xyzx mov_sat r6.x, r3.z mul r16.xyz, r6.xxxx, cb0[9].xyzx mul r17.xyz, r3.xxxx, r16.xyzx if_nz r12.w ldms_indexable(texture2dms)(float,float,float,float) r18.xyzw, r0.xyww, t9.xyzw, r2.w ldms_indexable(texture2dms)(float,float,float,float) r19.xyzw, r0.xyzw, t10.xyzw, r2.w mad r6.y, r5.w, l(12.000000), l(1.000000) exp r6.y, r6.y mad r12.yw, r6.yyyy, l(0.000000, 1.443000, 0.000000, 1.443000), l(0.000000, 1.443000, 0.000000, 9.443000) mad r18.xyz, r18.xyzx, l(2.000000, 2.000000, 2.000000, 0.000000), l(-1.000000, -1.000000, -1.000000, 0.000000) dp3 r6.y, r18.xyzx, r18.xyzx rsq r6.y, r6.y mul r18.xyz, r6.yyyy, r18.xyzx mul r6.y, r18.w, l(65535.000000) round_ne r6.y, r6.y mul r8.w, r6.y, l(0.003906) round_z r8.w, r8.w mad r6.y, r6.y, l(0.003906), -r8.w mul r6.y, r6.y, l(256.000000) round_ne r6.y, r6.y mul r19.xyz, r19.xyzx, r19.xyzx mad r8.w, r19.w, l(12.000000), l(1.000000) exp r8.w, r8.w mad r20.xy, r8.wwww, l(1.443000, 1.443000, 0.000000, 0.000000), l(1.443000, 9.443000, 0.000000, 0.000000) mad_sat r3.z, r3.z, l(0.700000), l(0.300000) mad r21.xyz, -r14.xwzx, r3.yyyy, cb0[8].xyzx dp3 r8.w, r21.xyzx, r21.xyzx rsq r8.w, r8.w mul r21.xyz, r8.wwww, r21.xyzx dp3 r8.w, r15.xyzx, r18.xyzx add r8.w, r8.w, r8.w mad r22.xyz, r18.xyzx, -r8.wwww, r15.xyzx mad r20.zw, r6.yyyy, l(0.000000, 0.000000, 0.000392, 0.000392), l(0.000000, 0.000000, 0.300000, 0.070000) mad r22.xyz, -r20.zzzz, r18.xyzx, r22.xyzx mul r23.xyz, r15.yzxy, r18.xyzx mad r23.xyz, r15.xyzx, r18.yzxy, -r23.xyzx mul r24.xyz, r18.yzxy, r23.xyzx mad r23.xyz, r23.zxyz, r18.zxyz, -r24.xyzx dp3 r8.w, r21.xyzx, r18.xyzx add r9.y, -r8.w, r20.w mad r9.y, -r9.y, r9.y, l(1.000000) max r9.y, r9.y, l(0.000000) log r9.y, r9.y mul r9.y, r9.y, r12.y exp r9.y, r9.y mul r9.y, r9.y, r12.w mul r9.y, r9.y, l(0.125000) dp3 r10.w, cb0[8].xyzx, r15.xyzx add r10.w, -r10.w, l(1.000000) mul r11.w, r10.w, r10.w mul r11.w, r11.w, r11.w mul r10.w, r10.w, r11.w mad r10.w, r10.w, l(0.150000), l(1.000000) mul r9.y, r9.y, r10.w add r21.xyz, -r22.xyzx, cb0[8].xyzx dp3 r10.w, r21.xyzx, r21.xyzx rsq r10.w, r10.w mul r21.xyz, r10.wwww, r21.xyzx dp3 r10.w, r21.xyzx, r18.xyzx add r10.w, r10.w, l(-0.150000) mad r10.w, -r10.w, r10.w, l(1.000000) max r10.w, r10.w, l(0.000000) log r10.w, r10.w mul r10.w, r10.w, r20.x exp r10.w, r10.w mul r11.w, r20.y, l(0.125000) mul r10.w, r10.w, r11.w dp3_sat r12.y, r23.xyzx, cb0[8].xyzx mul r12.y, r12.y, r12.y mul r10.w, r10.w, r12.y mad r6.y, r6.y, l(0.000392), r8.w add r6.y, r6.y, l(0.130000) mad r6.y, -r6.y, r6.y, l(1.000000) max r6.y, r6.y, l(0.000000) log r6.y, r6.y mul r6.y, r6.y, r20.x exp r6.y, r6.y mul r6.y, r11.w, r6.y dp3_sat r8.w, r7.xyzx, r15.xyzx mul r8.w, r8.w, r8.w mul r8.w, r8.w, r8.w mad r6.y, r6.y, r8.w, r10.w mul r8.w, r3.z, r9.y mul r18.xyz, r8.wwww, cb0[9].xyzx mul r18.xyz, r18.xyzx, cb0[9].wwww mul r18.xyz, r3.xxxx, r18.xyzx mul r3.z, r3.z, r6.y mul r20.xyz, r3.zzzz, cb0[9].xyzx mul r20.xyz, r20.xyzx, cb0[9].wwww mul r20.xyz, r3.xxxx, r20.xyzx mul r19.xyz, r19.xyzx, r20.xyzx mad r18.xyz, r18.xyzx, r11.xyzx, r19.xyzx else mul r17.xyz, r13.xyzx, r17.xyzx if_nz r6.z mad r3.z, -r5.w, l(0.747000), l(0.837000) mul r3.z, r3.z, r3.z mad r19.xyz, -r14.xwzx, r3.yyyy, cb0[8].xyzx dp3 r6.y, r19.xyzx, r19.xyzx rsq r6.y, r6.y mul r19.xyz, r6.yyyy, r19.xyzx dp3_sat r6.y, r15.xyzx, r19.xyzx dp3_sat r6.z, r7.xyzx, r19.xyzx dp3_sat r8.w, r7.xyzx, r15.xyzx mov_sat r9.y, r6.w mad r19.xyz, r8.xyzx, r8.xyzx, l(-0.080000, -0.080000, -0.080000, 0.000000) mad r19.xyz, r9.yyyy, r19.xyzx, l(0.080000, 0.080000, 0.080000, 0.000000) mul r6.z, r6.z, r6.z mul r9.y, r3.z, r3.z mad r10.w, r3.z, r3.z, l(-1.000000) mad r10.w, r6.z, r10.w, l(1.000000) mul r10.w, r10.w, r10.w mul r10.w, r10.w, l(3.141593) div r9.y, r9.y, r10.w add r20.xyz, -r19.xyzx, l(1.000000, 1.000000, 1.000000, 0.000000) add r6.y, -r6.y, l(1.001000) mul r10.w, r6.y, r6.y mul r10.w, r10.w, r10.w mul r6.y, r6.y, r10.w mad r19.xyz, r20.xyzx, r6.yyyy, r19.xyzx mul r10.w, r3.z, l(0.797885) mad r3.z, -r3.z, l(0.797885), l(1.000000) mad r11.w, r6.x, r3.z, r10.w mad r3.z, r8.w, r3.z, r10.w mul r3.z, r3.z, r11.w div r3.z, l(1.000000, 1.000000, 1.000000, 1.000000), r3.z mul r19.xyz, r9.yyyy, r19.xyzx mul r19.xyz, r3.zzzz, r19.xyzx mul r19.xyz, r19.xyzx, l(0.785398, 0.785398, 0.785398, 0.000000) if_nz r12.z mad r3.z, r6.z, l(-0.999934), l(1.000000) mul r3.z, r3.z, r3.z mul r3.z, r3.z, l(3.141593) div r3.z, l(0.000066), r3.z mad r6.y, r6.y, l(0.920000), l(0.080000) mad r6.z, r6.x, l(0.993537), l(0.006463) mad r8.w, r8.w, l(0.993537), l(0.006463) mul r6.z, r6.z, r8.w div r6.z, l(1.000000, 1.000000, 1.000000, 1.000000), r6.z mul r3.z, r3.z, r6.y mul r3.z, r6.z, r3.z mad r19.xyz, r3.zzzz, l(0.785398, 0.785398, 0.785398, 0.000000), r19.xyzx endif else mad r3.z, -r5.w, l(0.747000), l(0.837000) mul r3.z, r3.z, r3.z mad r14.xyz, -r14.xwzx, r3.yyyy, cb0[8].xyzx dp3 r3.y, r14.xyzx, r14.xyzx rsq r3.y, r3.y mul r14.xyz, r3.yyyy, r14.xyzx dp3_sat r3.y, r15.xyzx, r14.xyzx dp3_sat r6.y, r7.xyzx, r14.xyzx dp3_sat r6.z, r7.xyzx, r15.xyzx mul r6.y, r6.y, r6.y mul r8.w, r3.z, r3.z mad r9.y, r3.z, r3.z, l(-1.000000) mad r6.y, r6.y, r9.y, l(1.000000) mul r6.y, r6.y, r6.y mul r6.y, r6.y, l(3.141593) div r6.y, r8.w, r6.y add r3.y, -r3.y, l(1.001000) mul r8.w, r3.y, r3.y mul r8.w, r8.w, r8.w mul r3.y, r3.y, r8.w mad r3.y, r3.y, l(0.920000), l(0.080000) mul r8.w, r3.z, l(0.797885) mad r3.z, -r3.z, l(0.797885), l(1.000000) mad r6.x, r6.x, r3.z, r8.w mad r3.z, r6.z, r3.z, r8.w mul r3.yz, r3.yyzy, r6.yyxy div r3.z, l(1.000000, 1.000000, 1.000000, 1.000000), r3.z mul r3.y, r3.z, r3.y mul r19.xyz, r3.yyyy, l(0.785398, 0.785398, 0.785398, 0.000000) endif mul r6.xyz, r17.xyzx, r19.xyzx mul r18.xyz, r6.xyzx, cb0[9].wwww endif dp3 r3.y, -r15.xyzx, r7.xyzx add r3.y, r3.y, r3.y mad r6.xyz, r7.xyzx, -r3.yyyy, -r15.xyzx mad r14.xyz, r16.xyzx, r3.xxxx, r10.xyzx eq r16.xyzw, r9.zzzz, l(0.000000, 0.003922, 0.007843, 0.011765) and r16.xyzw, r16.xyzw, cb0[12].xxxx mad r3.y, r3.x, r2.x, cb0[12].w mul r3.y, r7.w, r3.y dp3 r3.z, r7.xyzx, r15.xyzx mul r8.w, r5.w, r5.w mul r8.w, r5.w, r8.w mad r9.yz, r5.wwww, l(0.000000, 0.650000, 0.040000, 0.000000), l(0.000000, 0.350000, 0.040000, 0.000000) mad r12.yw, r8.wwww, l(0.000000, 0.400000, 0.000000, 0.900000), l(0.000000, 0.300000, 0.000000, 0.100000) mul r17.xyz, r11.xyzx, r9.yyyy mad r8.xyz, -r8.xyzx, r8.xyzx, l(1.000000, 1.000000, 1.000000, 0.000000) mad r8.xyz, r5.wwww, r8.xyzx, r11.xyzx add r3.z, -r3.z, l(1.000000) mul r3.z, r3.z, r3.z mul r3.z, r3.z, r3.z min r3.z, r3.z, l(1.000000) add r8.w, -r9.z, r12.w mad r8.w, r3.z, r8.w, r9.z mad r8.xyz, r12.yyyy, r8.xyzx, -r17.xyzx mad r8.xyz, r3.zzzz, r8.xyzx, r17.xyzx add r8.xyz, -r8.wwww, r8.xyzx mad r8.xyz, r6.wwww, r8.xyzx, r8.wwww mul r8.xyz, r8.xyzx, r13.xyzx movc r8.xyz, r12.xxxx, l(1.000000,1.000000,1.000000,0), r8.xyzx ine r9.yz, r4.wwww, l(0, 4, 1, 0) if_nz r9.y add r3.z, -r5.w, l(1.000000) log r3.z, r3.z add r12.xy, r2.yzyy, r3.zzzz add r12.xy, r12.xyxx, l(-1.000000, -1.000000, 0.000000, 0.000000) max r12.xy, r12.xyxx, l(0.000000, 0.000000, 0.000000, 0.000000) sample_l_indexable(texturecube)(float,float,float,float) r17.xyzw, r6.xyzx, t2.xyzw, s2, r12.y dp4 r3.z, r16.xyzw, r17.xyzw sample_l_indexable(texturecube)(float,float,float,float) r12.xyw, r6.xyzx, t1.xywz, s1, r12.x mul r12.xyw, r8.xyxz, r12.xyxw mul r12.xyw, r3.yyyy, r12.xyxw mad r18.xyz, r12.xywx, cb0[13].xxxx, r18.xyzx else mov r3.z, l(0) endif mul r8.xyz, r3.zzzz, r8.xyzx add r10.xyz, r10.xyzx, cb0[12].yyyy mul r8.xyz, r8.xyzx, r10.xyzx add r3.z, -r7.w, l(1.000000) mad r8.xyz, r8.xyzx, r3.zzzz, r18.xyzx if_nz r12.z dp3 r5.w, r7.xyzx, r15.xyzx add r5.w, -r5.w, l(1.000000) mul r5.w, r5.w, r5.w mul r5.w, r5.w, r5.w min r5.w, r5.w, l(1.000000) mad r5.w, r5.w, l(0.920000), l(0.080000) mul r12.xyz, r5.wwww, r13.xyzx mad r17.xyz, -r13.xyzx, r5.wwww, l(1.000000, 1.000000, 1.000000, 0.000000) sample_l_indexable(texturecube)(float,float,float,float) r18.xyzw, r6.xyzx, t2.xyzw, s2, l(0.000000) dp4 r5.w, r16.xyzw, r18.xyzw sample_l_indexable(texturecube)(float,float,float,float) r6.xyz, r6.xyzx, t1.xyzw, s1, l(0.000000) mul r6.xyz, r6.xyzx, r12.xyzx mul r6.xyz, r3.yyyy, r6.xyzx mul r6.xyz, r6.xyzx, cb0[13].xxxx mad r6.xyz, r8.xyzx, r17.xyzx, r6.xyzx mul r12.xyz, r5.wwww, r12.xyzx mul r10.xyz, r10.xyzx, r12.xyzx mad r8.xyz, r10.xyzx, r3.zzzz, r6.xyzx endif ige r3.y, r4.w, l(7) if_nz r3.y add_sat r3.y, r9.w, l(-0.027451) mov_sat r9.x, r9.x add r6.x, -r9.x, l(1.000000) add r6.y, -r3.y, l(1.000000) mad r7.xyz, r7.xyzx, cb0[10].wwww, cb0[8].xyzx dp3_sat r3.y, r15.xyzx, -r7.xyzx mul r6.xy, r6.xyxx, cb0[10].yyyy mul r6.xy, r6.xyxx, l(-1.442695, -1.442695, 0.000000, 0.000000) exp r6.xy, r6.xyxx mad r3.y, r3.y, cb0[10].z, cb0[10].x dp2 r3.y, r3.yyyy, r6.xyxx mul r3.x, r3.x, r3.y mad r14.xyz, r3.xxxx, cb0[9].xyzx, r14.xyzx endif and r3.x, r9.y, r9.z if_nz r3.x add_sat r3.x, -r6.w, l(1.000000) mul r11.xyz, r3.xxxx, r11.xyzx mov r13.xyz, l(1.000000,1.000000,1.000000,0) endif mad r3.xyz, r11.xyzx, r14.xyzx, r5.xyzx mul r6.xyz, r8.xyzx, r13.xyzx mad r4.xyz, r13.xyzx, r8.xyzx, r4.xyzx ieq r4.w, r4.w, l(2) movc r4.w, r4.w, l(0), l(1.000000) mad r5.xyz, r6.xyzx, r4.wwww, r3.xyzx iadd r2.w, r2.w, l(1) endloop gather4_indexable(texture2d)(float,float,float,float) r0.xyzw, r1.xyxx, t3.xyzw, s3.x min r0.x, r0.y, r0.x min r0.x, r0.z, r0.x min o0.w, r0.w, r0.x mul o0.xyz, r1.wwww, r5.xyzx mul o1.xyz, r1.wwww, r4.xyzx mov o1.w, l(1.000000) ret // Approximately 356 instruction slots used ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ [/code]
DHR said:4everAwake..look the wip i send you. The shader for reflection has a manual fix (replace one line) and also in the star wars battlefront we found a similar issue that need manually remove one line (you can look the thread)

Upload the shaders here...i think will be similar issue to the previous one i mentioned. Its an specific issue with the wrapper.


I looked at the example in the Battlefront thread. I know there's a line you have to disable, but I was unable to determine which line it is with this shader:

cbuffer _Globals : register(b0)
{
float3 g_cameraPos : packoffset(c0);
float2 g_invScreenSize : packoffset(c1);
float4x4 g_invViewProjMatrix : packoffset(c2);
float4 g_cloudOffsetAndScale : packoffset(c6);
float4 g_cloudCoverageExponentAndFade : packoffset(c7);
float3 g_lightDir : packoffset(c8);
float4 g_keyColor : packoffset(c9);
float4 g_keyTranslucencyParams : packoffset(c10);
float4 g_subParams : packoffset(c11);
float4 g_envmapParams : packoffset(c12);
float g_skyEnvmap8BitTexInvScale : packoffset(c13);
float g_colorScale : packoffset(c13.y);
float4 g_envmapsMipmapCount : packoffset(c14);
}
SamplerState g_cloudShadowSampler_s : register(s0);
SamplerState g_skyEnvmapSampler_s : register(s1);
SamplerState g_customSampler_s : register(s2);
SamplerState g_ssaoSampler_s : register(s3);
Texture2D<float4> g_cloudShadowTexture : register(t0);
TextureCube<float4> g_skyEnvmap : register(t1);
TextureCube<float4> g_customEnvmap : register(t2);
Texture2D<float4> g_ssaoTexture : register(t3);
Texture2DMS<float4,2> g_depthTexture : register(t4);
Texture2DMS<float4,2> g_gbufferTexture0 : register(t5);
Texture2DMS<float4,2> g_gbufferTexture1 : register(t6);
Texture2DMS<float4,2> g_gbufferTexture2 : register(t7);
Texture2DMS<float4,2> g_gbufferTexture3 : register(t8);
Texture2DMS<float4,2> g_gbufferTexture4 : register(t9);
Texture2DMS<float4,2> g_gbufferTexture5 : register(t10);
Texture2DMS<float4> g_shadowAccumTexture : register(t11);
Texture2D<float> g_msaaClassifyTexture : register(t12);

Texture2D<float4> StereoParams : register(t125);
Texture1D<float4> IniParams : register(t120);

void main(
float4 v0 : SV_Position0,
out float4 o0 : SV_Target0,
out float4 o1 : SV_Target1)
{
const float4 icb[] = { { 0.250000, 0, 0, 0},
{ -0.250000, 0, 0, 0} };
float4 r0,r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11,r12,r13,r14,r15,r16,r17,r18,r19,r20,r21,r22,r23,r24;
uint4 bitmask, uiDest;
float4 fDest;

r0.xy = (int2)v0.xy;
r1.xy = g_invScreenSize.xy * v0.xy;
r0.zw = float2(0,0);
r1.z = g_msaaClassifyTexture.Load(r0.xyw).x;
r1.z = 0 < r1.z;
r1.zw = r1.zz ? float2(2.80259693e-045,0.499999493) : float2(1.40129846e-045,0.999998987);
r2.x = 1 + -g_envmapParams.w;
r2.yz = trunc(g_envmapsMipmapCount.xy);
r3.w = 1;
r4.xyz = float3(0,0,0);
r5.xyz = float3(0,0,0);
r2.w = 0;
while (true) {
r4.w = (int)r2.w >= (int)r1.z;
if (r4.w != 0) break;
r6.xy = icb[r2.w+0].xx * g_invScreenSize.xy + r1.xy;
r7.xyzw = g_gbufferTexture0.Load(r0.xy, r2.w).xyzw;
r8.xyzw = g_gbufferTexture1.Load(r0.xy, r2.w).xyzw;
r9.xyzw = g_gbufferTexture2.Load(r0.xy, r2.w).yxzw;
r10.xyz = g_gbufferTexture3.Load(r0.xy, r2.w).xyz;
r3.z = g_depthTexture.Load(r0.xy, r2.w).x;
r4.w = 255 * r9.w;
r4.w = round(r4.w);
r4.w = (int)r4.w;
r11.xyzw = r8.xyzw * r8.xyzw;
r12.xyzw = (int4)r4.wwww == int4(1,5,6,4);
if (r12.x != 0) {
r13.xyz = r11.www * r11.xyz;
} else {
r13.xyz = r11.www;
}
r5.w = 0 < r13.x;
r5.w = r5.w ? r7.w : 0;
r6.z = (int)r12.z | (int)r12.y;
r6.w = (int)r9.x & (int)r6.z;
r7.w = log2(abs(r9.y));
r7.w = g_envmapParams.z * r7.w;
r7.w = exp2(r7.w);
r7.xyz = r7.xyz * float3(2,2,2) + float3(-1,-1,-1);
r8.w = dot(r7.xyz, r7.xyz);
r8.w = rsqrt(r8.w);
r7.xyz = r8.www * r7.xyz;
r6.xy = r6.xy * float2(2,2) + float2(-1,-1);
r3.xy = float2(1,-1) * r6.xy;
r14.x = dot(r3.xyzw, g_invViewProjMatrix._m00_m10_m20_m30);
r14.y = dot(r3.xyzw, g_invViewProjMatrix._m01_m11_m21_m31);
r14.z = dot(r3.xyzw, g_invViewProjMatrix._m02_m12_m22_m32);
r3.x = dot(r3.xyzw, g_invViewProjMatrix._m03_m13_m23_m33);
r3.x = 1 / r3.x;
r14.xzw = r14.xzy * r3.xxx;
r3.y = dot(-r14.xzw, -r14.xzw);
r3.y = rsqrt(r3.y);
r15.xyz = -r14.xwz * r3.yyy;
r3.z = g_shadowAccumTexture.Load(r0.xy, r2.w).x;
r3.x = r14.y * r3.x + g_cameraPos.y;
r6.xy = g_lightDir.xz * r3.xx;
r6.xy = r6.xy * g_cloudOffsetAndScale.ww + r14.xz;
r6.xy = r6.xy * g_cloudOffsetAndScale.zz + g_cloudOffsetAndScale.xy;
r3.x = g_cloudShadowTexture.SampleLevel(g_cloudShadowSampler_s, r6.xy, 0).x;
r3.x = saturate(g_cloudCoverageExponentAndFade.x + r3.x);
r3.x = log2(r3.x);
r3.x = g_cloudCoverageExponentAndFade.y * r3.x;
r3.x = exp2(r3.x);
r6.x = dot(r14.xzw, r14.xzw);
r6.x = sqrt(r6.x);
r6.x = -g_cloudCoverageExponentAndFade.z + r6.x;
r6.x = saturate(g_cloudCoverageExponentAndFade.w * r6.x);
r6.x = r6.x * r6.x;
r6.y = 1 + -r3.x;
r3.x = r6.x * r6.y + r3.x;
r3.x = r3.z * r3.x;
r3.z = dot(r7.xyz, g_lightDir.xyz);
r6.x = saturate(r3.z);
r16.xyz = g_keyColor.xyz * r6.xxx;
r17.xyz = r16.xyz * r3.xxx;
if (r12.w != 0) {
r18.xyzw = g_gbufferTexture4.Load(r0.xy, r2.w).xyzw;
r19.xyzw = g_gbufferTexture5.Load(r0.xy, r2.w).xyzw;
r6.y = r5.w * 12 + 1;
r6.y = exp2(r6.y);
r12.yw = r6.yy * float2(1.44299996,1.44299996) + float2(1.44299996,9.44299984);
r18.xyz = r18.xyz * float3(2,2,2) + float3(-1,-1,-1);
r6.y = dot(r18.xyz, r18.xyz);
r6.y = rsqrt(r6.y);
r18.xyz = r18.xyz * r6.yyy;
r6.y = 65535 * r18.w;
r6.y = round(r6.y);
r8.w = 0.00390625 * r6.y;
r8.w = trunc(r8.w);
r6.y = r6.y * 0.00390625 + -r8.w;
r6.y = 256 * r6.y;
r6.y = round(r6.y);
r19.xyz = r19.xyz * r19.xyz;
r8.w = r19.w * 12 + 1;
r8.w = exp2(r8.w);
r20.xy = r8.ww * float2(1.44299996,1.44299996) + float2(1.44299996,9.44299984);
r3.z = saturate(r3.z * 0.699999988 + 0.300000012);
r21.xyz = -r14.xwz * r3.yyy + g_lightDir.xyz;
r8.w = dot(r21.xyz, r21.xyz);
r8.w = rsqrt(r8.w);
r21.xyz = r21.xyz * r8.www;
r8.w = dot(r15.xyz, r18.xyz);
r8.w = r8.w + r8.w;
r22.xyz = r18.xyz * -r8.www + r15.xyz;
r20.zw = r6.yy * float2(0.000392156886,0.000392156886) + float2(0.299999982,0.0699999928);
r22.xyz = -r20.zzz * r18.xyz + r22.xyz;
r23.xyz = r18.xyz * r15.yzx;
r23.xyz = r15.xyz * r18.yzx + -r23.xyz;
r24.xyz = r23.xyz * r18.yzx;
r23.xyz = r23.zxy * r18.zxy + -r24.xyz;
r8.w = dot(r21.xyz, r18.xyz);
r9.y = r20.w + -r8.w;
r9.y = -r9.y * r9.y + 1;
r9.y = max(0, r9.y);
r9.y = log2(r9.y);
r9.y = r12.y * r9.y;
r9.y = exp2(r9.y);
r9.y = r12.w * r9.y;
r9.y = 0.125 * r9.y;
r10.w = dot(g_lightDir.xyz, r15.xyz);
r10.w = 1 + -r10.w;
r11.w = r10.w * r10.w;
r11.w = r11.w * r11.w;
r10.w = r11.w * r10.w;
r10.w = r10.w * 0.150000006 + 1;
r9.y = r10.w * r9.y;
r21.xyz = g_lightDir.xyz + -r22.xyz;
r10.w = dot(r21.xyz, r21.xyz);
r10.w = rsqrt(r10.w);
r21.xyz = r21.xyz * r10.www;
r10.w = dot(r21.xyz, r18.xyz);
r10.w = -0.150000006 + r10.w;
r10.w = -r10.w * r10.w + 1;
r10.w = max(0, r10.w);
r10.w = log2(r10.w);
r10.w = r20.x * r10.w;
r10.w = exp2(r10.w);
r11.w = 0.125 * r20.y;
r10.w = r11.w * r10.w;
r12.y = saturate(dot(r23.xyz, g_lightDir.xyz));
r12.y = r12.y * r12.y;
r10.w = r12.y * r10.w;
r6.y = r6.y * 0.000392156886 + r8.w;
r6.y = 0.13000001 + r6.y;
r6.y = -r6.y * r6.y + 1;
r6.y = max(0, r6.y);
r6.y = log2(r6.y);
r6.y = r20.x * r6.y;
r6.y = exp2(r6.y);
r6.y = r6.y * r11.w;
r8.w = saturate(dot(r7.xyz, r15.xyz));
r8.w = r8.w * r8.w;
r8.w = r8.w * r8.w;
r6.y = r6.y * r8.w + r10.w;
r8.w = r9.y * r3.z;
r18.xyz = g_keyColor.xyz * r8.www;
r18.xyz = g_keyColor.www * r18.xyz;
r18.xyz = r18.xyz * r3.xxx;
r3.z = r6.y * r3.z;
r20.xyz = g_keyColor.xyz * r3.zzz;
r20.xyz = g_keyColor.www * r20.xyz;
r20.xyz = r20.xyz * r3.xxx;
r19.xyz = r20.xyz * r19.xyz;
r18.xyz = r18.xyz * r11.xyz + r19.xyz;
} else {
r17.xyz = r17.xyz * r13.xyz;
if (r6.z != 0) {
r3.z = -r5.w * 0.746999979 + 0.837000012;
r3.z = r3.z * r3.z;
r19.xyz = -r14.xwz * r3.yyy + g_lightDir.xyz;
r6.y = dot(r19.xyz, r19.xyz);
r6.y = rsqrt(r6.y);
r19.xyz = r19.xyz * r6.yyy;
r6.y = saturate(dot(r15.xyz, r19.xyz));
r6.z = saturate(dot(r7.xyz, r19.xyz));
r8.w = saturate(dot(r7.xyz, r15.xyz));
r9.y = saturate(r6.w);
r19.xyz = r8.xyz * r8.xyz + float3(-0.0799999982,-0.0799999982,-0.0799999982);
r19.xyz = r9.yyy * r19.xyz + float3(0.0799999982,0.0799999982,0.0799999982);
r6.z = r6.z * r6.z;
r9.y = r3.z * r3.z;
r10.w = r3.z * r3.z + -1;
r10.w = r6.z * r10.w + 1;
r10.w = r10.w * r10.w;
r10.w = 3.14159274 * r10.w;
r9.y = r9.y / r10.w;
r20.xyz = float3(1,1,1) + -r19.xyz;
r6.y = 1.00100005 + -r6.y;
r10.w = r6.y * r6.y;
r10.w = r10.w * r10.w;
r6.y = r10.w * r6.y;
r19.xyz = r20.xyz * r6.yyy + r19.xyz;
r10.w = 0.797884583 * r3.z;
r3.z = -r3.z * 0.797884583 + 1;
r11.w = r6.x * r3.z + r10.w;
r3.z = r8.w * r3.z + r10.w;
r3.z = r11.w * r3.z;
r3.z = 1 / r3.z;
r19.xyz = r19.xyz * r9.yyy;
r19.xyz = r19.xyz * r3.zzz;
r19.xyz = float3(0.785398185,0.785398185,0.785398185) * r19.xyz;
if (r12.z != 0) {
r3.z = r6.z * -0.999934375 + 1;
r3.z = r3.z * r3.z;
r3.z = 3.14159274 * r3.z;
r3.z = 6.56100965e-005 / r3.z;
r6.y = r6.y * 0.920000017 + 0.0799999982;
r6.z = r6.x * 0.993537128 + 0.0064628697;
r8.w = r8.w * 0.993537128 + 0.0064628697;
r6.z = r8.w * r6.z;
r6.z = 1 / r6.z;
r3.z = r6.y * r3.z;
r3.z = r3.z * r6.z;
r19.xyz = r3.zzz * float3(0.785398185,0.785398185,0.785398185) + r19.xyz;
}
} else {
r3.z = -r5.w * 0.746999979 + 0.837000012;
r3.z = r3.z * r3.z;
r14.xyz = -r14.xwz * r3.yyy + g_lightDir.xyz;
r3.y = dot(r14.xyz, r14.xyz);
r3.y = rsqrt(r3.y);
r14.xyz = r14.xyz * r3.yyy;
r3.y = saturate(dot(r15.xyz, r14.xyz));
r6.y = saturate(dot(r7.xyz, r14.xyz));
r6.z = saturate(dot(r7.xyz, r15.xyz));
r6.y = r6.y * r6.y;
r8.w = r3.z * r3.z;
r9.y = r3.z * r3.z + -1;
r6.y = r6.y * r9.y + 1;
r6.y = r6.y * r6.y;
r6.y = 3.14159274 * r6.y;
r6.y = r8.w / r6.y;
r3.y = 1.00100005 + -r3.y;
r8.w = r3.y * r3.y;
r8.w = r8.w * r8.w;
r3.y = r8.w * r3.y;
r3.y = r3.y * 0.920000017 + 0.0799999982;
r8.w = 0.797884583 * r3.z;
r3.z = -r3.z * 0.797884583 + 1;
r6.x = r6.x * r3.z + r8.w;
r3.z = r6.z * r3.z + r8.w;
r3.yz = r6.yx * r3.yz;
r3.z = 1 / r3.z;
r3.y = r3.y * r3.z;
r19.xyz = float3(0.785398185,0.785398185,0.785398185) * r3.yyy;
}
r6.xyz = r19.xyz * r17.xyz;
r18.xyz = g_keyColor.www * r6.xyz;
}
r3.y = dot(-r15.xyz, r7.xyz);
r3.y = r3.y + r3.y;
r6.xyz = r7.xyz * -r3.yyy + -r15.xyz;
r14.xyz = r16.xyz * r3.xxx + r10.xyz;
r16.xyzw = r9.zzzz == float4(0,0.00392200006,0.00784299988,0.0117650004);
r16.xyzw = r16.xyzw ? g_envmapParams.xxxx : 0;
r3.y = r3.x * r2.x + g_envmapParams.w;
r3.y = r3.y * r7.w;
r3.z = dot(r7.xyz, r15.xyz);
r8.w = r5.w * r5.w;
r8.w = r8.w * r5.w;
r9.yz = r5.ww * float2(0.649999976,0.0399999991) + float2(0.349999994,0.0399999991);
r12.yw = r8.ww * float2(0.399999976,0.899999976) + float2(0.300000012,0.100000001);
r17.xyz = r9.yyy * r11.xyz;
r8.xyz = -r8.xyz * r8.xyz + float3(1,1,1);
r8.xyz = r5.www * r8.xyz + r11.xyz;
r3.z = 1 + -r3.z;
r3.z = r3.z * r3.z;
r3.z = r3.z * r3.z;
r3.z = min(1, r3.z);
r8.w = r12.w + -r9.z;
r8.w = r3.z * r8.w + r9.z;
r8.xyz = r12.yyy * r8.xyz + -r17.xyz;
r8.xyz = r3.zzz * r8.xyz + r17.xyz;
r8.xyz = r8.xyz + -r8.www;
r8.xyz = r6.www * r8.xyz + r8.www;
r8.xyz = r13.xyz * r8.xyz;
r8.xyz = r12.xxx ? float3(1,1,1) : r8.xyz;
r9.yz = (int2)r4.ww != int2(4,1);
if (r9.y != 0) {
r3.z = 1 + -r5.w;
r3.z = log2(r3.z);
r12.xy = r3.zz + r2.yz;
r12.xy = float2(-1,-1) + r12.xy;
r12.xy = max(float2(0,0), r12.xy);
r17.xyzw = g_customEnvmap.SampleLevel(g_customSampler_s, r6.xyz, r12.y).xyzw;
r3.z = dot(r16.xyzw, r17.xyzw);
r12.xyw = g_skyEnvmap.SampleLevel(g_skyEnvmapSampler_s, r6.xyz, r12.x).xyz;
r12.xyw = r12.xyw * r8.xyz;
r12.xyw = r12.xyw * r3.yyy;
r18.xyz = r12.xyw * g_skyEnvmap8BitTexInvScale + r18.xyz;
} else {
r3.z = 0;
}
r8.xyz = r8.xyz * r3.zzz;
r10.xyz = g_envmapParams.yyy + r10.xyz;
r8.xyz = r10.xyz * r8.xyz;
r3.z = 1 + -r7.w;
r8.xyz = r8.xyz * r3.zzz + r18.xyz;
if (r12.z != 0) {
r5.w = dot(r7.xyz, r15.xyz);
r5.w = 1 + -r5.w;
r5.w = r5.w * r5.w;
r5.w = r5.w * r5.w;
r5.w = min(1, r5.w);
r5.w = r5.w * 0.920000017 + 0.0799999982;
r12.xyz = r13.xyz * r5.www;
r17.xyz = -r13.xyz * r5.www + float3(1,1,1);
r18.xyzw = g_customEnvmap.SampleLevel(g_customSampler_s, r6.xyz, 0).xyzw;
r5.w = dot(r16.xyzw, r18.xyzw);
r6.xyz = g_skyEnvmap.SampleLevel(g_skyEnvmapSampler_s, r6.xyz, 0).xyz;
r6.xyz = r12.xyz * r6.xyz;
r6.xyz = r6.xyz * r3.yyy;
r6.xyz = g_skyEnvmap8BitTexInvScale * r6.xyz;
r6.xyz = r8.xyz * r17.xyz + r6.xyz;
r12.xyz = r12.xyz * r5.www;
r10.xyz = r12.xyz * r10.xyz;
r8.xyz = r10.xyz * r3.zzz + r6.xyz;
}
r3.y = (int)r4.w >= 7;
if (r3.y != 0) {
r3.y = saturate(-0.0274509806 + r9.w);
r9.x = saturate(r9.x);
r6.x = 1 + -r9.x;
r6.y = 1 + -r3.y;
r7.xyz = r7.xyz * g_keyTranslucencyParams.www + g_lightDir.xyz;
r3.y = saturate(dot(r15.xyz, -r7.xyz));
r6.xy = g_keyTranslucencyParams.yy * r6.xy;
r6.xy = float2(-1.44269502,-1.44269502) * r6.xy;
r6.xy = exp2(r6.xy);
r3.y = r3.y * g_keyTranslucencyParams.z + g_keyTranslucencyParams.x;
r3.y = dot(r3.yy, r6.xy);
r3.x = r3.y * r3.x;
r14.xyz = r3.xxx * g_keyColor.xyz + r14.xyz;
}
r3.x = r9.y ? r9.z : 0;
if (r3.x != 0) {
r3.x = saturate(1 + -r6.w);
r11.xyz = r11.xyz * r3.xxx;
r13.xyz = float3(1,1,1);
}
r3.xyz = r11.xyz * r14.xyz + r5.xyz;
r6.xyz = r13.xyz * r8.xyz;
r4.xyz = r13.xyz * r8.xyz + r4.xyz;
r4.w = (int)r4.w == 2;
r4.w = r4.w ? 0 : 1;
r5.xyz = r6.xyz * r4.www + r3.xyz;
r2.w = (int)r2.w + 1;
}
r0.xyzw = g_ssaoTexture.Gather(g_ssaoSampler_s, r1.xy).xyzw;
r0.x = min(r0.x, r0.y);
r0.x = min(r0.x, r0.z);
o0.w = min(r0.x, r0.w);
o0.xyz = r5.xyz * r1.www;
o1.xyz = r4.xyz * r1.www;
o1.w = 1;
return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.20546
//
// using 3Dmigoto v1.2.3 on Wed Oct 14 10:35:16 2015
//
//
// Buffer Definitions:
//
// cbuffer $Globals
// {
//
// float3 g_cameraPos; // Offset: 0 Size: 12
// float2 g_invScreenSize; // Offset: 16 Size: 8
// float4x4 g_invViewProjMatrix; // Offset: 32 Size: 64
// float4 g_cloudOffsetAndScale; // Offset: 96 Size: 16
// float4 g_cloudCoverageExponentAndFade;// Offset: 112 Size: 16
// float3 g_lightDir; // Offset: 128 Size: 12
// float4 g_keyColor; // Offset: 144 Size: 16
// float4 g_keyTranslucencyParams; // Offset: 160 Size: 16
// float4 g_subParams; // Offset: 176 Size: 16 [unused]
// float4 g_envmapParams; // Offset: 192 Size: 16
// float g_skyEnvmap8BitTexInvScale; // Offset: 208 Size: 4
// float g_colorScale; // Offset: 212 Size: 4 [unused]
// float4 g_envmapsMipmapCount; // Offset: 224 Size: 16
//
// }
//
//
// Resource Bindings:
//
// Name Type Format Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// g_cloudShadowSampler sampler NA NA 0 1
// g_skyEnvmapSampler sampler NA NA 1 1
// g_customSampler sampler NA NA 2 1
// g_ssaoSampler sampler NA NA 3 1
// g_cloudShadowTexture texture float4 2d 0 1
// g_skyEnvmap texture float4 cube 1 1
// g_customEnvmap texture float4 cube 2 1
// g_ssaoTexture texture float4 2d 3 1
// g_depthTexture texture float4 2dMS2 4 1
// g_gbufferTexture0 texture float4 2dMS2 5 1
// g_gbufferTexture1 texture float4 2dMS2 6 1
// g_gbufferTexture2 texture float4 2dMS2 7 1
// g_gbufferTexture3 texture float4 2dMS2 8 1
// g_gbufferTexture4 texture float4 2dMS2 9 1
// g_gbufferTexture5 texture float4 2dMS2 10 1
// g_shadowAccumTexture texture float4 2dMS 11 1
// g_msaaClassifyTexture texture float 2d 12 1
// $Globals cbuffer NA NA 0 1
//
//
//
// Input signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Position 0 xyzw 0 POS float xy
//
//
// Output signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Target 0 xyzw 0 TARGET float xyzw
// SV_Target 1 xyzw 1 TARGET float xyzw
//
ps_5_0
dcl_globalFlags refactoringAllowed
dcl_immediateConstantBuffer { { 0.250000, 0, 0, 0},
{ -0.250000, 0, 0, 0} }
dcl_constantbuffer cb0[15], immediateIndexed
dcl_sampler s0, mode_default
dcl_sampler s1, mode_default
dcl_sampler s2, mode_default
dcl_sampler s3, mode_default
dcl_resource_texture2d (float,float,float,float) t0
dcl_resource_texturecube (float,float,float,float) t1
dcl_resource_texturecube (float,float,float,float) t2
dcl_resource_texture2d (float,float,float,float) t3
dcl_resource_texture2dms(2) (float,float,float,float) t4
dcl_resource_texture2dms(2) (float,float,float,float) t5
dcl_resource_texture2dms(2) (float,float,float,float) t6
dcl_resource_texture2dms(2) (float,float,float,float) t7
dcl_resource_texture2dms(2) (float,float,float,float) t8
dcl_resource_texture2dms(2) (float,float,float,float) t9
dcl_resource_texture2dms(2) (float,float,float,float) t10
dcl_resource_texture2dms(0) (float,float,float,float) t11
dcl_resource_texture2d (float,float,float,float) t12
dcl_input_ps_siv linear noperspective v0.xy, position
dcl_output o0.xyzw
dcl_output o1.xyzw
dcl_temps 25
ftoi r0.xy, v0.xyxx
mul r1.xy, v0.xyxx, cb0[1].xyxx
mov r0.zw, l(0,0,0,0)
ld_indexable(texture2d)(float,float,float,float) r1.z, r0.xyww, t12.yzxw
lt r1.z, l(0.000000), r1.z
movc r1.zw, r1.zzzz, l(0,0,2,0.499999), l(0,0,1,0.999999)
add r2.x, -cb0[12].w, l(1.000000)
round_z r2.yz, cb0[14].xxyx
mov r3.w, l(1.000000)
mov r4.xyz, l(0,0,0,0)
mov r5.xyz, l(0,0,0,0)
mov r2.w, l(0)
loop
ige r4.w, r2.w, r1.z
breakc_nz r4.w
mad r6.xy, icb[r2.w + 0].xxxx, cb0[1].xyxx, r1.xyxx
ldms_indexable(texture2dms)(float,float,float,float) r7.xyzw, r0.xyww, t5.xyzw, r2.w
ldms_indexable(texture2dms)(float,float,float,float) r8.xyzw, r0.xyww, t6.xyzw, r2.w
ldms_indexable(texture2dms)(float,float,float,float) r9.xyzw, r0.xyww, t7.yxzw, r2.w
ldms_indexable(texture2dms)(float,float,float,float) r10.xyz, r0.xyww, t8.xyzw, r2.w
ldms_indexable(texture2dms)(float,float,float,float) r3.z, r0.xyww, t4.yzxw, r2.w
mul r4.w, r9.w, l(255.000000)
round_ne r4.w, r4.w
ftoi r4.w, r4.w
mul r11.xyzw, r8.xyzw, r8.xyzw
ieq r12.xyzw, r4.wwww, l(1, 5, 6, 4)
if_nz r12.x
mul r13.xyz, r11.xyzx, r11.wwww
else
mov r13.xyz, r11.wwww
endif
lt r5.w, l(0.000000), r13.x
and r5.w, r7.w, r5.w
or r6.z, r12.z, r12.y
and r6.w, r9.x, r6.z
log r7.w, |r9.y|
mul r7.w, r7.w, cb0[12].z
exp r7.w, r7.w
mad r7.xyz, r7.xyzx, l(2.000000, 2.000000, 2.000000, 0.000000), l(-1.000000, -1.000000, -1.000000, 0.000000)
dp3 r8.w, r7.xyzx, r7.xyzx
rsq r8.w, r8.w
mul r7.xyz, r7.xyzx, r8.wwww
mad r6.xy, r6.xyxx, l(2.000000, 2.000000, 0.000000, 0.000000), l(-1.000000, -1.000000, 0.000000, 0.000000)
mul r3.xy, r6.xyxx, l(1.000000, -1.000000, 0.000000, 0.000000)
dp4 r14.x, r3.xyzw, cb0[2].xyzw
dp4 r14.y, r3.xyzw, cb0[3].xyzw
dp4 r14.z, r3.xyzw, cb0[4].xyzw
dp4 r3.x, r3.xyzw, cb0[5].xyzw
div r3.x, l(1.000000, 1.000000, 1.000000, 1.000000), r3.x
mul r14.xzw, r3.xxxx, r14.xxzy
dp3 r3.y, -r14.xzwx, -r14.xzwx
rsq r3.y, r3.y
mul r15.xyz, r3.yyyy, -r14.xwzx
ldms_indexable(texture2dms)(float,float,float,float) r3.z, r0.xyww, t11.yzxw, r2.w
mad r3.x, r14.y, r3.x, cb0[0].y
mul r6.xy, r3.xxxx, cb0[8].xzxx
mad r6.xy, r6.xyxx, cb0[6].wwww, r14.xzxx
mad r6.xy, r6.xyxx, cb0[6].zzzz, cb0[6].xyxx
sample_l_indexable(texture2d)(float,float,float,float) r3.x, r6.xyxx, t0.xyzw, s0, l(0.000000)
add_sat r3.x, r3.x, cb0[7].x
log r3.x, r3.x
mul r3.x, r3.x, cb0[7].y
exp r3.x, r3.x
dp3 r6.x, r14.xzwx, r14.xzwx
sqrt r6.x, r6.x
add r6.x, r6.x, -cb0[7].z
mul_sat r6.x, r6.x, cb0[7].w
mul r6.x, r6.x, r6.x
add r6.y, -r3.x, l(1.000000)
mad r3.x, r6.x, r6.y, r3.x
mul r3.x, r3.x, r3.z
dp3 r3.z, r7.xyzx, cb0[8].xyzx
mov_sat r6.x, r3.z
mul r16.xyz, r6.xxxx, cb0[9].xyzx
mul r17.xyz, r3.xxxx, r16.xyzx
if_nz r12.w
ldms_indexable(texture2dms)(float,float,float,float) r18.xyzw, r0.xyww, t9.xyzw, r2.w
ldms_indexable(texture2dms)(float,float,float,float) r19.xyzw, r0.xyzw, t10.xyzw, r2.w
mad r6.y, r5.w, l(12.000000), l(1.000000)
exp r6.y, r6.y
mad r12.yw, r6.yyyy, l(0.000000, 1.443000, 0.000000, 1.443000), l(0.000000, 1.443000, 0.000000, 9.443000)
mad r18.xyz, r18.xyzx, l(2.000000, 2.000000, 2.000000, 0.000000), l(-1.000000, -1.000000, -1.000000, 0.000000)
dp3 r6.y, r18.xyzx, r18.xyzx
rsq r6.y, r6.y
mul r18.xyz, r6.yyyy, r18.xyzx
mul r6.y, r18.w, l(65535.000000)
round_ne r6.y, r6.y
mul r8.w, r6.y, l(0.003906)
round_z r8.w, r8.w
mad r6.y, r6.y, l(0.003906), -r8.w
mul r6.y, r6.y, l(256.000000)
round_ne r6.y, r6.y
mul r19.xyz, r19.xyzx, r19.xyzx
mad r8.w, r19.w, l(12.000000), l(1.000000)
exp r8.w, r8.w
mad r20.xy, r8.wwww, l(1.443000, 1.443000, 0.000000, 0.000000), l(1.443000, 9.443000, 0.000000, 0.000000)
mad_sat r3.z, r3.z, l(0.700000), l(0.300000)
mad r21.xyz, -r14.xwzx, r3.yyyy, cb0[8].xyzx
dp3 r8.w, r21.xyzx, r21.xyzx
rsq r8.w, r8.w
mul r21.xyz, r8.wwww, r21.xyzx
dp3 r8.w, r15.xyzx, r18.xyzx
add r8.w, r8.w, r8.w
mad r22.xyz, r18.xyzx, -r8.wwww, r15.xyzx
mad r20.zw, r6.yyyy, l(0.000000, 0.000000, 0.000392, 0.000392), l(0.000000, 0.000000, 0.300000, 0.070000)
mad r22.xyz, -r20.zzzz, r18.xyzx, r22.xyzx
mul r23.xyz, r15.yzxy, r18.xyzx
mad r23.xyz, r15.xyzx, r18.yzxy, -r23.xyzx
mul r24.xyz, r18.yzxy, r23.xyzx
mad r23.xyz, r23.zxyz, r18.zxyz, -r24.xyzx
dp3 r8.w, r21.xyzx, r18.xyzx
add r9.y, -r8.w, r20.w
mad r9.y, -r9.y, r9.y, l(1.000000)
max r9.y, r9.y, l(0.000000)
log r9.y, r9.y
mul r9.y, r9.y, r12.y
exp r9.y, r9.y
mul r9.y, r9.y, r12.w
mul r9.y, r9.y, l(0.125000)
dp3 r10.w, cb0[8].xyzx, r15.xyzx
add r10.w, -r10.w, l(1.000000)
mul r11.w, r10.w, r10.w
mul r11.w, r11.w, r11.w
mul r10.w, r10.w, r11.w
mad r10.w, r10.w, l(0.150000), l(1.000000)
mul r9.y, r9.y, r10.w
add r21.xyz, -r22.xyzx, cb0[8].xyzx
dp3 r10.w, r21.xyzx, r21.xyzx
rsq r10.w, r10.w
mul r21.xyz, r10.wwww, r21.xyzx
dp3 r10.w, r21.xyzx, r18.xyzx
add r10.w, r10.w, l(-0.150000)
mad r10.w, -r10.w, r10.w, l(1.000000)
max r10.w, r10.w, l(0.000000)
log r10.w, r10.w
mul r10.w, r10.w, r20.x
exp r10.w, r10.w
mul r11.w, r20.y, l(0.125000)
mul r10.w, r10.w, r11.w
dp3_sat r12.y, r23.xyzx, cb0[8].xyzx
mul r12.y, r12.y, r12.y
mul r10.w, r10.w, r12.y
mad r6.y, r6.y, l(0.000392), r8.w
add r6.y, r6.y, l(0.130000)
mad r6.y, -r6.y, r6.y, l(1.000000)
max r6.y, r6.y, l(0.000000)
log r6.y, r6.y
mul r6.y, r6.y, r20.x
exp r6.y, r6.y
mul r6.y, r11.w, r6.y
dp3_sat r8.w, r7.xyzx, r15.xyzx
mul r8.w, r8.w, r8.w
mul r8.w, r8.w, r8.w
mad r6.y, r6.y, r8.w, r10.w
mul r8.w, r3.z, r9.y
mul r18.xyz, r8.wwww, cb0[9].xyzx
mul r18.xyz, r18.xyzx, cb0[9].wwww
mul r18.xyz, r3.xxxx, r18.xyzx
mul r3.z, r3.z, r6.y
mul r20.xyz, r3.zzzz, cb0[9].xyzx
mul r20.xyz, r20.xyzx, cb0[9].wwww
mul r20.xyz, r3.xxxx, r20.xyzx
mul r19.xyz, r19.xyzx, r20.xyzx
mad r18.xyz, r18.xyzx, r11.xyzx, r19.xyzx
else
mul r17.xyz, r13.xyzx, r17.xyzx
if_nz r6.z
mad r3.z, -r5.w, l(0.747000), l(0.837000)
mul r3.z, r3.z, r3.z
mad r19.xyz, -r14.xwzx, r3.yyyy, cb0[8].xyzx
dp3 r6.y, r19.xyzx, r19.xyzx
rsq r6.y, r6.y
mul r19.xyz, r6.yyyy, r19.xyzx
dp3_sat r6.y, r15.xyzx, r19.xyzx
dp3_sat r6.z, r7.xyzx, r19.xyzx
dp3_sat r8.w, r7.xyzx, r15.xyzx
mov_sat r9.y, r6.w
mad r19.xyz, r8.xyzx, r8.xyzx, l(-0.080000, -0.080000, -0.080000, 0.000000)
mad r19.xyz, r9.yyyy, r19.xyzx, l(0.080000, 0.080000, 0.080000, 0.000000)
mul r6.z, r6.z, r6.z
mul r9.y, r3.z, r3.z
mad r10.w, r3.z, r3.z, l(-1.000000)
mad r10.w, r6.z, r10.w, l(1.000000)
mul r10.w, r10.w, r10.w
mul r10.w, r10.w, l(3.141593)
div r9.y, r9.y, r10.w
add r20.xyz, -r19.xyzx, l(1.000000, 1.000000, 1.000000, 0.000000)
add r6.y, -r6.y, l(1.001000)
mul r10.w, r6.y, r6.y
mul r10.w, r10.w, r10.w
mul r6.y, r6.y, r10.w
mad r19.xyz, r20.xyzx, r6.yyyy, r19.xyzx
mul r10.w, r3.z, l(0.797885)
mad r3.z, -r3.z, l(0.797885), l(1.000000)
mad r11.w, r6.x, r3.z, r10.w
mad r3.z, r8.w, r3.z, r10.w
mul r3.z, r3.z, r11.w
div r3.z, l(1.000000, 1.000000, 1.000000, 1.000000), r3.z
mul r19.xyz, r9.yyyy, r19.xyzx
mul r19.xyz, r3.zzzz, r19.xyzx
mul r19.xyz, r19.xyzx, l(0.785398, 0.785398, 0.785398, 0.000000)
if_nz r12.z
mad r3.z, r6.z, l(-0.999934), l(1.000000)
mul r3.z, r3.z, r3.z
mul r3.z, r3.z, l(3.141593)
div r3.z, l(0.000066), r3.z
mad r6.y, r6.y, l(0.920000), l(0.080000)
mad r6.z, r6.x, l(0.993537), l(0.006463)
mad r8.w, r8.w, l(0.993537), l(0.006463)
mul r6.z, r6.z, r8.w
div r6.z, l(1.000000, 1.000000, 1.000000, 1.000000), r6.z
mul r3.z, r3.z, r6.y
mul r3.z, r6.z, r3.z
mad r19.xyz, r3.zzzz, l(0.785398, 0.785398, 0.785398, 0.000000), r19.xyzx
endif
else
mad r3.z, -r5.w, l(0.747000), l(0.837000)
mul r3.z, r3.z, r3.z
mad r14.xyz, -r14.xwzx, r3.yyyy, cb0[8].xyzx
dp3 r3.y, r14.xyzx, r14.xyzx
rsq r3.y, r3.y
mul r14.xyz, r3.yyyy, r14.xyzx
dp3_sat r3.y, r15.xyzx, r14.xyzx
dp3_sat r6.y, r7.xyzx, r14.xyzx
dp3_sat r6.z, r7.xyzx, r15.xyzx
mul r6.y, r6.y, r6.y
mul r8.w, r3.z, r3.z
mad r9.y, r3.z, r3.z, l(-1.000000)
mad r6.y, r6.y, r9.y, l(1.000000)
mul r6.y, r6.y, r6.y
mul r6.y, r6.y, l(3.141593)
div r6.y, r8.w, r6.y
add r3.y, -r3.y, l(1.001000)
mul r8.w, r3.y, r3.y
mul r8.w, r8.w, r8.w
mul r3.y, r3.y, r8.w
mad r3.y, r3.y, l(0.920000), l(0.080000)
mul r8.w, r3.z, l(0.797885)
mad r3.z, -r3.z, l(0.797885), l(1.000000)
mad r6.x, r6.x, r3.z, r8.w
mad r3.z, r6.z, r3.z, r8.w
mul r3.yz, r3.yyzy, r6.yyxy
div r3.z, l(1.000000, 1.000000, 1.000000, 1.000000), r3.z
mul r3.y, r3.z, r3.y
mul r19.xyz, r3.yyyy, l(0.785398, 0.785398, 0.785398, 0.000000)
endif
mul r6.xyz, r17.xyzx, r19.xyzx
mul r18.xyz, r6.xyzx, cb0[9].wwww
endif
dp3 r3.y, -r15.xyzx, r7.xyzx
add r3.y, r3.y, r3.y
mad r6.xyz, r7.xyzx, -r3.yyyy, -r15.xyzx
mad r14.xyz, r16.xyzx, r3.xxxx, r10.xyzx
eq r16.xyzw, r9.zzzz, l(0.000000, 0.003922, 0.007843, 0.011765)
and r16.xyzw, r16.xyzw, cb0[12].xxxx
mad r3.y, r3.x, r2.x, cb0[12].w
mul r3.y, r7.w, r3.y
dp3 r3.z, r7.xyzx, r15.xyzx
mul r8.w, r5.w, r5.w
mul r8.w, r5.w, r8.w
mad r9.yz, r5.wwww, l(0.000000, 0.650000, 0.040000, 0.000000), l(0.000000, 0.350000, 0.040000, 0.000000)
mad r12.yw, r8.wwww, l(0.000000, 0.400000, 0.000000, 0.900000), l(0.000000, 0.300000, 0.000000, 0.100000)
mul r17.xyz, r11.xyzx, r9.yyyy
mad r8.xyz, -r8.xyzx, r8.xyzx, l(1.000000, 1.000000, 1.000000, 0.000000)
mad r8.xyz, r5.wwww, r8.xyzx, r11.xyzx
add r3.z, -r3.z, l(1.000000)
mul r3.z, r3.z, r3.z
mul r3.z, r3.z, r3.z
min r3.z, r3.z, l(1.000000)
add r8.w, -r9.z, r12.w
mad r8.w, r3.z, r8.w, r9.z
mad r8.xyz, r12.yyyy, r8.xyzx, -r17.xyzx
mad r8.xyz, r3.zzzz, r8.xyzx, r17.xyzx
add r8.xyz, -r8.wwww, r8.xyzx
mad r8.xyz, r6.wwww, r8.xyzx, r8.wwww
mul r8.xyz, r8.xyzx, r13.xyzx
movc r8.xyz, r12.xxxx, l(1.000000,1.000000,1.000000,0), r8.xyzx
ine r9.yz, r4.wwww, l(0, 4, 1, 0)
if_nz r9.y
add r3.z, -r5.w, l(1.000000)
log r3.z, r3.z
add r12.xy, r2.yzyy, r3.zzzz
add r12.xy, r12.xyxx, l(-1.000000, -1.000000, 0.000000, 0.000000)
max r12.xy, r12.xyxx, l(0.000000, 0.000000, 0.000000, 0.000000)
sample_l_indexable(texturecube)(float,float,float,float) r17.xyzw, r6.xyzx, t2.xyzw, s2, r12.y
dp4 r3.z, r16.xyzw, r17.xyzw
sample_l_indexable(texturecube)(float,float,float,float) r12.xyw, r6.xyzx, t1.xywz, s1, r12.x
mul r12.xyw, r8.xyxz, r12.xyxw
mul r12.xyw, r3.yyyy, r12.xyxw
mad r18.xyz, r12.xywx, cb0[13].xxxx, r18.xyzx
else
mov r3.z, l(0)
endif
mul r8.xyz, r3.zzzz, r8.xyzx
add r10.xyz, r10.xyzx, cb0[12].yyyy
mul r8.xyz, r8.xyzx, r10.xyzx
add r3.z, -r7.w, l(1.000000)
mad r8.xyz, r8.xyzx, r3.zzzz, r18.xyzx
if_nz r12.z
dp3 r5.w, r7.xyzx, r15.xyzx
add r5.w, -r5.w, l(1.000000)
mul r5.w, r5.w, r5.w
mul r5.w, r5.w, r5.w
min r5.w, r5.w, l(1.000000)
mad r5.w, r5.w, l(0.920000), l(0.080000)
mul r12.xyz, r5.wwww, r13.xyzx
mad r17.xyz, -r13.xyzx, r5.wwww, l(1.000000, 1.000000, 1.000000, 0.000000)
sample_l_indexable(texturecube)(float,float,float,float) r18.xyzw, r6.xyzx, t2.xyzw, s2, l(0.000000)
dp4 r5.w, r16.xyzw, r18.xyzw
sample_l_indexable(texturecube)(float,float,float,float) r6.xyz, r6.xyzx, t1.xyzw, s1, l(0.000000)
mul r6.xyz, r6.xyzx, r12.xyzx
mul r6.xyz, r3.yyyy, r6.xyzx
mul r6.xyz, r6.xyzx, cb0[13].xxxx
mad r6.xyz, r8.xyzx, r17.xyzx, r6.xyzx
mul r12.xyz, r5.wwww, r12.xyzx
mul r10.xyz, r10.xyzx, r12.xyzx
mad r8.xyz, r10.xyzx, r3.zzzz, r6.xyzx
endif
ige r3.y, r4.w, l(7)
if_nz r3.y
add_sat r3.y, r9.w, l(-0.027451)
mov_sat r9.x, r9.x
add r6.x, -r9.x, l(1.000000)
add r6.y, -r3.y, l(1.000000)
mad r7.xyz, r7.xyzx, cb0[10].wwww, cb0[8].xyzx
dp3_sat r3.y, r15.xyzx, -r7.xyzx
mul r6.xy, r6.xyxx, cb0[10].yyyy
mul r6.xy, r6.xyxx, l(-1.442695, -1.442695, 0.000000, 0.000000)
exp r6.xy, r6.xyxx
mad r3.y, r3.y, cb0[10].z, cb0[10].x
dp2 r3.y, r3.yyyy, r6.xyxx
mul r3.x, r3.x, r3.y
mad r14.xyz, r3.xxxx, cb0[9].xyzx, r14.xyzx
endif
and r3.x, r9.y, r9.z
if_nz r3.x
add_sat r3.x, -r6.w, l(1.000000)
mul r11.xyz, r3.xxxx, r11.xyzx
mov r13.xyz, l(1.000000,1.000000,1.000000,0)
endif
mad r3.xyz, r11.xyzx, r14.xyzx, r5.xyzx
mul r6.xyz, r8.xyzx, r13.xyzx
mad r4.xyz, r13.xyzx, r8.xyzx, r4.xyzx
ieq r4.w, r4.w, l(2)
movc r4.w, r4.w, l(0), l(1.000000)
mad r5.xyz, r6.xyzx, r4.wwww, r3.xyzx
iadd r2.w, r2.w, l(1)
endloop
gather4_indexable(texture2d)(float,float,float,float) r0.xyzw, r1.xyxx, t3.xyzw, s3.x
min r0.x, r0.y, r0.x
min r0.x, r0.z, r0.x
min o0.w, r0.w, r0.x
mul o0.xyz, r1.wwww, r5.xyzx
mul o1.xyz, r1.wwww, r4.xyzx
mov o1.w, l(1.000000)
ret
// Approximately 356 instruction slots used

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

Dual boot Win 7 x64 & Win 10 (1809) | Geforce Drivers 417.35

Posted 10/14/2015 02:42 PM   
I'm not the expert, but you can try replacing this line (line 54) [code]r1.zw = r1.zz ? float2(2.80259693e-045,0.499999493) : float2(1.40129846e-045,0.999998987);[/code] for this one: [code]r1.zw = r1.zz ? float2(2.0,0.499999) : float2(1.0,0.999999);[/code] Is the same issue pattern in the reflection shader i send you in the WIP version.
I'm not the expert, but you can try replacing this line (line 54)
r1.zw = r1.zz ? float2(2.80259693e-045,0.499999493) : float2(1.40129846e-045,0.999998987);


for this one:
r1.zw = r1.zz ? float2(2.0,0.499999) : float2(1.0,0.999999);



Is the same issue pattern in the reflection shader i send you in the WIP version.

MY WEB

Helix Mod - Making 3D Better

My 3D Screenshot Gallery

Like my fixes? you can donate to Paypal: dhr.donation@gmail.com

Posted 10/14/2015 08:19 PM   
I hit that same decompiler bug in some of the bloom pixel shaders in Mad Max, where we are somehow replaced 0x3e000000 (0.125) with 1040187392.0 (0x4e780000). Here 2.0 (0x40000000) was somehow replaced with 2.8e-45 (0x00000002).
I hit that same decompiler bug in some of the bloom pixel shaders in Mad Max, where we are somehow replaced 0x3e000000 (0.125) with 1040187392.0 (0x4e780000). Here 2.0 (0x40000000) was somehow replaced with 2.8e-45 (0x00000002).

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

Posted 10/14/2015 11:40 PM   
  32 / 143    
Scroll To Top