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?