You are here

Merricksdad's Gmax Tutorials: Create a Weapon Model from a 2d Texture

Google Image Result: Fantasy Weapon Concept Art
Google Image Result: Glacial Ice
GMax Create AuroraBase

In this tutorial, I'll walk you (at a brisk pace) through the methods I use to create my weapon models.

This series features five videos which range in length from 6 minutes, to just over 11 minutes. Each video is both linked and embedded in this script. If you would like to view the videos as a playlist, visit https://www.youtube.com/playlist?list=PL5ocXJqMTYcOlJ2QJH1AIMG1HqtRa22oF

Before You Get Started

You might want to check out what kind of weapons I have been making. You can view the related forum at http://forum.bioware.com/topic/500798-merricksdads-weapon-a-day/, or check out the upload package here on the new vault at http://neverwintervault.org/project/nwn1/model/merricksdads-weapon-clones, where I have a bunch of images of the project's contents.

These items are all one-part in that they include only one part of the three weapon sections (top, mid, bottom). The other two parts are blanked out with a "null" model (actually a model file with a dummy attached to the base node). Because of that mode of creation, these items are not made to be interchangeable with other weapon parts in the same baseitem type. They might not even be able to use the same weapon visual effects. These are quicky items, and when I do these for my own personal use, I usually build the weapon VFX right onto the weapon, which is made for a specific creature or NPC. You can still use this method to make part-wise weapons.

What Tools You Need

GMAX

NWMax

A Paintshop-style art program (I am using PSP 7.02)

A text editor (I am using Notepad++)

You may want NWNExplorer

