Converting Effect XNBs to HLSL

This guide describes a method of converting XNA effects from XNB to HLSL source code. The XNB files used in this guide are XNA 4.0 originally compiled for HiDef Xbox 360. This guide should still apply to XNA 3.1 and all other target platforms regardless of HiDef/Reach or compressed or not. Untested with XNA versions prior to 3.1.

Step 1 - Extract the CSO (DX9 compiled shader) from the XNB container using an extractor of your choice (such as this).

Step 2 - Open the CSO in a hex editor and grab any variable information (more details available here).


Step 3 - Run the CSO through the XenosRecomp tool (streamlined through the implementation here).

Step 4 - Clean the output by removing everything before main().


Step 5 - Review the actual shader code (located within main() after the variable declarations) and remove any unused variables.

Step 6 - Reformat to fit the standard XNA HLSL format using the additional variable information from the CSO.


Step 7 - Clean up as desired.





No comments:

Post a Comment