Background Hods


(Eville Jedi) #1

Any chance for a reference background hod with a planet?


[EXAMPLE] Backgrounds #1 - Discussion
(BitVenom) #2

We’re gonna do an example background pack early next week. LOTS of stuff to cover in that package. I don’t know about a planet. Maybe. I only say that because that’s up to Cole really - the current example doesn’t have one, so adding it is his work, not mine.


(making space ships) #3

I’ll throw in a .DAE with a planet into the examples update for you to put your eyeballs on but we will have to do live documentation with Dave as I never messed with any of the crazy planet shader options.


(Eville Jedi) #4

awesome, even if the example isn’t documented I can still experiment


(BitVenom) #5

100% ready to fly. Ask anything you might want to know - I won’t have time to do proper docs for a bit (I am about to start some really hardcore engine/gamesim stuff that will keep me super busy for weeks).

Planets are an example of objects that get most of their in-game look from Shader Parameters. When you see a Parameter block in the DAE for a specific material, and you aren’t sure where it comes from, or what it is meant to do, go find the .surf for the material, or even sometimes the .prog for the surf - it’ll list all of the properties that can be set from DAE or LUA, and should help you understand a bit better. Or just ask around here.


(Tempest6677) #6

Thank you for this!


(Eville Jedi) #7

A couple of notes from the example

I had to comment out the ‘Testmap=1’ in the files to get them to work. The stress test is fun!

I get a random CTD and ‘access violation’ on the Astronaut murdering for sport and fleet test. There was nothing in the HW2.log. This could be due to some mod file conflicts, but I am not sure yet, just haven’t seen the access violation message before

I was able to export the planet example from Max 2011, however a lot of things were wrong.

  1. the hod was 80 mb. I didn’t see any notes on what HODOR script to run so I ran it like a ship

  2. no light or animation mad. again may be a HODOR setting?

  3. no stars or animation in game and the clouds didn’t look like they were working either

I have yet to try custom background export, that is up next.


(BitVenom) #8

There’s a command-line for test maps - it wasn’t in the docs? (-testmaps)

No idea about the CTD - I will look later.

The HOD should be nearly 80MB, yes. You can just convert it like a ship, absolutely. You should have gotten a .MAD from it too, but I can’t say we support 2011, so I really don’t know. There are stars, and lights too. If you take the stock DAE for the planetexample and throw that at HODOR you should get the .HOD/.MAD combo exactly as-is from the data\backgrounds\planetexample folder… (planetexample_light.hod is 80MB, planetexample_light.mad is very, very small).

Did you forget to copy the stuff in ‘data’ to your mod? Those are the levels and final examples for use with the test levels and stuff - that could be an issue…


(Eville Jedi) #9

Here are my steps

copied the data folder from the example into my data folder, tested the maps as is and other than the random crashes when changing levels everything worked fine.

imported the planetexample_Light.dae into max, looked at it and exported it to a new folder and file name PLANET_EXAMPLE.DAE without any modifications.

copied the source/planet .tgas into the PLANET_EXAMPLE folder

created a hodor script

## My HODOR Params - by Timmy
= -$HWRM_BASE=G:\SteamLibrary\steamapps\common\Homeworld
= -$SHIPS_BASE=G:\BACKGROUNDS
= -$SHIP_NAME=PLANET_EXAMPLE
= -$SHADER_MAP=$[HWRM_BASE]\GBXTools\HODOR\SHADERS.MAP
##= -$SHADE_OPT_LOADDAE=Force8888
= -$HOD_SAVE_OPTS=ForceScars FilterScars=thruster,bay
= -$CONVERT_IN=$[SHIPS_BASE]\$[SHIP_NAME]\$[SHIP_NAME].DAE
= -$CONVERT_OUT=$[SHIPS_BASE]\$[SHIP_NAME]\$[SHIP_NAME].HOD
= -do=convert
= -action=null
= -wait

executed the HODOR script

