Hello There, Guest! Login Register


Thread Rating:
  • 2 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Guide] Compiling Pixel Shaders (.PSH)
#1
This is for anyone who has HLSL knowledge or just wants to play around with the .PSH files. It's kind of unneeded for those who have experience with HLSL, but I'll post it anyway.

Unlike .VSH shaders, which get compiled on the fly, .PSH shaders need to be compiled beforehand. To do so, you need to use the 'fxc.exe' (Official DirectX compiler)

If you open an existing .PSH, you'll notice that the actual code is in there too (0000PSRC Node), but if you'd modify it, it wouldn't do anything, because it's pretty much just a note/reference for what is in the compiled section.

[Image: treenotecode.png]

Luckily for us, if you want to modify one of the original .PSH shaders, you can just copy and modify it externally, then compile it again. But this guide is for both modified originals and completely newly written ones, the same process to get it into the game is the same.


The manual way:

Before we get started, create a folder that you'll use every time you want to compile and place the fxc.exe inside of it. You'll also need to copy over the "pixel_program" and "shared_program" folders from the SWG .tre's, you just need the include folder and .inc files so you can skip the .PSH files.

Once you have your pixel shader code saved and in your compile folder, follow these steps:

1.) Open up your Command Prompt (Start>Run>cmd.exe).

2.) Change to the directories to your Compile folder, in my case it would be C:\Users\Timbab\Desktop\Modding\Compiler, so I'd type in:

Code:
cd Desktop\Modding\Compiler

3.) Type in the compile command.

In the example bellow, I .cpp as input, but it can be any text format, like .txt, etc, just whatever you wrote your code in.

Code:
fxc /T ps_X_X /Fo output.psh input.cpp

Example:

fxc /T ps_2_0 /Fo 2d_blur.psh blur.cpp


fxc = uses exe, /T ps_2_0 = uses Pixel Shader 2, /Fo = compile command, 2d_blur.psh = output, blur.cpp = input file with the code

4.) If you compiled it successfully, you'll need to open up any original .PSH (We use this as a template for the existing Node structure) with treExplorer, then edit and replace the contents of the PEXE node with your newly compiled code.

Open the new .PSH with the program of your choice, select everything and copy and replace everything that is in the PEXE node. Make sure that it starts with 00 02:

[Image: pasteandedit1.png]

For me, every time I copy & paste it, it'll add something in front of it, like:

[Image: pasteandedit2.png]

So in case it does, remove it, and you're good to go! All you need to do now is save/export it from treExplorer and test it out.


Note: To make life easier, I've attached a compile ready folder for both the NGE and preCU shaders, including an older SWG era fxc.exe and the newest one, plus a .bat, where you only need to enter the input and output file name, so you don't have to retype the command line every time.


Example:
[Image: inputoutput.png]


Attached Files
.zip   preCU Compiler.zip (Size: 518.68 KB / Downloads: 20)
.zip   NGE Compiler.zip (Size: 519 KB / Downloads: 13)
 
Reply
#2
Cant get this to work. I compile it using the NGE folders attached to your thread here, and then i paste the new code into the PEXE node. I edit it to start with 00 02, and it just crashed the client.

specifically, i am trying to convert the file called h_color2_specmap_bump_ps20

are you able to do it and get it to work in swgemu? What could I be missing?
 
Reply
  



Forum Jump:


Browsing: 1 Guest(s)