Jump to content


Photo

Exporting models from Blender into TDM

blender lwo export

50 replies to this topic

#26 chedap

chedap

    Member

  • Member
  • PipPip
  • 102 posts

Posted 31 May 2018 - 05:16 PM

It's two models snapped together.



#27 RPGista

RPGista

    Advanced Member

  • Member
  • PipPipPip
  • 1595 posts

Posted 09 June 2018 - 12:41 PM

Hey chedap, I love the .ase exporter, it defaults to sensible options and gets the material right and outputs smaller files. I exported a new sword model I made, its not that small (around 4k) and it handled that beautifully. However, when I tried bringing in other models I was working on, I got this error while dmapping: "unknown token. 'MESH_FACE10000:' while parsing MESH_FACE_LIST". Obs pointed out it should be something with the exporter, and indeed, changing back to the previous one I was using, the models load in game without problems. Check out his post: http://forums.thedar...328#entry422955 .

If it makes a difference, the models I was importing were on the heavy side, each had several separate meshes and the tris count ranged from around 5k to 15k (they are groups of trees).

 

Hopefully this isnt difficult to fix? Thanks for this, its great work. 


Edited by RPGista, 09 June 2018 - 12:42 PM.

  • chedap likes this

#28 chedap

chedap

    Member

  • Member
  • PipPip
  • 102 posts

Posted 10 June 2018 - 06:24 AM

Yep, was a 10k+ tris formatting hiccup, should be fixed now.

Gotta say though, "heavy" trees would seem like prime candidates for lwo. Or are you using tricks like egg-shaped custom normals?


  • RPGista likes this

#29 Samson-

Samson-

    Newbie

  • Member
  • Pip
  • 5 posts

Posted 28 June 2018 - 03:28 PM

Hi guys - I'm getting my feet wet with modeling, and was hoping maybe someone could help with a couple of questions.

 

I was starting with some base models from D3 to experiment.  I was originally using one of the default blender .lwo export scripts, which did not seem to ever set smoothing on export, so unless i edited the materials to use the renderbump command, the models were faceted in game.  I switched to the script referenced earlier in this post, and smoothing is definitely now set in the exported .lwo ( Yeah! ), but now I'm having a different issue - I can't seem to set a hard edge.  Even if I select a portion of the model and split it off ( select faces then 'Y' to split ), the engine still smooths across that edge.  The only way I could find to stop the behaviour was to assign the same material with a different name to the split portion of the mesh.  Anyone experience this before?  Using Blender 2.77 fwiw.  Remove doubles is NOT set on the export script - just the smoothing option is set.

 

My second question is about baking normals ( which is turning out to be a pretty interesting rabbit hole ).  I was trying to model a simple cup - ( styrofoam coffee cup ).  I made high and low poly models, and baked the normal from the high to the low, and it generally seems to work.  The issue I'm having is the seam where the normal map wraps around the cup.  Where the halves of the map meet, the normals look obviously inverted on the model in game.  I tried splitting the model in half, unwrapping the UV's for half the model to the full texture space,  mirroring the half to complete the model, welding the halves together, moving the mirrored UVs off the 0-1 UV map, baking the normal map, then moving the mirrored UVs back.  This looks better, but the normals still seem to be wrong when looking at the model from different angles in game.  I feel like I'm missing something here, any ideas would be appreciated. Thanks!



#30 chedap

chedap

    Member

  • Member
  • PipPip
  • 102 posts

Posted 29 June 2018 - 12:05 AM

Even if I select a portion of the model and split it off ( select faces then 'Y' to split ), the engine still smooths across that edge.

That would happen if you forgot to remove renderbump command from your material definition.

The issue I'm having is the seam where the normal map wraps around the cup.  Where the halves of the map meet, the normals look obviously inverted on the model in game.  I tried splitting the model in half, unwrapping the UV's for half the model to the full texture space,  mirroring the half to complete the model, welding the halves together, moving the mirrored UVs off the 0-1 UV map, baking the normal map, then moving the mirrored UVs back.  This looks better, but the normals still seem to be wrong when looking at the model from different angles in game.

