How to fix/disable shaders in games(DLL,guide and fixes).
  160 / 167    
[quote="lumpeh"]So i'm playing round with the debug and Killing Floor (UE 2.5 i think). Its dumping all the shaders and its code, but in game cycling through the shaders shows no changes. I've tried with and without UseRenderedShaders but nothing ever gets shut off. Any tips on what i could try?[/quote]Try changing OverrideMethod to 0, 1, or 2. That can sometimes help in situations like this. If dumpall is working, but shader hunting is not, you can conceivably still find your shader using Tsaebeht's Binary Search Engine. Not sure of current state.
lumpeh said:So i'm playing round with the debug and Killing Floor (UE 2.5 i think). Its dumping all the shaders and its code, but in game cycling through the shaders shows no changes. I've tried with and without UseRenderedShaders but nothing ever gets shut off. Any tips on what i could try?
Try changing OverrideMethod to 0, 1, or 2. That can sometimes help in situations like this.

If dumpall is working, but shader hunting is not, you can conceivably still find your shader using Tsaebeht's Binary Search Engine. Not sure of current state.

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 10/26/2014 10:19 PM   
[quote="bo3b"][quote="4everAwake"]How do I go about applying a convergence lock (for a fix)? I did a search and I heard mention that it could be done. But I was unable to find any further details regarding this. Do I just assign a really common texture to a preset index?[/quote]I'm not sure this has been documented anywhere. The one game I know this works in Last Remnant: http://helixmod.blogspot.com/2013/09/the-last-remnant-new-version-update-0620.html Take a look at that fix to see if that is what you need. If not, ping eqzitara by email, because I know he figured out how to do this.[/quote] Thanks for that bo3b. I think that's how it's done- apply a preset index to a texture that's always on screen, like a HUD element. Also I know there are a few profiles that have convergence locks. Off of the top of my head, Crysis profile & Google Earth profile has one.
bo3b said:
4everAwake said:How do I go about applying a convergence lock (for a fix)? I did a search and I heard mention that it could be done. But I was unable to find any further details regarding this. Do I just assign a really common texture to a preset index?
I'm not sure this has been documented anywhere.

The one game I know this works in Last Remnant: http://helixmod.blogspot.com/2013/09/the-last-remnant-new-version-update-0620.html


Take a look at that fix to see if that is what you need. If not, ping eqzitara by email, because I know he figured out how to do this.


Thanks for that bo3b. I think that's how it's done- apply a preset index to a texture that's always on screen, like a HUD element. Also I know there are a few profiles that have convergence locks. Off of the top of my head, Crysis profile & Google Earth profile has one.

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

Posted 10/27/2014 07:24 AM   
Whar is the reason for shader hunting not to work? My implementation of shader hunting have worked all the time. As far as can tell.
Whar is the reason for shader hunting not to work?

My implementation of shader hunting have worked all the time. As far as can tell.

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 10/27/2014 10:19 AM   
[quote="bo3b"][quote="lumpeh"]So i'm playing round with the debug and Killing Floor (UE 2.5 i think). Its dumping all the shaders and its code, but in game cycling through the shaders shows no changes. I've tried with and without UseRenderedShaders but nothing ever gets shut off. Any tips on what i could try?[/quote]Try changing OverrideMethod to 0, 1, or 2. That can sometimes help in situations like this. If dumpall is working, but shader hunting is not, you can conceivably still find your shader using Tsaebeht's Binary Search Engine. Not sure of current state.[/quote] No such luck with OverrideMethod :( one thing i've noticed is that i get 102 vertex and 102 pixel shaders alldumped, but in game it only cycles through 50 of each even with UseRenderedShaders off. I shall check out Tsaebeht's utility. *edit* seems his dropbox mirror to the file is dead these days. Might be worth mirroring it on the helix blog ? [i]with[/i] Tsaebeht's permission of course! ;)
bo3b said:
lumpeh said:So i'm playing round with the debug and Killing Floor (UE 2.5 i think). Its dumping all the shaders and its code, but in game cycling through the shaders shows no changes. I've tried with and without UseRenderedShaders but nothing ever gets shut off. Any tips on what i could try?
Try changing OverrideMethod to 0, 1, or 2. That can sometimes help in situations like this.

If dumpall is working, but shader hunting is not, you can conceivably still find your shader using Tsaebeht's Binary Search Engine. Not sure of current state.


