|
|
Ineteresting, that could save a lot of work in some places.
ADB
Samuel Benge wrote:
> 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
>
> ------------------------------------------------------------------------
> [Image] [Image] [Image]
--
//Anthony D. Baye, Student - Comp.Sci.
#default{pigment{rgb<0,.4,1>}finish{reflection 0.3 specular 0.6}}#macro
m(a,g,e)#local A=0;
#while(A<360)#local
am=a*.75;cylinder{vrotate(a*x,A*g*z),vrotate(am*x,(A+135)*g*z)e}
#local A=A+90;#end #local B=0;#while(B<360)sphere{a*x,e rotate B/2*g*z}#local
B=B+1;
#end #end m(2,1,.03)m(2,-1,.03)light_source{<-3,10,-15>,rgb
1}camera{location-7*z look_at 0}
Post a reply to this message
|
|