seedhartha

TOOL:KotorBlender (for Blender 2.93)

Recommended Posts

I got pretty excited when I read it, but I'm probably missing something to get the whole picture. There's two issues at work here, right? One is smoothing groups, which get screwed once you convert the binary. The other is rerigging, because Obsidian.

So at least working with the model in KotorBlender for the same game would be safe shading-wise, because of the binary importer/exporter, but then one of the issues listed as of yet is the lack of smoothing groups support.

Now, since you need to rerig the model to port it right, you'd still need to compile it with MDLEdit or MDLOps, because of the differing supermodels, which affect animations. So what is the "export for TSL" checkbox for exactly?

And of course, as for head models, you modding wizards work your magic by making manual adjustments with the model editor.

Share this post


Link to post
Share on other sites
Quote

So what is the "export for TSL" checkbox for exactly?

Number of things, including swapping some function pointers and appending additional data to mesh headers. This has everything to do with model format and almost nothing to do with its contents. i.e. you cannot target K1 supermodels from K2 models without some modification of the bone structure. This is by design, and I have no intention to automate these modifications at the moment.

Quote

So at least working with the model in KotorBlender for the same game would be safe shading-wise, because of the binary importer/exporter, but then one of the issues listed as of yet is the lack of smoothing groups support.

Smoothing groups is a 3ds Max concept to influence vertex normal calculation. MDL knows nothing of smoothing groups and so does Odyssey engine. What I meant by lack of smoothing groups is that in version 3.0 of KotorBlender, original normals are not preserved, and shading might get screwed. However, I have since implemented import & export of original normals and will soon release an update.

  • Thanks 1

Share this post


Link to post
Share on other sites
26 minutes ago, La Ingobernable said:

I got pretty excited when I read it, but I'm probably missing something to get the whole picture.

The only significant workflow change is that you'll be able to drop MDLEdit and the ASCII to/from conversion. Everything else will remain the same.

Once the importing of vanilla normals is implemented, that will solve some shading problems that can happen currently due to the smoothing group approach. But it won't fundamentally change anything about how handling models works.

  • Thanks 1

Share this post


Link to post
Share on other sites

So then that's great, since you'll no longer need to compromise or sacrifice shading when tweaking models. But how would you replace supermodels without MDLEdit?

Share this post


Link to post
Share on other sites
14 hours ago, Hunters Run said:

Is there a way to auto smooth models in game?

I've just realized that I don't fully understand how normals work in Blender under the hood, and that results on export are most likely incorrect. Will have to investigate this some more.

UPDATE: False alarm. Current approach works, although exported normals a tiny bit different from original values, most likely due to precision error. To answer your question, in order to export an "auto smoothed" model, you tick Export Custom Normals checkbox on export and ensure that Custom Split Normals Data is set under Object Data Properties -> Geometry. When "Import Normals" checkbox is ticked on import, Custom Split Normals Data and Auto Smooth are set automatically.

  • Thanks 1

Share this post


Link to post
Share on other sites

My problem may arise from the fact that I am using a completely custom model.  To illustrate the problem:

No  Custom Split Normals and  Export Custom Normals is unchecked:

 

KotOR0000.thumb.png.a5ee4cca413a501af0184cc2b05daabf.png

 

Custom Split Normals and  Export Custom Normals is checked:

 

KotOR0000a.thumb.png.1f92e2eba78c84da581ee22c45f573e0.png

 

same model in blender with Custom Split Normals:

 

 

 

1.thumb.png.9cc1936347bed8b2e12b7c2bfc5124fc.png

 

 

Same model with sharp edges shown:

 

 

2.thumb.png.cfb43c6abee5150855e9c7e12c401a00.png

 

 

Share this post


Link to post
Share on other sites

Don't see the diff in the first two pictures.

This is what I think is going on: Sharp Edges and Auto Smooth are a display-only thing in Blender. These affect how split normals (vertex normal per polygon) are calculated, but do not result in new geometry.

Because split normals are not supported by MDL, what current approach does is it calculates vertex normal as an average of its split normals, effectively cancelling them out, unless all split normals are pointing in a single (imported) direction.

