POV-Ray : Newsgroups : povray.binaries.images : A method creat uniform thick shell : Re: A method creat uniform thick shell Server Time
26 May 2024 11:15:31 EDT (-0400)
  Re: A method creat uniform thick shell  
From: And
Date: 24 Jul 2018 08:40:00
Message: <web.5b571d64dce0719ae897ce530@news.povray.org>
"And" <49341109@ntnu.edu.tw> wrote:
> I have written a macro which uses above technique to make an isosurface thin
> shell. I post it below. But I found that it is only for a small thickness or it
> don't have a constant thickness result. Furthermore, for many functions its
> result is not expect.
>
> So, don't take too much expect with it.
>
> //-------------------macro-----------------------------
>
> #macro Shape_ThinShellOf3DFunction(input_function, _min_extent, _max_extent,
> _thickness, _max_gradient)
> #local CSG_OVERLAP=0.001;
> #local h=0.00001;
> #local normalized_function =
> function(var1,var2,var3)
> {
> input_function(var1,var2,var3)
> /sqrt(
> pow((input_function(var1+h,var2,var3)-input_function(var1,var2,var3))/h,2)
> +pow((input_function(var1,var2+h,var3)-input_function(var1,var2,var3))/h,2)
> +pow((input_function(var1,var2,var3+h)-input_function(var1,var2,var3))/h,2)
> )
> }
> difference{
> isosurface{
> function{normalized_function(x,y,z)-_thickness/2}
> max_gradient _max_gradient
> contained_by{box{_min_extent,_max_extent}}
> all_intersections
> }
> isosurface{
> function{normalized_function(x,y,z)+_thickness/2}
> max_gradient _max_gradient
>
contained_by{box{_min_extent-<CSG_OVERLAP,CSG_OVERLAP,CSG_OVERLAP>,_max_extent+<CSG_OVERLAP,CSG_OVERLAP,CSG_OVERLAP>}
}
> all_intersections
> }
> }
> #end
>
>
>
>
>
> //---------------------Here is a good look example------
>
> #declare f_noise3d = function { internal(76) }
> #declare f_test=
> function(x,y,z){
> x*x+y*y+z*z-1- 0.5*f_noise3d(x/0.3,y/0.3,z/0.3)
> }
>
> difference{
> Shape_ThinShellOf3DFunction(f_test, <-1.3,-1.3,0>, <1.3,1.3,1.3>, 0.04, 10)
> box{<-1.5,-1.5,-0.1>,<1.5,0,1.5>}
> texture{
>     pigment{rgb<1,1,1>}
>     finish{
>         ambient 0.1
>         diffuse 0.6
>     }
> }
> }
>
> //----------------------------------------------------------


Use the macro. and input function below

#declare f_parabola=function(x,y,a){
y-a*x*x
}

#declare f_curve = function(x,y) {
pow(f_parabola(x,y,1), 2) + 0.2*y*y - 0.02
}

#declare f_circle = function(x,y) {
x*x + y*y - 0.5*0.5
}


#declare h = 0.5;


#declare f_test=
function(x,y,z){
(z/h)*f_curve(x,y) + (1-z/h)*f_circle(x,y) - 0.2*f_noise3d(x/0.2,y/0.2,z/0.2)
}


object{
Shape_ThinShellOf3DFunction(f_test, <-1.4,-1.3,0>, <1.4,1.4,0.5>, 0.024, 10)

texture{
    pigment{rgbt<0.014,0.011,0.007, 0.9>}
    finish{
        ambient 0.0
        diffuse 1.0

        reflection {0.01, 0.89 fresnel}conserve_energy
    }
}
interior{
    ior 1.46
    fade_colour rgb<0.6, 0.4, 0.3>
    fade_distance 2.6
    fade_power 1001
}
no_radiosity


}


Post a reply to this message


Attachments:
Download 'scene glass.png' (104 KB)

Preview of image 'scene glass.png'
scene glass.png


 

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.