TDM uses DirectX normal maps (Y-). So if you had Blender bake Y+ ones you could see weirdness at the seams, while at a glance it would seem the map is doing its job.
Other than that, could be different things, hard to guess without pictures. Try on a simple sphere: does the issue persist?

#31 Samson-

Samson-

    Newbie

  • Member
  • Pip
  • 5 posts

Posted 29 June 2018 - 04:48 PM

That would happen if you forgot to remove renderbump command from your material definition.

 

You know, when I first read this comment, I thought to myself 'man, what kind of idiot does this guy think I am? I checked the material def a bunch of times!'.  Turns out you know exactly what kind of idiot I am - I was editing the wrong material def. :)  Fixed it  and problem resolved.

 

 

TDM uses DirectX normal maps (Y-). So if you had Blender bake Y+ ones you could see weirdness at the seams, while at a glance it would seem the map is doing its job.

So in blender is it as simple as switching +Y to -Y under bake/swizzle?  ( does D3 also use -Y?)

 

Thanks a ton for the help - saved me lots of frustration!



#32 chedap

chedap

    Member

  • Member
  • PipPip
  • 102 posts

Posted 01 July 2018 - 04:43 AM

Glad it helped, both were guesses on my part.

So in blender is it as simple as switching +Y to -Y under bake/swizzle?

Yes, but you don't even have to re-bake the whole thing, just inverting the green channel on an exported image gives the same result (e.g. in IrfanView "Image>Negative>Green channel").
And yes, Doom 3 also uses Y-.

Edited by chedap, 01 July 2018 - 04:45 AM.


#33 panel123

panel123

    Newbie

  • Member
  • Pip
  • 1 posts

Posted 08 July 2018 - 08:27 AM

I’m glad that you shared this useful info with us. thank you


Edited by panel123, 08 July 2018 - 08:28 AM.


#34 Samson-

Samson-

    Newbie

  • Member
  • Pip
  • 5 posts

Posted 14 July 2018 - 04:19 PM

Hey, another quick question - does anyone have a link to the current/appropriate .ase import/export script for blender/TDM/D3?  Did a quick search but maybe I missed it.

 

Thanks again!



#35 chedap

chedap

    Member

  • Member
  • PipPip
  • 102 posts

Posted 15 July 2018 - 09:02 AM

Look through the thread, I've modified an existing exporter.
Haven't had the time to dig into importers yet (there are at least 3 out there). Haven't properly tested them either, but I don't think either works with Blender 2.7+

Edited by chedap, 15 July 2018 - 09:02 AM.


#36 chedap

chedap

    Member

  • Member
  • PipPip
  • 102 posts

Posted 05 September 2018 - 10:10 AM

*
POPULAR

Alright, so I've checked out the four existing .ase importers, and they all could probably work with minimal tweaking, but they're all fairly basic. So this time I decided to write one from scratch.

Download Blender .ASE importer

