Author Topic: Tutorial: Creating a Custom Clan Logo  (Read 15544 times)

Offline Joker{eXtreme}

  • Rank: Private
  • *
  • Posts: 6108
    • http://www.mycallofduty.com
Tutorial: Creating a Custom Clan Logo
« on: July 23, 2007, 03:39:44 pm »
Originally Posted by Tally

I've been asked several times to post my tutorial on creating a clan logo here. So, here it is.

Please bear in mind that this tutorial is not specifically for eXtreme+ mod. Hence, the code I include with the tutorial needs to be applied with care to the gametype files.

I should really do a proper eXtreme+ one, but either too lazy or am too busy - I cant decide which lol

===============================================================================

Custom Clan Logo

creating a custom hud element - Part 1: Shaders

In this tutorial I will show you how to do the following things:

1.    Create an IWI file

2.    Create a Materials file to reference the IWI file

3.    Create a hud element and call it out from a gametype script

With these things, you can end up with a logo which is placed in the top-right hand corner of the MP screen. This can be a clan logo, or anything you like really. This particular type of hud element is known as a ‘shader’. There are other types of hud elements, and later I will describe how to create a string hud element.

You will need a DDS plugin for whatever graphics package you will be using. You can find both a PS and a PSP one in the ‘resources’ section above.

Also, you will need the 2 converters to convert back and forth from IWI to DDS, DDS to IWI. These can also be found in the ‘resources’ section above.

Further, you will need a Hex editor to edit a materials file. See the download in the ‘resources’ section above.

IWI file logo

First, create your logo. This is the one I will use as an example. It is one I created for a clan called ‘Telford Light Infantry’ (TLI):



I will be using Photoshop CS for the purposes of this tutorial.

1.    Create a new canvas 256x256. Images in COD2 will only work if they are RMS (root means square), or what Chris_P calls ‘to the power of’. Everything therefore has to go up in times the original size: 32, 64, 128, 256, 512, etc.

Fill it with a mid grey with the paint bucket. The go to layers, and click on the channels tab as marked:



This will create a new alpha channel:



Alpha channels mask off any image, so that they effectively ‘don’t show’ on the server screen. In a moment, we will remove just the area for the logo image, but still mask off the ‘square’ part of the canvas – the bit we don’t want.

2.    Now click back on the RGB channel, and switch back to layers by clicking the ‘layers’ tab.

3.    Press Ctrl + SHIFT + N to create a new layer. Get your logo image and paste it on the layer. Size it up if you need so that it fits on the area:



4.    Make sure the logo image layer (layer 2) is active. Then get the Magic Wand tool, and select around the image. Then go to Select > Inverse:



5.    Switch  back to channels, and click on the alpha channel.

6.    You will see that the selection now reveals the logo image in outline form:



7.    Press SHIFT + D, to restore the color palette to its default Black/White status. Press Delete, and you will remove the mask from the alpha channel. This means that the logo image will show ‘through’ the alpha mask on the server, but the ‘square’ part of the canvas wont be seen:



8.    Switch back to layers again, and flatten the image:



9.     Go to File > Save As, and chose DDS format. Use the default settings on the NVidia plugin, but make sure you set the 2 critical settings – DXT5, and generate (not ‘use existing’) mipmaps. These are the settings that will make an IWI file valid. Anything else doesn’t work:



Save the file as ‘hudclanlogo.dds’.

10.    Copy your new DDS logo file to your desktop, and have the DDS2IWI converter on the desktop too. Drag and drop the DDS file onto the converter, and the newly generated IWI will pop out the other side.

11.    Create a new folder on your desktop, and call it ‘images’. Drag the hudclanlogo.iwi file into that folder.

Done.

Materials File

Now we need to create a custom materials file to reference the IWI file. As was stated above in the ‘resources’ section, no image in COD2 can be used if it doesn’t have a materials file to reference it. This is fine if you are merely customizing an existing IWI file, like a skin or something, but when you create a new image, as in this case, we need to create a custom materials file to go with it.

There are 2 ways to create a custom materials file – using the Asset Manager, which are part of the IW Tools, or take an existing materials file and edit it. We will take an existing one, and edit the information.

The best ones to use are those that you know for sure reference 2D images. I cant really advise you about this, as it is really all a question of knowing what ones are what.

For our purposes, I’m going to use one I know is a 2D materials file. So, go to your COD2 ‘main’ folder, and open iw_13.iwd with winrar. Find the ‘materials’ folder, and scroll down until you find ‘hudcolorbar’.

Open the file with your Hex editor, and you will see this



It is the marked area that concerns us – we are going to change it.

The important thing to know about editing an existing materials file to suit your own custom purposes, is that you CANNOT use any more, or any less characters than already exist. In this case, there are 11. So, we are going to rename this to ‘hudclanlogo’ which is 11 characters.

So edit the info so that is looks like this:



Save this file to your desktop, and then rename the actual materials file – ‘hudclanlogo’. This will now reference your IWI file called ‘hudclanlogo.iwi’.

Create a new folder, and call it ‘materials’.

New Hud Element Call Out

Now we need to enter the script which will callout the IWI file.

There are 2 ways to call this out. You can either edit each gametype file individually, or you can use the _callbacksetup,gsc file. Scripting the hud element in here will work for TDM, DM, CTF, and S&D. However, it will crash HQ. But if you don’t use HQ in your server rotation, then that should be fine.

On the assumption that you do use HQ, I will demonstrate how to script it into the gametype files themselves. I’ll show you with TDM, but the principle is the same for all of them.

Open iw_15.iwd with winrar, and open the maps\mp\gametypes folders, and drag the TDM gametype file onto the desktop. Open it with programmers notepad.

The actual script we are going to use is this one:

Code: [Select]
      level.svrlogo = newHudElem();
       level.svrlogo.x = 580;
       level.svrlogo.y = 40;
       level.svrlogo.alignX = "center";
       level.svrlogo.alignY = "middle";
       level.svrlogo.archived = false;
       level.svrlogo.alpha = .8;
       level.svrlogo.sort = 8000;
       level.svrlogo setShader("hudclanlogo", 50,50);
There are several elements in this which I must explain.

The first is the positioning. This is done via a screen x/y coordinate.

alignX – this refers to three possible positions: right, left, or center

alignY – this refers to three possible positions: top, bottom, or middle

Then there is the distance between x-and-y. To place a hud element on the screen in the left-hand corner, you would have:

X = 0
Y = 0
alignX=left
alignY=top

To place it in the right-hand corner, you would have:

X = 650
Y = 0
alignX=left
alignY=top

To place it in the lower left-hand corner, you would have:

X = 0
Y = 475
alignX=left
alignY=top


This shows that the screen is broken up into a grid reference which is 650 along the top, and 475 down from the top. X is vertical; Y is horizontal.

If you wanted to place the hud on the bottom of the screen it is best (easier) to use the center/middle reference, as this places the coordinates on top of each other. I have found this easier to control (which is why the coordinates in the script are like this). But it doesn’t really matter which method of referencing you use.

The next thing I want to explain is this:

Quote
level.svrlogo setShader("hudclanlogo", 50,50);
This is the ‘sizing’ of the IWI file. You can make it up to 200 times its original size. As 100 is the original size, this effectively means you can double its size.

The next thing to explain is this:

Quote
level.svrlogo.alpha = .8
This controls the opacity (transparency). 1 = default.

.1-9 fades it out in increments of .1 factor

Ok, so that explains the element. Now to insert it.

There are 2 places in the gametype where you can place it: main() or Callback_StartGameType(). Either will do.

So, I will insert it at the Callback_StartGameType().

First, we must precache it (see above tutorial on adding a weapon to understand precaching):

Code: [Select]
    precacheShader("hudclanlogo");This loads it into server memory as the gametype is complied (‘formed’).

So, the whole script would be this:

