/* * Experimental scene to see if photons can simulate the projection * of images through lenses * * Copyright 2008 Christian Froeschlin, www.chrfr.de * * Don't trust any formulas in this scene file, I don't know squat about * optics, also, the scale is not very realistic. This was based mostly on * information from the physics classroom at * http://www.glenbrook.k12.il.us/gbssci/Phys/Class/refrn/u14l5a.html. */ #include "colors.inc" global_settings { assumed_gamma 1.0 max_trace_level 10 photons {count 100000} } camera { location <0.0, 1.0, -5.0> look_at <0.0, 1.0, 0.0> angle 90 } // Presentation environment should be dark #default {finish {ambient 0.02}} sphere {0, 1000 pigment {color SkyBlue} hollow} // Sky plane {y, 0 pigment{checker color White color Black}} // Ground // Lens specification #declare LENS_IOR = 1.5; // Index of refraction #declare LENS_RADIUS = 1.5; // (curvature) [m] #declare LENS_DIAM = 2.0; // (size/height) [m] // Derived lens parameters #declare LENS_DIAM2 = LENS_DIAM / 2; #declare LENS_THICKNESS = 2 * (LENS_RADIUS - sqrt(LENS_RADIUS*LENS_RADIUS-LENS_DIAM2*LENS_DIAM2)); #declare LENS_CENTER = LENS_RADIUS - LENS_THICKNESS / 2; // Dist. center of curv to center of lens #declare LENS_POWER = (LENS_IOR - 1) * (2/LENS_RADIUS); // Dioptrin (= 1/f, f in m) #declare LENS_FOCUS = 1/LENS_POWER; // Focal length [m] #declare OBJ_DIST = 3; #declare SCREEN_DIST = 1 / (LENS_POWER - (1/OBJ_DIST)); // Light should be far enough away from the object so that // photons shot from the light source center through slide // actually hit the lens. This distance is larger than you // might expect from real life because the light source is // just a point. Using a light grid (or area_light in 3.7b) // might help in this respect. #declare LIGHT_DIST = OBJ_DIST + 10; light_source { < -LIGHT_DIST, 1, 0> color rgb White //area_light 0.5*y, 0.5*z, 17, 17 area_illumination } // Confine light source and source image in some sort // of casing to keep the environment dark cylinder { -(LIGHT_DIST+1)*x, -OBJ_DIST*x, 1 open translate y pigment {color White} } // Lens intersection { sphere {-LENS_CENTER*x, LENS_RADIUS} sphere { LENS_CENTER*x, LENS_RADIUS} translate y // Optical axis at height 1m interior {ior LENS_IOR} pigment {color rgbt 1} photons {refraction on reflection off collect off} } // Screen plane {-x, -SCREEN_DIST pigment {color White}} // Pigment for test object #declare pslide = pigment { checker color rgbf <0,0,0,0.8> color rgbf <1,1,1,0.8> scale 0.25 // For loading a test image to project instead /* image_map { sys "your_image.bmp" filter all 0.8 } rotate 90*y translate 0.5*z translate 0.5*y */ } // test object to project box { <0,0.5,-0.5>, <0.01,1.5,0.5> pigment {pslide} photons {target refraction on reflection off collect off} translate -OBJ_DIST*x }