What you need to do instead, with custom meshes, is to add Edge Split modifier to your mesh and apply that prior to export (KB doesn't automatically apply modifiers on export, regression on my part). Edge Split generates new geometry based on sharp edges and angles between edges, which is exactly what we need.

With Edge Split you no longer need Auto Smooth, Custom Split Normals or Export Custom Normals.

P.S. Since you're also using quads, make sure to download KB 3.1.1 (or later) - it fixes export of quads UV.

Share this post


Link to post
Share on other sites

Published version 3.2.0. Thank you guys for asking and making me look at things more thoroughly.

I've fixed some custom meshes related issues, particularly modifiers not being applied on export. More importantly, I've added an option to merge duplicate vertices and mark sharp edges, which is a similar feature to smoothing groups in Max. This is important because KotOR models have a LOT of duplicate vertices, which is exactly how smoothing groups work - they create additional geometry where surface needs not to be smooth. Same result can be achieved with sharp edges and Edge Split modifier in Blender.

Some example screenshots:

New Import Options

import-options.jpeg

Normals Algorithm = None (normals are ignored)

t3m3-none.jpeg

Notice sharp edges on the head, despite normals not being imported. That is because of duplicate vertices.

Normals Algorithm = Custom (MDL normals are used as is)

t3m3-custom.jpeg

Notice how smooth edges on the left arm are. There are duplicate vertices there, but custom normals make them look smooth.

 Normals Algorithm = Sharp Edges, Sharp Edge Angle = 10 degrees (duplicate vertices are merged and sharp edges are marked)

t3m3-sharp-edges-10-degrees.jpeg

Notice how edges on the head are still sharp, despite duplicate vertices being merged. That is the result of these edges being marked as sharp. Unfortunately, edges on the left arm were not marked as sharp, because we could not merge duplicate vertices there - they have different UV coordinates. This happens on more than one model - maybe I'd need to improve the algorithm in the future.

t3m3-sharp-edges-edit-mode.jpeg

  • Thanks 2

Share this post


Link to post
Share on other sites

Reworked armature support in version 3.2.1. Tried exporting armature keyframes directly, but this solution ended up being too complex and slow. So this is how editing animations currently works (and is very likely to stay that way, since I'm satisfied with the result):

  • Import model with "Import Animations" ticked
  • Select animation under Object Properties -> Odyssey Animations and press Play button to focus on it
  • Position bone objects, insert/remove keyframes, etc.
  • Set current frame to frame 0 or exactly 5 frames left from any animation. That is the Rest Pose
  • Press Rebuild Armature. This step is entirely optional, but useful if you want to test your animation with the skinmesh
  • Export model with "Export Animations" ticked

 

anim-2-edit-keyframes.jpg

 

anim-4-test-skinmesh.jpg

anim-5-end-result.jpg

  • Thanks 2

Share this post


Link to post
Share on other sites
13 hours ago, Hunters Run said:

Is there currently a way to only import animations without geometry? 

In 3.3.0 now you can. You can even add supermodel animations on top of head models and they will look ok.

I have also finally fixed precision issues with export of custom normals. Exported models now look exactly as they were imported, and MDLedit no longer raises a warning.

Overall, I did some testing and this version seems to be pretty robust. I'm tempted to say it's final for now.

  • Thanks 1

Share this post


Link to post
Share on other sites

I was experiencing a traceback error when trying to export an item model. After some research this is because the placeable classification  did not exist. Instead there are two door classifications.  I just want to check that this wasn't by design.

Share this post


Link to post
Share on other sites
2 hours ago, Hunters Run said:

I just want to check that this wasn't by design.

Was a bug, fixed it in the repo. Doesn't feel good spamming DS with all the minor versions, so I guess I'll wait until more bugfixes are accumulated.

Share this post


Link to post
Share on other sites

Released 3.4.0 with this and a couple of other fixes, but most importantly I have reworked the UI. It now fits Blender 2.8 style alot better.

Here are some screenshots:

kotorblender_3_4_screenshot3.jpeg

  • Like 2
  • Thanks 1
  • Light Side Points 1

Share this post


Link to post
Share on other sites

Yooooo, this looks amazing! My only questions thus far... how does it handle smoothgroups? I've always had edit it gmax to fix the smoothgroups and then import into Blender.

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.