Here's something I began developing recently. It takes any old CSG
object and attempts to round its edges. It's based on the object pigment
pattern and works by exploiting the 'accuracy' of a surface normal.
It doesn't work too well if objects have preexisting round edges (eg.
spheres, cylinders), and doesn't leave the surface normals of the object
pointing in the original directions... which means it won't give you
100% accurate reflections and shading.
It looks nice enough, and is a good way to round the edges of complex
CSG without coding all kinds of cylinders and spheres into your object
definition.
This code will produce all three states as shown in the attached images:
#declare round_edges=on;
#declare edge_amount=1;
#declare edge_samples=20;
#declare obj=
union{
#local frame=
difference{
#local r=0.2;
box{-1,1}
box{-1+(x+y-z)*r,1-(x+y-z)*r}
box{-1+(x-y+z)*r,1-(x-y+z)*r}
box{-1+(-x+y+z)*r,1-(-x+y+z)*r}
}
object{frame rotate y*45}
object{frame rotate x*45}
object{frame rotate z*45}
}
object{obj
pigment{rgb<.2 .5 1>}
finish{
brilliance 2 diffuse .4
specular 1 roughness .1
}
#if(round_edges=on)
normal{
average
normal_map{
#local V=0;
#while(V<=1)
[1
object{obj } 1-V*1
accuracy (.01+V/10)*edge_amount
translate<
rand(R)-rand(R),
rand(R)-rand(R),
rand(R)-rand(R)
>*.00001
]
#local V=V+1/edge_samples;
#end
// uncomment to add bumpy surface normal
//[5 granite -1 accuracy .001
//poly_wave 2 scale .3]
}
}
#end
// uncomment to add corresponding pigment
//pigment{granite poly_wave 2 scale .3
//color_map{[0 rgb 1][1 rgb .5]}}
}
Is this helpful to anyone? Questions and comments, appreciated as always!
-Sam
Post a reply to this message
Attachments:
Download 're1.jpg' (28 KB)
Download 're2.jpg' (28 KB)
Download 're3.jpg' (38 KB)
Preview of image 're1.jpg'
Preview of image 're2.jpg'
Preview of image 're3.jpg'
|