Supports:
- Transformed meshes (position, rotation, scale)
- Multi-materials / sub-materials
- Smoothing groups (correctly converts to sharp edges)
- Split vertex-per-face normals
- Vertex colors
- UV coordinates, multiple UV channels
- Can turn tris to quads without disturbing split normals
- Can import multiple files at once, grouping meshes per-file
- Can look up textures if the path is the exact match
- Adds image nodes for Cycles (if it's the current renderer)

Limitations:
- Static triangulated meshes only
- Only imports diffuse and specular colors, not transparency, emission, etc.
- Slow when importing hundreds of files with "to quads" and "group objects" checked

- Doesn't use Blender's validate method on meshes, to avoid deleting two-sided surfaces

This is a beta release of sorts. It seems to run smoothly on TDM models and synthetic tests, as well as vanilla D3 & Q4, but I want to run some more tests still. Specifically, I might add quad support and change some material import logic if needed.
In the meantime I'd appreciate any reports of import failures. These would spit out some traceback info to Blender's info bar. I mean this thing (not "system console" or "Python console") -  which will also print some non-critical errors encountered while parsing the file. Let me know if you can't explain some of those too.


  • Bikerdude, Judith, Dragofer and 2 others like this

#37 Bikerdude

Bikerdude

    Mod hero

  • Member
  • PipPipPipPipPip
  • 20281 posts

Posted 05 September 2018 - 01:29 PM

Alright, so I've checked out the four existing .ase importers, and they all could probably work with minimal tweaking, but they're all fairly basic. So this time I decided to write one from scratch.

Can I ask if the .ASE export file size is as efficient as .LWO..?



#38 chedap

chedap

    Member

  • Member
  • PipPip
  • 102 posts

Posted 05 September 2018 - 02:52 PM

Nope, that's the main drawback. Generally, lwo is roughly 10 times smaller.



#39 RPGista

RPGista

    Advanced Member

  • Member
  • PipPipPip
  • 1595 posts

Posted 06 September 2018 - 09:14 AM

Alright, so I've checked out the four existing .ase importers, and they all could probably work with minimal tweaking, but they're all fairly basic. So this time I decided to write one from scratch.

 

TDM gets its very own ASE exporter? Thats absoutely amazing, man. Youve become our resident file formats expert in no time. I will be sure to check this guy out, as Ive been working with vertex blends and Ive been having difficulties making them work on the lwos Im exprting. Those new features and improvements sound incredible, specially al the attention to normals, which are the most troublesome part of game modelling for me. And the efficiency gains... Huge kudos.


Edited by RPGista, 06 September 2018 - 09:15 AM.


#40 RPGista

RPGista

    Advanced Member

  • Member
  • PipPipPip
  • 1595 posts

Posted 06 September 2018 - 09:30 AM

Actually I also have a question about your lwo exporter. Ive been using it flawlessly and getting consistent results. But I am getting problems with vertex alpha blends using lwos. The model with materials show up but there doesnt seem to be any blending occuring (each section only shows one material). Maybe Im making some simple mistake somewhere along the line, but looking for options inside blender I noticed this function at the botton of the material windows, and thought it would be a good idea to select the vertex map for each mesh before exporting but the button is simply non selectable. You cant change the "none" option. Is this a problem? Or am I missing something?

 

Attached File  01.jpg   30.67KB   0 downloads



#41 chedap

chedap

    Member

  • Member
  • PipPip
  • 102 posts

Posted 06 September 2018 - 11:32 AM

TDM gets its very own ASE exporter?

Exporter's on the previous page, this one's an importer.

Actually I also have a question about your lwo exporter. Ive been using it flawlessly and getting consistent results. But I am getting problems with vertex alpha blends using lwos.

I only changed a couple of lines in the lwo exporter, it isn't mine.

That said, you should be able to select any of your vertex color layers, like so. Make sure you have some data to export, I guess? I don't really know if the option works, I haven't tested it in lwo's personally (might test it later today)

 

Edit: imported blend_ground.ase from "A House of Locked Secrets", selected vertex color layer, exported it back out as .lwo, seems to be working as expected. Keep in mind that your blend won't show up in DR, only in-game.

Edit of edit: or not. what's up with the bricks showing through where they shouldn't? Will look into it.


Edited by chedap, 06 September 2018 - 12:02 PM.


#42 nbohr1more

nbohr1more

    Darkmod PR, Wordsmith

  • Development Role
  • PipPipPipPipPip
  • 9105 posts

Posted 06 September 2018 - 12:12 PM

Thanks for all the hard work. :)

 

Would you be interested in assisting with this issue:

 

http://bugs.thedarkm...iew.php?id=4825

 

(model side changes)?


Please visit TDM's IndieDB site and help promote the mod:

http://www.indiedb.c...ds/the-dark-mod

(Yeah, shameless promotion... but traffic is traffic folks...)

#43 chedap

chedap

    Member

  • Member
  • PipPip
  • 102 posts

Posted 06 September 2018 - 12:19 PM

Preliminary stuff on lwo vertex colors: you have to export as "idtech-compatible" to have any blending show up in TDM. But it only seems to export boundaries between colors? Or something with the alpha? I don't know, it's weird, and the exporter has a bunch of vertex color-related code commented out. I'll get around to it by the end of the week, but it's not immediately obvious.

Would you be interested in assisting with this issue:
 
http://bugs.thedarkm...iew.php?id=4825

