|
![](/i/fill.gif) |
Josh wrote:
> I am working on some timple functions to make my own grass (I want the
> challenge of making my own, I know there are some out there already). The
> way I'm doing it right now gives me the results I want (it looks like I
> want it to look), but the parsing process is very slow due to the nested
> loops that I use. I am using splines to calculate the path I want. With
> my spline, I simply draw triangles to make up the grass. There is a loops
> the goes up the spline, while drawing triangles. This loop is contained in
> another loop whose roll it is to create multiple blades. Heck, here is the
> source code:
>
>
>
>
> As already stated, the parsing step is very slow and takes a lot of ram
> (once it hits swap, the time required goes through the roof. Can someone
> help me come up with a good optimization scheme?
>
Yes, you want to avoid the swapping out.
What everyone does with this is to take advantage of "instancing"
Basically you want to group some subset of your traingles in a mesh
block with an assigned name. Then you reuse this mesh object to build
your larger structure. In the case of grass or hair the best break
point is usually at the "patch" level, so to speak. (ie meaning a
"patch" of grass.) Instancing individual blades is usually too small a
number of triangles to be efficient so you put some number of blades
into a patch then reuse the patch to produce a grass "lawn"
The last time I did this I believe I made patches of about 75 blades of
grass, each blade with five triangles. But that number can be quite
flexble according to what you are trying to do and what kind of memory
you have. I also sometimes produce an array of grass patches each
randomly different, then access the array randomly to get a more
irregular look.
Post a reply to this message
|
![](/i/fill.gif) |