|
|
Hello,
Here's a method for slicing a height_field into many pieces and
translating/scaling the parts to create caves and overhangs. It renders
faster than an isosurface, but produces visible seams. It's still pretty
slow :(
The left portion of the attached image shows an unmodified height_field.
The portion to the right is the same height_field sliced 50 times. A
surface normal was added to diminish the appearance of seams. With
enough slices, and with a smoother controlling pigment to create the
overhangs, some of the sharper features can go away.
The coincident surfaces near the base is a consequence of giving the
ground plane a difference pigment than the height_field.
The macro places the object between <0,0,0> & <1,1,1>.
// code
// the slicer macro
// you can add this to hf_tools.inc for convenience
// hfs = your height_field
// hfs_control_pigment = the controlling pigment
// hfs_n_slices = number of slices
#macro hf_slicer(hfs, hfs_control_pigment, hfs_n_slices)
#local hfs_incre=1/hfs_n_slices;
#local hfs_function=function{pigment{hfs_control_pigment}}
#local hfs_p1=0;
#local hfs_V=0;
union{
#while(hfs_V<=1)
#local hfs_pv=hfs_function(0,hfs_V,0).x;
#local hfs_p2=hfs_p1;
#local hfs_p1=hfs_pv;
#if(hfs_V>0)
object{hfs
#if(hfs_p1>hfs_p2)
clipped_by{plane{y,hfs_p1}} clipped_by{plane{y,hfs_p2 inverse}}
#else
clipped_by{plane{y,hfs_p1 inverse}} clipped_by{plane{y,hfs_p2}}
#end
translate -y*hfs_p2
scale<1,hfs_incre/(hfs_p1-hfs_p2),1>
translate y*hfs_V
}
#else
#declare hfs_rectifier = hfs_p1;
#end
#local hfs_V=hfs_V+hfs_incre;
#end
translate -y*hfs_incre
}
#end
// the height_field
#declare hf=
height_field{
function 512,512{
pigment{
pigment_pattern{spherical translate(x+y) scale 1/2}
poly_wave .25
pigment_map{
[0 rgb 0]
[1
granite scale 1.5
cubic_wave
]
}
}
}
smooth
}
// This pigment controls the overhangs.
// 'hf_slicer' tests values between <0,0,0> & <0,1,0>.
#declare modifying_pigment=
pigment{
planar
pigment_map{
[0 rgb 1]
[.5 bumps scale .07]
[1 rgb 0]
}
}
// the ground plane
plane{y,0 pigment{rgb 1}}
// the height_field-based object
object{
// Here's the macro instance using:
// -the pre-declared height_field
// -the pre-declared pigment controlling the overhangs
// -50 slices
hf_slicer(hf, modifying_pigment, 50)
// center and scale the object
translate-(x+z)/2
scale<10,5,10>
pigment{rgb 1}
//normal{granite .5 scale<10,.5,10> no_bump_scale accuracy .001}
}
// end code
Sam
Post a reply to this message
Attachments:
Download 'hf_slicer.jpg' (148 KB)
Preview of image 'hf_slicer.jpg'
|
|