No such luck with OverrideMethod :( one thing i've noticed is that i get 102 vertex and 102 pixel shaders alldumped, but in game it only cycles through 50 of each even with UseRenderedShaders off. I shall check out Tsaebeht's utility.

*edit*

seems his dropbox mirror to the file is dead these days. Might be worth mirroring it on the helix blog ? with Tsaebeht's permission of course! ;)

Posted 10/27/2014 01:51 PM   
I tried the latest HelixMod with Killing Floor, and I get partial results. The shader hunting is partly working, in that I can see shaders go on and off, but it doesn't seem to hit every shader in the scene. But I'd also note that the game is pretty good by default in 3D. I didn't see much that needed fixing, what are you running across? This might be one of those games that interacts badly with HelixMod. You could try changing the settings to different levels, because that will typically use different shaders, but outside of that I'm not sure what to suggest.
I tried the latest HelixMod with Killing Floor, and I get partial results. The shader hunting is partly working, in that I can see shaders go on and off, but it doesn't seem to hit every shader in the scene. But I'd also note that the game is pretty good by default in 3D. I didn't see much that needed fixing, what are you running across?

This might be one of those games that interacts badly with HelixMod.

You could try changing the settings to different levels, because that will typically use different shaders, but outside of that I'm not sure what to suggest.

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 10/28/2014 03:59 AM   
I was using a test level from the Workshop so i could meddle unmolested by Zeds. In order of beginner to complex; (1)Add custom convergence presets bound to keys/set one for aimming (i could get this one done pretty quickly from what i've looked at) (2)Fix skyboxes on some of the official maps. (not too bad on the whole but would be nice) (3)Stereoize the Hud - Separate textures and make player tags comfortable and if necessary get rid of health tags for the commando class. The last one is the most uncomfortable i think. I have come across and bound a console command to disable the entire HUD at will, but it means you lose the damage indicators which is awkward when a Clot sneaks up on you. If HelixMod can't do it, never mind. Hopefully KF2 will do better as its UE3.0 based i believe :)
I was using a test level from the Workshop so i could meddle unmolested by Zeds. In order of beginner to complex;

(1)Add custom convergence presets bound to keys/set one for aimming (i could get this one done pretty quickly from what i've looked at)

(2)Fix skyboxes on some of the official maps. (not too bad on the whole but would be nice)

(3)Stereoize the Hud - Separate textures and make player tags comfortable and if necessary get rid of health tags for the commando class.

The last one is the most uncomfortable i think. I have come across and bound a console command to disable the entire HUD at will, but it means you lose the damage indicators which is awkward when a Clot sneaks up on you. If HelixMod can't do it, never mind. Hopefully KF2 will do better as its UE3.0 based i believe :)

Posted 10/28/2014 11:28 AM   
Sounds good. You should be able to do 1, even with no shader hunting as it's independent of that. You can very likely do 2, as long as you can find the skybox shader. Skybox fixes are generally pretty easy. 3 is hard and not likely if cannot find the tag or HUD shader. If you can find them, then pushing them deeper is pretty easy, as well as texture separation. Putting them to the 'proper' depth, attached to a character is generally quite hard, but just pushing them deeper (like 40% max depth) is very easy.
Sounds good.

You should be able to do 1, even with no shader hunting as it's independent of that.

You can very likely do 2, as long as you can find the skybox shader. Skybox fixes are generally pretty easy.

3 is hard and not likely if cannot find the tag or HUD shader. If you can find them, then pushing them deeper is pretty easy, as well as texture separation. Putting them to the 'proper' depth, attached to a character is generally quite hard, but just pushing them deeper (like 40% max depth) is very easy.

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 10/28/2014 10:51 PM   
I think short of an actual mod with a custom UTX pack for the hud, its kinda stuck. It wouldn't be client-side either. On the plus side i've found replacing an Aliase bind in the user.ini with;[code]Aliases[36]=(Command="showhud | IronSightZoomIn | onrelease IronSightZoomOut | onrelease showhud",Alias="Aiming")[/code] will get rid of it as long as you keep looking down the sights. Theres also a 'light hud' option and you can turn down the hud to 50% opaque. I've tried several official maps and no shader hunting success. Going to look at the convergence binds next! Won't be much of a 'real' fix though :(
I think short of an actual mod with a custom UTX pack for the hud, its kinda stuck. It wouldn't be client-side either. On the plus side i've found replacing an Aliase bind in the user.ini with;
Aliases[36]=(Command="showhud | IronSightZoomIn | onrelease IronSightZoomOut | onrelease showhud",Alias="Aiming")
will get rid of it as long as you keep looking down the sights. Theres also a 'light hud' option and you can turn down the hud to 50% opaque. I've tried several official maps and no shader hunting success. Going to look at the convergence binds next! Won't be much of a 'real' fix though :(

Posted 10/29/2014 01:37 PM   
Does anyone have any advice on how to go about fixing broken ray-marched volumetric light effects? I've been playing around with the shaders involved for one of these in Dreamfall for a couple of hours with limited success - I can do the easy fix for the texcoord outputs from the vertex shaders easily enough (at least - the two that are used when the camera is outside the volume), but I'm still left with a halo in the left eye. If the camera is inside the volume I also get a left-eye only halo (from inside it's rendered as a full screen quad, so the VS doesn't use the MVP). From a distance the entire volume moves off to the side in the left eye as well, which would seem to be related. I've been playing around with adjustments inside the pixel shaders that only apply when StereoParams.z == -1 (left eye), and so far I've managed to distort the halo in weird and wonderful ways, but I don't really feel like I'm getting closer to a solution... I've stuck all the shaders that play a role in this effect under here, with headers re-attached from the unity assets files: http://darkstarsword.net/dreamfall-broken-shaders/LightShafts/ (The various pixel shaders in Final Interpolation are used from different camera angles around and within the volume, probably related to the direction of light, and the three folders seem to be different layers/passes). The particular effect is not far into the game - it's at the end of the dark tunnel for the second dreamer that needs help - talk to the dreamer and turn on at least one of the street lights for it to appear (it becomes brighter once the second light is on). EDIT: Updated URL
Does anyone have any advice on how to go about fixing broken ray-marched volumetric light effects?

I've been playing around with the shaders involved for one of these in Dreamfall for a couple of hours with limited success - I can do the easy fix for the texcoord outputs from the vertex shaders easily enough (at least - the two that are used when the camera is outside the volume), but I'm still left with a halo in the left eye. If the camera is inside the volume I also get a left-eye only halo (from inside it's rendered as a full screen quad, so the VS doesn't use the MVP).

From a distance the entire volume moves off to the side in the left eye as well, which would seem to be related.

I've been playing around with adjustments inside the pixel shaders that only apply when StereoParams.z == -1 (left eye), and so far I've managed to distort the halo in weird and wonderful ways, but I don't really feel like I'm getting closer to a solution...

I've stuck all the shaders that play a role in this effect under here, with headers re-attached from the unity assets files:
http://darkstarsword.net/dreamfall-broken-shaders/LightShafts/

(The various pixel shaders in Final Interpolation are used from different camera angles around and within the volume, probably related to the direction of light, and the three folders seem to be different layers/passes).

The particular effect is not far into the game - it's at the end of the dark tunnel for the second dreamer that needs help - talk to the dreamer and turn on at least one of the street lights for it to appear (it becomes brighter once the second light is on).

EDIT: Updated URL

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 11/06/2014 04:39 PM   
I did some searching and I'm pretty sure this is the broken effect they are using, which is public domain with the source code available - now to study how this effect works: https://github.com/robertcupisz/LightShafts
I did some searching and I'm pretty sure this is the broken effect they are using, which is public domain with the source code available - now to study how this effect works:

https://github.com/robertcupisz/LightShafts

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 11/07/2014 12:27 AM   
Great find! Great approach! Going at the fix from the top down is a whole new avenue. Taking a quick look at the github code, his code already supports multiple cameras, and was added as a way to support Oculus Rift. You could conceivably use the same mechanism for a 3D fix. Check his commit here: [url]https://github.com/robertcupisz/LightShafts/commit/d61c849f3f45641287f6811277fde24366757a7d[/url] He modifies it from the m_MainCamera to a more general m_CurrentCamera. I can't correlate your ASM code back to the shader you reference there, but it's always possible that DreamFall picked up an older version before he made it multi-camera aware. If you think the shader API itself is the same, same input/output, you can conceivably just drop in the latest version and have it compiled on the fly. The HelixMod supports both ASM and HLSL compilation, with the flag UseAsm=false/true. If you set it to false, it in theory will compile HLSL. I don't believe anyone has ever done this before, so it might be interesting to try.
Great find! Great approach! Going at the fix from the top down is a whole new avenue.

Taking a quick look at the github code, his code already supports multiple cameras, and was added as a way to support Oculus Rift. You could conceivably use the same mechanism for a 3D fix.

Check his commit here: https://github.com/robertcupisz/LightShafts/commit/d61c849f3f45641287f6811277fde24366757a7d

He modifies it from the m_MainCamera to a more general m_CurrentCamera.


I can't correlate your ASM code back to the shader you reference there, but it's always possible that DreamFall picked up an older version before he made it multi-camera aware.

If you think the shader API itself is the same, same input/output, you can conceivably just drop in the latest version and have it compiled on the fly. The HelixMod supports both ASM and HLSL compilation, with the flag UseAsm=false/true. If you set it to false, it in theory will compile HLSL. I don't believe anyone has ever done this before, so it might be interesting to try.

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 11/07/2014 07:05 AM   
I don't think the support for the second camera really helps us unless Dreamfall starts using the Unity plugin to use two cameras for 3D Vision (and the fact that the first comment on that plugin is "this doesn't work", doesn't really inspire me with much confidence). The commit you pointed to only alters the C# code, not the HLSL (or actually something called Cg, which is subtly different to HLSL). As for compiling it - I'm able to get the free version of Unity to do that if I remove the Hidden keyword so it shows up in the UI, and I've proved that the compiled code can replace the shaders dumped from Helix mod, so long as none of the inputs or outputs from the program change. I'm not sure if it is possible to use anything other than Unity to compile it - certainly their surface shaders need the magic inside UnityShaderCompiler.exe to handle the #pragma surface. Additional inputs can be defined in Cg tied to specific registers that will be passed in from Helix mod. I'm actually wondering if it might be worth exploring the possibility of using the same techniques Unity modders do which might allow us to replace shaders in the .asset files and add whatever extra inputs we like... Back to the problem at hand, In addition to stereoising the texcoord output of the vertex shaders, I've worked out that the _LightPos input to the pixel shaders is the mono screen coordinates of the light source, so I stereoised that and suddenly all the light shafts popped into 3D - which looked great, other than the horribly distorted halo that now appears in both eyes. I've worked out that the issue is the coordinates being read from s1 (_DepthEpi). That texture is written from the Coords.shader, which also takes _LightPos as an input. I can apply the same correction to it in that shader and the distorted halo lines up with the character again - at least in the eye that originally didn't have a halo in the first place. The rays remain 3D with this correction here as well, so I'm pretty confident that this is the right place to do it. The problem seems to be that Coords.shader is only used for a mono render target - adding a test to conditionally disable the output based on the StereoParams.x being less or more than 0 only disabled it when StereoParams.x > 0, which would explain why I can fix the halo in the right eye only. So, I'm trying to work out how to force it to be stereoised, but not having much luck yet. This is what I have: [code] // Fixes shadow placement. The fact that this worked was a surprise to me - I // thought the driver's default was for square render targets to be mono DefSquareSurfaceMode = 2 // Stereoize the _DepthEpi surface used for volumetric light shafts, which is // written from the Hidden/Coord shader and read from the Hidden/Final // Interpolation shader. SurfaceCreationModeList = 0; [SF0] DefMode = 1 Format = 114 Width = 1024 Height = 1024 Usage = 1 Pool = 0 Levels = 1 [PS8415AC69] GetSampler1FromReg = 1 [PS4C517B70] GetSampler1FromReg = 1 [/code] Which is based on this output from the log file, as well as decoding the DDS header in the Tex1.dds dumped out with F12: [code] D3DUSAGE_RENDERTARGET/D3DUSAGE_DEPTHSTENCIL Height 1024 Width 1024 Usage 1 Format 114 Pool 0 Levels 1 texptr 0 nIndex 1, Mode 1 D3DUSAGE_RENDERTARGET/D3DUSAGE_DEPTHSTENCIL Height 1024 Width 1024 Usage 1 Format 114 Pool 0 Levels 1 texptr 0 nIndex 2, Mode 1 GetSampler1FromReg GetTexture lpTex h 1024 w 1024 u 1 t 1 f 114 tex 34f1b060 shad 8415ac69 D3DUSAGE_RENDERTARGET/D3DUSAGE_DEPTHSTENCIL Height 1024 Width 1024 Usage 1 Format 114 Pool 0 Levels 1 texptr 34f1b060 nIndex 3, Mode 1 D3DUSAGE_RENDERTARGET/D3DUSAGE_DEPTHSTENCIL Height 1024 Width 1024 Usage 1 Format 114 Pool 0 Levels 1 texptr 34f1b060 nIndex 4, Mode 1 D3DUSAGE_RENDERTARGET/D3DUSAGE_DEPTHSTENCIL Height 1024 Width 1024 Usage 1 Format 114 Pool 0 Levels 1 texptr 34f1b060 nIndex 5, Mode 1 D3DUSAGE_RENDERTARGET/D3DUSAGE_DEPTHSTENCIL Height 1024 Width 1024 Usage 1 Format 114 Pool 0 Levels 1 texptr 34f1b060 nIndex 6, Mode 1 D3DUSAGE_RENDERTARGET/D3DUSAGE_DEPTHSTENCIL Height 1024 Width 1024 Usage 1 Format 114 Pool 0 Levels 1 texptr 34f1b060 nIndex 7, Mode 1 D3DUSAGE_RENDERTARGET/D3DUSAGE_DEPTHSTENCIL Height 1024 Width 1024 Usage 1 Format 114 Pool 0 Levels 1 texptr 34f1b060 nIndex 8, Mode 1 D3DUSAGE_RENDERTARGET/D3DUSAGE_DEPTHSTENCIL Height 1024 Width 1024 Usage 1 Format 114 Pool 0 Levels 1 texptr 34f1b060 nIndex 9, Mode 1 D3DUSAGE_RENDERTARGET/D3DUSAGE_DEPTHSTENCIL Height 1024 Width 1024 Usage 1 Format 114 Pool 0 Levels 1 texptr 34f1b060 nIndex 10, Mode 1 D3DUSAGE_RENDERTARGET/D3DUSAGE_DEPTHSTENCIL Height 1024 Width 1024 Usage 1 Format 114 Pool 0 Levels 1 texptr 34f1b060 nIndex 11, Mode 1 D3DUSAGE_RENDERTARGET/D3DUSAGE_DEPTHSTENCIL Height 1024 Width 1024 Usage 1 Format 114 Pool 0 Levels 1 texptr 34f1b060 nIndex 12, Mode 1 GetSampler1FromReg GetTexture lpTex h 1024 w 1024 u 1 t 1 f 114 tex 720bf9c0 shad 4c517b70 D3DUSAGE_RENDERTARGET/D3DUSAGE_DEPTHSTENCIL Height 1024 Width 1024 Usage 1 Format 114 Pool 0 Levels 1 texptr 720bf9c0 nIndex 13, Mode 1 D3DUSAGE_RENDERTARGET/D3DUSAGE_DEPTHSTENCIL Height 1024 Width 1024 Usage 1 Format 114 Pool 0 Levels 1 texptr 720bf9c0 nIndex 14, Mode 1 GetSampler1FromReg GetTexture lpTex h 1024 w 1024 u 1 t 1 f 114 tex 720c0a00 shad 4c517b70 D3DUSAGE_RENDERTARGET/D3DUSAGE_DEPTHSTENCIL Height 1024 Width 1024 Usage 1 Format 114 Pool 0 Levels 1 texptr 720c0a00 nIndex 15, Mode 1 D3DUSAGE_RENDERTARGET/D3DUSAGE_DEPTHSTENCIL Height 1024 Width 1024 Usage 1 Format 114 Pool 0 Levels 1 texptr 720c0a00 nIndex 16, Mode 1 GetSampler1FromReg GetTexture lpTex h 1024 w 1024 u 1 t 1 f 114 tex 720bf9c0 shad 4c517b70 D3DUSAGE_RENDERTARGET/D3DUSAGE_DEPTHSTENCIL Height 1024 Width 1024 Usage 1 Format 114 Pool 0 Levels 1 texptr 720bf9c0 nIndex 17, Mode 1 D3DUSAGE_RENDERTARGET/D3DUSAGE_DEPTHSTENCIL Height 1024 Width 1024 Usage 1 Format 114 Pool 0 Levels 1 texptr 720bf9c0 nIndex 18, Mode 1 GetSampler1FromReg GetTexture lpTex h 1024 w 1024 u 1 t 1 f 114 tex 720c0a00 shad 4c517b70 D3DUSAGE_RENDERTARGET/D3DUSAGE_DEPTHSTENCIL Height 1024 Width 1024 Usage 1 Format 114 Pool 0 Levels 1 texptr 720c0a00 nIndex 19, Mode 1 D3DUSAGE_RENDERTARGET/D3DUSAGE_DEPTHSTENCIL Height 1024 Width 1024 Usage 1 Format 114 Pool 0 Levels 1 texptr 720c0a00 nIndex 20, Mode 1 GetSampler1FromReg GetTexture lpTex h 1024 w 1024 u 1 t 1 f 114 tex 720bf9c0 shad 4c517b70 [/code] Does that look correct? Earlier I also tried setting DefSquareSurfaceMode = 1, which broke shadows, but didn't seem to change anything on this effect :( Also, is there anything special that needs to happen in the texld instruction when sampling a stereoised texture? How does it know which to sample - does the driver automatically sample the one that matches the current eye being drawn? I guess what I'm asking is how is this supposed to work?
I don't think the support for the second camera really helps us unless Dreamfall starts using the Unity plugin to use two cameras for 3D Vision (and the fact that the first comment on that plugin is "this doesn't work", doesn't really inspire me with much confidence).

The commit you pointed to only alters the C# code, not the HLSL (or actually something called Cg, which is subtly different to HLSL). As for compiling it - I'm able to get the free version of Unity to do that if I remove the Hidden keyword so it shows up in the UI, and I've proved that the compiled code can replace the shaders dumped from Helix mod, so long as none of the inputs or outputs from the program change. I'm not sure if it is possible to use anything other than Unity to compile it - certainly their surface shaders need the magic inside UnityShaderCompiler.exe to handle the #pragma surface.

Additional inputs can be defined in Cg tied to specific registers that will be passed in from Helix mod. I'm actually wondering if it might be worth exploring the possibility of using the same techniques Unity modders do which might allow us to replace shaders in the .asset files and add whatever extra inputs we like...



Back to the problem at hand,

In addition to stereoising the texcoord output of the vertex shaders, I've worked out that the _LightPos input to the pixel shaders is the mono screen coordinates of the light source, so I stereoised that and suddenly all the light shafts popped into 3D - which looked great, other than the horribly distorted halo that now appears in both eyes.

I've worked out that the issue is the coordinates being read from s1 (_DepthEpi). That texture is written from the Coords.shader, which also takes _LightPos as an input. I can apply the same correction to it in that shader and the distorted halo lines up with the character again - at least in the eye that originally didn't have a halo in the first place. The rays remain 3D with this correction here as well, so I'm pretty confident that this is the right place to do it.

The problem seems to be that Coords.shader is only used for a mono render target - adding a test to conditionally disable the output based on the StereoParams.x being less or more than 0 only disabled it when StereoParams.x > 0, which would explain why I can fix the halo in the right eye only.

So, I'm trying to work out how to force it to be stereoised, but not having much luck yet. This is what I have:

// Fixes shadow placement. The fact that this worked was a surprise to me - I
// thought the driver's default was for square render targets to be mono
DefSquareSurfaceMode = 2


// Stereoize the _DepthEpi surface used for volumetric light shafts, which is
// written from the Hidden/Coord shader and read from the Hidden/Final
// Interpolation shader.
SurfaceCreationModeList = 0;
[SF0]
DefMode = 1
Format = 114
Width = 1024
Height = 1024
Usage = 1
Pool = 0
Levels = 1

[PS8415AC69]
GetSampler1FromReg = 1
[PS4C517B70]
GetSampler1FromReg = 1


Which is based on this output from the log file, as well as decoding the DDS header in the Tex1.dds dumped out with F12:

D3DUSAGE_RENDERTARGET/D3DUSAGE_DEPTHSTENCIL Height 1024 Width 1024 Usage 1 Format 114 Pool 0 Levels 1 texptr 0 nIndex 1, Mode 1 
D3DUSAGE_RENDERTARGET/D3DUSAGE_DEPTHSTENCIL Height 1024 Width 1024 Usage 1 Format 114 Pool 0 Levels 1 texptr 0 nIndex 2, Mode 1
GetSampler1FromReg GetTexture lpTex h 1024 w 1024 u 1 t 1 f 114 tex 34f1b060 shad 8415ac69
D3DUSAGE_RENDERTARGET/D3DUSAGE_DEPTHSTENCIL Height 1024 Width 1024 Usage 1 Format 114 Pool 0 Levels 1 texptr 34f1b060 nIndex 3, Mode 1
D3DUSAGE_RENDERTARGET/D3DUSAGE_DEPTHSTENCIL Height 1024 Width 1024 Usage 1 Format 114 Pool 0 Levels 1 texptr 34f1b060 nIndex 4, Mode 1
D3DUSAGE_RENDERTARGET/D3DUSAGE_DEPTHSTENCIL Height 1024 Width 1024 Usage 1 Format 114 Pool 0 Levels 1 texptr 34f1b060 nIndex 5, Mode 1
D3DUSAGE_RENDERTARGET/D3DUSAGE_DEPTHSTENCIL Height 1024 Width 1024 Usage 1 Format 114 Pool 0 Levels 1 texptr 34f1b060 nIndex 6, Mode 1
D3DUSAGE_RENDERTARGET/D3DUSAGE_DEPTHSTENCIL Height 1024 Width 1024 Usage 1 Format 114 Pool 0 Levels 1 texptr 34f1b060 nIndex 7, Mode 1
D3DUSAGE_RENDERTARGET/D3DUSAGE_DEPTHSTENCIL Height 1024 Width 1024 Usage 1 Format 114 Pool 0 Levels 1 texptr 34f1b060 nIndex 8, Mode 1
D3DUSAGE_RENDERTARGET/D3DUSAGE_DEPTHSTENCIL Height 1024 Width 1024 Usage 1 Format 114 Pool 0 Levels 1 texptr 34f1b060 nIndex 9, Mode 1
D3DUSAGE_RENDERTARGET/D3DUSAGE_DEPTHSTENCIL Height 1024 Width 1024 Usage 1 Format 114 Pool 0 Levels 1 texptr 34f1b060 nIndex 10, Mode 1
D3DUSAGE_RENDERTARGET/D3DUSAGE_DEPTHSTENCIL Height 1024 Width 1024 Usage 1 Format 114 Pool 0 Levels 1 texptr 34f1b060 nIndex 11, Mode 1
D3DUSAGE_RENDERTARGET/D3DUSAGE_DEPTHSTENCIL Height 1024 Width 1024 Usage 1 Format 114 Pool 0 Levels 1 texptr 34f1b060 nIndex 12, Mode 1
GetSampler1FromReg GetTexture lpTex h 1024 w 1024 u 1 t 1 f 114 tex 720bf9c0 shad 4c517b70
D3DUSAGE_RENDERTARGET/D3DUSAGE_DEPTHSTENCIL Height 1024 Width 1024 Usage 1 Format 114 Pool 0 Levels 1 texptr 720bf9c0 nIndex 13, Mode 1
D3DUSAGE_RENDERTARGET/D3DUSAGE_DEPTHSTENCIL Height 1024 Width 1024 Usage 1 Format 114 Pool 0 Levels 1 texptr 720bf9c0 nIndex 14, Mode 1
GetSampler1FromReg GetTexture lpTex h 1024 w 1024 u 1 t 1 f 114 tex 720c0a00 shad 4c517b70
D3DUSAGE_RENDERTARGET/D3DUSAGE_DEPTHSTENCIL Height 1024 Width 1024 Usage 1 Format 114 Pool 0 Levels 1 texptr 720c0a00 nIndex 15, Mode 1
D3DUSAGE_RENDERTARGET/D3DUSAGE_DEPTHSTENCIL Height 1024 Width 1024 Usage 1 Format 114 Pool 0 Levels 1 texptr 720c0a00 nIndex 16, Mode 1
GetSampler1FromReg GetTexture lpTex h 1024 w 1024 u 1 t 1 f 114 tex 720bf9c0 shad 4c517b70
D3DUSAGE_RENDERTARGET/D3DUSAGE_DEPTHSTENCIL Height 1024 Width 1024 Usage 1 Format 114 Pool 0 Levels 1 texptr 720bf9c0 nIndex 17, Mode 1
D3DUSAGE_RENDERTARGET/D3DUSAGE_DEPTHSTENCIL Height 1024 Width 1024 Usage 1 Format 114 Pool 0 Levels 1 texptr 720bf9c0 nIndex 18, Mode 1
GetSampler1FromReg GetTexture lpTex h 1024 w 1024 u 1 t 1 f 114 tex 720c0a00 shad 4c517b70
D3DUSAGE_RENDERTARGET/D3DUSAGE_DEPTHSTENCIL Height 1024 Width 1024 Usage 1 Format 114 Pool 0 Levels 1 texptr 720c0a00 nIndex 19, Mode 1
D3DUSAGE_RENDERTARGET/D3DUSAGE_DEPTHSTENCIL Height 1024 Width 1024 Usage 1 Format 114 Pool 0 Levels 1 texptr 720c0a00 nIndex 20, Mode 1
GetSampler1FromReg GetTexture lpTex h 1024 w 1024 u 1 t 1 f 114 tex 720bf9c0 shad 4c517b70


Does that look correct?

Earlier I also tried setting DefSquareSurfaceMode = 1, which broke shadows, but didn't seem to change anything on this effect :(

Also, is there anything special that needs to happen in the texld instruction when sampling a stereoised texture? How does it know which to sample - does the driver automatically sample the one that matches the current eye being drawn?

I guess what I'm asking is how is this supposed to work?

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 11/07/2014 11:34 AM   
The latest update for Sims 4 finally introduced swimming pools (hurray!). But this also brought back the issues with refraction Sims 2 and Sims 3 already had. For these games the solution was very simple as the issue was fixed by the adequate profile (Aion, later The Sims 3 profile itself). For Sims 4 these profiles also fix the water issue but in addition mess up the HUD completely and also cause issues with ambient occlusion. So I guess the only solution is to fix the water shaders. Unfortunately I have no idea how to fix refraction issues and hope that You can give me some hints. The issue looks like this: http://photos.3dvisionlive.com/3d4dd/image/54638154d475fef77800018f/ There is a shift between the parts above and under the water surface depending on the distance. The reflections are also messed up but can be disabled by the game settings. I think this should be the relevant PS: [code]// // Generated by shader FountainWater.fx // // Parameters: // // float4 CascadeShadowParams[6]; // float4 ExteriorLightData[4]; // float FresnelOffset; // float4 LightColors[4]; // float4 LightDirections[4]; // float NormalMapScale; // float ReflectionBlend; // float ReflectionStrength; // float RefractionDistortionScale; // float3 ShadowTint; // float SpecularPower; // float SpecularStrength; // float4 diffuse; // sampler2D samplerDiffuseMap; // samplerCUBE samplerEnvCubeMap; // sampler2D samplerNormalMap; // sampler2D samplerShadowMainMap; // sampler2D samplerWaterReflectionMapForLot; // sampler2D samplertranslucentTexture; // float4 shadowTextureData; // // // Registers: // // Name Reg Size // ------------------------------- ----- ---- // ExteriorLightData c6 2 // diffuse c10 1 // CascadeShadowParams c12 6 // LightDirections c18 2 // LightColors c20 2 // shadowTextureData c22 1 // FresnelOffset c23 1 // NormalMapScale c24 1 // RefractionDistortionScale c25 1 // ReflectionStrength c26 1 // ReflectionBlend c27 1 // SpecularStrength c28 1 // SpecularPower c29 1 // ShadowTint c30 1 // samplertranslucentTexture s0 1 // samplerNormalMap s1 1 // samplerDiffuseMap s2 1 // samplerEnvCubeMap s3 1 // samplerWaterReflectionMapForLot s4 1 // samplerShadowMainMap s5 1 // // // Default values: // // ExteriorLightData // c6 = { 0, 0, 0, 0 }; // c7 = { 0, 0, 0, 0 }; // // diffuse // c10 = { 1, 1, 1, 1 }; // // CascadeShadowParams // c12 = { 0, 0, 0, 0 }; // c13 = { 0, 0, 0, 0 }; // c14 = { 0, 0, 0, 0 }; // c15 = { 0, 0, 0, 0 }; // c16 = { 0, 0, 0, 0 }; // c17 = { 0, 0, 0, 0 }; // // LightDirections // c18 = { 0, 0, 0, 0 }; // c19 = { 0, 0, 0, 0 }; // // LightColors // c20 = { 0, 0, 0, 0 }; // c21 = { 0, 0, 0, 0 }; // // shadowTextureData // c22 = { 1024, 1024, 0.000976563, 0.000976563 }; // // FresnelOffset // c23 = { 0.2, 0, 0, 0 }; // // NormalMapScale // c24 = { 1, 0, 0, 0 }; // // RefractionDistortionScale // c25 = { 0.45, 0, 0, 0 }; // // ReflectionStrength // c26 = { 1, 0, 0, 0 }; // // ReflectionBlend // c27 = { 1, 0, 0, 0 }; // // SpecularStrength // c28 = { 1, 0, 0, 0 }; // // SpecularPower // c29 = { 500, 0, 0, 0 }; // // ShadowTint // c30 = { 0.5, 0.5, 0.5, 0 }; // ps_3_0 def c0, 2.00787401, -1.03937006, 0, 1 def c1, 0.135000005, 0.25, 0.300000012, 0.0500000007 def c2, 1, 0.5, 2, 0.119999997 dcl_texcoord v0.xy dcl_texcoord2 v1.xyz dcl_texcoord3 v2 dcl_color1 v3.xyz dcl_texcoord4 v4 dcl_texcoord7 v5 dcl_color v6 dcl_2d s0 dcl_2d s1 dcl_2d s2 dcl_cube s3 dcl_2d s4 dcl_2d s5 mov r0.xyz, c12 mad r1.xyz, v4, r0, c13 add r2.xy, v4.w, -c16.yxzw mov r0.xyz, c14 mad r0.xyz, v4, r0, c15 cmp r1.xyz, r2.y, r1, v4 cmp r2.xyz, r2.x, r0, r1 mov r0.zw, c0 mad r0.xy, c22.zwzw, -r0.zwzw, r2 mad r0.zw, r2.z, c0.xywz, c0 texldp r0, r0, s5 mov r2.w, c0.w add r4.y, r2.y, c22.w mov r4.xzw, r2 texldp r1, r2, s5 mov r5.zw, c22 mad r3.xy, r5.zwzw, -c2, r2 texldp r2, r4, s5 mov r3.zw, r4 mov r0.z, r2.x mov r0.y, r1.x dp3 r4.w, c1.xyxw, r0 mov r1.xzw, r3 texldp r0, r3, s5 mov r2.zw, r1 mad r2.xy, r5.zwzw, c2.zxzw, r3 mov r3.xzw, r2 texldp r2, r2, s5 add r1.y, r3.y, c22.w texldp r3, r3, s5 mov r0.w, r3.x texldp r1, r1, s5 mov r0.y, r1.x texld r1, v5, s1 mov r1.xy, r1.wzzw texld r3, v5.zwzw, s1 mov r1.zw, r3 mov r0.z, r2.x mad r2, r1, c0.x, c0.y dp2add_sat r1.x, r2, r2, c0.z dp2add_sat r1.y, r2.wzzw, r2.wzzw, c0.z dp4 r0.w, c2.w, r0 add r0.xy, -r1, c0.w add r3.w, r4.w, r0.w rsq r1.x, r0.x rsq r1.y, r0.y rcp r0.y, r1.x rcp r1.y, r1.y mov r0.xz, r2.xyyw mov r1.xz, r2.wyzw mad_sat r0.w, v4.w, c17.z, c17.w add r0.xyz, r0, r1 mul r0.xy, r0, c24.x lrp r1.w, r0.w, c0.w, r3.w dp3 r0.w, r0, r0 add_sat r4.xyz, r1.w, c30 rsq r0.w, r0.w mad r1.xy, r0.xzzw, r0.w, v0 mul r2.xyz, r0, r0.w texld r1, r1, s2 mul r1.w, r1.w, c10.w mad r0.xy, r2.xzzw, c25.x, v6 mov r0.zw, v6 texldp r0, r0, s0 nrm r3.xyz, v1 mad r1.xyz, c10, r1, -r0 dp3 r0.w, r2, r3 mad r1.xyz, r1.w, r1, r0 add r1.w, -r0.w, c0.w mul r0.xyz, r1, v3 mul r2.w, r1.w, r1.w mul r0.xyz, r4, r0 mad_sat r1.w, r1.w, r2.w, c23.x add r0.w, r0.w, r0.w add_sat r2.w, r1.w, c1.z mad r1.xyz, r2.w, r0, r1 mad r0.xyz, r2, r0.w, -r3 dp3_sat r3.x, r0, c7 dp3_sat r3.y, r0, c19 texld r0, r0, s3 // no effect add r0.w, c29.x, c29.x mad r4.xy, r0.w, -r3, r0.w add r4.xy, r3, r4 rcp r4.x, r4.x rcp r4.y, r4.y mul r4.xy, r3, r4 mul r3.xyz, r4.y, c21 mad r3.xyz, r4.x, c6, r3 mad r1.xyz, c26.x, v3, r1 mul r0.xyz, r0, r3 mul r3.xy, r2.xzzw, v6.w mul r0.xyz, r0, c28.x mad_sat r2.xyz, r0, r1.w, r1 mul r2.w, r1.w, c27.x mad r0.xy, r3, c1.w, v6 mov r0.zw, v6 texldp r0, r0, s4 lrp r1.xyz, r2.w, r0, r2 add r0.xyz, -r1, v2 mov_sat r0.w, v2.w mad oC0.xyz, r0.w, r0, r1 mov oC0.w, c0.z // approximately 106 instruction slots used (13 texture, 93 arithmetic) [/code] This is the VS: [code]// // Generated by shader FountainWater.fx // // Parameters: // // float2 DiffuseUVScale; // float4 FogParams; // float4 GameTimeData; // float3 HorizonDark; // float3 HorizonLight; // float Layer2Shift; // float4 LightmapSizeParameters; // float3 MinspecHorizonColor; // float2 NormalUVScale; // float4x4 ObjectToClipSpaceMatrix; // float4x4 ObjectToWorldSpaceMatrix; // float3 SkyDark; // float3 SkyLight; // float3 SunVector; // float2 WaterScrollSpeedLayer1; // float2 WaterScrollSpeedLayer2; // float4 WorldSpaceCameraPosition; // float4x4 WorldToLightSpaceMatrix; // float4 viewDistanceBasis; // // // Registers: // // Name Reg Size // ------------------------ ----- ---- // MinspecHorizonColor c0 1 // SunVector c1 1 // HorizonLight c12 1 // HorizonDark c13 1 // SkyLight c14 1 // SkyDark c15 1 // NormalUVScale c16 1 // WaterScrollSpeedLayer1 c17 1 // WaterScrollSpeedLayer2 c18 1 // Layer2Shift c19 1 // GameTimeData c200 1 // WorldSpaceCameraPosition c201 1 // ObjectToWorldSpaceMatrix c202 3 // ObjectToClipSpaceMatrix c206 4 // FogParams c218 1 // DiffuseUVScale c219 1 // viewDistanceBasis c226 1 // LightmapSizeParameters c227 1 // WorldToLightSpaceMatrix c244 3 // // // Default values: // // MinspecHorizonColor // c0 = { 0.875, 0.984, 0.992, 0 }; // // SunVector // c1 = { 0.57735, -0.57735, 0.57735, 0 }; // // HorizonLight // c12 = { 0.875, 0.984, 0.992, 0 }; // // HorizonDark // c13 = { 0.875, 0.984, 0.992, 0 }; // // SkyLight // c14 = { 0.898, 0.965, 0.914, 0 }; // // SkyDark // c15 = { 0.6, 0.918, 0.949, 0 }; // // NormalUVScale // c16 = { 1, 1, 0, 0 }; // // WaterScrollSpeedLayer1 // c17 = { 0.01, 0.025, 0, 0 }; // // WaterScrollSpeedLayer2 // c18 = { 0.015, -0.036, 0, 0 }; // // Layer2Shift // c19 = { 1.5, 0, 0, 0 }; // // GameTimeData // c200 = { 0, 0, 0, 0 }; // // WorldSpaceCameraPosition // c201 = { 0, 0, 0, 0 }; // // ObjectToWorldSpaceMatrix // c202 = { 0, 0, 0, 0 }; // c203 = { 0, 0, 0, 0 }; // c204 = { 0, 0, 0, 0 }; // // ObjectToClipSpaceMatrix // c206 = { 0, 0, 0, 0 }; // c207 = { 0, 0, 0, 0 }; // c208 = { 0, 0, 0, 0 }; // c209 = { 0, 0, 0, 0 }; // // FogParams // c218 = { 0.0001, 0, 1, 2 }; // // DiffuseUVScale // c219 = { 1, 1, 0, 0 }; // // viewDistanceBasis // c226 = { 0, 0, 0, 0 }; // // LightmapSizeParameters // c227 = { 0, 0, 0, 0 }; // // WorldToLightSpaceMatrix // c244 = { 0, 0, 0, 0 }; // c245 = { 0, 0, 0, 0 }; // c246 = { 0, 0, 0, 0 }; // vs_3_0 def c2, 0.5, 0.00390625, -128, 1 def c3, 0.5, 0, 1, -2 def c4, -1, 1, 3, 0 dcl_position v0 dcl_texcoord v1 dcl_position o0 dcl_texcoord o1.xyz dcl_texcoord1 o2.xy dcl_texcoord2 o3 dcl_texcoord3 o4 dcl_color1 o5.xyz dcl_texcoord4 o6 dcl_texcoord6 o7.xyz dcl_texcoord7 o8 dcl_color o9 mad r0.w, v0.z, c2.y, v0.w add r1.y, r0.w, c2.z mad r1.xzw, v0.xyyx, c3.xyxy, c3.yyyz mul r0.zw, c2.x, v1 dp4 o0.z, r1, c208 mul o1.xy, r0.zwzw, c219 mul r2.zw, r0, c16.xyxy dp4 r0.y, r1, c203 mul r2.xy, c2.x, v0 slt r0.w, c201.y, r0.y mul o2.xy, r2, c227 mad o1.z, r0.w, c3.w, c3.z mov r0.w, c200.x mad o8.xy, c17, r0.w, r2.zwzw add r0.w, r0.w, c19.x dp4 r0.x, r1, c202 dp4 r0.z, r1, c204 mad o8.zw, c18.xyxy, r0.w, r2 add r4.xyz, -r0, c201 dp3 r0.w, -r4, c226 mul r2.xyz, r4, c4.xyxw mad o4.w, r0.w, c218.x, c218.y nrm r3.xyz, r2 mov r2.xyz, c13 add r2.xyz, -r2, c12 dp3 r0.w, r3, c1 mov o3.xyz, r4 add r2.w, r0.w, c2.w mul_sat r0.w, r3.y, c4.z mul_sat r2.w, r2.w, c2.x min r3.w, r2.w, c2.w mov r3.xyz, c15 add r3.xyz, -r3, c14 mad r2.xyz, r3.w, r2, c13 mad r3.xyz, r2.w, r3, c15 add r2.xyz, r2, -r3 add r0.w, -r0.w, c2.w mad o5.xyz, r0.w, r2, r3 dp4 r2.x, r1, c206 dp4 r2.w, r1, c209 dp4 r2.y, r1, c207 add r3.x, r2.x, r2.w mov o0.xyw, r2 add r3.y, r2.w, -r2.y mov r1.x, r2.w mul o9.xy, r3, c2.x mov r0.w, c2.w dp4 o6.x, r0, c244 dp4 o6.y, r0, c245 dp4 o6.z, r0, c246 mov o3.w, c3.y mov o4.xyz, c0 mov o6.w, r1.x mul o9.zw, r1.x, c3.xyyz mov o7.x, c202.x mov o7.y, c203.x mov o7.z, c204.x // approximately 59 instruction slots used [/code] Any suggestions are welcome ;)
The latest update for Sims 4 finally introduced swimming pools (hurray!). But this also brought back the issues with refraction Sims 2 and Sims 3 already had. For these games the solution was very simple as the issue was fixed by the adequate profile (Aion, later The Sims 3 profile itself). For Sims 4 these profiles also fix the water issue but in addition mess up the HUD completely and also cause issues with ambient occlusion. So I guess the only solution is to fix the water shaders. Unfortunately I have no idea how to fix refraction issues and hope that You can give me some hints.
The issue looks like this:

http://photos.3dvisionlive.com/3d4dd/image/54638154d475fef77800018f/

There is a shift between the parts above and under the water surface depending on the distance. The reflections are also messed up but can be disabled by the game settings.
I think this should be the relevant PS:
//
// Generated by shader FountainWater.fx
//
// Parameters:
//
// float4 CascadeShadowParams[6];
// float4 ExteriorLightData[4];
// float FresnelOffset;
// float4 LightColors[4];
// float4 LightDirections[4];
// float NormalMapScale;
// float ReflectionBlend;
// float ReflectionStrength;
// float RefractionDistortionScale;
// float3 ShadowTint;
// float SpecularPower;
// float SpecularStrength;
// float4 diffuse;
// sampler2D samplerDiffuseMap;
// samplerCUBE samplerEnvCubeMap;
// sampler2D samplerNormalMap;
// sampler2D samplerShadowMainMap;
// sampler2D samplerWaterReflectionMapForLot;
// sampler2D samplertranslucentTexture;
// float4 shadowTextureData;
//
//
// Registers:
//
// Name Reg Size
// ------------------------------- ----- ----
// ExteriorLightData c6 2
// diffuse c10 1
// CascadeShadowParams c12 6
// LightDirections c18 2
// LightColors c20 2
// shadowTextureData c22 1
// FresnelOffset c23 1
// NormalMapScale c24 1
// RefractionDistortionScale c25 1
// ReflectionStrength c26 1
// ReflectionBlend c27 1
// SpecularStrength c28 1
// SpecularPower c29 1
// ShadowTint c30 1
// samplertranslucentTexture s0 1
// samplerNormalMap s1 1
// samplerDiffuseMap s2 1
// samplerEnvCubeMap s3 1
// samplerWaterReflectionMapForLot s4 1
// samplerShadowMainMap s5 1
//
//
// Default values:
//
// ExteriorLightData
// c6 = { 0, 0, 0, 0 };
// c7 = { 0, 0, 0, 0 };
//
// diffuse
// c10 = { 1, 1, 1, 1 };
//
// CascadeShadowParams
// c12 = { 0, 0, 0, 0 };
// c13 = { 0, 0, 0, 0 };
// c14 = { 0, 0, 0, 0 };
// c15 = { 0, 0, 0, 0 };
// c16 = { 0, 0, 0, 0 };
// c17 = { 0, 0, 0, 0 };
//
// LightDirections
// c18 = { 0, 0, 0, 0 };
// c19 = { 0, 0, 0, 0 };
//
// LightColors
// c20 = { 0, 0, 0, 0 };
// c21 = { 0, 0, 0, 0 };
//
// shadowTextureData
// c22 = { 1024, 1024, 0.000976563, 0.000976563 };
//
// FresnelOffset
// c23 = { 0.2, 0, 0, 0 };
//
// NormalMapScale
// c24 = { 1, 0, 0, 0 };
//
// RefractionDistortionScale
// c25 = { 0.45, 0, 0, 0 };
//
// ReflectionStrength
// c26 = { 1, 0, 0, 0 };
//
// ReflectionBlend
// c27 = { 1, 0, 0, 0 };
//
// SpecularStrength
// c28 = { 1, 0, 0, 0 };
//
// SpecularPower
// c29 = { 500, 0, 0, 0 };
//
// ShadowTint
// c30 = { 0.5, 0.5, 0.5, 0 };
//

ps_3_0
def c0, 2.00787401, -1.03937006, 0, 1
def c1, 0.135000005, 0.25, 0.300000012, 0.0500000007
def c2, 1, 0.5, 2, 0.119999997
dcl_texcoord v0.xy
dcl_texcoord2 v1.xyz
dcl_texcoord3 v2
dcl_color1 v3.xyz
dcl_texcoord4 v4
dcl_texcoord7 v5
dcl_color v6
dcl_2d s0
dcl_2d s1
dcl_2d s2
dcl_cube s3
dcl_2d s4
dcl_2d s5
mov r0.xyz, c12
mad r1.xyz, v4, r0, c13
add r2.xy, v4.w, -c16.yxzw
mov r0.xyz, c14
mad r0.xyz, v4, r0, c15
cmp r1.xyz, r2.y, r1, v4
cmp r2.xyz, r2.x, r0, r1
mov r0.zw, c0
mad r0.xy, c22.zwzw, -r0.zwzw, r2
mad r0.zw, r2.z, c0.xywz, c0
texldp r0, r0, s5
mov r2.w, c0.w
add r4.y, r2.y, c22.w
mov r4.xzw, r2
texldp r1, r2, s5
mov r5.zw, c22
mad r3.xy, r5.zwzw, -c2, r2
texldp r2, r4, s5
mov r3.zw, r4
mov r0.z, r2.x
mov r0.y, r1.x
dp3 r4.w, c1.xyxw, r0
mov r1.xzw, r3
texldp r0, r3, s5
mov r2.zw, r1
mad r2.xy, r5.zwzw, c2.zxzw, r3
mov r3.xzw, r2
texldp r2, r2, s5
add r1.y, r3.y, c22.w
texldp r3, r3, s5
mov r0.w, r3.x
texldp r1, r1, s5
mov r0.y, r1.x
texld r1, v5, s1
mov r1.xy, r1.wzzw
texld r3, v5.zwzw, s1
mov r1.zw, r3
mov r0.z, r2.x
mad r2, r1, c0.x, c0.y
dp2add_sat r1.x, r2, r2, c0.z
dp2add_sat r1.y, r2.wzzw, r2.wzzw, c0.z
dp4 r0.w, c2.w, r0
add r0.xy, -r1, c0.w
add r3.w, r4.w, r0.w
rsq r1.x, r0.x
rsq r1.y, r0.y
rcp r0.y, r1.x
rcp r1.y, r1.y
mov r0.xz, r2.xyyw
mov r1.xz, r2.wyzw
mad_sat r0.w, v4.w, c17.z, c17.w
add r0.xyz, r0, r1
mul r0.xy, r0, c24.x
lrp r1.w, r0.w, c0.w, r3.w
dp3 r0.w, r0, r0
add_sat r4.xyz, r1.w, c30
rsq r0.w, r0.w
mad r1.xy, r0.xzzw, r0.w, v0
mul r2.xyz, r0, r0.w
texld r1, r1, s2
mul r1.w, r1.w, c10.w
mad r0.xy, r2.xzzw, c25.x, v6
mov r0.zw, v6
texldp r0, r0, s0
nrm r3.xyz, v1
mad r1.xyz, c10, r1, -r0
dp3 r0.w, r2, r3
mad r1.xyz, r1.w, r1, r0
add r1.w, -r0.w, c0.w
mul r0.xyz, r1, v3
mul r2.w, r1.w, r1.w
mul r0.xyz, r4, r0
mad_sat r1.w, r1.w, r2.w, c23.x
add r0.w, r0.w, r0.w
add_sat r2.w, r1.w, c1.z
mad r1.xyz, r2.w, r0, r1
mad r0.xyz, r2, r0.w, -r3
dp3_sat r3.x, r0, c7
dp3_sat r3.y, r0, c19
texld r0, r0, s3 // no effect
add r0.w, c29.x, c29.x
mad r4.xy, r0.w, -r3, r0.w
add r4.xy, r3, r4
rcp r4.x, r4.x
rcp r4.y, r4.y
mul r4.xy, r3, r4
mul r3.xyz, r4.y, c21
mad r3.xyz, r4.x, c6, r3
mad r1.xyz, c26.x, v3, r1
mul r0.xyz, r0, r3
mul r3.xy, r2.xzzw, v6.w
mul r0.xyz, r0, c28.x
mad_sat r2.xyz, r0, r1.w, r1
mul r2.w, r1.w, c27.x
mad r0.xy, r3, c1.w, v6
mov r0.zw, v6
texldp r0, r0, s4
lrp r1.xyz, r2.w, r0, r2
add r0.xyz, -r1, v2
mov_sat r0.w, v2.w
mad oC0.xyz, r0.w, r0, r1
mov oC0.w, c0.z

// approximately 106 instruction slots used (13 texture, 93 arithmetic)

This is the VS:
//
// Generated by shader FountainWater.fx
//
// Parameters:
//
// float2 DiffuseUVScale;
// float4 FogParams;
// float4 GameTimeData;
// float3 HorizonDark;
// float3 HorizonLight;
// float Layer2Shift;
// float4 LightmapSizeParameters;
// float3 MinspecHorizonColor;
// float2 NormalUVScale;
// float4x4 ObjectToClipSpaceMatrix;
// float4x4 ObjectToWorldSpaceMatrix;
// float3 SkyDark;
// float3 SkyLight;
// float3 SunVector;
// float2 WaterScrollSpeedLayer1;
// float2 WaterScrollSpeedLayer2;
// float4 WorldSpaceCameraPosition;
// float4x4 WorldToLightSpaceMatrix;
// float4 viewDistanceBasis;
//
//
// Registers:
//
// Name Reg Size
// ------------------------ ----- ----
// MinspecHorizonColor c0 1
// SunVector c1 1
// HorizonLight c12 1
// HorizonDark c13 1
// SkyLight c14 1
// SkyDark c15 1
// NormalUVScale c16 1
// WaterScrollSpeedLayer1 c17 1
// WaterScrollSpeedLayer2 c18 1
// Layer2Shift c19 1
// GameTimeData c200 1
// WorldSpaceCameraPosition c201 1
// ObjectToWorldSpaceMatrix c202 3
// ObjectToClipSpaceMatrix c206 4
// FogParams c218 1
// DiffuseUVScale c219 1
// viewDistanceBasis c226 1
// LightmapSizeParameters c227 1
// WorldToLightSpaceMatrix c244 3
//
//
// Default values:
//
// MinspecHorizonColor
// c0 = { 0.875, 0.984, 0.992, 0 };
//
// SunVector
// c1 = { 0.57735, -0.57735, 0.57735, 0 };
//
// HorizonLight
// c12 = { 0.875, 0.984, 0.992, 0 };
//
// HorizonDark
// c13 = { 0.875, 0.984, 0.992, 0 };
//
// SkyLight
// c14 = { 0.898, 0.965, 0.914, 0 };
//
// SkyDark
// c15 = { 0.6, 0.918, 0.949, 0 };
//
// NormalUVScale
// c16 = { 1, 1, 0, 0 };
//
// WaterScrollSpeedLayer1
// c17 = { 0.01, 0.025, 0, 0 };
//
// WaterScrollSpeedLayer2
// c18 = { 0.015, -0.036, 0, 0 };
//
// Layer2Shift
// c19 = { 1.5, 0, 0, 0 };
//
// GameTimeData
// c200 = { 0, 0, 0, 0 };
//
// WorldSpaceCameraPosition
// c201 = { 0, 0, 0, 0 };
//
// ObjectToWorldSpaceMatrix
// c202 = { 0, 0, 0, 0 };
// c203 = { 0, 0, 0, 0 };
// c204 = { 0, 0, 0, 0 };
//
// ObjectToClipSpaceMatrix
// c206 = { 0, 0, 0, 0 };
// c207 = { 0, 0, 0, 0 };
// c208 = { 0, 0, 0, 0 };
// c209 = { 0, 0, 0, 0 };
//
// FogParams
// c218 = { 0.0001, 0, 1, 2 };
//
// DiffuseUVScale
// c219 = { 1, 1, 0, 0 };
//
// viewDistanceBasis
// c226 = { 0, 0, 0, 0 };
//
// LightmapSizeParameters
// c227 = { 0, 0, 0, 0 };
//
// WorldToLightSpaceMatrix
// c244 = { 0, 0, 0, 0 };
// c245 = { 0, 0, 0, 0 };
// c246 = { 0, 0, 0, 0 };
//

vs_3_0
def c2, 0.5, 0.00390625, -128, 1
def c3, 0.5, 0, 1, -2
def c4, -1, 1, 3, 0
dcl_position v0
dcl_texcoord v1
dcl_position o0
dcl_texcoord o1.xyz
dcl_texcoord1 o2.xy
dcl_texcoord2 o3
dcl_texcoord3 o4
dcl_color1 o5.xyz
dcl_texcoord4 o6
dcl_texcoord6 o7.xyz
dcl_texcoord7 o8
dcl_color o9
mad r0.w, v0.z, c2.y, v0.w
add r1.y, r0.w, c2.z
mad r1.xzw, v0.xyyx, c3.xyxy, c3.yyyz
mul r0.zw, c2.x, v1
dp4 o0.z, r1, c208
mul o1.xy, r0.zwzw, c219
mul r2.zw, r0, c16.xyxy
dp4 r0.y, r1, c203
mul r2.xy, c2.x, v0
slt r0.w, c201.y, r0.y
mul o2.xy, r2, c227
mad o1.z, r0.w, c3.w, c3.z
mov r0.w, c200.x
mad o8.xy, c17, r0.w, r2.zwzw
add r0.w, r0.w, c19.x
dp4 r0.x, r1, c202
dp4 r0.z, r1, c204
mad o8.zw, c18.xyxy, r0.w, r2
add r4.xyz, -r0, c201
dp3 r0.w, -r4, c226
mul r2.xyz, r4, c4.xyxw
mad o4.w, r0.w, c218.x, c218.y
nrm r3.xyz, r2
mov r2.xyz, c13
add r2.xyz, -r2, c12
dp3 r0.w, r3, c1
mov o3.xyz, r4
add r2.w, r0.w, c2.w
mul_sat r0.w, r3.y, c4.z
mul_sat r2.w, r2.w, c2.x
min r3.w, r2.w, c2.w
mov r3.xyz, c15
add r3.xyz, -r3, c14
mad r2.xyz, r3.w, r2, c13
mad r3.xyz, r2.w, r3, c15
add r2.xyz, r2, -r3
add r0.w, -r0.w, c2.w
mad o5.xyz, r0.w, r2, r3
dp4 r2.x, r1, c206
dp4 r2.w, r1, c209
dp4 r2.y, r1, c207
add r3.x, r2.x, r2.w
mov o0.xyw, r2
add r3.y, r2.w, -r2.y
mov r1.x, r2.w
mul o9.xy, r3, c2.x
mov r0.w, c2.w
dp4 o6.x, r0, c244
dp4 o6.y, r0, c245
dp4 o6.z, r0, c246
mov o3.w, c3.y
mov o4.xyz, c0
mov o6.w, r1.x
mul o9.zw, r1.x, c3.xyyz
mov o7.x, c202.x
mov o7.y, c203.x
mov o7.z, c204.x

// approximately 59 instruction slots used

Any suggestions are welcome ;)

My original display name is 3d4dd - for some reason Nvidia changed it..?!

Posted 11/12/2014 04:17 PM   
Hey guys, just wanted to post here and tell you all that you do amazing work! What would we do without the shader tweaks? I'm enjoying my games so much more with all the patches. I hope 3D vision lives long and prosper!
Hey guys, just wanted to post here and tell you all that you do amazing work!

What would we do without the shader tweaks? I'm enjoying my games so much more with all the patches. I hope 3D vision lives long and prosper!

Posted 11/12/2014 04:34 PM   
I do not manage to convert V1.1 vertex shader to V3.0. I tried to make it manually and with the shader converter tool, but I got crash with the game (RoF) with the modified shader. Here is the original shader [code]vs_1_1 def c66, 3, 1, 0, 0.999000013 def c67, 1000, 0, 0, 0 dcl_position v0 dcl_normal v1 dcl_texcoord v2 dcl_blendindices v3 dcl_texcoord1 v4 mov r0.w, c64.w mov r1.xyz, v0 mov r1.w, c64.w mul r2.x, v3.x, c66.x mov a0.x, r2.x dp4 r0.x, r1, c0[a0.x] dp4 r0.y, r1, c1[a0.x] dp4 r0.z, r1, c2[a0.x] dp4 oPos.x, r0, c60 dp4 oPos.y, r0, c61 dp4 oPos.z, r0, c62 dp4 oPos.w, r0, c63 dp3 r1.x, v1, c0[a0.x] dp3 r1.y, v1, c1[a0.x] dp3 r1.z, v1, c2[a0.x] dp3 r0.w, r1, r1 rsq r0.w, r0.w mul r1.xyz, r0.w, r1 mad r3, v4.xyzx, c66.yyyz, c66.zzzy dp4 r4.x, r3, c0[a0.x] dp4 r4.y, r3, c1[a0.x] dp4 r4.z, r3, c2[a0.x] add r2.xyz, -r4, c65 dp3 r0.w, r2, r1 mul r0.w, r0.w, c66.w mad r2.xyz, r1, r0.w, r4 mov oT1.xyz, r1 add r1.xyz, -r2, c65 mad r1.xyz, r1, -c67.x, r4 add oT2.xyz, -r0, r1 mov oT0.xy, v2 [/code] and the modified shader (by converter tool) [code] vs_3_0 def c66, 3, 1, 0, 0.999000013 def c67, 1000, 0, 0, 0 dcl_position o10 dcl_texcoord1 o1.xyz dcl_texcoord2 o2.xyz dcl_texcoord o0.xy dcl_position v0 dcl_normal v1 dcl_texcoord v2 dcl_blendindices v3 dcl_texcoord1 v4 mov r0.w, c64.w mov r1.xyz, v0 mov r1.w, c64.w mul r2.x, v3.x, c66.x mov a0.x, r2.x dp4 r0.x, r1, c0[a0.x] dp4 r0.y, r1, c1[a0.x] dp4 r0.z, r1, c2[a0.x] dp4 o10.x, r0, c60 dp4 o10.y, r0, c61 dp4 o10.z, r0, c62 dp4 o10.w, r0, c63 dp3 r1.x, v1, c0[a0.x] dp3 r1.y, v1, c1[a0.x] dp3 r1.z, v1, c2[a0.x] dp3 r0.w, r1, r1 rsq r0.w, r0.w mul r1.xyz, r0.w, r1 mad r3, v4.xyzx, c66.yyyz, c66.zzzy dp4 r4.x, r3, c0[a0.x] dp4 r4.y, r3, c1[a0.x] dp4 r4.z, r3, c2[a0.x] add r2.xyz, -r4, c65 dp3 r0.w, r2, r1 mul r0.w, r0.w, c66.w mad r2.xyz, r1, r0.w, r4 mov o1.xyz, r1 add r1.xyz, -r2, c65 mad r1.xyz, r1, -c67.x, r4 add o2.xyz, -r0, r1 mov o0.xy, v2[/code] if someone can help...
I do not manage to convert V1.1 vertex shader to V3.0.
I tried to make it manually and with the shader converter tool, but I got crash with the game (RoF) with the modified shader.
Here is the original shader

vs_1_1
def c66, 3, 1, 0, 0.999000013
def c67, 1000, 0, 0, 0
dcl_position v0
dcl_normal v1
dcl_texcoord v2
dcl_blendindices v3
dcl_texcoord1 v4
mov r0.w, c64.w
mov r1.xyz, v0
mov r1.w, c64.w
mul r2.x, v3.x, c66.x
mov a0.x, r2.x
dp4 r0.x, r1, c0[a0.x]
dp4 r0.y, r1, c1[a0.x]
dp4 r0.z, r1, c2[a0.x]
dp4 oPos.x, r0, c60
dp4 oPos.y, r0, c61
dp4 oPos.z, r0, c62
dp4 oPos.w, r0, c63
dp3 r1.x, v1, c0[a0.x]
dp3 r1.y, v1, c1[a0.x]
dp3 r1.z, v1, c2[a0.x]
dp3 r0.w, r1, r1
rsq r0.w, r0.w
mul r1.xyz, r0.w, r1
mad r3, v4.xyzx, c66.yyyz, c66.zzzy
dp4 r4.x, r3, c0[a0.x]
dp4 r4.y, r3, c1[a0.x]
dp4 r4.z, r3, c2[a0.x]
add r2.xyz, -r4, c65
dp3 r0.w, r2, r1
mul r0.w, r0.w, c66.w
mad r2.xyz, r1, r0.w, r4
mov oT1.xyz, r1
add r1.xyz, -r2, c65
mad r1.xyz, r1, -c67.x, r4
add oT2.xyz, -r0, r1
mov oT0.xy, v2



and the modified shader (by converter tool)
vs_3_0
def c66, 3, 1, 0, 0.999000013
def c67, 1000, 0, 0, 0
dcl_position o10
dcl_texcoord1 o1.xyz
dcl_texcoord2 o2.xyz
dcl_texcoord o0.xy
dcl_position v0
dcl_normal v1
dcl_texcoord v2
dcl_blendindices v3
dcl_texcoord1 v4
mov r0.w, c64.w
mov r1.xyz, v0
mov r1.w, c64.w
mul r2.x, v3.x, c66.x
mov a0.x, r2.x
dp4 r0.x, r1, c0[a0.x]
dp4 r0.y, r1, c1[a0.x]
dp4 r0.z, r1, c2[a0.x]
dp4 o10.x, r0, c60
dp4 o10.y, r0, c61
dp4 o10.z, r0, c62
dp4 o10.w, r0, c63
dp3 r1.x, v1, c0[a0.x]
dp3 r1.y, v1, c1[a0.x]
dp3 r1.z, v1, c2[a0.x]
dp3 r0.w, r1, r1
rsq r0.w, r0.w
mul r1.xyz, r0.w, r1
mad r3, v4.xyzx, c66.yyyz, c66.zzzy
dp4 r4.x, r3, c0[a0.x]
dp4 r4.y, r3, c1[a0.x]
dp4 r4.z, r3, c2[a0.x]
add r2.xyz, -r4, c65
dp3 r0.w, r2, r1
mul r0.w, r0.w, c66.w
mad r2.xyz, r1, r0.w, r4
mov o1.xyz, r1
add r1.xyz, -r2, c65
mad r1.xyz, r1, -c67.x, r4
add o2.xyz, -r0, r1
mov o0.xy, v2


if someone can help...

Posted 11/15/2014 11:51 AM   
  160 / 167    
Scroll To Top