> G:\SteamLibrary\steamapps\common\Homeworld\GBXTools\HODOR>hodor -script=PLANET_E
> XAMPLE.HODOR
> DAE->HOD: Loading G:\BACKGROUNDS\PLANET_EXAMPLE\PLANET_EXAMPLE.DAE
> DAE->HOD: Creating Homeworld2 Multi Mesh File - Version 512
> DAE->HOD: Creating STAT[BTG_EX] with Shader[background]
> -- Building LMIP[G:\SteamLibrary\steamapps\workshop\content\244160\412433578\Sou
> rce\Planet\planetexample_DIFF] for Param[$diffuse] (4096x2048 - 8888)
> DAE->HOD: Creating STAT[PEX] with Shader[bg_planet]
> -- Building LMIP[G:\SteamLibrary\steamapps\workshop\content\244160\412433578\Sou
> rce\Planet\planet_DIFF] for Param[$terrain] (4096x2048 - DXT1)
> -- Building LMIP[G:\SteamLibrary\steamapps\workshop\content\244160\412433578\Sou
> rce\Planet\planet_GLOW] for Param[$night] (4096x2048 - DXT1)
> -- Building LMIP[G:\SteamLibrary\steamapps\workshop\content\244160\412433578\Sou
> rce\Planet\planet_SPEC] for Param[$enviro] (4096x2048 - DXT1)
> -- Building LMIP[G:\SteamLibrary\steamapps\workshop\content\244160\412433578\Sou
> rce\Planet\planet_CLD1] for Param[$clouds] (4096x2048 - DXT1)
> -- Building LMIP[G:\SteamLibrary\steamapps\workshop\content\244160\412433578\Sou
> rce\Planet\planet_WARP] for Param[$warp] (4096x2048 - DXT1)
> -- Building LMIP[G:\SteamLibrary\steamapps\workshop\content\244160\412433578\Sou
> rce\Planet\planet_NORM] for Param[$normal] (4096x2048 - DXT1)
> DAE->HOD: Generating Scene Data LOD[0]
> DAE->HOD: Generating Animation Channels
> Press any key to continue . . .

only a hod was generated.

copied the ‘planetexample’ folder in backgrounds to planettest renamed every file in there to planettestXXXX and then copied in the newly export hod

copied the ExamplePlanetLevel.level file and renamed it to ExamplePlanetTest.level and pointed it at the new background planettest hod name

In game the planet showed up textured and lit, the background was there, but no stars or animation and the cloud layers didn’t look the same. though I think the WARP was working (I’d assume it is the heat distortion like effect?), it might just be the lack of animation


(BitVenom) #10

Some settings you should change (hard to read given the size of that shot…)

X - Remove Single Key
x - Bake Animation (aka don’t bake)
x - Deformations (aka no deformations)
x - Single Matrix (aka don’t use matrices)

That may help. Worst case, PM me your DAE and I can look. Otherwise that shot looks fine - minus the missing stars. The stars are in the other hod (planetexample.hod) - and should ‘just work’.


Moving animations in MAX
(making space ships) #11

You’re creating a planetexample.hod where you should be creating a planetexample_Light.hod. The _Light is the actual background, the .HOD is the stars/deprecated but still supported classic style background meshes. In effect you are not seeing stars because you overwrote their HOD.

Rename your .DAE to have the _Light suffix and you should be groovy.


(Eville Jedi) #12

Those settings worked, now have animated planet

For the stars I don’t see where it is getting the information for them, there is nothing in the alpha channels of the background file and no objects in the dae. I feel like a file is missing to generate the _light.hods?

also it seems like translation animations are a CTD? I was able to move the planet root object statically but not key frame it like a ship animation. I could change the axis of rotation by rotating the joint, but scaling and translation looked like they were ignored. (if I wanted to make the planet closer to the camera I didn’t see any options for that in the extra.lua)

I also tried creating a seperate planet JNT to add another planet and it exported but CTD in game

however custom textures for the BG mesh and the planets work fine on export so that Is a huge plus

(bg image only, no planet, lighting was copied from another file so is completely wrong)


(making space ships) #13

Stars are a whole separate thing and will have to be documented because it is complicated at first look.

The quick version: stars are hand painted 1x1 pixels in Photoshop over the background, at resolution (so 8,388,608 possible star locations although there is a built in combiner that prevents stars from being too close together).

Working on them looks like this:

You have your basic colored stars in a layer:

and your “hero” textured stars in a separate, overlaying layer:

and finally a star tinting layer that alters the color, distance, size laid on top of both layers:

If you refer to the STARS.DEF that came with HODOR you’ll see:

##=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=##
#### Example Star Definition File
##=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=##

