POV-Ray : Newsgroups : povray.newusers : trace pixels to object they represent in scenes involving reflections Server Time
27 Jul 2024 18:29:29 EDT (-0400)
  trace pixels to object they represent in scenes involving reflections (Message 1 to 4 of 4)  
From: mirrorguy
Subject: trace pixels to object they represent in scenes involving reflections
Date: 26 Jul 2024 15:25:00
Message: <web.66a3f6ebf52e949b689a3d2ec2594d66@news.povray.org>
hello all. I have an application where I would like to render scenes involving
multiple mirrors and I would like to be able to trace which object is
represented by a given pixel or region of pixels in a rendered image and if
possible get some kind of backtrace of mirrored surfaces the raytracer
encountered while rendering the pixel(s).

Is there a way to do this and if so where would I look to find out how? Thanks.


Post a reply to this message

From: Alain Martel
Subject: Re: trace pixels to object they represent in scenes involving reflections
Date: 27 Jul 2024 14:02:07
Message: <66a5361f$1@news.povray.org>
Le 2024-07-26 à 15:20, mirrorguy a écrit :
> hello all. I have an application where I would like to render scenes involving
> multiple mirrors and I would like to be able to trace which object is
> represented by a given pixel or region of pixels in a rendered image and if
> possible get some kind of backtrace of mirrored surfaces the raytracer
> encountered while rendering the pixel(s).
> 
> Is there a way to do this and if so where would I look to find out how? Thanks.
> 
> 
For the back trace, you should use photon mapping.
Place a light at the camera location.
Make the mirrors that you can see directly as target.
Making mirrors that you can't see directly as target only make the 
photons mapping take longer as photons will get shot at them but get 
intercepted on the way.
Now, move the camera up to get a plunging view.
Render.

To make an object a target, add this in it's description :
photons{target 1} //This allow photons to get shot at the object

To turn photon mapping, add this in the global_settings block :
(minimal)
photons{spacing 0.1}// set to 10 photons per linear unit
// 100 per square unit
// feel free to increase if needed.

You may use count instead of spacing, but, with multiple targets, the 
required value often get frighteningly large.

By default, ALL light will shoot photons at all target objects.
This can be turned off with this in the light's definition :
photons{reflection off refraction off}// default is both ON

You may want your light and reflections to go farther than the default 
of 5 surfaces. For that, add this to the global_settings :
max_trace_level 10 // allow a ray to interact with 10 surfaces
// may get up to 255

You may want to give the ground a finish with «brilliance 0» so that the 
light from a light set low to the ground will fully illuminate is from 
far away.

The illumination of the ground will show the path from the camera 
through the mirrors and the final destination.
The object, or parts of objects, illuminated will show you what the 
camera actually see.


Post a reply to this message

From: Bald Eagle
Subject: Re: trace pixels to object they represent in scenes involving reflections
Date: 27 Jul 2024 15:10:00
Message: <web.66a545599a10a2d61f9dae3025979125@news.povray.org>
Alain Martel <kua### [at] videotronca> wrote:

> The illumination of the ground will show the path from the camera
> through the mirrors and the final destination.
> The object, or parts of objects, illuminated will show you what the
> camera actually see.


:O   Really?
We can do that?

Can you make a simple scene with 2 mirrors and a box showing this?

- BW


Post a reply to this message

From: Bald Eagle
Subject: Re: trace pixels to object they represent in scenes involving reflections
Date: 27 Jul 2024 17:10:00
Message: <web.66a561789a10a2d61f9dae3025979125@news.povray.org>
"mirrorguy" <nomail@nomail> wrote:
> hello all. I have an application where I would like to render scenes involving
> multiple mirrors and I would like to be able to trace which object is
> represented by a given pixel or region of pixels in a rendered image and if
> possible get some kind of backtrace of mirrored surfaces the raytracer
> encountered while rendering the pixel(s).
>
> Is there a way to do this and if so where would I look to find out how? Thanks.

So, it sounds to me like you want to look at the trace () function.

https://wiki.povray.org/content/Reference:Vector_Expressions#Functions

trace(OBJECT_IDENTIFIER, A, B, [VECTOR_IDENTIFIER]). trace helps you finding the
exact location of a ray intersecting with an object's surface. It traces a ray
beginning at the point A in the direction specified by the vector B. If the ray
hits the specified object, this function returns the coordinate where the ray
intersected the object. If not, it returns <0,0,0>. If a fourth parameter in the
form of a vector identifier is provided, the normal of the object at the
intersection point (not including any normal perturbations due to textures) is
stored into that vector. If no intersection was found, the normal vector is
reset to <0,0,0>.

Note: Checking the normal vector for <0,0,0> is the only reliable way to
determine whether an intersection has actually occurred, intersections can and
do occur anywhere, including at <0,0,0>.

Example:

#declare MySphere = sphere { <0, 0, 0>, 1 }
#declare Norm = <0, 0, 0>;
#declare Start = <1, 1, 1>;
#declare Inter=
trace ( MySphere, Start, <0, 0, 0>-Start, Norm );

object {
  MySphere
  texture {
    pigment { rgb 1}
    }
  }

#if (vlength(Norm)!=0)
cylinder {
  Inter, Inter+Norm, .1
  texture {
    pigment {color red 1}
    }
  }
#end



What you may have to do is write a scene where you simulate the entire backward
raytracing process, and have an array of reflecting objects that you check with
the trace() function and if you get a hit, store that in a 1D array.
Daisy-chain your way into the scene until you either hit some sort of background
object, or a reflected object.  Store that 1D array of objects reflected off of
into a 2D array with indices of the x, y screen coordinates.
Then move on to the next pixel.
Then you can write the array to a text file, and maybe place a 1-pixel cube at
that point, with a color code or something.
You might also be able to do something with a spline and use that as a function
in a pigment{} statement to texture a plane....   details for later.

What you might do is put all of your mirrors into a union {} and use that as
your initial trace() target, and if it gets hit, then you can use the
intersection point to cycle through your array of objects and do an inside ()
test on each of them until you get a hit.

https://wiki.povray.org/content/Reference:Numeric_Expressions#Functions

inside(O,V)
It returns either 0.0, when the vector V is outside the object, specified by the
object-identifier O, or 1.0 if it is inside.



Very interesting idea, and it may be slow, but if you decide to implement it, I
can offer advice and guidance - I'm interested in seeing this work.

- Bill

Note: The inside keyword does not accept object-identifiers to non-solid
objects.


Post a reply to this message

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