unit transparency

A forum for discussing map making ideas and problems for the Myth series.
spicysaltysquid
Posts: 7
Joined: Sun Apr 19, 2020 11:29 pm

unit transparency

Post by spicysaltysquid »

I'm dabbling in mapmaking and unit making, and am trying to import new sprites for a few new units. I'm using Oak, but I can't seem to figure out how to specify which color represents transparency. I've tried making and importing an alpha mask bitmap too, but that doesn't seem to work either (I get an error about the filename not matching, even though it does match the original bitmap filename).

Can someone please help, I've figured everything else out but it is not good if my units have a blue box around them :p

I have photoshop, if that is helpful with this.

PS Been playing the Myth games since their original release. My brother and I have been playing multiplayer a lot together since COVID19 began - we're very pleased to see a community is still supporting the game!
spicysaltysquid
Posts: 7
Joined: Sun Apr 19, 2020 11:29 pm

Re: unit transparency

Post by spicysaltysquid »

Well I figured it out. For future reference here's the workflow I'm using. I'm working off of Sprite sheets:

1. Load sprite sheet in Photoshop, save as a PSD
2. Set Image->Mode->RGB Color
3. Select and Delete the background if it isn't already transparent (magic wand can make this easy)
4. If working with a sprite sheet, use Slice tool to slice individual frames
5. File->Export->Save For Web
6. Select the slices to export, output format should be
  • PNG-24
  • Transparency box checked
  • Convert to sRGB box checked
7. Hit save and choose a folder for the slices i.e.
  • myunit/walk
  • myunit/stand
  • myunit/attack
  • etc
8. Setting the Reg Point later (when building the Collection) is a lot easier if all images are the same size, an easy way to resize in batch is to use imagemagick's mogrify tool, just specify dimensions that are at least as large as your largest image (run from each image directory):

Code: Select all

mogrify -extent 312x198 -background none -gravity center -define png:format=png32 *.png
9. Fire up Oak, do Tools->Build Standard Collection


For Step 8, importing the collection, follow this that I found in another thread:
Melekor wrote:If you have rendered all of your sequences from the same camera position, so that all of your renders are lined up, you can use Oak's "build standard collection" tool (in the Tools menu). It handles almost all of the collection building process for you, including indexing.

Basically, the tool wants the renders arranged in a folder structure, one folder per sequence (animation).

e.g.

Code: Select all

myunit/walk/
myunit/attack/
myunit/taunt/
Then you select the "myunit" folder in the tool, fill in the options and click OK.

The images in each folder are sorted by filename and then the frames and views are filled out in order from the sorted images. The tool defaults to 8 views per sequence, meaning the images are ordered like this

Code: Select all

                views
frames 1  2  3  4  5  6  7  8
       9 10 11 12 13 14 15 16
                (etc)
If you tick the checkbox for "frames then views ordering", then they are ordered as

Code: Select all

       views
frames  1 9   etc
        2 10
        3 11
        4 12
        ..
If the number of views for your unit isn't the default of 8, you will have to use the script mechanism to specify it for each sequence. This is done by creating a text file that goes into the folders that the tool will read.

The script should be named "script.txt" and it can be placed in the root folder myunit/script.txt as well as in each animation folder, myunit/walk/script.txt etc. If a folder has no script, it inherits the script from its parent.

An example script file showcasing all the possible parameters:

Code: Select all

(3 3 2 1 2)
Frames 5
Views 5
BitmapOrder FramesThenViews
The first parameter is called the "frame mapping" which can be used to permute or duplicate frames.
BitmapOrder can be either FramesThenViews or ViewsThenFrames.
Frames and Views - self explanatory.

The reg. point X, Y fields are used to specify where the bottom of the sprite is. This is typically somewhere between a unit's feet - check out other collections in the editor to see where you should set this.
Last edited by spicysaltysquid on Sun Apr 26, 2020 5:39 pm, edited 1 time in total.
User avatar
Melekor
Site Admin
Posts: 2449
Joined: Sat May 01, 2004 12:10 am
Contact:

Re: unit transparency

Post by Melekor »

Glad you were able to get the process working! Hope you will share the new units with us when they are finished :D
spicysaltysquid
Posts: 7
Joined: Sun Apr 19, 2020 11:29 pm

Re: unit transparency

Post by spicysaltysquid »

Hi @Melekor I definitely will share everything I make.

One more piece I haven't figured out - how do I add shadows to the Sequences using Oak?
User avatar
paladin MAIK
Posts: 339
Joined: Mon Aug 06, 2012 12:31 am
Location: (Russia)
Contact:

Re: unit transparency

Post by paladin MAIK »