16:  Neb07.TGA
32:  Neb01.TGA
48:  Neb02.TGA
64:  Neb04.TGA
88:  Neb05.TGA
100: Neb06.TGA
188: Neb07.TGA

128: B01.tga
144: B02.tga
160: B03.tga

These numbers refer to the value of the Red channel for your textured, hero stars. The STARS.DEF is like SHADERS.MAP- a remapping reference for HODOR. If you look in data\Background\Stars you’ll find the actual star art. We’ll have to release the HODOR script and Photoshop actions to make these but we’re not there yet.


(Eville Jedi) #14

what are the tga names for the star files? it looks like there would be _STAR, _HERO, _TINT or something


(making space ships) #15

Those targas in the code block are the star names. When painting stars I used a palette like thus:

so that I could eyedrop off the color place the star. Because you’re dealing with the value of the Red channel to designate which star (ie 128 in Red would be the B01.tga star) the names don’t seem to matter much (to me).

Tinting, size, distance are all done programagically by Dave based on blue/green channel values.


(Eville Jedi) #16

That is a helpful reference

What I meant though was what is the name of the .tga file to export with the BG to generate the stars

as far as I can tell the BG shader only looks for _DIFF for the _light.hod, but for the stars do we use the cosmic shader since it has _MASK?

also how do you generate the starfield in photoshop with random single pixels, the best I could come up with was generate noise and then use magic wand to delete stuff until there was a small number of points


(making space ships) #17

The stars live in the .HOD just like they always have. The _Light.HOD is the new format that we added, it contains the sky sphere, planets (if any), 3D mesh cards (ie, Tanis background, the ruins at Karos, etc, if any) the lights and background texture. The classic .HOD file contains the stars and old school mesh sphere, if it exists (ie, HW2 backgrounds).

As per the background documentation that I wrote (included in the documentation folder with the background example):

draw_sphere = 0.0 – Set to 1 to disable background sphere only, reverts to vertex background if a HW2C background

So if your classic mod used custom backgrounds you can set that draw_sphere to “1” to see it again. Essentially we preserved classic mod background behavior by drawing our sphere in front of the classic vertex painted backgrounds and gave the user the ability to decide which to use. The stars are set to render through either the vertex painted meshes or our new sky sphere. With me so far?

.HOD : stars, vertex painted background (if needed, just stars if it doesn’t exist)
._Light.HOD : HWR’s new background tech.

When we release the HODOR script and Photoshop action for this you’ll want to generate a starfield template from a skysphere mesh you create or you can use the one we use (included in the background example workshop files) as the UV maps are set up for it. Edit the stars, and run the Photoshop action which will extract your layers (colored, textured, tints) and compress them into two separate .TGAs which you will point HODOR at. HODOR will take those two .TGAs and write a .HOD for you containing the stars.

As far as making these things when the time comes I’ll include as much source material as I can with the recommendation that for your sanity’s sake you use them as starting templates because the alternative is to use the pencil brush to draw each individual star by hand using the pencil tool which is what I did for the textured stars for every HW1 and HW2 background and that was ~6-8 hours at night for a couple of months straight.


(Eville Jedi) #18

draw_sphere = 0.0 – Set to 1 to disable background sphere only, reverts to vertex background if a HW2C background

that might explain why I got the LSD hall of mirror effect on some old maps

Okay good to know that I wasn’t missing something in the example.

having an image generate the stars is way better than the old hack we used by creating thousands of pebbles with an algorithm in the determ chunk!


(BitVenom) #19

faints - Seriously?! Holy crap I really hope you guys collectively in the future ask us for help - because that’s just crazy. Yeah, the star tool works great - you still have to paint a bunch of stars, but it works well. I imagine that enterprising members of the community will make star ‘templates’ with pretty layouts that others can clone or borrow from to speed making pretty backgrounds.

Hell, the really enterprising among you should make entirely new, full featured backgrounds - auction them off or just put them up for others to use. It’d make for great portfolio material, and may be easier for some than making new meshes (some people do 3D objects, some people paint…)


(Eville Jedi) #20

the work arounds we did for not having good tools support in classic HW2…

(scratch writing the background hod logic for image convolution edge detection and delauny trianglulation around a sphere; precise positioning of collision mesh verts as subsystems to allow turrets to fire through ‘simulated shields’; or some of the incredibly ridiculous sob lua stuff that should have been single line built in functions)