POV-Ray : Newsgroups : povray.general : Seeing the Light : Re: Seeing the Light Server Time
2 Aug 2024 20:22:06 EDT (-0400)
  Re: Seeing the Light  
From: Chris B
Date: 4 Aug 2004 19:13:07
Message: <41116d83$1@news.povray.org>
"Rick Measham" <nomail@nomail> wrote in message
news:web.4110918616c0096978d4ef100@news.povray.org...
> The ceiling in my office is white.. snip .. when I turn the light on and I
look
> directly at the light, the ceiling looks dark. .. snip .. In POV-Ray, is
it possible to automate this?
>

Well you can cheat   :o)

The following scene tests whether the light source is in shot and, if it is,
it wraps the light in a bright and slightly translucent sphere, making the
sphere visible and blocking out most of the light. To test whether the light
is in shot it defines a box that exactly fills the screen and traces a line
from the light source to the camera.
If the line intersects the box, the light is in shot. (If you use up or
right vectors in your camera statement you'll need to change the size of the
box accordingly)

Any good?


#declare lookAt=<0,7.5,10>;   // Centre of light is just in shot
//#declare lookAt=<0,7.6,10>; // Centre of light is just out of shot
#declare cameraPos=<0,0,-5>;
#declare lightLocation=<0,0,0>;

camera {location cameraPos look_at lookAt}
light_source { lightLocation color rgb <1, 1, 1>}
sphere { 0, 10 pigment { radial frequency 80}}


#include"transforms.inc"

// Create a screen object 1 unit from the camera
// centred on the centre of the image
#declare screenObject = object{
  box {<-0.677,-0.5,0><0.677,0.5,0.001>}
  #declare orientationVector = lookAt-cameraPos;
  Reorient_Trans(z,<orientationVector.x,0,orientationVector.z>)

Reorient_Trans(<orientationVector.x,0,orientationVector.z>,orientationVector
)
  translate cameraPos+vnormalize(lookAt-cameraPos)
}

// Trace a ray through the camera and the light
// to see if it hits the screen object
#declare hitNormal = <0,0,0>;
#declare hitLocation =
trace(screenObject,lightLocation,cameraPos-lightLocation,hitNormal);

// if the ray hit the 'screen' (in front of the camera), the light is in
shot
#if (vlength(vnormalize(hitLocation-cameraPos) -
vnormalize(lightLocation-cameraPos)) = 0
   & vlength(hitNormal)!=0)
  // So add a sphere to block the light
  sphere {
    lightLocation, 0.1
    pigment { color rgb <5,5,5,0.04> }
  }
#end

Have fun,
Chris.


Post a reply to this message

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