POV-Ray : Newsgroups : povray.general : Iris Diaphragm -> Help Please! : Re: Iris Diaphragm -> Help Please! Server Time
30 Jul 2024 12:28:02 EDT (-0400)
  Re: Iris Diaphragm -> Help Please!  
From: triple r
Date: 13 Feb 2009 21:50:00
Message: <web.49963066e4df7abef2b9ba40@news.povray.org>
"Anthony D. Baye" <Sha### [at] spamnomorehotmailcom> wrote:
> Any suggestions would be greatly appreciated.

Of course I needn't emphasize that you should try to understand this rather than
just use it, but, based on some pre-existing code, here's an approximation of
the iris in the photo you provided.  To prevent overlap, you just have to
rotate the blades a little in the right direction.  Interestingly, if you put
this right in front of the camera and use focal blur, you can use this physical
aperture to give you the right bokeh pattern.  Kinda neat, but it takes a lot of
samples.  Anyway:

- Ricky



camera{
    location <0,2,-2>
    look_at <0,0,0>
    sky z
}

light_source{
    <25,8,-10>
    rgb 2
    area_light 10*x,10*y,10,10
    circular
    orient
    jitter
    adaptive 2
}

#declare eps = 1.0e-5;
#declare major_rad = 1.0;            //outer radius of the blades
#declare minor_rad = 0.15;           //width of the blades
#declare hole_rad = 0.02;            //radius of the holes
#declare blade_thickness = 0.005;
#declare blade_angle_span = 135;     //where does the blade end?
#declare blade_angle = 30;           //rotate the blades!
#declare num_blades = 7;
#declare casing_rim_width = 0.02;
#declare casing_rim_height = 0.04;
#declare casing_width = 0.02;

// The angle to rotate a blade by (degrees) so that
// the blades layer rather than collide.
#declare blade_overlap_fudge_factor = 0.4;

#declare blade =
    difference{
        union{
            cylinder{-y*(blade_thickness-eps), y*(blade_thickness-eps),
                      minor_rad}
            difference{
                cylinder{<0,-blade_thickness,-major_rad+minor_rad>,
                         <0, blade_thickness,-major_rad+minor_rad>,
                         major_rad
                }
                cylinder{<0,-blade_thickness-eps,-major_rad+minor_rad>,
                         <0, blade_thickness+eps,-major_rad+minor_rad>,
                         major_rad-minor_rad*2
                }
                plane{ vrotate(-z,blade_angle_span*y), -minor_rad }
                plane{ -x, 0 }
            }
        }
        cylinder{<0,-blade_thickness-2*eps,0>,
                 <0, blade_thickness+2*eps,0>,hole_rad}
        rotate y*blade_angle_span/2
        rotate z*blade_overlap_fudge_factor
        rotate -y*blade_angle_span/2
        translate y*0.01
    }

#declare casing =
    difference{
        cylinder{<0,-casing_width,0>,
                 <0,casing_rim_height,0>,major_rad+casing_rim_width}
        cylinder{<0,-casing_width-2*eps,0>,
                 <0,casing_rim_height+2*eps,0>,major_rad-2*minor_rad}
        cylinder{<0,0,0>,<0,casing_rim_height+eps,0>,major_rad}
        // punch a hole in the casing
        #declare b=0;
        #while(b<num_blades)
            cylinder{<0,-casing_width-3*eps,0>,
                     <0,casing_rim_height+2*eps,0>,hole_rad
                translate z*(major_rad-minor_rad)
                rotate y*360*b/num_blades
            }
            #declare b=b+1;
        #end
    }

#declare iris =
    union{
        object{casing}
        #declare b=0;
        #while(b<num_blades)
            object{blade
                rotate -y*blade_angle
                translate z*(major_rad-minor_rad)
                rotate y*360*b/num_blades
            }
            #declare b=b+1;
        #end
        translate y*casing_width
        pigment{rgb 1.0}
        finish{
            ambient 0
            diffuse 0.05
            reflection 0.2
            specular 1.0
            roughness 0.1
        }
    }


plane{y,0
    pigment{rgb <0.9,0.75,0.6>}
    finish{ambient 0 diffuse 1.0}
}

sky_sphere{
    pigment{
        gradient y
        color_map{
            [0 rgb 0]
            [0.5 rgb 0]
            [1 rgb 1]
        }
        scale 1.2
        turbulence 0.5
    }
}

object{iris}


Post a reply to this message

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