Code: [Select]
Callback_StartGameType()
{
    level.splitscreen = isSplitScreen();

    // defaults if not defined in level script
    if(!isDefined(game["allies"]))
        game["allies"] = "american";
    if(!isDefined(game["axis"]))
        game["axis"] = "german";

    // server cvar overrides
    if(getCvar("scr_allies") != "")
        game["allies"] = getCvar("scr_allies");
    if(getCvar("scr_axis") != "")
        game["axis"] = getCvar("scr_axis");

    precacheShader("hudclanlogo");

    precacheStatusIcon("hud_status_dead");
    precacheStatusIcon("hud_status_connecting");
    precacheRumble("damage_heavy");
    precacheString(&"PLATFORM_PRESS_TO_SPAWN");

    thread maps\mp\gametypes\_menus::init();
    thread maps\mp\gametypes\_serversettings::init();
    thread maps\mp\gametypes\_clientids::init();
    thread maps\mp\gametypes\_teams::init();
    thread maps\mp\gametypes\_weapons::init();
    thread maps\mp\gametypes\_scoreboard::init();
    thread maps\mp\gametypes\_killcam::init();
    thread maps\mp\gametypes\_shellshock::init();
    thread maps\mp\gametypes\_hud_teamscore::init();
    thread maps\mp\gametypes\_deathicons::init();
    thread maps\mp\gametypes\_damagefeedback::init();
    thread maps\mp\gametypes\_healthoverlay::init();
    thread maps\mp\gametypes\_friendicons::init();
    thread maps\mp\gametypes\_spectating::init();
    thread maps\mp\gametypes\_grenadeindicators::init();
 
       level.svrlogo = newHudElem();
       level.svrlogo.x = 580;
       level.svrlogo.y = 40;
       level.svrlogo.alignX = "center";
       level.svrlogo.alignY = "middle";
       level.svrlogo.archived = false;
       level.svrlogo.alpha = .8;
       level.svrlogo.sort = 8000;
       level.svrlogo setShader("hudclanlogo", 50,50);
Close and save to your desktop.

Now, do this to all the gametypes you wish to use in your rotation.

On your desktop, create a set of nested folders: maps\mp\gametypes

Place the edited gametype files in there.

You should now have three new folders on your desktop: ‘images’, ‘materials’, and ‘maps’.

Pack these into an IWD file (see above for details on how to make one). Call it something like zzz_logomod.iwd

Place this in your COD2 ‘main’ folder. Start up a New Server to test it, and you should get something like this:


Offline mixmanone

  • Rank: Private
  • *
  • Posts: 8
    • http://www.sobsquad.net/
Tutorial: Creating a Custom Clan Logo
« Reply #1 on: July 30, 2007, 09:02:36 am »
One question what size should we make the image, because when i put 256x256 pixel it show small.

Should it be in pixel, inches, cm, or mm?

Offline Joker{eXtreme}

  • Rank: Private
  • *
  • Posts: 6108
    • http://www.mycallofduty.com
Tutorial: Creating a Custom Clan Logo
« Reply #2 on: July 30, 2007, 09:11:32 am »
Quote from: "mixmanone"
One question what size should we make the image, because when i put 256x256 pixel it show small.

Should it be in pixel, inches, cm, or mm?


Needs to be created in pixels -- if 256 x 256 is too small for you, then try 512 x 512

Offline Tally

  • Rank: Private
  • *
  • Posts: 65
Tutorial: Creating a Custom Clan Logo
« Reply #3 on: July 30, 2007, 11:19:10 am »
Quote from: "mixmanone"
One question what size should we make the image, because when i put 256x256 pixel it show small.

Should it be in pixel, inches, cm, or mm?


As Joker says - pixels. The game doesnt understand anything else.

If you've created a shader 256 x 256, you increase the size via the script.

The example script has:

level.svrlogo setShader("hudclanlogo", 50,50);

Just cahnge that to:

level.svrlogo setShader("hudclanlogo", 100, 100);

Or, go beyond 100 (which is a % - so, 100 is 100%, which is 256 x 256).

Offline mixmanone

  • Rank: Private
  • *
  • Posts: 8
    • http://www.sobsquad.net/
Tutorial: Creating a Custom Clan Logo
« Reply #4 on: July 30, 2007, 11:42:41 am »
Thanks Joker Thanks Tally got it to work.

Offline kazantia

  • Rank: Private
  • *
  • Posts: 3
Tutorial: Creating a Custom Clan Logo
« Reply #5 on: July 31, 2007, 05:20:57 pm »
well i followed the tut and created my own Logo for the game

i only have 1 problem
I don't see it i n my game

when i start the server (linux) i see all the iwd files that are loaded but don't see my zzz_logoofn.iwd in there
i also don't receive any error from the server and he is running fine
except without logo!

I probably missed something but what?
i hope someone can help me

Offline kazantia

  • Rank: Private
  • *
  • Posts: 3
Tutorial: Creating a Custom Clan Logo
« Reply #6 on: August 01, 2007, 04:19:39 pm »
K guy's
I have solved my problem by putting the directly in the extreme mod

thanks anyway

Offline BlackWidow

  • Rank: Private
  • *
  • Posts: 6
Tutorial: Creating a Custom Clan Logo
« Reply #7 on: August 17, 2007, 11:16:20 pm »
Ok, we got the logo to work on the server, but I can't get it to be transparent. I followed the tutorial to the best of my knowledge... Can someone look at this screen shot and see if they can tell from there what I did wrong?....lol



Thanks so much,
BW

Offline KillTheEnemy

  • Rank: Private
  • *
  • Posts: 31
Tutorial: Creating a Custom Clan Logo
« Reply #8 on: August 18, 2007, 12:39:02 pm »
When making the logo itself, you need to make sure the alpha channel is done up so that areas not part of the image are completely black. In the alpha channel, black is transparent, white is opaque. Revisit steps 4-7

Offline BlackWidow

  • Rank: Private
  • *
  • Posts: 6
Tutorial: Creating a Custom Clan Logo
« Reply #9 on: August 18, 2007, 01:18:20 pm »
Quote from: "KillTheEnemy"
When making the logo itself, you need to make sure the alpha channel is done up so that areas not part of the image are completely black. In the alpha channel, black is transparent, white is opaque. Revisit steps 4-7



Yes I have the psd, to show that it is that way. I don't understand...lol.. Thank you for responding...

BW

Offline KillTheEnemy

  • Rank: Private
  • *
  • Posts: 31
Tutorial: Creating a Custom Clan Logo
« Reply #10 on: August 18, 2007, 08:44:07 pm »
Then can you post up the IWI file so I can have a quick look?

Offline Joker{eXtreme}

  • Rank: Private
  • *
  • Posts: 6108
    • http://www.mycallofduty.com
Tutorial: Creating a Custom Clan Logo
« Reply #11 on: August 18, 2007, 08:46:40 pm »
Blackwidow, blackwidow, blackwidow.....................what clan do I know that name from ;)

Offline BlackWidow

  • Rank: Private
  • *
  • Posts: 6
Tutorial: Creating a Custom Clan Logo
« Reply #12 on: August 19, 2007, 02:09:34 pm »
Quote from: "{PST}*Joker"
Blackwidow, blackwidow, blackwidow.....................what clan do I know that name from ;)


I'm Toxic_Geek's wife...lol..... His server is Geeks W/ Guns...lol.. :P

Offline 2Dark4U

  • Rank: Private
  • *
  • Posts: 35
    • http://www.cba.clanservers.com
Tutorial: Creating a Custom Clan Logo
« Reply #13 on: August 29, 2007, 11:39:20 am »
i have tryed this a few ways now , but i still keep runin into the
same error

Too many unique materials (1024 or more)

and then the server quits

Offline ThePlague

  • Rank: Private
  • *
  • Posts: 69
Tutorial: Creating a Custom Clan Logo
« Reply #14 on: September 23, 2007, 07:09:38 am »
Also, you will need the 2 converters to convert back and forth from IWI to DDS, DDS to IWI.

Erm Ive searched like mad and cant find these apps...
Anyone know where I can get them from?

Thanks!