|
|
"Bill Pragnell" <bil### [at] hotmailcom> wrote in message
news:web.44759ba38c28dbe6731f01d10@news.povray.org...
> Following a problem I had with slow mesh parsing (see povray.general),
> here
> is my solution, with an example pic, using an optimized mesh2 object.
>
> My goal was to create a fairly good mountain landscape for use in
> backgrounds, etc, without resorting to fiddling with image heightfields or
> waiting for isosurfaces. So this is a heightfield generated using only
> SDL,
> using an 'envelope' function to control the height of mountains generated
> from pigment functions. I've included the complete scene, with some brief
> comments - hopefully someone will find it useful! I'm using 1 pov-unit = 1
> metre, approximately, so by all means have a play with the numbers.
>
> Bill
>
It's always a good exercise to write a mesh2 generator in POV SDL to better
understand both the programming and mesh2 formats. Good work. A couple
hints for you here:
1) changing both SineEdge and LandHeight to functions rather than macros
adds speed. Parse time dropped from about 90secs to 60secs for me:
#declare SineEdge2 = function
(xp){select(xp,select(xp+pi,0,0.5*cos(xp)+0.5),1)}
#declare LandHeight2=function
(xp,yp){SineEdge2(xp+6)*(0.5*land1((xp+hilloff)/sc1, 0, yp/sc1).x +
0.5*land2((xp+hilloff)/sc2, 0, yp/sc2).x)}
2) There is the function pattern for height_fields which does pretty much
what you did by hand only much faster (drops down to a mere 6sec parse time,
plus smoothing can be added):
#macro Region2(xs, ys, maxh, dx)
height_field {
#local m=(2*xs/dx+2);
#local n=(2*ys/dx+2);
function m,n {pattern{function{LandHeight2( (x)*2*xs-xs
, -((y-1/n)*2*ys-ys) )}}}
//smooth
translate <-1/2,0,-1/2>
scale <2*xs,maxh,2*ys>
texture { t1 scale maxh }
texture { t2 scale maxh }
}
#end
Good work on weeding through the math involved in mesh creation though. I
did it once for a moebius generator and it was quite educational. (You
forgot the smoothing normals though! And uv mapping support!)
-tgq
Post a reply to this message
|
|