|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
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'
|
|
| |
| |
|
|
|
|
| |
| |
|
|
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
|
|
| |
| |
|
|
From: Tim Nikias
Subject: Re: Rounding out sharp CSG edges (94kb total, 3 jpegs)
Date: 24 Oct 2004 05:52:02
Message: <417b7b42$1@news.povray.org>
|
|
|
| |
| |
|
|
Neat code! Would it be okay if I'd put that up in my POV-Code section? Won't
be there for a few days though, as I'm rehauling the website, but
nontheless...
Regards,
Tim
--
"Tim Nikias v2.0"
Homepage: <http://www.nolights.de>
Post a reply to this message
|
|
| |
| |
|
|
From: LightBeam
Subject: Re: Rounding out sharp CSG edges (94kb total, 3 jpegs)
Date: 24 Oct 2004 08:20:44
Message: <417b9e1c$1@news.povray.org>
|
|
|
| |
| |
|
|
Ouch ! :-O
Are your a magician or someone else ?
;-))
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Samuel Benge <stb### [at] hotmailcom> wrote:
> Is this helpful to anyone? Questions and comments, appreciated as always!
Very helpful indeed; thanks for posting it, a valuable piece of code!
Beginners might not know R is a random number seed, so add:
#declare R = seed(0);
-Mark Slone
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Anthony D. Baye wrote:
> Ineteresting, that could save a lot of work in some places.
Thanks!
-Sam
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Tim Nikias wrote:
> Neat code! Would it be okay if I'd put that up in my POV-Code section? Won't
> be there for a few days though, as I'm rehauling the website, but
> nontheless...
>
> Regards,
> Tim
Tim, I wouldn't have posted it here if I was snooty about it being
redistributed. Go ahead!
-Sam
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
LightBeam wrote:
> Ouch ! :-O
> Are your a magician or someone else ?
> ;-))
No, magician wear funny capes :) Reminds me of a hilarous episode of
Seinfeld....
-Sam
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Renderdog wrote:
> Samuel Benge <stb### [at] hotmailcom> wrote:
>
>>Is this helpful to anyone? Questions and comments, appreciated as always!
>>
>
> Very helpful indeed; thanks for posting it, a valuable piece of code!
>
> Beginners might not know R is a random number seed, so add:
>
> #declare R = seed(0);
>
> -Mark Slone
Yikes! I always put that near the top of my scene code, so I totally
missed it. For the record, I used
#declare R = seed(0009);
because out of the twenty seeds I tried, that one had less surface
normal inaccuracies. Maybe I should post the complete code somewhere....
Thanks for catching that, Renderdog!
-Sam
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Samuel Benge wrote:
That really is very cool. This *and* the fake scattering. Amazing
innovation.
-Shay
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |