Bo3b's School For Shaderhackers
  6 / 88    
@bo3b AWESOME!!!!!!! While I haven't made the wiki page;)) I have most of the stuff right here (I just used a different game) Very nicely structured tutorials and awesome info;)) Now... GIVE US THE NEXT LESSONS ^_^ I am very interested in the FIXIN' part;)) (As I am pretty noobie when it comes to DirectX 9 assembly). Btw is there somewhere where I can read some information about what are the registres? like r1, r2,v4, ( I think oC0 is the color)... Awesome work!!!
@bo3b

AWESOME!!!!!!! While I haven't made the wiki page;)) I have most of the stuff right here (I just used a different game)
Very nicely structured tutorials and awesome info;))


Now... GIVE US THE NEXT LESSONS ^_^ I am very interested in the FIXIN' part;)) (As I am pretty noobie when it comes to DirectX 9 assembly).
Btw is there somewhere where I can read some information about what are the registres? like r1, r2,v4, ( I think oC0 is the color)...


Awesome work!!!

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)

#76
Posted 08/18/2014 06:26 PM   
@helifax I think [url=http://msdn.microsoft.com/en-us/library/windows/desktop/bb219840(v=vs.85).aspx]this[/url] is what you're looking for. :)
@helifax
I think this is what you're looking for. :)
#77
Posted 08/18/2014 08:25 PM   
[quote="TsaebehT"]@helifax I think [url=http://msdn.microsoft.com/en-us/library/windows/desktop/bb219840(v=vs.85).aspx]this[/url] is what you're looking for. :)[/quote] Yupp;)) Thanks;)) I also found the post from mike ( on page 2 I think where he gives all the resources).
TsaebehT said:@helifax
I think this is what you're looking for. :)


Yupp;)) Thanks;)) I also found the post from mike ( on page 2 I think where he gives all the resources).

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)

#78
Posted 08/18/2014 09:33 PM   
So..... I found this shader (Pixel Shader) which apparently controls the shadows in Risen3. [code] // // Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111 // // Parameters: // // float2 NearFar; // // // Registers: // // Name Reg Size // ------------ ----- ---- // NearFar c0 1 // // // Default values: // // NearFar // c0 = { 0, 0, 0, 0 }; // preshader rcp r0.x, c0.y mul r1.x, r0.x, (20) rcp c0.x, r1.x // approximately 3 instructions used // // Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111 // // Parameters: // // sampler2D BlurSamplerPnt; // sampler2D DepthSampler; // // // Registers: // // Name Reg Size // -------------- ----- ---- // DepthSampler s0 1 // BlurSamplerPnt s1 1 // ps_3_0 def c1, 1, 0, 0, 0 dcl_texcoord v0.xy dcl_texcoord1 v1.xy dcl_texcoord2 v2.xy dcl_texcoord3 v3.xy dcl_texcoord4 v4.xy dcl_2d s0 dcl_2d s1 texld r0, v1, s0 texld r1, v2, s0 mov r0.y, r1.x texld r1, v3, s0 mov r0.z, r1.x texld r1, v4, s0 mov r0.w, r1.x texld r1, v0, s0 add r0, r0, -r1.x mov r1.x, c1.x mad_sat r0, r0_abs, -c0.x, r1.x texld r1, v0, s1 texld r2, v1, s1 mad r1, r2, r0.x, r1 texld r2, v2, s1 mad r1, r2, r0.y, r1 texld r2, v3, s1 mad r1, r2, r0.z, r1 texld r2, v4, s1 mad r1, r2, r0.w, r1 dp4 r0.x, r0, c1.x add r0.x, r0.x, c1.x rcp r0.x, r0.x mul oC0, r0.x, r1 // approximately 24 instruction slots used (10 texture, 14 arithmetic) [/code] Now I looked on Helix Guide (on the blog to see what I need to declare to insert stereo) I also read quite alot on MSDN about ps3 registers and instructions... But have NO idea what do actually do here.... Another thing worth mentioning is that I can basically REMOVE all the code except for [code] preshader rcp r0.x, c0.y mul r1.x, r0.x, (20) rcp c0.x, r1.x [/code] and I still get the shadows. I have no idea what a "pre" shader is or how it comes in the scene... Thus no idea what to modify, where and how... Any Ideas? ^_^ Thx:D
So.....

I found this shader (Pixel Shader) which apparently controls the shadows in Risen3.

//
// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111
//
// Parameters:
//
// float2 NearFar;
//
//
// Registers:
//
// Name Reg Size
// ------------ ----- ----
// NearFar c0 1
//
//
// Default values:
//
// NearFar
// c0 = { 0, 0, 0, 0 };
//

preshader
rcp r0.x, c0.y
mul r1.x, r0.x, (20)
rcp c0.x, r1.x

// approximately 3 instructions used
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111
//
// Parameters:
//
// sampler2D BlurSamplerPnt;
// sampler2D DepthSampler;
//
//
// Registers:
//
// Name Reg Size
// -------------- ----- ----
// DepthSampler s0 1
// BlurSamplerPnt s1 1
//

ps_3_0
def c1, 1, 0, 0, 0
dcl_texcoord v0.xy
dcl_texcoord1 v1.xy
dcl_texcoord2 v2.xy
dcl_texcoord3 v3.xy
dcl_texcoord4 v4.xy
dcl_2d s0
dcl_2d s1
texld r0, v1, s0
texld r1, v2, s0
mov r0.y, r1.x
texld r1, v3, s0
mov r0.z, r1.x
texld r1, v4, s0
mov r0.w, r1.x
texld r1, v0, s0
add r0, r0, -r1.x
mov r1.x, c1.x
mad_sat r0, r0_abs, -c0.x, r1.x
texld r1, v0, s1
texld r2, v1, s1
mad r1, r2, r0.x, r1
texld r2, v2, s1
mad r1, r2, r0.y, r1
texld r2, v3, s1
mad r1, r2, r0.z, r1
texld r2, v4, s1
mad r1, r2, r0.w, r1
dp4 r0.x, r0, c1.x
add r0.x, r0.x, c1.x
rcp r0.x, r0.x
mul oC0, r0.x, r1

// approximately 24 instruction slots used (10 texture, 14 arithmetic)


Now I looked on Helix Guide (on the blog to see what I need to declare to insert stereo)
I also read quite alot on MSDN about ps3 registers and instructions...

But have NO idea what do actually do here....


Another thing worth mentioning is that I can basically REMOVE all the code except for

preshader
rcp r0.x, c0.y
mul r1.x, r0.x, (20)
rcp c0.x, r1.x

and I still get the shadows.

I have no idea what a "pre" shader is or how it comes in the scene... Thus no idea what to modify, where and how...
Any Ideas? ^_^ Thx:D

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)

#79
Posted 08/18/2014 09:36 PM   
Are you sure to have the right shader file? Sounds to me that you have the wrong one.
Are you sure to have the right shader file? Sounds to me that you have the wrong one.

#80
Posted 08/19/2014 01:19 AM   
Remove this code preshader rcp r0.x, c0.y mul r1.x, r0.x, (20) rcp c0.x, r1.x Preshaders is not a valid format and leaving it in causes an error. Ussually you can just remove pre shader code. I've heard you may need to rewrite it in but TBH I never ran into it so I dont think so. I even remember helix saying you can just remove preshader code. If shader doesnt work still.. Make a dx9settings.ini overridemethod = 2 Though it may not be a shadow shader like above says. At a quick glimpse I thought it was depth of field from headers. ----------------------------- When something doesnt go according to plan exit game. Check your log file. It would tell you that there is an error and even which shader is causing it.
Remove this code

preshader
rcp r0.x, c0.y
mul r1.x, r0.x, (20)
rcp c0.x, r1.x

Preshaders is not a valid format and leaving it in causes an error.
Ussually you can just remove pre shader code. I've heard you may need to rewrite it in but TBH I never ran into it so I dont think so. I even remember helix saying you can just remove preshader code.

If shader doesnt work still..
Make a dx9settings.ini
overridemethod = 2


Though it may not be a shadow shader like above says. At a quick glimpse I thought it was depth of field from headers.
-----------------------------
When something doesnt go according to plan exit game. Check your log file. It would tell you that there is an error and even which shader is causing it.

Co-founder/Web host of helixmod.blog.com

Donations for web hosting @ paypal -eqzitara@yahoo.com
or
https://www.patreon.com/user?u=791918

#81
Posted 08/19/2014 01:39 AM   
[quote="helifax"]@bo3b AWESOME!!!!!!! While I haven't made the wiki page;)) I have most of the stuff right here (I just used a different game) Very nicely structured tutorials and awesome info;)) Now... GIVE US THE NEXT LESSONS ^_^ I am very interested in the FIXIN' part;)) (As I am pretty noobie when it comes to DirectX 9 assembly). Btw is there somewhere where I can read some information about what are the registres? like r1, r2,v4, ( I think oC0 is the color)... Awesome work!!![/quote]Thanks! I'm glad it all seems like a good format and is working for people. For everyone, even if you are looking at a different game, please go ahead and post a screen snapshot and a shader, it's more fun to share. More lessons are forthcoming. As you might expect, these are fairly time consuming to make.
helifax said:@bo3b

