POV-Ray : Newsgroups : povray.advanced-users : Modeling a diffuse object with photon mapping and a lens : Modeling a diffuse object with photon mapping and a lens Server Time
6 Oct 2024 12:45:26 EDT (-0400)
  Modeling a diffuse object with photon mapping and a lens  
From: anidonu
Date: 5 Jul 2006 15:30:00
Message: <web.44ac11f7db45e029947c79ba0@news.povray.org>
It's straightforward to model a light source  with a lens to form a real
image.  But is it possible to form an image of a diffuse object?
Comments are welcome on why this file does not do so.

/*  Makes a photon mapping scene with single or crossed cylindrical lenses

    The lens is formed from the intersection of a glass cylinder height
2*HCyl along the y-axis, with a plane parallel to its axis.
    The radius of the cylinder is RCyl.
    The refractive index of the glass is RefIndx
    The intersecting plane, parallel to the xy plane, is SCyl
    The lens stands on its end on a checkered plane
    A square array of distant lightsources is imaged by the lens to a focus
screen
    The screen position is animated
    A transparent 'slide' is in front of the lights array
*/

#include "colors.inc" #include "textures.inc"

global_settings {  assumed_gamma 2.2       max_trace_level 32
                   photons { count 1500000 max_trace_level 32 }
                }

#declare k = 0.5; //clock;

/*********************************************************************************************************/

/* Choose a single lens or a crossed pair in contact */
#declare Crossed = no;
#declare Crossed = yes;

/********************************************************************************************************/
/*Specify the lens setup*/

#declare RCyl = 200;
#declare SCyl = 192;
#declare RefIndx = 1.517;
#declare CapHght = RCyl - SCyl;
#declare HCyl = sqrt(RCyl*RCyl - SCyl*SCyl );


#declare PlanoCyl = intersection { cylinder { -y*HCyl, y*HCyl,RCyl}
                                   plane { z,SCyl inverse }
                                   material { texture { pigment { rgbt
<0.9,0.98,0.9,0.98> }
                                                        finish { ambient
0.02 diffuse 0.008 reflection 0.01 } }
                                              interior { ior RefIndx }
                                            }
                                 }

#declare BFL = RCyl/(RefIndx-1);

/************************* Setup the focus screen and a baffle */

#declare Screen = box { <-1,-1,0>,<1,1,0.1> scale 50 pigment { rgb 1 }
finish { ambient 0.02 diffuse 0.8} }
#declare ScrnPos = -z*(BFL+ 50*(2*k-1));

#declare Stop = intersection { box { <-200,-200,0>,<200,200,1> }
                               box { <-HCyl,-HCyl,-1>,<HCyl,HCyl,2> inverse
}
                               pigment { rgb 1 } finish { ambient 0 diffuse
0 reflection 0 }
                             }

/************************** Photon mapping lightsources
*******************************/

#switch ( Crossed)
  #case( yes) #declare LyteBryte = 0.0003*1e0; #break
  #case(no)   #declare LyteBryte = 0.003;  #break
#end

#declare Step = 2.5e2;
#declare I = -1e3;

#declare LiteMatrix = union { #while ( I<=1e3)
                                 #declare J = -1e3;
                                 #while ( J<=1e3)
                                    light_source { <I,J,15000>, color rgb
LyteBryte
                                                    photons {refraction on
reflection on}
                                                 }
                                    #declare J = J + Step;
                                 #end
                                 #declare I = I + Step;
                              #end
                            }


/**************************   The test object is a partially transparent
color_map ********************/


#declare Slide = box { <-1e3,-1e3,0>,<1e3,1e3,1e1>
                       pigment { gradient x color_map{ [0 rgbt<0,1,0,0.5> ]
                                                       [1 rgbt<1,0,1,0.5> ]
                                                     }
                                  translate -x*0.5
                                  scale 1e2
                               }
                        finish { ambient 0 diffuse 1.0 }
                     }

/*******************************  THe scene
******************************************/


// CamNum = 1 for an oblique downward look at scene
// CamNum = 2 for the camera 150mm infront of and looking at screen

#declare CamNum = 1;
#switch ( CamNum )
  #case(1) #declare CamPos = 1e3; #declare CamAng = 5; #break
  #case(2) #declare CamPos = ScrnPos+z*150; #declare CamAng = 55; #break
#end



#declare Projekta = union { object { PlanoCyl  translate -z*SCyl}
                            #if( Crossed = yes) object { PlanoCyl  rotate
z*90 translate -z*(SCyl+CapHght)} #end
                            object { LiteMatrix  translate z*15100 }


                            photons { target }
                          }

object { Slide translate z*15000 photons { target } }
object { Projekta }
object { Screen   translate ScrnPos  photons { target }}
object { Stop translate z*5}

background { rgb 0.5 }

camera { location  CamPos look_at  ScrnPos angle CamAng }


Post a reply to this message

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