Part 1: Texture and Wireframe (http://youtu.be/gG-juaobs2U)

In part one, I quickly show you where I get some texures. To get you started, go to google and simply search for "glacial ice". Not far down the page, you will see this image which I sample for the ice color in this tutorial.

When you find a texture like this, you can just screen capture it, or right click to copy the image, then go to your paint program and just paste it. The next thing you need is some kind of concept art, or a screenshot from an item you want to clone. If you do a search for "fantasy weapon concept art", you may see this image not far down the list.

Once again, when you find an item you want to create, just screen shot it, or copy the image from the context menu of the image, then paste it into your paint program.

Creating A Texture

So the next thing you need to do is create an actual texture for your item. NWN works with textures which are in dimensions of binary numbers (ie. 16, 32, 64, 128, 256, 512, 1024, etc.).  In the video tutorial, I have selected one of the items from the  image above and made it conform to an image size of 64x256. I can easily import that directly into GMAX's material manager and create shapes in other binary numbers and have that texture fit them without stretching. This works very nicely for making weapon models quickly.

The next thing I do in the video is select a portion of the spear tip and make it icy looking. To do that I did these processes:

  1. In the texture image, select a section of the texture to use as the icy color, and then copy it to the clipboard
  2. In the concept art image, manually select the portion of the tip I want to be icy
  3. In the layers control, I added another blank-transparent layer
  4. In the NEW layer, with the concept art section selected, have the program "paste into selection"
  5. In the layers control, add another blank-transparent layer
  6. With the concept art region still selected, switch to the base layer containing the concept art and copy the selection to the clipboard
  7. In the topmost and newest blank layer, again do a "paste into selection"
  8. In the layers control, set the mix mode of that layer to "soft light". This will cause the shape of the weapon head to mix well with the underlying texture.
  9. Clone that layer and set the mix mode of the new layer to "overlay". That will further colorize the selected area with more weapon and less texture.

Feel free to play with this section to get the desired result. I am going to make the spear head transparent in the later videos, so I needed a texture color that is bright and not too sharp. If you like, increase the brightness and contrast on your concept art so you can get more weapon edges to show on the ice after it is done. I did not.

So, now you need to save your desired texture into your override folder. On my machine, the neverwinter override folder is located at "c:\neverwinternights\nwn\override\". You should have your texture already in your override folder so when you export your model, the model and the texture will be in the same location, and useable for testing. If you already know what you are doing with your model and texture, you can certainly do it a different way than I am showing here.

Create A Base

After your texture is ready, it is time to get into GMAX and start making the mesh. Open GMAX with NWMax running. You'll need NWMax or a similar script set for exporting NWN models. We won't be using any other tools aside from what comes with GMAX other than that exporter.

In the tutorial, you will notice I already have a base set up with a proper name. If you are wondering what name your base should have, refer to your extracted or custom baseitems.2da file. Weapon files start with the text found in the ItemClass column in baseitems.2da. A full item filename follows this format:

<ItemClass>_<partLocation>_<2 digit part ID><1 digit color ID>

In the previous formula, partLocation is a letter t, m, or b, and refers to the top, mid, or bottom section of a 3-part model. The 2-digit part ID combined with the 1-digit color ID create a number which is in a range, generally set to 10-100 in the baseitems.2da line referenced by your item type. Those are, respectively, MinRange and MaxRange columns in that file. I usually set my MaxRange column higher, to 250, and have seen other world creators user higher numbers. I personally don't even know if numbers higher than 255 will work. In any case, the 2-digit part ID appears in the toolset as the part dropdown, and the 1-digit color ID appears in the color dropdown. When I make items for the related package, I generally start at item part 9 (or 09), and color 1. So, since I am making a spear, my base name is wplss_t_091, which stands for weapon-polearm-shortspear-top part-appearance 9-color 1.

To create a base from scratch, you can find AuroraBase listed in the "helpers" tab of the "create" panel (defaults to the right side of the gmax view window. Click the button to prepare a base, then click in the viewport to place it. A dialog should appear asking you a few simple questions about placement. Set the base to 0,0,0 by default (using the checkbox). Select model type "character" and specify a name for the base, as discussed above.

You can also see in the GMAX scene that I have preloaded a spear tip which is currently sitting a the position it would be if the entire 3-part item was loaded. This gives me an idea of where I should position my weapon. In general, point [0,0,0] in relation to the aurorabase is linked to the right hand node. Two-handed weapons are slightly more complex, but not by much. Also, there is a small fraction of space that any item needs to be shifted left, or larger-handled items may protrude through the front of the knuckles. In many cases, I simply leave the center at [0,0,0], especially on weapons made for custom model NPCs where I fixed the offset.

The first thing you need to do in GMAX once you get your base created is to create a plane. In the video, you can see I create a long rectangle approximately the shape I want. I then manually enter the size numbers of 256x64. This is 2x the scale of the texture I made earlier, which allows me to very easily fit the texture to the plane. Feel free to set the center to [0,0,0] if you desire, but as long as it is placed the way you want it, and it is attached to the base, it will render properly (unless you animate it or skin it). You should immediately link the plane to your base. You may or may not see me use the link tool from the main toolbar to attach it to the base.

This tutorial item does not discuss rotation or scaling, and so does not discuss the serious need to reset that scale before exporting. Look for that in a later tutorial.

In the video, since I know the spear is not a complex shape, I leave the height and width sections on the plane as 4 each. In a more complex item, I generally set the sections to 20x10. We are going to be cutting edges and shifting vertices around a lot. In a more complex item, the closer you have a useful vertex to any given corner on your concept art, the easier it will be to shape your paper doll.

So, yeah, now it is time to make a paper doll. It is basically that simple. You are going to design folds from which to make raised sections, sharp sections, or generally 3d looking bits. In the case of this spear, there are not a lot of raised sections. In the video, I specifically target the edges of the blade, a few corners here and there, and I make a point to detail the cutout around sections of the handle I want to detail.

Your tools you need to know here are:

  1. Divide Edges (cut one edge in two, making new polygons, and give you new vertices to move around)
  2. Turn Edges (changes the shape of faces and positions edges in a way which you can better modify them)
  3. Move vertex (yup)
  4. Weld target vertex (drag one vertex and glue it to another)
  5. How to apply the modier "UVW Map" (this resets your texture placement after you move verts around. You'll use it a lot)

Ok, so let's dig in. In the video you can see my happily hacking away at the edges of the spear head, all the way down to the tip of the staff. Hack hack, chop chop. I also do a lot of edge turning so the cross-bars of any of my poly's are not too long. Your crossing edges should be perpendicular to the item as much as possible in this stage to help you align the texture and the mesh. Here are some tips:

  1. Target points of detail with at least one extra vertex per side of the object. I've done that with the spear staff in the video.
  2. Judge how many verts you need for any curves. A good rule of thumb is one vert per 30 degrees of curve. Feel free to do more, NWN can handle more verts/faces than most people give it credit. (shadows are another thing)
  3. When making blade sections, determine ahead of time if your blade is triangular to the center, or if the center has a flat section. Add extra verts to make a flat plateau in the middle for that flat section later. If you have a blood groove in your blade, do another line in the middle of the plateau.
  4. Think about your 3d aspect. Do you want your handle to be a square dowel (having just one line down the middle in this stage), or a hexagonal cylinder (having two lines down the middle equidistant from the sides).
  5. Think about your texture. Any surface that we raise later that leaves a flat side perpendicular to the texture plane will appear smudged. If you have enough texture to wrap the edge, fine, but if you don't, plan to NOT have any faces perpendicular to the texture plane. I'll show this in a later part when I shape the back of the spear head with a slope which prevents any perpendicular-to-the texture faces.

Ok, if you feel satisfied with your hack job, we'll move on to part 2.

Part 2: Cut and Shape (http://youtu.be/IhINp1OzURs)

In this part, we'll cut the paper doll out and give it some 3D substance. But first, make sure you have your verts and edges how you want them in the 3d object. You can see me do a few bits I didn't tidy up in part one's video.

Cutting Cutting Cutting

Since this is a paper doll, we need to cut it out to use it. There is a lot of extra paper around your concept art we need to dispose of. But first, I must tell you a secret: we are going to want to tidy up the texture again later, and so we need to keep the overall model size in a useful scale for our texture. To do that, I specifically leave two opposite corners of "paper" on the model, but not touching any other faces we will be using in the final product.

Now, select any face you don't plan to keep and delete them (delete key). OK or ignore the warnings about deleting unused vertices. You don't want floaters in your model, so flush them down good.

Next, you have two options to raise your flat into a 3d area:

  1. You can select just the verts you need to raise and raise them. Choose this method if you have NO outer edges that need to have a thicker mold.
  2. You can select the entire group of faces that makes up your model and extrude the whole thing. You then work backward by snapping verts around blades and handles back to the base plane. This is more time consuming but prevents a lot of logical errors later. You can also pick and choose to move a few verts into extra curves if you need more volume.

In video 2, I extrude the entire item. I then use "Target Weld" to snap unwanted verts back to the base plane. Using this method, I shape the edge of the blade, and also create a square dowel for the majority of the staff. I also adjust a few edges I aparently had facing the wrong direction earlier near the back of the spear head. Since I have a few extra verts up there, I also take a few and make a 3d curved surface instead of having any polys perpendicular to the texture plane. This makes the item look nicer, and prevents perpendicular texture smearing.
 

Later in this section, I take time to detail a few sections of the handle out. What I am doing is extruding the sections I want to have a cliff and then I take the unwanted section and bind them back to the staff. This ends up making a few extra faces I don't want, so I delete them. If I didn't delete them now, when I double this half of the item and bind it back to the first half, those faces would be inside the object. Having twined faces (multiple faces comprised of the same verts, with different or same face-normal modes), or faces inside an element is a surefire way to have shadow artifacts in-game. Near the end, I grid-align some of the verts that were displaced off the base plane when I extruded them. This helps me weld them to the cloned other side in the next video.

There really wasn't much work in this section, but if you feel like you want to add more model detail, this is where you would do it. After we clone this half to make the opposite half, it will be twice as much work to make a change later.

Part 3: Clone and Detail (http://youtu.be/7a0lPMiBf1A)

It is now time to clone your item and make the other side. Before we do that, make sure to apply your texture using "UVW Map" one more time. After that, delete your bounding faces we no longer need.

Also before you do your cloning, you want to make sure your texture is not bleeding paper at the edges. To do that, apply an "Unwrap UVW" modifier and edit that modifier. As in video 3, adjust your texture verts so that all the edges are within the darker portion of your texture. This will help properly color your weapon. Don't worry if your texture gets slightly stretchy. You should have plenty of faces you can adjust if you have a portion you think is odd looking. Your texture should also be large enough that in-game it gets smoothed to reduce the weirdness.

Getting right down to it now, all we need to do now is this process combination:

  1. select your half
  2. clone it
  3. apply a "mirror" modifier to the clone, and flip it in the z direction (over the x-y plane)
  4. collapse the modifier stack
  5. select your first half again
  6. do an "attach" method and select your second half
  7. select all verts of the combined object
  8. weld all verts within the range of 0.01 (or 0.1 if your verts are not close)

There, you have a 3d object now. It should be completely enclosed and cast a perfect shadow without artifacts. The engine can handle a surprisingly large quantities of polygons when a model is made properly this way.

In the video, I want a separate visual appearance for the icy spearhead. I select the colored head section and detach it from the main object. I then apply a "cap holes" modifier to each separate object to reduce look-through model sections.

One more thing you might want to do is smooth your model. Up unti now, your original faces would all share the same smoothing group, and all your extruded faces may have zero smoothing at all. In the video, I select each model and smooth them separately. I generally use a smoothing angle of 90, but if I have a lot of jagged bits, I might go for 60 or even 30, to give them each character in-game. If you have some sharp angles you want to have appear as rounded, use 120. Note that in-game, my icy spear head is going to have a secondary smoothing placed on it by the mechanics that govern the use of opacity. That includes the automatic application of environment maps.

In video 3, I take time to make the spear head crystalline. I find that you have a few options to make stuff look glassy:

  1. Use TXI files to modify your texture
  2. Make transparent textures and use TXI to negate the metallic environment map
  3. Use the opacity modifier on the AuroraTrimesh modifier

I've studied real crystals for years and finally came to the conclusion that to make a good 3d model of a crystal you need a few things:

  1. Partial transparency
  2. An outside face
  3. The ability to see the face on the opposite side of the crystal through the front face
  4. Maybe some inner-crystal artifacts

What I do in the video is this:

  1. Give the outside crystal faces an AuroraTrimesh modifier
  2. Set the opacity to 0.5
  3. I also like my crystals to have an inner glow, so I set the self illumination to a color similar to the crystal. In this case I use cyan for a light cyan crystal. Don't make yours too bright unless that is what you have planned it to look like. It will glow in interior settings, even in full darkness.
  4. Now clone the outside crystal faces
  5. Apply a "normal" modifier to the clone and tell it to "flip normals". This gives you the crystal backface appearance.
  6. On the clone's trimesh modifier, remove any self illumination because you won't see it in-game, but it uses processor time. Also make sure your opacity is same or similar to your outer face. Also remove the shadows from the inner crystal. There is no need to waste shadows in-game.

One thing to note is that NWMax modifies the opacity of the texture used in addition to the opacity number on the trimesh modifier. If you want your scene to be representative of what you will see in-game (minus the self illumination), clone the material and apply that new material to each section you need to have a different opacity.

Next we'll export the model.

Part 4: Export to Model (http://youtu.be/0NPJW4S2Sgs)

Before you actually export the model, there are a few considerations to make:

  1. Does your model base have the proper export directory set?
  2. Are your model parts in an order which optimizes its appearanace in game?

In video 4, the first thing I do is Order Children from the NWMax toolset. You can find this on the Mesh Tools panel. What I am doing is making sure that anything that is behind or inside a transparent object is drawn first. If you don't do this, the parts inside might not show properly. I name the inner crystal faces "inner", and the outer faces "outer". Place the inner faces on the top of the child stack, as you would with anything drawn inside another object. Place anything on the outside of your model last. In my case, I am drawing the staff section last.

Next, with the model base selected, make sure the export directory is set to your override directory, or another location you intend to run this stuff from.

Now, the next part is a bit weird. What I am doing is creating the invisible bottom and middle sections of the weapon. Since I make single-part weapons, and the toolset requires you to pick a bottom and middle part, in addition to my custom top part, you won't have anything that fits the weapon properly. So what I do is make blanks, or "null models" for the top and bottom parts.

  1. Select the model base and any one child object (in this case I select the staff section)
  2. Clone those items and move them up or away from your current exportable model.
  3. Rename the base as the mid part of the same weapon (in this case wplss_m_091)
  4. Use the NWMax tool called "To Dummy" from the General Utils panel to turn those extra staff bits into no-draw dummies

If you don't have anything attached to a base, then you don't have a valid model in NWN. The toolset will not recognize it as a part model. So you NEED at least a no-draw dummy node for it to be valid.

Once you have your blanks made, you can export all three parts to your override directory. Export them from the AuroraBase. I also suggest exporting them all individually. The older version of NWMax I am using has some bugs that make exporting multiple items faulty at times.

In video 4, I then open NWN Explorer to view my item as it should appear in game. Note that the explorer does not properly render transparency, self illumination, and if faces are too close, they can appear backwards. Never take the appearance the explorer gives you as being equal to the in-game product. Your items should appear under NWN Overrides > Models. Filenames in caps appear before filenames in lower case. I name mine in lower case so I can find them near the bottom. I am looking for a model named "wplss_t_091". It looks good in the explorer, so now let't put it in the toolset.

To get it in the toolset, you need these things to be true:

  1. You must have a model part (in this case we made top bottom and mid parts)
  2. You must have a matching item icon for each part you want to have appear in the toolset
  3. Your item must be named within the range set in the baseitems.2da file

In the video, the first thing I do is check baseitems.2da for the icon size. Under the shortspear entry, I can see that the icon size is 1x4, which means 32px by 128px, so my texture I use as the item icon needs to be exactly that size. Next I verify that the item title must begin with wplsp. Item icons are prefixed with the letter "i", so my item icon must be named "iwplss_t_091". My bottom and middle parts need to be named similarly.

I then open up my paint program and make three black images of that size. I then set their alpha channel to be equal to nothing. That makes the entire image transparent so the toolset will not draw anything. Make sure to save your images as TGA format.

Now open up the toolset, go to the weapon palette and clone the spear weapon. If you have done everything correctly, you can now select part 9 for the spear. Strangely enough, I have made a mistake and cannot see them in the toolset. What I did was misname my icon files as iwplsp instead of iwplss. Small difference, but the toolset cannot find the spear icons so it gives up trying to build that index.

Part 5: Icon and Test (http://youtu.be/8yW7NFN_c9A)

In part 5, I return immediately with my icon filename fixed. I start right back in the toolset where we left off and can easily see part 9 models in the toolset. Again, beware that what you see in the toolset is not 100% representative of what the item will look like in-game, but it is much much closer than the rendering in NWN Explorer.

Since the apperance is much better in the toolset, I tend to use this appearance to make my actual item icon from. To do this, just Print Screen to get the image to your clipboard. Now go back to your paint program and paste it as a new image.

Now, you need to get your weapon image to fit the constraints of the icon size, which we determined was 32 x 128, so cut out your weapon icon you want and resize and either crop it, or paste it to another new image.

Next, you want to determine which axis of your image is most out of scale with the intended icon. My cut out is too tall and not wide enough, so I know my length is most out of proportion. I then resize the image so that my length becomes 128, but my width is less than 32. I have it set so it keeps the aspect ratio because I don't want my image getting distorted. Now, to get the image to be 32 wide, I increase the canvas size to 32x128 and fill in the edges to match my black flood-filled background.

You want the black to not show in-game, so you next need to select all the black, then invert the selection. This leaves you with the item selected. If you have an item icon with holes or airspace, unselect those holes now. The spear does not have any open parts. Now, in my selection tool dropdown, I set the alpha channel to my selection. This makes all the black transparent in-game. Note here that my paint program is a little picky and in the toolset my icon is NOT transparent. This is because I forgot to collapse my layers and have confused the image exporter code.

Bear with the last part of this video as I open Neverwinter Nights. Running the video capture at the same time seems to make it very slow to load.

You may have noticed, the first time I was in the toolset, I named the item Glacial Spike and then placed a copy inside my little ice floe placeable. Once in-game, I go grab that item from the ice floe to test it out. It looks good enough, but I might go back and change the hand-placement. I wanted it to be extra long, but now it kinda looks off-center. I may slide my model up the Y axis in GMAX to compensate.

OK, so the first zone I show the item in is brightly lit, near actual sunlight colors. I don't see any shadow artifacts, and the color is good enough for a first run.

Next I check my dungeon-lit area. For some reason exterior settings do not properly light items with Self Illumination values set. So even if the outdoor area is pitch black, it won't light up. However, in interior settings, the item will be lit no matter how dark or light. As soon as I go into the castle, you can clearly see the item is more colorful. Even in the shadow of a pillar, you can clearly see the frozen speartip. As I spin around and try to make you sick, you can see the tip is transparent, but because I have two 50% opacity faces back-to-back, you can't see much through it.

If you have a bright light set up like I do, you can check for a few more things. First, move around and see if you can get any shadow artifacts on the ground. Any face which is twinned, or any face inside the other object but sharing vertices, will cast a long stretching shadow. That shadow, if it passes through proper shadows, will negate the normal shadow. Let's call it anti-shadow. You don't want anti-shadow. Anti-shadow does not follow the rules of game physics and can trail off to point 0,0 in your area. It will cut through and override many drawn models. Basically, it is bad.

At the end of the video, I show you that even a transparent model does not allow you to see particle effects, such as the light behind me, through the glassy portion of the item. There are ways of getting around that, but I don't show that here.

Well, that concludes this video-based tutorial. You can now easily create simple weapon models from any 2d texture. I suggest you do this about 100 times and then you'll be a master already. This method can be applied to other more difficult model varieties, such as tilesets.

Look for future videos where I show you the following:

  1. Create multiple items from a single texture containing multiple weapons
  2. Use TXI to make animated textures on your weapons
  3. Use TXI to make your transparent weapon parts mix with background emitter particles
  4. Apply emitter particles directly to your weapon model

I'd like to thank:

  • JOCO and others (who I don't know) for work on the NWMax script toolset. While I don't use the upgrades offered by MDA, let's thank him too, for making improvements available
  • Rolo for suggestions, and most importantly hosting, care, and keeping!
  • TAD for getting me back into NWN more deeply with the CCC
  • OTR for suggestions and all his poking and proding of the NWN framework over the years (He's why I came back to NWN)
  • Anybody who has made suggestions or requests. These little things help keep NWN alive
  • The rest of the community, of course!
First Release: 
  • up
    50%
  • down
    50%
Rolo Kipp

This is totally awesome! Fantastic tutorial MD =)

  • up
    50%
  • down
    50%
CaveGnome

This is a great tutorial ! Thanks.

  • up
    50%
  • down
    50%
Black Rider

Thanks you for writing out all this! With this tutorial, I learned quiet a few more tweaks on how to handle things in Gmax!

Would it be possible to upload those videos here, too or link to a downloadlocation?

  • up
    50%
  • down
    50%
merricksdad

If I had more room, I would offer them here or on my dropbox. As it is, all I can suggest at the moment is a greasemonkey script for downloading youtube videos:

http://userscripts.org/scripts/show/25105

He also offers a link to an extension instead. Either one works really well

  • up
    50%
  • down
    50%
Black Rider

OK. Thanks! Will do it that way then.

  • up
    50%
  • down
    50%