Here’s another wee widget, a job I’m working on has a load of trees in it and one of the guys here used the aec trees in 3ds max 7 (objects > aec objects > foliage) which use a plane mapped with a leaf picture and an opacity map which is pretty slow in vray so I wrote a little script that copies a selected object to the position and orientation of the leaf faces - It’s a hell of a lot quicker to render geometry than opacity maps. Here’s the workflow:
Take a tree object and convert it into an editable poly object.
Go into polygon mode and find the material id of the leaves / flowers / whatever you want to replace.
Make a little bit of leaf geometry to replace the flowers with.
Select your editable poly tree and run the script.
Set the replace id spinner to the material id of the objects you want to replace.
Pick the leaf object using the “pick leaf object” button.
Hit make leaves.
Wait for fuck ages.
You’ll end up with a new editable mesh object with all of the leaves so you can now add a delete mesh modifier onto your editable poly tree to remove all of the old leaves. It’s not the smartest of scripts and probably has loads of error situations so make sure to save your scene / do a hlod before you run make leaves.
I reckon the best way to use this is as a step to making vray proxy objects, I wouldnt try using it on multiple obejcts just yet.
I actually generates one editable mesh for the new leaves so you can move it along with the tree. I could add in options for instancing quite happily - The reason it was done was mainly to sort out a job where someone here was doing things the dumb, brute force approach on around 4.5 million polygons so the script was meant to facilitate a way to convert the opacity maps to geometry to facilitate the making of vray proxy objects. I’ll stick in the option for instancing of the leaves in the next wee bit if you think it’d be helpful.
Yeah indeed - I’ve rewritten it to allow you to define a selection of leaf obnjects first and then it’ll randomly pick on of the leaf objects to replace an opacity mapped face so you have that functionality now - I’ll add in the support for different material ids. I reckon instanced leaves (as in a seperate object for each leaf) would possibly make something like your select by name dialog crawl - I’ll add it in as an option but not the default.
Sorry but I havent put it up yet, there’s a problem with me accessing certain parts of my site from my work connection so I’ll have to upload it from home - it should be up in a few hours, I’ll put an entry on the site.
Excellent - glad its useful. Again any ideas that you think might be useful, post them here. So far I’ll be adding in support for multiple selections of leaf objects and random material ids in the leaves to give more variation again - Anything you can think of though I’d be happy to look at adding it in.
what would be even cooler if it were able to say, trace the alpha channel of the leave map and make the leaf geometry based on the black outline around the leaf shape in the alpha mat.
Then dispose the leaf plane and apply the diffuse texture to the newly create leaf geometry.
Although i think thats a little bit impossible.. LOL … would be great if it was possible tho.
Actually you could kinda do it.. althought im sure sure if its feasable and would require some decent scripting… picture this if you will.
1. apply a displace modifier (standard max one) to the leaf plane
2. put the leafs alpha map into the displace modifiers map slot
3. displace by a certain amount say 5mm
4. add a slice modifier set to remove top (or bottom, cant remember which)
5. move the slice modifier 4.5mm inti the object (thus leaving a small bit of leaf shape geometry)
6. add a shell modifier to make it solid
you might need to a mesh smooth or tesselate to get enough geometry in the leaf place for it to displace properly.
yeah it’s called clip mapping and the way you described is a hack to do that - I’d say something like that to do an entire tree would be bonkers and end up with a huge amount of geometry but I’m looking into bitmaps and driving scripts based on their values so it is a possibility. The method you described is very doable though.
I was wondering how tuff it would be to trace the leaf edge with a spline, if you sampled the alpha there wouldn’t be too much data to consider, maybe..
that’s just what I did. I just traced the alpha with a spline by hand, not too hard to do. depending on what kind of tree you have you can get away with only 4 vertex points, then converted it to a mesh, it doesnt need a shell modifier like da force said, because the vray mat renders both sides anyway.
the xfrog tree I used has allready 4 differt mat. ids for the leaves, that way you can replace it with 4 different colors too.
I’ll add in support to replace multiple ids too. As far as the splne tracing thing, I think somene may have done this but I’m not sure whether it was in max or in a compositor as some kind of auto rotoscoping…
the more I think about it the more impossible I think it is, in maxscript anyways. It can be done in PS easily just convert a selection to a path. and of course any raster to vector proggy. Joost’s method is sounding pretty good.