LoneWanderer

Porting free models from the Internet into KOTOR/TSL

Recommended Posts

I’ve noticed that some free models from the Internet have licenses that allow to use them in mods, in few cases even to modify the models and re-release them.

No experience with 3d tools, but I want to try porting something relatively simple into TSL, probably, weapons (swords, blasters), since they don’t have animations. I have a few questions:

1. Choosing the suitable model. There are many models of similar items from various authors. The archives have a different number of files with different extensions. One archive with blaster has 2 .odf, 2 .msh, 1 .tga files, other one has 1 .stl, 3 .obj files. Which file types are more suitable for porting? What files should be present in archive with, for example, sword model?

Perhaps fan-models from certain games (JKA, Battlefront 2 (2005), etc.) are more preferable than random models from the Internet?

How many polygons should have a weapon model? Are there any other limitations that I should know about?

 

2. What tools do I need to open the 3d model and port it into TSL?

 

3. The process of porting weapon model. Do you know any instructions or tutorials? What needs to be adjusted after converting a weapon model?

Share this post


Link to post
Share on other sites

Static objects like weapons should be pretty straightforward even if you have little/no experience. Animated objects (like bodies - armour/robes/clothes) are possible but require a fairly reasonable degree of experience to convert.

You have two main options for software. The first is 3DS Max (which you can get via an educational license if you are a school/university student) or the cut down crippleware (and thus free) version of it, GMax. Alternatively there is Blender. Both have import/export scripts for KOTOR models, KOTORMax in the case of the former and KOTORBlender in the case of the latter.

How you get the source model into your program of choice depends on what format it is in. As mentioned, GMax is crippleware, so it's the most limited. You can get an OBJ import script for it, so that route is feasible. For Max and Blender, there are various native and 3rd party import scripts around for different game model formats. In regards to some of those you mentioned, STL is a 3D printing format and should never be used for game meshes. TGA is a texture format, not a model. I have no idea what an ODF is (unless it's the open source Word DOC equivalent - maybe it's a readme). MSH is pretty generic and could literally be any of a number of different game-specific formats. OBJ is a static model format that is widely used and typically natively supported by almost any 3D program. Although not mentioned, FBX is another format you'll see commonly which both Max and Blender will accept (but not GMax).

If you are sourcing models intended for direct use in another game then you'll almost certainly need to deal with whatever native format they are in. Possibly conversion via a separate tool may be necessary (as with some Source engine games, for example) or you may need to find a specific 3rd party import script that will handle that format. Blender typically has more support for that sort of thing. You can try searching the Xentax and ZenHax (a Xentax splinter group) forums for those. There is also Noesis, a free program that supports a lot of different game formats natively, and which has additional format support via scripts from Xentax/ZenHax. Noesis will allow you to export models in a wide variety of common formats like OBJ or FBX, so it can be handy for conversions.

Regarding mesh density/poly count, if it is already a game mesh then it's unlikely to be a problem. Even models intended for current AAA first person shooters wouldn't really be an issue in pure poly count terms, although it would be a complete waste in KOTOR. The main issue with poly count is shadow casting. The engine will crash if a shadow casting mesh is over about 3-3.5K triangles. But that has an easy solution, you just make a dummy shadowcasting mesh that is low poly and don't enable its render flag.

