[TUTORIAL] Blender - Basic Backgrounds


(Taiidan Republic Mod) #1

This tutorial explains how to make basic* backgrounds for HWRM levels using the Blender HWRM Toolkit and the example backgrounds published by Gearbox.

This tutorial builds on the excellent youtube video by @sastrei here:

*by “basic” I mean no planets or fancy objects in the background. I will make another tutorial for those…


Modding tutorials Master Thread
(Taiidan Republic Mod) #2

STEP 1 – EXAMPLE IMPORT

Using the HWRM Toolkit, import the example background DAE file example_light.DAE.

The hierarchy you will see is very similar to ships & subsystems:

01_tree

The following items are new/different for backgrounds:
- JNT[PRE_Space] – holds the background mesh itself (a sphere) & flare key joint
- JNT[POST_Planet] – to hold planet (big background objects), not used in this example, I think it is not necessary…
- HOLD_LITE – holds directional and ambient lights

Note that the material uses the background shader.


(Taiidan Republic Mod) #3

STEP 2 – BACKGROUND MODIFICATION

Now modify the background by:

  1. Changing the image to your own background iamge (^2 sizes, most seem to be 4096x2048, .TGA format). You can open the example file in GIMP/photoshop and overwrite it.
  2. Moving the directional lights to match the light sources on your background. Change the RGB values of the lamp to match. Additional lights can be created using the joint tools:

02_light_tools

Note: it is necessary to have 2 directional lights. Without them, the game will crash (but HODOR will not give an error message…) More than 4 directional lights seems not to work…


(Taiidan Republic Mod) #4

STEP 3 – CUBE MAPS

Cube maps are a set of images that define what will be reflected on a ship’s shiny surfaces (defined in the REFL texture of a ship).

To create the cube maps, a series of cameras are used in Blender. These can be created using the toolkit as follows.

03_cubemap_tools

The “Render Cube Maps” button is a little clunky - it currently generates PNG files, which will need to be opened in GIMP or photoshop and saved as DDS with the suffix “yourbackground_hq_negx.dds” etc.


(Taiidan Republic Mod) #5

STEP 4 – EXPORT AND HOD CREATION

The background can be exported as a DAE file using File > Export > HWRM DAE file.

The HODOR script works in the same way as for a ship or subsystem. The important thing to note is that the background image should be “8888” (no compression) because we do not want any loss or compression in background images:

= -$SHADE_OPT_LOADDAE=Force8888

The final HOD file must have the name background_light.HOD where “background” is your background name.


(Taiidan Republic Mod) #6

STEP 5 – STARFIELDS (OPTIONAL)

The starfield (which is not mandatory for a background) is defined in a separate HOD file.

There are two options:

  • Use an existing HWRM starfield HOD (no one will notice…)
  • Create a new starfield HOD which can be reverse-engineered as follows:
  1. Use a HODOR script like this to convert the example starfield into TGA files:
= -$HWRM_BASE=C:\Program Files (x86)\Steam\steamapps
= -$COSMIC_MESH=C:\Program Files (x86)\Steam\steamapps\common\Homeworld\HomeworldRM\Data\background\m15\m15_light.hod
= -$COSMIC_SRCSTAR=C:\Program Files (x86)\Steam\steamapps\common\Homeworld\HomeworldRM\Data\background\m15\m15.hod
= -$$COSMIC_DEFS=$[HWRM_BASE]\common\Homeworld\GBXTools\HODOR\STARS.DEF
= -$$COSMIC_OPTS=Mat=background Width=4096 Height=2048
= -$COSMIC_DSTRGB=C:\Users\you\Desktop\m15_RGB.TGA
= -$COSMIC_DSTTEX=C:\Users\you\Desktop\m15_Tex.TGA
= -do=cosmic
= -action=null

What this does is to take the background sphere in “xx_light.HOD” and map the stars onto the same UV map, producing two TGA files that define the stars.

  1. Edit the starfield TGA files in GIMP or photoshop, being careful to respect the following rules regarding RGB of the pixels (defined in “STARS.DEF”, which lives where HODOR lives and can be customised to point to custom TGA star images in data/background/stars/). Note that if you used your background_light.HOD in the above HODOR script, the UV mapping of the starfield will match, so you can work on your starfield with the background on a different layer.

Here is an example of what can be produced by carefully controlling the RGB values of the pixels in the “TEX” and “RGB” files:

05_stars

xx_TEX.TGA “R” xx_TEX.TGA “G” xx_TEX.TGA “B” xx_RGB.TGA “RGB”
star type star size ??? star colour
  1. Use a HODOR script like this to convert the TGA files into a new starfield HOD, which must be called background.HOD where “background” is your background name.
= -$HWRM_BASE=C:\Program Files (x86)\Steam\steamapps
= -$COSMIC_MESH=C:\Program Files (x86)\Steam\steamapps\common\Homeworld\HomeworldRM\Data\background\your_background\your_background_light.hod
= -$COSMIC_SRCSTAR=C:\Program Files (x86)\Steam\steamapps\common\Homeworld\HomeworldRM\Data\background\your_background\your_background.hod
= -$COSMIC_DSTSTAR=C:\Program Files (x86)\Steam\steamapps\common\Homeworld\HomeworldRM\Data\background\your_background\your_background.hod
= -$$COSMIC_DEFS=$[HWRM_BASE]\common\Homeworld\GBXTools\HODOR\STARS.DEF
= -$$COSMIC_OPTS=Mat=background Width=4096 Height=2048
= -$COSMIC_SRCRGB=C:\Users\you\Desktop\your_stars_RGB.TGA
= -$COSMIC_SRCTEX=C:\Users\you\Desktop\your_stars_Tex.TGA
= -do=cosmic
= -action=null

Note that SRCSTAR and DSTSTAR can be the same HOD (which would be overwritten).


(Taiidan Republic Mod) #7

STEP 6 – FILE SETUP AND TEST

You should have the following files in your background directory /data/background/your_background/. For the lua files for your first background you can simply copy the example files and then start playing.

File Purpose
your_background.HOD stars
your_background_light.HOD background and lights
your_background.lua defines a “flare key” for lens flare
your_background_extra.lua various lighting parameters

The flare key lua file references a joint in the background (in the example below “Flare_Key”) to hang the lens flare on.

lensflares = 
{
    lensflare0 =
    {
        name = "EZ05_Flare",
        follow = "Flare_Key",
        infinite = 1
    },
}

To use the background, you need to make a .level file point to the background as follows:

loadBackground("your_background")

Have fun!


(GOLIATH Mod) #8

THANKS! This is going to be totally useful!