-
Notifications
You must be signed in to change notification settings - Fork 4
Integrating Tools
Shader Patch comes with a set of tools to support custom material creation. In order to use custom materials in your mod you must integrate these tools into your munge process.
This guide will teach you how to do just that. The process should be incredibly simple, but the guide does assume that you've already installed Shader Patch and that you're familiar with (at least to a basic extent) the structure of the modtools.
First you're going to hit up the latest release page and look for shaderpatch-x64-tools.7z. If you're unfamiliar with .7z archives you can use the open source 7-Zip to open them.
Next you're going to go to your modtools install directory, from there you'll go into ToolsFL\bin\ and paste the files found inside the downloaded archive into it.
The tools are now installed and ready to be called from the munge scripts.
Now that we've installed our tools we're practically ready to burst from excitement! But we just have a couple things left to do before we're ready to start going crazy with our custom materials.
You can integrate the tools with any .lvl's build process but I'm only going to cover integrating with sides and worlds. But first we need to decide if we want to integrate on a per-mod basis or for all future mods we make.
Go back to your modtools install directory and now depending on if you want to integrate for all future mods or for an existing mod you'll either go into Data\_BUILD or DataMOD\_BUILD. Now if you've never messed with the munge scripts before then don't panic, pre-edited ones are linked to below that you can copy-n-paste.
To begin simply open up Worlds\munge_world.bat in your favourite text editor. Then go over here, copy the complete contents of the gist and replace the contents of your munge_world.bat with it.
Almost the same as above, open up Worlds\munge_side.bat. Go over here, copy and replace.
Now because Shader Patch's integration introduces a new intermediate directory for it's munge files when you hit Clean this any munged SP textures/materials/etc won't actually be cleaned. This is annoying as manually cleaning is a pain and there are times when you do have to do a completely fresh munge.
With that in mind let's set about automating it. This is more complicated than integrating the mungers themselves because each Side, World, etc has its own clean.bat that controls what directories get cleaned. This means that if we have a world TEST and we want to add automated SP cleaning for it then we need to edit _BUILD\Worlds\TEST\clean.bat, likewise if we want to do the same thing for a side named TEST we'll need to edit _BUILD\SIDE\TEST\clean.bat.
In both cases however the edits are the same and you can find them already done to clean.bat over here.
TODO: Write manual integration documentation here.
WorldEdit has a munge runner that doesn't use the munge_side.bat and munge_world.bat. But it can have custom commands added to it, you can find a config here that has the commands for munging Shader Patch sides and worlds in it. Take that file and put it in data_MOD/.WorldEdit. Note that this will erase your current munge config for WorldEdit.
Alternatively you can add the following custom commands yourself.
| Command |
|---|
%TOOLSFL_BIN_PATH%\sp_texture_munge --sourcedir %SOURCE_PATH% --outputdir %OUTPUT_PATH%\..\PC_SP |
%TOOLSFL_BIN_PATH%\material_munge --sourcedir %SOURCE_PATH% --mungedsourcedir %OUTPUT_PATH% --outputdir %OUTPUT_PATH%\..\PC_SP --descdir %TOOLSFL_BIN_PATH%\rendertype_descriptions |
| Command |
|---|
%TOOLSFL_BIN_PATH%\levelpack -inputfile REQ.req -common %COMMON_FILES% -platform %PLATFORM% -sourcedir %SOURCE_PATH% -inputdir %OUTPUT_PATH%\..\PC_SP %OUTPUT_PATH% %PROJECT_PATH%\_BUILD\Sides\Common\munged\PC_SP %PROJECT_PATH%\_BUILD\Sides\Common\munged\PC -outputdir %OUTPUT_PATH%\..\PC_SP |
| Command |
|---|
%SystemRoot%\System32\cmd.exe /C "if not exist %LVL_OUTPUT_PATH%\SP mkdir %LVL_OUTPUT_PATH%\SP" |
%TOOLSFL_BIN_PATH%\levelpack -inputfile *.req -common %COMMON_FILES% -platform %PLATFORM% -sourcedir %SOURCE_PATH% -outputdir %LVL_OUTPUT_PATH%\SP -inputdir %OUTPUT_PATH%\..\PC_SP %OUTPUT_PATH% %PROJECT_PATH%\_BUILD\Sides\Common\munged\PC_SP %PROJECT_PATH%\_BUILD\Sides\Common\munged\PC |
| Command |
|---|
%TOOLSFL_BIN_PATH%\sp_texture_munge --sourcedir %SOURCE_PATH% --outputdir %OUTPUT_PATH%\..\PC_SP |
%TOOLSFL_BIN_PATH%\material_munge --sourcedir %SOURCE_PATH% --mungedsourcedir %OUTPUT_PATH% --outputdir %OUTPUT_PATH%\..\PC_SP --descdir %TOOLSFL_BIN_PATH%\rendertype_descriptions |
%TOOLSFL_BIN_PATH%\spfx_munge --sourcedir %SOURCE_PATH% --outputdir %OUTPUT_PATH%\..\PC_SP |
| %TOOLSFL_BIN_PATH%\configmunge -inputfile *.tmpfx -sourcedir %OUTPUT_PATH%..\PC_SP -outputdir %OUTPUT_PATH%..\PC_SP -chunkid fx -ext game_envfx -platform PC |
| Command |
|---|
%SystemRoot%\System32\cmd.exe /C "if not exist %LVL_OUTPUT_PATH%\SP mkdir %LVL_OUTPUT_PATH%\SP" |
%TOOLSFL_BIN_PATH%\levelpack -inputfile *.req -common %COMMON_FILES% -onlyfiles -writefiles %OUTPUT_PATH%\..\PC_SP\SP_MZ.files -platform %PLATFORM% -sourcedir %SOURCE_PATH% -inputdir %OUTPUT_PATH%\..\PC_SP %OUTPUT_PATH% %PROJECT_PATH%\_BUILD\Worlds\Common\munged\PC_SP %PROJECT_PATH%\_BUILD\Worlds\Common\munged\PC -outputdir %OUTPUT_PATH%\..\PC_SP |
%TOOLSFL_BIN_PATH%\levelpack -inputfile *.mrq -common %COMMON_FILES% %OUTPUT_PATH%\..\PC_SP\SP_MZ.files -platform %PLATFORM% -sourcedir %SOURCE_PATH% -inputdir %OUTPUT_PATH%\..\PC_SP %OUTPUT_PATH% %PROJECT_PATH%\_BUILD\Worlds\Common\munged\PC_SP %PROJECT_PATH%\_BUILD\Worlds\Common\munged\PC -outputdir %OUTPUT_PATH%\..\PC_SP |
%TOOLSFL_BIN_PATH%\levelpack -inputfile *.req -common %COMMON_FILES% -platform %PLATFORM% -sourcedir %SOURCE_PATH% -outputdir %LVL_OUTPUT_PATH%\SP -inputdir %OUTPUT_PATH%\..\PC_SP %OUTPUT_PATH% %PROJECT_PATH%\_BUILD\Worlds\Common\munged\PC_SP %PROJECT_PATH%\_BUILD\Worlds\Common\munged\PC |
| Directory |
|---|
%BASE_PATH%\..\PC_SP |
| Directory |
|---|
%BASE_PATH%\..\PC_SP |
Assuming you took one of the above integration steps you're now all setup to start munging custom materials!