Early on, I was working on the problem of rendering a virtual forest based on real LiDAR data in order to do things like a detailed, vegetation included, viewshed. There are other things we can do with this data, including discovering the boundary of the canopy (and thus find canopy gaps) and rendering a vegetation surface model.
Let’s start with a single tree. If we have a tree, height x, and we have a tree model, height 1, then we can place a tree in our scene height 1x. If we want to use Povray to render a surface model, we can use a linear pattern applied to our tree to render what parts of the tree are closer and which are further.
#include "transforms.inc"
#declare Camera_Location = <0,80,0>;
#declare Camera_Lookat = <0,0,0>;
#include "tree1.inc"
camera {orthographic
location Camera_Location
look_at Camera_Lookat
right 100
up 100}
// Unioned box is used to normalize the scaling of the pigment
union {
object { TREE
scale 80
}
box {-1000,1000}
pigment {
gradient x color_map {
[0 color rgb 1]
[1 color rgb 0]
}
scale <vlength(Camera_Location-Camera_Lookat),1,1>
Reorient_Trans(x, Camera_Lookat-Camera_Location)
translate Camera_Location
}
finish {ambient 1}
}
My tree is the default tree from POV-Tree: http://web.archive.org/web/20071101052625/propro.ru/go/Wshop/povtree/download.html.
Here’s my ini file:
All_Console=Off
All_File="false"
Antialias=Off
Bits_Per_Color=16
Bounding=On
Bounding_Threshold=10
Continue_Trace=Off
Create_Histogram=Off
Debug_Console=On
Debug_File="false"
Display=On
Draw_Vistas=On
End_Column=600
End_Row=600
Fatal_Console=On
Fatal_File="false"
Height=600
Jitter=Off
Light_Buffer=On
Output_Alpha=Off
Output_File_Type=n
Output_To_File=On
Quality=0
Remove_Bounds=On
Render_Console=On
Render_File="false"
Split_Unions=On
Start_Column=1
Start_Row=1
Statistic_Console=On
Statistic_File="false"
Verbose=On
Vista_Buffer=On
Warning_Console=On
Warning_File="false"
Width=600
You’ll notice I’m outputing as a 16-bit per channel PNG, so I can capture the full dynamic range of values without loosing too much of the precision in the distance values. Now, just a little algebra, and we have distance from camera calculated, but I’ll leave that to a future post.
Here’s where I’m going– imagine a PostGIS database full of LiDAR vegetation points and ground points. A nearest neighbor search and a little arithmetic tells us the local height of the vegetation point. Now we iterate through a grid extracting sections of this dataset, using a simple query and a little AWK scripting to output the include file, the povray file, and render the image of tree height. The tree height interpolator is then a simple 3D tree shaped stamp that we scale, rotate, and stamp all across our landscape, thus creating a PovRay generated digital surface model of vegetation.
Edit:
Oh, and I must credit the source for my height mapping:
http://news.povray.org/povray.advanced-users/thread/%3Cweb.49c79d64a563150ecb94416e0@news.povray.org%3E/