Hi spicysaltysquid. You can add shadows simply by copying a bitmap from another collection (warrior, for example). This is the easiest way, since almost everyone collections has the same shadows.
Image
spicysaltysquid
Posts: 7
Joined: Sun Apr 19, 2020 11:29 pm

Re: unit transparency

Post by spicysaltysquid »

Thanks paladin MAIK, that is what I was planning on doing but I can't find a way to get the shadow attached to the sequence.

In Oak I can go to Shadows and do "Add Shadows from File" and they get added, but after that how do I bring that shadow bmp into one of the sequences?

Or is there a way to bring them in using the Build Standard Collection tool?
hmp
Posts: 146
Joined: Fri Dec 14, 2007 3:00 am

Re: unit transparency

Post by hmp »

I'm not sure if there is a more automated way using the collection builder, but you can manually add shadows to a sequence. Just open the sequence you want to edit, and then switch the main collection window to the shadows tab. You need to then click the grid button to change the view, and then you should be able to drag and drop.
spicysaltysquid
Posts: 7
Joined: Sun Apr 19, 2020 11:29 pm

Re: unit transparency

Post by spicysaltysquid »

Oh I can't believe it is that easy! Heh I was using the list view and just could not find a way to make it work!

Wow that makes substituting bitmaps so much easier for me, I was rebuilding my collection each time.

Thanks a bunch hmp!
User avatar
Melekor
Site Admin
Posts: 2449
Joined: Sat May 01, 2004 12:10 am
Contact:

Re: unit transparency

Post by Melekor »

I have some code laying around for autogenerating shadows but I never got around to integrating it into the UI. Should really do that at some point, real shame to let it go to waste.
User avatar
Melekor
Site Admin
Posts: 2449
Joined: Sat May 01, 2004 12:10 am
Contact:

Re: unit transparency

Post by Melekor »

spicysaltysquid wrote:Hi @Melekor I definitely will share everything I make.

One more piece I haven't figured out - how do I add shadows to the Sequences using Oak?
Can you upload your folder structure for the auto tool somewhere? I want to use it for testing while I integrate shadow generation. Don't have any lying around, it's been literally years since I looked at this stuff
spicysaltysquid
Posts: 7
Joined: Sun Apr 19, 2020 11:29 pm

Re: unit transparency

Post by spicysaltysquid »

Hey Melekor, sure here's a folder for one unit with all the script.txt files in place; auto-shadows sounds great :-)

https://drive.google.com/open?id=1gB5I- ... WdAbTMk2zu
User avatar
paladin MAIK
Posts: 339
Joined: Mon Aug 06, 2012 12:31 am
Location: (Russia)
Contact:

Re: unit transparency

Post by paladin MAIK »

Looks like a supermutant from fallout 2 :)
Image
User avatar
Melekor
Site Admin
Posts: 2449
Joined: Sat May 01, 2004 12:10 am
Contact:

Re: unit transparency

Post by Melekor »

spicysaltysquid wrote:Hey Melekor, sure here's a folder for one unit with all the script.txt files in place; auto-shadows sounds great :-)

https://drive.google.com/open?id=1gB5I- ... WdAbTMk2zu
Perfect, thanks!
User avatar
Point
Posts: 1800
Joined: Mon Mar 22, 2004 12:58 pm

Re: unit transparency

Post by Point »

Melekor Dynamic shadows.... DYNAMIC SHADOWS ...DYNAMIC SHADOWS!... DYNAMIC SHADOWS!!! Implementing dynamic shadows would be the bomb !
if one does not learn from the failings of the past they are likely to suffer its return.
User avatar
Melekor
Site Admin
Posts: 2449
Joined: Sat May 01, 2004 12:10 am
Contact:

Re: unit transparency

Post by Melekor »

Time flies, hard to believe it's already been almost a month since I promised to add shadow generation. I finally had a few hours to sit down and do this today.

New alpha up on the builds page including the shadow functionality. I also added support for specifying a lot more stuff in script.txt, here is an example that shows most of the options:

Code: Select all

RegPoint (160,140)
BitmapOrder FramesThenViews
ObjectScale 1.0
Radius 25
Top 90
Bottom -10
TicksPerFrame 4
KeyFrame 0
LoopFrame 0
FirstSoundTag 
KeySoundTag 
LastSoundTag 
TransferPeriod 2
TransferMode None
GenerateShadows True
GenerateShadows.SunElevationAngle 35
GenerateShadows.SunYawAngle 45
GenerateShadows.MaxFalloff 0.5
GenerateShadows.MaxDarkness 0.8
I have not extensively tested this stuff so it could be buggy. Let me know if any of the options don't work or if you run into any issues.
Post Reply