Home > Software > TMSB Tutorial 4A: Basic XML File Customization
TMSB Tutorial 4A: Basic XML File Customization
Making basic changes to The Mirror's Surface Breaks configuration files should be easy, especially for anyone who has worked with XML files before. When I designed TMSB, I did my best to come up with XML schemas that were straightforward and easy to understand. I've worked fairly extensively with Apache Tomcat configurations, and (although I think Apache Tomcat is a fine piece of server software) I really used that as a model for how not to handle the XML schema design.
There are only two major quirks that I deliberately introduced:
UTF-16 seemed like the most straightforward Unicode encoding when I was designing TMSB. I wanted to use Unicode so users who wrote in a foreign language could use their own characters instead of having to Romanize the text. I needed to pick a particular Unicode character set because interally, TMSB juggles data around and giving it the ability to handle multiple character sets would have been really complicated, and I just didn't feel like it was worth the hassle (and potential bugs related to that functionality).
Speaking of juggling the data around, this is mostly related to the <Import> tag. There are a couple of more-or-less standard ways of doing this in XML, but this was another area where it seemed like they were more trouble than they were worth. So when TMSB loads an XML file, before it hands it off to the .NET XML processor, it performs all of the work related to the <Import> tag (as well as stripping out any comments[1]).
Getting Started
There are two ways to get yourself an XML file to begin your modifications on:
Either way, the best location (in most cases) to copy the file to is the TMSB_Config directory located underneath your own user profile directory (for example, C:\Users\blincoln\Documents\TMSB_Config on Windows 7) - not the TMSB_Config directory underneath where TMSB itself is located. There are a couple of reasons this is (generally) the preferred approach:
The one exception to this recommendation is on the off chance that you are maintaining a TMSB installation on a multi-user system, and want to make a custom configuration available for everyone that uses it. In that case, go right ahead and put them in the TMSB_Config directory underneath the TMSB installation directory.
When you create the copy, be sure to give it a distinctive filename, and don't put "Fragment" at the beginning of that name. When populating the drop-down menus, TMSB ignores any file whose name started with "Fragment", because the assumption is that those are incomplete files referenced by others.
Once you've created the copied file, you can customize it to your heart's content, as long as you use a text editor that is capable of handling UTF-16-encoded text files (for example, Notepad.exe, at least on newer versions of Windows).
Like all of the tutorial configuration files, complete (and tested) versions of the results below are included in the Tutorial subdirectory of TMSB_Config wherever you unpacked the software to (TMSB version 1.2 or later). These can be used to refer to if you run into trouble, or you can just copy them into your TMSB_Config directory if you would rather just use them instead of know how to create custom configurations.
Example 1: Ratio-Only Calculated Images Configuration
Let's start with an easy example: creating a custom "calculated images" processing configuration that only produces variations based on the ratio of each channel to every other channel.
Example 2: Making an R72-Only Filter Emulation Configuration
Let's say that you like the "Classic R72" false colour image generated by the Focused: Filter Emulation processing configuration, but don't like any of the others that it produces. To create a custom processing configuration that only generates that one result, you will need to customize two sub-sections of that configuration.
<CustomGreyscaleChannels>
<CustomGreyscaleChannel>
<ChannelName>
Custom-R72_Classic-Red
</ChannelName>
<Type>
CustomScriptCode
</Type>
<CustomScriptCode>
= (pow((((%SpecialBand:NearInfraredNonspecific% * 0.8) + (%SpecialBand:Red% * 0.2))), 0.65) - 0.10) * 1.30
</CustomScriptCode>
<UseAsLuminanceChannel>
false
</UseAsLuminanceChannel>
<UseAsThreeChannelChannel>
false
</UseAsThreeChannelChannel>
<OutputTransformation>
Clip: 0.0 - 1.0
</OutputTransformation>
</CustomGreyscaleChannel>
<CustomGreyscaleChannel>
<ChannelName>
Custom-R72_Classic-Green
</ChannelName>
<Type>
CustomScriptCode
</Type>
<CustomScriptCode>
= pow(((%SpecialBand:NearInfraredNonspecific% - 0.06) / 1.02), 0.97)
</CustomScriptCode>
<UseAsLuminanceChannel>
false
</UseAsLuminanceChannel>
<UseAsThreeChannelChannel>
false
</UseAsThreeChannelChannel>
<OutputTransformation>
Clip: 0.0 - 1.0
</OutputTransformation>
</CustomGreyscaleChannel>
<CustomGreyscaleChannel>
<ChannelName>
Custom-R72_Classic-Blue
</ChannelName>
<Type>
CustomScriptCode
</Type>
<CustomScriptCode>
= pow(((%SpecialBand:NearInfraredNonspecific% - 0.01) / 0.91), 0.87) - 0.04
</CustomScriptCode>
<UseAsLuminanceChannel>
false
</UseAsLuminanceChannel>
<UseAsThreeChannelChannel>
false
</UseAsThreeChannelChannel>
<OutputTransformation>
Clip: 0.0 - 1.0
</OutputTransformation>
</CustomGreyscaleChannel>
</CustomGreyscaleChannels>
<CustomThreeChannelImages>
<CustomThreeChannelImage>
<UserDefinedName>
FC-3C-Custom-R72_Classic
</UserDefinedName>
<RedChannelName>
Custom-R72_Classic-Red
</RedChannelName>
<GreenChannelName>
Custom-R72_Classic-Green
</GreenChannelName>
<BlueChannelName>
Custom-R72_Classic-Blue
</BlueChannelName>
<IncludeInSecondOrderImages>
true
</IncludeInSecondOrderImages>
<OutputTransformation>
Normalize: Standard
</OutputTransformation>
</CustomThreeChannelImage>
</CustomThreeChannelImages>
Example 3: Creating and Mapping a Custom Tinting Colour
If you like the idea of tinting your greyscale ultraviolet-A images, but don't like the particular shade of neon pink I chose to include in the Photography - Moderate processing configurations, here's how you can replace it with one more to your liking. This requires editing the Global-Colours.xml configuration file, so you'll need write access to the TMSB_Config directory underneath the installation directory (not just your own personal TMSB_Config directory). If (like most people) you are running Windows® and are an administrator on the machine, you already have write access to that location.
Note that because of that requirement, this example is not included in the Tutorial directory. You'll need to make these customizations yourself.
<TintingColour>
<Name>
Joan_Jett_Blazer_Pink
</Name>
<Format>
UnsignedInteger16
</Format>
<Red>
52428
</Red>
<Green>
13107
</Green>
<Blue>
26214
</Blue>
</TintingColour>
This example uses 16-bit unsigned integer values for the colour levels (numbers between 0 and 65535). If you would prefer to use 8-bit integer values (0-255, like most image-editing software), or 32-bit floating-point values, you can use those instead, by changing the <Format> value.
<TintingColour>
<Name>
Joan_Jett_Blazer_Pink
</Name>
<Format>
Byte8
</Format>
<Red>
204
</Red>
<Green>
51
</Green>
<Blue>
102
</Blue>
</TintingColour>
The same block but configured to use 32-bit colour values:
<TintingColour>
<Name>
Joan_Jett_Blazer_Pink
</Name>
<Format>
Float32
</Format>
<Red>
0.8
</Red>
<Green>
0.2
</Green>
<Blue>
0.4
</Blue>
</TintingColour>
You should only include one of these, because each tinting colour name must be unique in the file.
In Closing
That wasn't so hard, was it? Who wants a stupid GUI configuration editor anyway?[2] If you're interested in some more advanced customizations (creating input and processing configurations from scratch), you can proceed on to the rest of the articles in this section.
1. |
For reasons I haven't bothered to research (but which are no doubt questionable), part of the XML specification is that comments cannot be nested. This is one of those decisions that seems to me to have been made offhand by a developer or two many years ago without realizing the countless frustrations they were laying on the shoulders of future generations.
For example, a common troubleshooting technique is to comment out large blocks of code to narrow down where a problem is occuring. With XML, anyone who does this has to either inspect those large blocks with a fine-toothed comb to make sure there are no nested comments inside, or divide it up into chunks based on the location of the nested comments. This becomes particularly annoying when dealing with content being referenced in other files. By removing anything contained within comment tags before the XML is handed off to the .NET XML processor, the entire problem is avoided. It doesn't matter if comments are nested, because everything contained within the highest level of comment tag is removed. |
2. | Everyone who uses the software, including me, that's who. |