|
|
"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
|
|