POV-Ray : Newsgroups : povray.advanced-users : Modeling a diffuse object with photon mapping and a lens Server Time
1 Nov 2024 09:22:43 EDT (-0400)
  Modeling a diffuse object with photon mapping and a lens (Message 1 to 5 of 5)  
From: anidonu
Subject: Modeling a diffuse object with photon mapping and a lens
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

From: Alain
Subject: Re: Modeling a diffuse object with photon mapping and a lens
Date: 6 Jul 2006 13:25:29
Message: <44ad4789$1@news.povray.org>
anidonu nous apporta ses lumieres en ce 05/07/2006 15:24:
> 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 }
>                              }
Beter to use difference than intersection and inverse, it's clearer.
> 
> /************************** 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}
Would be beter to use a merge here to remove internal surfaces.
>                             #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 }
This is you lense, it MUST have photons{target refracion on}, otherwize, you don't
shoot any photon 
at it.
> object { Screen   translate ScrnPos  photons { target }}
This the screen on whitch you project the photons, it DON'T need a photons block. You
don't shoot 
photons at it, it collect them and make them visible.
> object { Stop translate z*5}
> 
> background { rgb 0.5 }
> 
> camera { location  CamPos look_at  ScrnPos angle CamAng }
> 
> 
> 
> 
> 
The light_source are to close to the slide: Put them back by about 10 times or make
them parallel.

-- 
Alain
-------------------------------------------------
Beam me up Scotty. This isn't the men's room.


Post a reply to this message

From: Alain
Subject: Re: Modeling a diffuse object with photon mapping and a lens
Date: 7 Jul 2006 18:24:56
Message: <44aedf38$1@news.povray.org>
Alain nous apporta ses lumieres en ce 06/07/2006 13:24:
After further testing, and remembering another post, I came up with another solution:
1 - Remove all photons from the scene.
2 - Remove all lights.
3 - Give your slide a high ambient like finish{ambient 5} and remove the transmit.
4 - Add this in the global_settings: radiosity{count 150}
You may also use a spot light that illuminate the slide from it's front, or a light at
the back and 
use double_illuminate for the slide.

Note: two crossed plano-cylindrical lences are not good at generating an image, beter
to use a 
plano-spherical one.

-- 
Alain
-------------------------------------------------
WARNING: The consumption of alcohol may lead you to think people are laughing WITH
you.


Post a reply to this message

From: anidonu
Subject: Re: Modeling a diffuse object with photon mapping and a lens
Date: 8 Jul 2006 10:20:00
Message: <web.44afbca77bb1cecf947c79ba0@news.povray.org>
Alain,

I used cylindrical lenses just for amusement.  You may care to visit my
web-site 'donzoptix.co.uk' to see some of my work with complex optical
systems, including multi-element zooming lenses and aspherical surfaces.

So....have you actually created with a lens an image of a glowing slide,
using double-illuminate and radiosity?

Alain <ele### [at] netscapenet> wrote:
> Alain nous apporta ses lumieres en ce 06/07/2006 13:24:
> After further testing, and remembering another post, I came up with another
solution:
> 1 - Remove all photons from the scene.
> 2 - Remove all lights.
> 3 - Give your slide a high ambient like finish{ambient 5} and remove the transmit.
> 4 - Add this in the global_settings: radiosity{count 150}
> You may also use a spot light that illuminate the slide from it's front, or a light
at the back and
> use double_illuminate for the slide.
>
> Note: two crossed plano-cylindrical lences are not good at generating an image,
beter to use a
> plano-spherical one.
>
> --
> Alain
> -------------------------------------------------
> WARNING: The consumption of alcohol may lead you to think people are laughing WITH
you.


Post a reply to this message

From: Alain
Subject: Re: Modeling a diffuse object with photon mapping and a lens
Date: 8 Jul 2006 16:19:21
Message: <44b01349@news.povray.org>
anidonu nous apporta ses lumieres en ce 08/07/2006 10:15:
> Alain,
> 
> I used cylindrical lenses just for amusement.  You may care to visit my
> web-site 'donzoptix.co.uk' to see some of my work with complex optical
> systems, including multi-element zooming lenses and aspherical surfaces.
> 
> So....have you actually created with a lens an image of a glowing slide,
> using double-illuminate and radiosity?
> 
> Alain <ele### [at] netscapenet> wrote:
>> Alain nous apporta ses lumieres en ce 06/07/2006 13:24:
>> After further testing, and remembering another post, I came up with another
solution:
>> 1 - Remove all photons from the scene.
>> 2 - Remove all lights.
>> 3 - Give your slide a high ambient like finish{ambient 5} and remove the transmit.
>> 4 - Add this in the global_settings: radiosity{count 150}
>> You may also use a spot light that illuminate the slide from it's front, or a light
at the back and
>> use double_illuminate for the slide.
>>
>> Note: two crossed plano-cylindrical lences are not good at generating an image,
beter to use a
>> plano-spherical one.
>>
>> --
>> Alain
>> -------------------------------------------------
>> WARNING: The consumption of alcohol may lead you to think people are laughing WITH
you.
> 
> 
> 
> 
>

Kind of.
My radiosity settings are:
radiosity{count 1600 pretrace_start 0.04 pretrace_end 0.005 low_error_factor 0.2
nearest_count 10}
Slide set with ambient 1500. Slightly altered colour_map: whider coloured areas
separated by narow 
black strips. Circular lense.
Still prety fuzzy. Also, some strange colour changes as the screen moves away, one
frame is mostly 
green, the next is magenta.

In my current tests, I don't use any light, only radiosity and high ambient for the
slide.

-- 
Alain
-------------------------------------------------
No matter how much you do, you never do enough.


Post a reply to this message

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