Parts
- Introduction on decals
- Converting normal maps
- World Machine Templates
- Generating a map-wide normal texture
- Generating a map-wide lighting texture
Requisites
Map editing tools, such as:
Generation tools, such as:
Image editing tools, such as:
Decal templates for this article:
Instead of using a generation tool you can use any tool that can generate a lightmap.
If you use World Machine then you require at least the Indie version of World Machine. With the free edition you cannot generate textures that have sufficient size for any reasonably result.
Map-wide lighting maps
Units can cast shadows. Props can cast shadows. But the terrain itself can not cast shadows. Self-intersecting shadows are quite hard to compute with a rasterizer and in 2007 this was probably out of reach for the target audience of the game. With this article we'll focus on generating shadows and then manipulating the light map to make it useful for a map in Supreme Commander.
As an example we'll work with the map Long John Silver:
Which has the following heightmap:
With World Machine we'll generate the following light map:
With our favorite image editing software we'll turn it into a light map with an alpha channel as a mask:
And with our template we'll place the decal exactly centered in the map ensuring that everything is properly aligned. This will result in images such as:
On Long John Silver - with the map-wide shadows map
On Long john Silver - without the map-wide shadows map
On Mellow Shallows - with the map-wide normal map
On Mellow Shallows - without the map-wide normal map
Maps that already use this technique:
- todo
Workflow in World Machine
We don't need World Machine to do a lot of complicated tasks. There are a few important tasks:
- Change the resolution of the output
- Import the previous heightmap with correct interpolation
- Add a light map maker.
- Export the light map.
You can find a ready-to-use world machine file in the decal template repository that you can find at the top.
We'll start off with changing the resolution. Generally you want a resolution of 4096x4096
. Navigate to World Commands -> Project World Parameters
and change the resolution accordingly. If you just want to preview your results make sure to set it to 1024x1024
or 2048x2048
such that it takes less long to render.
Adjusting the resolution in the project settings in World Machine
Next off we need to select our heightmap. You can export your heightmap from the Ozone editor or from the GPG editor. Make sure to rename the raw file from .raw
to .r16
as otherwise World Machine will not realise it is a raw file with 16 bits per pixel. Select your raw file and then select the correct interpolation mode. I personally like to use Fractal but any except Nearest Neighbours
is fine. The Nearest Neighbours
will make the heightmap quite blocky.
Selecting the correct heightmap in r.16
format and choosing an interpolation mode
Then we create the rest of the node network. For this the node network is quite simple - we add in a Converter -> Light Map Maker
and then link the input / output accordingly.
There are a few relevant settings:
Illumination Model
: set this toRaytraced Lighting
as that is the only mode that supports direct shadows.Included Lighting
: depending on the style of the map you may or may not want to include indirect shadows. For this article we include all the lighting - both direct and indirect shadows will be generated. Feel free to experiment with this setting.Sun Heading
: The sun heading / direction - does not match directly with the heading / direction of the editor / supreme commander.Sun Altitude
: The altitude of the stun - does not match directly with the altitude of the editor / supreme commander..
Last but not least is building the result. Make sure to save these with 8 bits per pixels. We do not need the full 16 bits for decals as we do for heightmaps. The building process can take a while. Once that is done we're ready to jump into our image editing software.
Image Editing Software
The actions in question depend on your software suite. You do not need Photoshop - Gimp is sufficient. Essentially we want to transform the lightmap map generated into a different format.
Photoshop
- Open the light map.
- Create an alpha channel.
- Copy the gray channel into the alpha channel.
- Invert the alpha channel.
- Make the RGB channels black.
- Switching the mode from a gray image to an RGB image (if applicable).
- Reduce the resolution of the lightmap to the resolution of your heightmap.
And that is essentially it. You can apply filters to the alpha channel to create various effects - just make sure to keep the RGB channel completely black.
Gimp
- Open the light map.
- Open channels (not layers) view.
- Move "Gray" channel to alpha via "Colors > Color to Alpha" (Tool default is white color > shadows should also be white in the alpha channel).
- Tweak "Brightness" (not "Contrast") in the alpha channel to decide how black the shadow should be.
- Make the original greyscale layer black.
- Change from Grayscale to RGB via "Image > Mode > RGB".
Common
What is most relevant is that the parts that are supposed to be shadows are white in the alpha channel - for this article we want to darken the terrain where this is the case.
Store the resulting image as a .dds
with BC3 with interpolated alpha
compression or as DXT5. For more information about this:
Make sure to save it in a directory such as /maps/example-map.v0001/env/decals/lightmap.dds
where example-map.v0001
is replaced with the name of your map. It is critical that it is stored in the env/decals
hierarchy structure - otherwise the game and the Ozone editor will not recognize your textures as decals.
Using the decal presets
Start up your map in the GPG editor. Make sure to copy it to the /maps
directory of the original Supreme Commander installation directory - otherwise the GPG editor will not be able to load your map and probably crash.
Once loaded up it is time to copy the correct template to your map. I assume that your map is square as all the presets are square too. If you use area's to hide certain bits of the map then that doesn't matter too much. Choose your template depending on the map size. As for this tutorial we'll work with the 10x10.lua
template as Long John Silver
is 10x10.
For the template I've removed the normal texture as it is not relevant for this guide. Make sure to replace example-map.v0001
with your map name. In the case of the guide this is adaptive_long_john_silver
. Then make sure that the path is correct - if you followed the guide precisely then you should be good.
Decals = {
--
['9000'] = {
type = 'Albedo',
name0 = '/maps/adaptive_long_john_silver/env/decals/lightmap.dds',
name1 = '',
scale = { 512, 512, 512 },
position = { 0, 0, 0 },
euler = { -0, 0, 0 },
far_cutoff = 10000,
near_cutoff = 0,
remove_tick = 0,
},
--
}
Import your adjusted 10x10.lua
by going to File -> Import -> Decals
in the GPG editor. You should see a decal that stretches across the entire map - if it is too big or too small than you've chosen the wrong template for your map. Save the map and then all should be good.
If you want to load in an adjusted light map you can save over the original one and then:
- Reload the map in the editor.
- Delete the decal and import it back in with the template.
Testing your map
Make sure to test your map by copying it back to the folder that is used by the vault. Generally this is /%USERPROFILE%/My Games/Gas Powered Games/Supreme Commander Forged Alliance/maps
where %USERPROFILE%
is replaced with the user profile that has the game installed.
Frequently Asked Questions (FAQ)
My map looks all weird after importing - what is going on?
The default texture that is loaded when it can't find a texture
The engine uses this when it can't find a texture. There could be various reasons:
- The path in your template file is off. Make sure that the local path actually references a file in your map folder structure. As an example, if your path is
/maps/adaptive_long_john_silver/env/decals/lightmap.dds
then there should be a folder calledenv
inside your map folder, followed by a folder calleddecals
with a texture namedlightmap.dds
in it. Make sure to watch for typos. - The GPG editor sometimes refuses to load in textures. I am not entirely confident as to why this is. From practice I know that you can save the map and open it up with the Ozone editor. If it shows correctly in the Ozone editor then it will show correctly in-game. Of course - it can't hurt to check that.
My map looks all weird for other people who downloaded it from the vault - what is going on?
The path to your texture files may not always be properly updated - in that case you need to manually update it. This is easiest done in the Ozone editor. We only use the GPG editor to load in a perfectly map-wide aligned decal - from that point on you are free to go back to the Ozone editor and change the texture as you desire.
When updating the texture in the Ozone editor nothing changes!
The Ozone editor caches textures to speed up the application. It is best to save the adjusted texture with a separate name - then reload the map folder by switching back and forth the map folder. You'll see the new texture and you can now safely replace it with the old one. At the end make sure you only have the texture you use in your map folder as these textures take up a lot of bandwidth.
Sources
About decals in general:
About ray tracing:
About light maps and baking (in Unity 3D):
Changelog
18-12-2020 : Improved the article, included gimp approach described by @svenni_badbwoi
About you
If you have interesting sources, approaches, opinions or ideas that aren't listed yet but may be valuable to the article: feel free to leave a message down below or contact me on Discord. The idea is to create a bunch of resources to share our knowledge surrounding various fields of development in Supreme Commander.
If you've used this resource for one of your maps feel free to make a post below: I'd love to know about it!
Shadows on the LOUD-version of the map Islet