AWESOME!!!!!!! While I haven't made the wiki page;)) I have most of the stuff right here (I just used a different game)
Very nicely structured tutorials and awesome info;))


Now... GIVE US THE NEXT LESSONS ^_^ I am very interested in the FIXIN' part;)) (As I am pretty noobie when it comes to DirectX 9 assembly).
Btw is there somewhere where I can read some information about what are the registres? like r1, r2,v4, ( I think oC0 is the color)...


Awesome work!!!
Thanks! I'm glad it all seems like a good format and is working for people.

For everyone, even if you are looking at a different game, please go ahead and post a screen snapshot and a shader, it's more fun to share.

More lessons are forthcoming. As you might expect, these are fairly time consuming to make.

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

#82
Posted 08/19/2014 08:30 AM   
[quote="helifax"][quote="TsaebehT"]@helifax I think [url=http://msdn.microsoft.com/en-us/library/windows/desktop/bb219840(v=vs.85).aspx]this[/url] is what you're looking for. :)[/quote] Yupp;)) Thanks;)) I also found the post from mike ( on page 2 I think where he gives all the resources).[/quote]Yes, this is a good reference. I'll try to make a glossary/extras page to give more background on different things, and the ASM language spec is a great reference. For people interested in the output register from this question, here is the Microsoft spec on those output registers, including oC0. http://msdn.microsoft.com/en-us/library/windows/desktop/bb172920(v=vs.85).aspx
helifax said:
TsaebehT said:@helifax
I think this is what you're looking for. :)


Yupp;)) Thanks;)) I also found the post from mike ( on page 2 I think where he gives all the resources).
Yes, this is a good reference. I'll try to make a glossary/extras page to give more background on different things, and the ASM language spec is a great reference.

For people interested in the output register from this question, here is the Microsoft spec on those output registers, including oC0.

http://msdn.microsoft.com/en-us/library/windows/desktop/bb172920(v=vs.85).aspx

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

#83
Posted 08/19/2014 08:31 AM   
For the preshader section, it's worth trying eqzitara's suggestions. We can't use preshader in our override shaders, because they require a link to the games C code through a mechanism that we don't have access to. I think that it might be theoretically possible to support that, but we know that HelixMod does not support it, and it's obsolete for anything above SM3. The preshader is code that is executed on the CPU instead of on the GPU, and it's only done once for each frame. Here is some description: [url]http://www.riemers.net/eng/Tutorials/XNA/Csharp/Series3/Preshaders.php[/url] I see this preshader in the FEAR games, and it's used to move the clouds underneath the skybox. So if we modify the sky, we have no clouds. This is getting pretty far afield from the Shaderhackers School though, and really should be in the HelixMod thread, as the main place to ask deeper questions like this. Let's move this discussion over there, if you don't mind. (I'd like to keep this thread from getting too complex too fast, the goal here is to help the very new people. The goal in the HelixMod thread is to help the very deep, complex questions. Hope that's OK.)
For the preshader section, it's worth trying eqzitara's suggestions.

We can't use preshader in our override shaders, because they require a link to the games C code through a mechanism that we don't have access to. I think that it might be theoretically possible to support that, but we know that HelixMod does not support it, and it's obsolete for anything above SM3.

The preshader is code that is executed on the CPU instead of on the GPU, and it's only done once for each frame. Here is some description: http://www.riemers.net/eng/Tutorials/XNA/Csharp/Series3/Preshaders.php

I see this preshader in the FEAR games, and it's used to move the clouds underneath the skybox. So if we modify the sky, we have no clouds.


This is getting pretty far afield from the Shaderhackers School though, and really should be in the HelixMod thread, as the main place to ask deeper questions like this. Let's move this discussion over there, if you don't mind.

(I'd like to keep this thread from getting too complex too fast, the goal here is to help the very new people. The goal in the HelixMod thread is to help the very deep, complex questions. Hope that's OK.)

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

#84
Posted 08/19/2014 08:43 AM   
Hey Bo3b, I ran into a problem in Lesson 1. Symptoms: I can cycle shaders with Num 1 and 2, and 4 and 5 No shaders are dumped when I press Num 3 or Num 6 There is no dumps folder in \the ball\Binaries\Win32 There is a dumps folder in \the ball, but it's empty Info: I'm using the full version of The Ball, because I own it Below are the contents of my DX9settings.ini, located in \the ball\Binaries\Win32. I believe it's working at least partly, because I'm only seeing 29 VS and 73 PS when I shader hunt. [General] UseRenderedShaders=true DumpAll=true
Hey Bo3b, I ran into a problem in Lesson 1.