As far as other limitations go, a big one is that Odyssey (KOTOR's engine) doesn't support emissive textures. It does, however, support emissive meshes, which it calls self-illumination. This means if you have any glowy bits on your model, they'll need to be split out to their own separate mesh so that the self-illum flag can be enabled on them. Alternatively, it may be easier to create new overlay meshes to sit on top of the original, especially if they are simple shapes like buttons and so forth. Beyond that I can't think of anything too significant.

  • Thanks 1

Share this post


Link to post
Share on other sites

I'll add a few notes to DP's already fairly comprehensive answer.

6 hours ago, LoneWanderer said:

What files should be present in archive with, for example, sword model?

Apart from the 3d model itself, you're going to need a texture, but just one. Modern game assets use a variety of texture images, all serving a different purpose: diffuse, ambient occlusion, normal maps, roughness map, metalness map, etc. For good ol' KoTOR, you'll only be interested in the diffuse map (also often called "albedo" or "base color"). KoTOR does support normal maps/bump maps, but honestly I've never been able to see the difference in-game, so don't bother with those.

6 hours ago, LoneWanderer said:

Perhaps fan-models from certain games (JKA, Battlefront 2 (2005), etc.) are more preferable than random models from the Internet?

While there's a lot of cool stuff that has been done in their respective modding communities, remember to ask for permission to the mods' original authors before starting to port stuff. Otherwise, you won't be allowed to post your port mod here, nor to ask for assistance in the process should you need it. In my experience, provided the authors haven't gone AWOL, they'll generally agree to it as long you as you give them proper credit for the assets.

6 hours ago, LoneWanderer said:

2. What tools do I need to open the 3d model and port it into TSL?

Just want to add that, once you've done all the prep work in your 3D software, you'll want to use MDLEdit to convert the .ascii files (created by KOTORMax/KOTORBlender) into KoTOR's preferred file format (.mdl/.mdx).

6 hours ago, LoneWanderer said:

3. The process of porting weapon model. Do you know any instructions or tutorials? What needs to be adjusted after converting a weapon model?

Yep! I remembered a couple of old tutorials on Youtube showing how to import new weapons in Kotor. They both use NWMax and MDLOps, so remember to use KOTORMax/KOTORBlender and MDLEdit instead.

Custom Models in Star Wars: KOTOR 1 & 2

KotOR1 Modding Tut Part 1 Part 2 Part 3

These should help you kickstart your project.

  • Thanks 1

Share this post


Link to post
Share on other sites
7 hours ago, Stormie97 said:

you're going to need a texture, but just one

In regards to both type and number, I'll point out that Odyssey has a single material assignment per-mesh. It doesn't support multi-materials, except for walkmeshes. In practice what this means is that a model made up of many individual meshes could have multiple different diffuse textures, as long as they are each assigned to a different mesh. This is extremely common practice for body models in Jedi Outcast/Academy, for example. Although when it comes to bodies in KOTOR, typically you want a single texture because of how texture variants work (but that's a whole other thing).

One major difference between Odyssey and other engines of similar vintage is that is does not use specular maps. Spec maps are used to fake surface highlights from lights, to provide a suggestion of reflectivity. Instead, Odyssey relies solely on cube maps, which it refers to as environment maps, blended over the top of the diffuse. It controls this via the alpha channel of the diffuse, which acts as a mask. The darker the alpha, the more of the envmap that shows through. The classic example of this in action is the silver/metal Sith Trooper. If you want a metal look for a weapon, which is likely, then you're going to have to get to grips with creating an envmap mask. If the model comes with a spec map it's possible you may be able to use that as a basis (probably by inverting it).

Share this post


Link to post
Share on other sites

 DarthParametric, Stormie97 Thank you for your input! Now I have an idea where to start.

9 hours ago, DarthParametric said:

One major difference between Odyssey and other engines of similar vintage is that is does not use specular maps. Spec maps are used to fake surface highlights from lights, to provide a suggestion of reflectivity. Instead, Odyssey relies solely on cube maps, which it refers to as environment maps, blended over the top of the diffuse.

So, shining and light areas on metal won't appear on models like this one (just an example of blaster with metal texture, not something I plan to port, at least at the moment) unless I apply environment map?

Share this post


Link to post
Share on other sites

So, I managed to port this sword model into TSL with GMax. The texture of blade seems to be more flat and looks worse than on the site. Guess, this is because I applied only diffuse texture to the model in GMax, when archive had diffuse, metallic, Normal_DirectX, roughness map textures. Sadly, no specular map.

Spoiler

90025297_Portedsword.jpg.ef6dc7b8ec44e1c49fe39c93114abae3.jpg

@Stormie97 said that game's engine supports normal maps, how to apply this Normal_DirectX map to the model?

Also, is there any way to get anything useful from metallic and roughness maps? Enhancing diffuse texture with them or, perhaps, using metallic map instead of specular to produce an envmap mask?

 

On 8/13/2021 at 9:26 AM, DarthParametric said:

Spec maps are used to fake surface highlights from lights, to provide a suggestion of reflectivity. Instead, Odyssey relies solely on cube maps, which it refers to as environment maps, blended over the top of the diffuse. It controls this via the alpha channel of the diffuse, which acts as a mask. The darker the alpha, the more of the envmap that shows through. The classic example of this in action is the silver/metal Sith Trooper. If you want a metal look for a weapon, which is likely, then you're going to have to get to grips with creating an envmap mask. If the model comes with a spec map it's possible you may be able to use that as a basis (probably by inverting it).

Do I even need environment map texture file? I'll write the process as I understood it. Correct me if I wrong.

1.Obtain specular map texture. Invert it.

2.In graphics editor convert specular map texture to alpha mask by adding alpha channels to pixels based on their color/brightness.

3.Add alpha mask from previous step as new layer to diffuse texture. Merge them.

In result I'll get 1 new diffuse texture, which I'll apply to the model.

 

One more thing about textures, when I applied the diffuse texture to the model, in the Odyssey Trimesh Params the value "#5" appeared in the field Ambient (in Material Editor only Diffuse is set), but standard game's models had "None" in the field.

Spoiler

1157056762_swordingmax.thumb.jpg.a03d6cd9216a897a911b39b4448c7a8f.jpg

Regarding 'ignore_basepointer' object (triangle in the upper-left window and the line in the lower-left window): how far from the geometry of the sword (parallelepiped) should it come out?

Share this post


Link to post
Share on other sites
7 hours ago, LoneWanderer said:

when archive had diffuse, metallic, Normal_DirectX, roughness map textures. Sadly, no specular map.

You're using a model with PBR textures, metal-rough in this particular case (the other major type is spec-gloss). Odyssey pre-dates PBR usage by a decade or more. PBR attempts to approximate real world lighting and thus has no lighting data baked into the textures. Ye olde engines like Odyssey use Blinn-Phong, which is all faked and thus relies heavily on baking highlights and shadows into the diffuse map.

It's not really practical to convert existing textures from one to the other. It's something that needs to be done at the authoring stage. Those texture outputs are from Substance Painter. I doubt they supplied the source files, but if they did it would be possible to edit it and export it with baked lighting.

7 hours ago, LoneWanderer said:

@Stormie97 said that game's engine supports normal maps

It does, but not like a modern engine. It's implementation is extremely anaemic and you're not going to see any real benefit from it, especially on something like a sword. That said, enabling it is done via TXI semantics, and it is tied heavily to envmap use (the envmap mask acting as a mask for the normal map as well).

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.