Please elaborate on what needs to be done (I don't have access to the referenced thread btw).
I've seen the issue and exchanged some PMs with @stgatilov, although I thought the issue was the same as this one. I've since learned the latter is called the "shadow terminator" problem and is a common occurence in a lot of engines. Maybe it is the same as the one on the tracker, maybe not.

Edited by chedap, 06 September 2018 - 12:46 PM.


#44 RPGista

RPGista

    Advanced Member

  • Member
  • PipPipPip
  • 1595 posts

Posted 06 September 2018 - 05:47 PM

Edit of edit: or not. what's up with the bricks showing through where they shouldn't? Will look into it.

 

Thing is, I cant click on the dropdown at all, it simply wont respond, so I cant choose the vertex color map. The "none" is fixed. I am using version 2.79b (or was it c?), so maybe its some sort of incompatibility... Good to hear you are on the major issue, though.


Edited by RPGista, 06 September 2018 - 05:48 PM.


#45 chedap

chedap

    Member

  • Member
  • PipPip
  • 102 posts

Posted 07 September 2018 - 08:58 AM

What other games even use .lwo? This whole idtech-compatible thing is a bit baffling to me. The "incompatible" files seem pretty compatible with TDM, meanwhile the Blender importer (that ships with it) chokes on them.

So yeah, anyway, I just removed a couple lines and it works, with the added bonus of now being able to export "sharp" vert-per-face colors, like so. Another headscratcher. Downoad here for now, but I guess I'll probably eventually rewrite this one as well.

The "none" is fixed.

I'm on 2.79b, can't reproduce. Are you saying it's actually inactive or that "none" is the only choice in the drop-down selection? Can you try it on another version (or same but fresh)? Just download a zip version, unpack and run, no installation required, won't ruin your configs.


  • RPGista likes this

#46 Arcturus

Arcturus

    Advanced Member

  • Development Role
  • PipPipPip
  • 1645 posts

Posted 07 September 2018 - 09:24 AM

While you're at it, could you also looks into "custom" vertex normals issue that I mentioned here: http://forums.thedar...dm/#entry421539 ?


It's only a model... /// My channel on YouTube


#47 chedap

chedap

    Member

  • Member
  • PipPip
  • 102 posts

Posted 07 September 2018 - 09:53 AM

You can export those using the modified .ase exporter. With regards to lwo, I don't see vertex normals in the spec. Here's how TDM source code describes handling them:

Calculate the vertex normals.  For each polygon vertex, sum the normals of the polygons that share the point.  If the normals of the current and adjacent polygons form an angle greater than the max smoothing angle for the current polygon's surface, the normal of the adjacent polygon is excluded from the sum.  It's also excluded if the polygons aren't in the same smoothing group.

This seems to confirm what I assumed about lwo smoothing previously: with quads triangulated, smoothing gets skewed at the surface boundaries, since one of adjacent quads is counted twice.


Edited by chedap, 07 September 2018 - 09:56 AM.


#48 Arcturus

Arcturus

    Advanced Member

  • Development Role
  • PipPipPip
  • 1645 posts

Posted 07 September 2018 - 11:16 AM

Works great:

 

Rh7tLRP.jpg


  • Bikerdude likes this

It's only a model... /// My channel on YouTube


#49 Skaruts

Skaruts

    Member

  • Member
  • PipPip
  • 279 posts

Posted 08 October 2018 - 10:37 AM

Perhaps it might be useful to keep links for the latest versions of the scripts in the first post. Someone looking for that might have to re-read the whole thread. Or like me, someone who hasn't yet read the whole thread might be wasting time downloading one of the previous ones.

 

I've tried using your ase exporter, but something's wrong. The exported model isn't textured. I'm using R Soul's Material Manager, but it doesn't seem to make a difference.

Nevermind that. Seems like the problem was that I had several UV layers. 


Edited by Skaruts, 08 October 2018 - 11:28 AM.


#50 Judith

Judith

    Advanced Member

  • Member
  • PipPipPip
  • 1731 posts

Posted 08 October 2018 - 11:09 AM

FYI, .ase models don't have the same workflow as .lwo, you need to edit them in notepad and assign material paths there.





Reply to this topic



  



Also tagged with one or more of these keywords: blender, lwo, export

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users