PDA

View Full Version : Bake instances



mijaba
05-20-2014, 07:30 AM
It would fabulous if we could bake instancing as a separate object. It would ALSO be cool if we could load instance references from a text file rather than the object itself.
Any thoughts on how this could be done otherwise? Thanks!

ernpchan
05-20-2014, 08:23 AM
There's a python script that will bake instances. Check your scripts folder.

raw-m
05-20-2014, 11:12 AM
As ernpchan says, also Scene2Modeler (http://www.svenart.de/lscripts.htm) will get all the bakes into one object. There's 2 scripts, one for Layout and one for Modeler. Run the Layout script on your objects and once done hop to Modeler and run the other script to collect the objects.

There are other similar scripts but this one worked best for my setup. It maybe a bit painful if you have 1000s of objects!

Waves of light
05-20-2014, 12:55 PM
Having just baked out 75,000+ stadium seats, let me share my story.

First off - Baking the instances. There were two scripts that I tested, bake_instance.py (found under C:\Program Files\NewTek\LightWave11.6.1\support\plugins\scrip ts\Python\Layout\Generic) and Mike Green's MG_bake_selected_instancers_GN.py (http://www.mikegreen.name/Lscripts.html)

What I found was that both scripts would become extremely slow the more instances backed. E.g. using bake_instance.py on all the top tier of seats took 18 hours to bake! I tried this with Mike's script and could see that we were heading towards similar timings. So, to get around this I broke my instance placeholder layer into layers containing no more than 2000 objects. After this, I found that the baking routine was a lot quicker. Mike's script also uses less RAM and is slightly quicker at baking instances.

This is all done in Layout and after I'd baked a set of seats, I used cp_SaveTransformed by Chris Peterson (xChrisx on the forum) to save out each instance as its own .lwo file. For some reason I couldn't get scene2modeler to work. I don't know if this was due to the number of instances I was trying to bake, but once I had a working workflow, I stuck with it.

One note: Re. cp_SaveTransformed - If you select 'Selected' it will only bake out 1,000 instances regardless of how many instances you have selected. Instead, I used 'All' - which saves out a single lwo for any additional items, but you can always delete them if you don't want them.

In the end, I wanted to join the instances together and make single .lwo and be able to export to .obj. So I used Collapse Object function in Modeler.

raw-m
05-20-2014, 01:02 PM
Wave of Light, I enjoyed that story!

Waves of light
05-20-2014, 01:08 PM
Wave of Light, I enjoyed that story!

Cheers Mark.

It was so I could have an obj of a football stadium I was doing. I'm just glad it wasn't for a client, because I wouldn't have been able to deliver it. It took me a week (and lots of moaning and help from lightwave users on skype) to figure out the pitfalls.

jeric_synergy
05-20-2014, 05:50 PM
Hmmmm, I wonder what the deal with speed was? Was the s/w having to reload an accumulating mesh repeatedly or something? Perhaps a different strategy of duplication in LWM might offer significant speed increases?

Like, possibly, saving out an array of destination points and allowing LWM do the heavy lifting of copying would be faster than whatever is currently happening. --Or not.

--Also, does an individual point in Modeler have rotation values? --I'd think it must, for spline operations, but I've been wrong a lot lately.

lertola2
05-21-2014, 02:00 PM
I did not see mentioned in this thread that you can combine your baked instances into a single .lwo by exporting an fbx file and importing it into modeler. That method does have the drawback that each instance gets unique surface names created for it. The best solution to that problem that I know about is to use this script to select similar named surface polys and rename them yourself: https://www.lightwave3d.com/assets/plugins/entry/cp_selectsurfnames/

-Joe

raw-m
05-21-2014, 02:59 PM
Cheers Mark.

It was so I could have an obj of a football stadium I was doing. I'm just glad it wasn't for a client, because I wouldn't have been able to deliver it. It took me a week (and lots of moaning and help from lightwave users on skype) to figure out the pitfalls.

You did a cracking job there and clearly a great way to learn. Hope it earns you a packet!

Waves of light
05-22-2014, 02:35 AM
Hmmmm, I wonder what the deal with speed was? Was the s/w having to reload an accumulating mesh repeatedly or something? Perhaps a different strategy of duplication in LWM might offer significant speed increases?

Like, possibly, saving out an array of destination points and allowing LWM do the heavy lifting of copying would be faster than whatever is currently happening. --Or not.

--Also, does an individual point in Modeler have rotation values? --I'd think it must, for spline operations, but I've been wrong a lot lately.

You can visibly see it slowing down as it gets further into the routine. There needs to be some dump process, so that it bakes say 1000 instances, dumps a temp file, bakes the next 1000 and then joins them all up at the end.

At the moment it looks like the calculation/process is this

Bake A
Bake B, save A and B
Bake C, save A, B and C
Bake D, save A,B,C and D

And so on.


I did not see mentioned in this thread that you can combine your baked instances into a single .lwo by exporting an fbx file and importing it into modeler. That method does have the drawback that each instance gets unique surface names created for it. The best solution to that problem that I know about is to use this script to select similar named surface polys and rename them yourself: https://www.lightwave3d.com/assets/plugins/entry/cp_selectsurfnames/

-Joe

Joe - I did see your response regarding export and import as an fbx file in another thread. However, when I tried it with the overall bake, it crashed Lightwave. I have 32GB of RAM, so I would have hoped that would be enough to hand the export. If I get a chance, I will try the fbx export on sections of the instance placeholders and see if that works.


You did a cracking job there and clearly a great way to learn. Hope it earns you a packet!

I wish, it was for a TurboSquid model, ready for the World Cup in Brazil - you can see it here: http://www.turbosquid.com/3d-models/3d-model-est%C3%A1dio-maracan%C3%A3-football-stadium/810178

But yes, the whole design process and making it compatible with other formats was definitely a worthwhile learning experience.

If I get the chance, I will upload a .lws file with the instance placeholder and the seats and you guys can see if you can come up with a better solution.

Ricky.

jeric_synergy
05-22-2014, 10:25 AM
This has been a very informative thread.

Anytime LWM displays something, it's a big loss: a facility to suppress display updating would probably be worthwhile. (LW12)

Waves of light
05-23-2014, 04:23 AM
This has been a very informative thread.

Anytime LWM displays something, it's a big loss: a facility to suppress display updating would probably be worthwhile. (LW12)

Ok, here's a little breakdown for you:

Stadium seats - 424 polys each.

Section 1 - 2522 seats - 9mins to bake
Section 2 - 2353 seats - 8mins to bake
Section 3 - 2325 seats - 8mins to bake (only 1 min approx. to get half way on the progress bar)
Section 4 - 1646 seats - 3mins to bake
Section 5 - 1901 seats - 4mins to bake
Section 6 - 4224 seats - 44 mins to bake!

Here's the scene file with the entire placeholders polys (approx 15,000) and seats (folded and unfolded) for you guys to play with:

121997

When you run bake_instance.py or Mike's script, be sure to have the Object properties panel open for the Placeholder layer (if you're using Mike's script) or the seats layer (if using the native baking script) and watch the 'Objects in Scene' rise quickly and reduces to a snails pace when it bakes the higher numbers.

And the only way to kill the script is to open Windows Task Manager and kill Layout.

Oh and sorry for the thread hijacking mijaba.

Regards,
Ricky.