How to render many object instances easily?


#1

A common technique in CG art programs is to use “particles” to generate fields of grass (or things like hair, leaves, rock debris, etc). For grass, a few different grass strands are modelled, say 4 varieties, and then use the computer program (such as Blender) to place many thousands of these grass strands, randomly picked from the 4 that you’ve modelled, distributed on a 3D plane.

Radiance does not have any “particle” distribution features as far as I’m aware, so I was looking for a way I could place these thousands of strands. I wrote a script which would take the thousands of locations and rotations and scales of the placed particles from Blender, and generate Radiance instructions. I’ve tried generating the Radiance instructions in the form of thousands of !xform -t ... -rx ... -ry ... -rz ... -s ... grass-n.rad and also in the form of thousands of instance modifiers. Here is an example of using instances:

void instance particle_0
13 lib/bahia-grass/obj/bahia-grass-1.oct -t 0.11021173000335693 1.9706244468688965 0.0 -rx 88.51563847329432 -ry 7.2024686307242956 -rz 140.9574962413829 -s 0.7970437407493591
0
0

void instance particle_1
13 lib/bahia-grass/obj/bahia-grass-1.oct -t 1.5387978553771973 1.315934419631958 0.0 -rx 84.4261036888842 -ry -8.60175753315376 -rz 69.45851593417747 -s 0.7061752080917358
0
0

void instance particle_2
13 lib/bahia-grass/obj/bahia-grass-1.oct -t -0.3547959327697754 -1.8694648742675781 0.0 -rx 80.69210074134077 -ry 5.019809964460436 -rz -174.83666886437183 -s 0.6724437475204468
0
0

... [etc] ...

I found that with 50 or so xform or instance calls, the octree generation step oconv foo.rad > foo.oct is very quick, almost instantaneous, say milliseconds. However, as I increase it to more than 50, say, 51 or 52 particles, the octree generation step starts taking say a few seconds to complete. Then say with 60 particles it might take 10 seconds to complete. With 70 it might take 20 seconds to complete. With 100, it might take 5 minutes to complete. This non-linear increase in processing time makes it difficult to process 1000 of these xform or instance statements in a single .rad file. I guess I can split it up into multiple rad files, but I haven’t tried it.

Note: both xform and instances have the same issue.

Can someone explain why this processing takes so long, and what I can do to mitigate it?


#2

There are some notes about using octree instances, which also applies to meshes, that one should endeavor to have a few hundred to a hundred thousand or so surfaces per octree or mesh before you start instancing them, and make sure that the geometry occupies something that fits reasonably well into a cube. It can be square or even rectangular, but not extremely long in one dimension and thin in the other two dimensions.

The upshot is that you should make yourself a square patch of thick grass with a 10-50 thousand polygons, put that in a mesh or octree, and instance it to make your lawn. Don’t try instancing individual blades of grass.


#3

I see. I’ve followed your advice and I have created a circular patch of grass of various species, and then instanced them around a scene. I chose a circular patch as this would allow patches to blend and mix within each other. It works great now and I only have about a few hundred instances (~50-100 patches * 4 types of species)

Here’s the result! If I added more types of things, like small coloured flowers, danelions, other types of weeds, and bits of dead leaf debris, I think it could be very realistic indeed!

I’ll post a breakdown of the workflow and release all assets for free once I’ve done a bit more clean up :slight_smile:


#4

Just a small update showing with 3 more particle assets: dead leaves, white flowers, and yellow flowers. (I measured some yellow and white flowers I had in my back yard but I need to get the botanical name to properly classify it :slight_smile:)

radiance-grass

Mmm, uploading to the forum caused Discourse to resize the image and make it a bit blurry, oh well.


Work in progress - living room