Torchmodders

Mod Projects => Vkoslak's Playground => Topic started by: Vkoslak on May 20, 2018, 04:36:22 pm


Title: OgreXmlConverter options to make mesh files smaller, with script!
Post by: Vkoslak on May 20, 2018, 04:36:22 pm
I was playing around with an exporter earlier and captured the options it passes to OgreXmlConverter.
The meshes the created with the exporter were always smaller than when I just dragged the mesh to the exe.

"-e -t -td tangent -ts 4 P:\Blender\models\pinata\export\Llama.mesh.xml"

What they mean:
-e             = DON'T generate edge lists (for stencil shadows)
-t             = Generate tangents (for normal mapping)
-td [uvw|tangent]           = Tangent vertex semantic destination (default tangent)
-ts [3|4]      = Tangent size (3 or 4 components, 4 includes parity, default 3)


This resulted in my Fionna.mesh being reduced from 722KB with drag n drop to 298KB.


Being lazy and not wanting to type in those parameters every time I need to convert a mesh...

I made a batch file to do it for me  ;D

Slap the batch file I've attached below into the same directory as your OgreCommandLineUtils, and then drag your XML files over the batch file instead of the exe.

Title: Re: OgreXmlConverter options to make mesh files smaller, with script!
Post by: Kva3imoda on May 20, 2018, 05:10:23 pm
I have to try this. You tested these models in the game, are there any problems?

Do these keys "-e -t -td tangent -ts 4" work for a file shortcut? Because I use the OgreXmlConverter as "Send to..." because it is much more convenient than "drag&drop".
Title: Re: OgreXmlConverter options to make mesh files smaller, with script!
Post by: Vkoslak on May 20, 2018, 06:49:38 pm
I just loaded up my model in guts.  Looks fine to me. Animations are working.  No issues.


I tried it with a shortcut.  That works too.

Just set it like this with the quotes around the exe.
"C:\OgreCommandLineTools\OgreXMLConverter.exe" -e -t -td tangent -ts 4
Title: Re: OgreXmlConverter options to make mesh files smaller, with script!
Post by: Lord Nyriox on May 29, 2018, 01:26:55 pm
What they mean:
-e             = DON'T generate edge lists (for stencil shadows)
-t             = Generate tangents (for normal mapping)
-td [uvw|tangent]           = Tangent vertex semantic destination (default tangent)
-ts [3|4]      = Tangent size (3 or 4 components, 4 includes parity, default 3)

@Vkoslak

Dude...do not get your command-line options mixed up. 

When I tried to use these options on a mesh I have been converting back and forth between XML and MESH, I received an error during the second conversion, saying that these "tangents" were "already generated". 

A quick Google search on "Ogre mesh tangents" turned up this discussion (https://forums.ogre3d.org/viewtopic.php?t=43830), which discusses how to make bump-mapping textures work. 

In short, you are actually optimizing on one side (edge-lists), and de-optimizing on another (by adding data for a texturing feature your model does not use). 

Try removing everything but "-e" and compare sizes (on a new mesh) with your old script.  You might be pleasantly surprised. 

Title: Re: OgreXmlConverter options to make mesh files smaller, with script!
Post by: Vkoslak on May 29, 2018, 07:48:45 pm
That is a huge savings.

I was only using what the default was in the exporter. 

Unless we figure out how to get a normal map shader program working in torchlight the tangent options aren't needed.

Good find!

I'll update my batch file.
Title: Re: OgreXmlConverter options to make mesh files smaller, with script!
Post by: Lord Nyriox on May 29, 2018, 09:40:00 pm
Good find!

I'll update my batch file.

I have been doing quite a bit of work requiring OgreXMLConverter lately.  It was actually in an effort to integrate your work into my own suite of automation scripts that I discovered the issue.  ;}

Why not try my scripts out as well? 
https://torchmodders.com/forums/3d-modelling-animation/(script)-automatic-mesh-and-skeleton-rebuilding-and-optimization/ (https://torchmodders.com/forums/3d-modelling-animation/(script)-automatic-mesh-and-skeleton-rebuilding-and-optimization/)
Title: Re: OgreXmlConverter options to make mesh files smaller, with script!
Post by: Phanjam on May 30, 2018, 02:24:08 am
Thanks so much @Vkoslak and @Lord Nyriox for these! They add a lot of value to the body-of-knowledge on modding in general!