Symptoms:
I can cycle shaders with Num 1 and 2, and 4 and 5
No shaders are dumped when I press Num 3 or Num 6
There is no dumps folder in \the ball\Binaries\Win32
There is a dumps folder in \the ball, but it's empty

Info:
I'm using the full version of The Ball, because I own it
Below are the contents of my DX9settings.ini, located in \the ball\Binaries\Win32. I believe it's working at least partly, because I'm only seeing 29 VS and 73 PS when I shader hunt.
[General]
UseRenderedShaders=true
DumpAll=true

#85
Posted 08/19/2014 09:58 AM   
@Pirateguybrush: Had the same issues as You using also the full version of The Ball. In my case I have used initially the version of a debug dll I have downloaded some weeks ago from the helixmod blog. I replaced it with the dll of the download that bo3b has directly linked in his lesson (although I think that they should be identical...). I also removed DX9settings.ini, startet The Ball again and switched through the shaders. Then I added DX9settings.ini and tried it again. Can't say what helped exactly but finally dumping worked for me (dumps folder in \the ball\Binaries\Win32).
@Pirateguybrush:
Had the same issues as You using also the full version of The Ball. In my case I have used initially the version of a debug dll I have downloaded some weeks ago from the helixmod blog. I replaced it with the dll of the download that bo3b has directly linked in his lesson (although I think that they should be identical...). I also removed DX9settings.ini, startet The Ball again and switched through the shaders. Then I added DX9settings.ini and tried it again. Can't say what helped exactly but finally dumping worked for me (dumps folder in \the ball\Binaries\Win32).

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

#86
Posted 08/19/2014 10:29 AM   
Hm. I was using the version linked. I tried redownloading and replacing it, and created a new DX9Settings.ini - no change.
Hm.
I was using the version linked. I tried redownloading and replacing it, and created a new DX9Settings.ini - no change.

#87
Posted 08/19/2014 10:43 AM   
I see this also with the full game. It seems to get confused on the working directory, and created a Dumps folder and LOG.txt two directories up at the ..\common\The Ball\ directory. The second time I ran it, it generated my single shaders in the correct spot, but the LOG.txt is still active two directories up. This happens with some games, and generally is because of too many launchers like Steam confusing the working directory. One thing to try is to go offline on Steam, that changes the launch sequence. Also try launching the game exe directly from the folder, not through Steam. If it doesn't work for you on second or third launch, maybe try the demo version just to see.
I see this also with the full game. It seems to get confused on the working directory, and created a Dumps folder and LOG.txt two directories up at the ..\common\The Ball\ directory.

The second time I ran it, it generated my single shaders in the correct spot, but the LOG.txt is still active two directories up. This happens with some games, and generally is because of too many launchers like Steam confusing the working directory.

One thing to try is to go offline on Steam, that changes the launch sequence. Also try launching the game exe directly from the folder, not through Steam.


If it doesn't work for you on second or third launch, maybe try the demo version just to see.

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

#88
Posted 08/19/2014 11:51 AM   
[quote="bo3b"] One thing to try is to go offline on Steam, that changes the launch sequence. Also try launching the game exe directly from the folder, not through Steam. [/quote] This could be the real reason why it suddenly worked for me. I had to run Steam offline (connection issues...) and when experimenting with removing/adding DX9Settings.ini and dlls I began to start the game directly with its exe-file.
bo3b said:
One thing to try is to go offline on Steam, that changes the launch sequence. Also try launching the game exe directly from the folder, not through Steam.

This could be the real reason why it suddenly worked for me. I had to run Steam offline (connection issues...) and when experimenting with removing/adding DX9Settings.ini and dlls I began to start the game directly with its exe-file.

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

#89
Posted 08/19/2014 12:08 PM   
Odd, I was trying to replicate it and couldn't until I deleted the Dumps folder. It seems to work perfectly fine as long as the Dumps directory already exists ... SaveAsBatRunMe: [code]@Echo Off for %%? in (PixelShader,VertexShader) do ( MD "Dumps\AllShaders\%%?\" "Dumps\SingleShaders\%%?\" )[/code]edit:Sorry just kind of whipped it up here ... it creates all the necessary Dumps folders when run from the same location as the debug dll.
Odd, I was trying to replicate it and couldn't until I deleted the Dumps folder. It seems to work perfectly fine as long as the Dumps directory already exists ...
SaveAsBatRunMe:
@Echo Off
for %%? in (PixelShader,VertexShader) do (
MD "Dumps\AllShaders\%%?\" "Dumps\SingleShaders\%%?\"
)
edit:Sorry just kind of whipped it up here ... it creates all the necessary Dumps folders when run from the same location as the debug dll.
#90
Posted 08/19/2014 02:55 PM   
  6 / 88    
Scroll To Top