POV-Ray : Newsgroups : povray.advanced-users : trace macro misunderstanding ? Server Time
23 Dec 2024 18:00:09 EST (-0500)
  trace macro misunderstanding ? (Message 1 to 4 of 4)  
From: fdecomite
Subject: trace macro misunderstanding ?
Date: 8 Oct 2009 09:05:01
Message: <web.4acde30d7ae8ca664f4c73fb0@news.povray.org>
I would like to find when and where a ray hits a specified object.
The hit could take place after one or more reflections on other objects.
I thought the trace macro would help, but it seems that trace() pays no
attention to auxiliary objects, finding the way of the ray in straight line....
Am i missing something ?


Post a reply to this message

From: Mike Williams
Subject: Re: trace macro misunderstanding ?
Date: 8 Oct 2009 10:01:58
Message: <eKYl8FCU8ezKFwpr@econym.demon.co.uk>
Wasn't it fdecomite who wrote:
>I would like to find when and where a ray hits a specified object.
>The hit could take place after one or more reflections on other objects.
>I thought the trace macro would help, but it seems that trace() pays no
>attention to auxiliary objects, finding the way of the ray in straight line....
>Am i missing something ?

Trace() only considers one object. To follow the reflections you'd have 
to trace every possible reflective, refractive or transparent object and 
see which one gets hit first, then use the normal value you get back 
from trace() to work out where the ray bounces to after that.

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

From: Tim Attwood
Subject: Re: trace macro misunderstanding ?
Date: 9 Oct 2009 00:08:07
Message: <4aceb727$1@news.povray.org>
>I would like to find when and where a ray hits a specified object.
> The hit could take place after one or more reflections on other objects.
> I thought the trace macro would help, but it seems that trace() pays no
> attention to auxiliary objects, finding the way of the ray in straight 
> line....

I think the better question would be why? What are you trying to do?
When is a tricky question, do you mean the frame number of an
animation? Do you mean how many reflective bounces will
be checked?  Do you mean distance?

> Am i missing something ?

It seems so.
A ray is half of a line, it starts at some point in space and
travels (or is "cast") in some direction.
Trace() calculates the nearest intersection between a ray and
a given object (if it hits it) and returns the location and surface
normal at that point.
Rays do not reflect... in the rendering process new rays are
cast from the intersection point, a ray is cast at every light,
and a ray is cast in the reflection direction if the surface is reflective.

Given a ray R1, (with a starting point P1, and a direction DIR1) ,
and an object O1 then

#declare NORM = <0,0,0>;
#declare HIT = trace(O1,P1,DIR1,NORM);

will return HIT and NORM vectors, if the length of the NORM
vector is zero, then there is no intersection of the ray R1 with
object O1, otherwise HIT contains the intersection point, and
NORM contains the surface normal of O1 at the intersection
point.

So to create a ray R2 which is a reflection of ray R1 at HIT,
you start at the location P2 and travel in the direction DIR2,
where
P2 = HIT
DIR2 = -vaxis_rotate(DIR1,NORM,180)

Rinse and repeat for every object of intrest and every bounce.


Post a reply to this message

From: fdecomite
Subject: Re: trace macro misunderstanding ?
Date: 9 Oct 2009 03:40:00
Message: <web.4acee7ad6e5003f14f4c73fb0@news.povray.org>
Thanks Tim,
I think I understand it now.
Still working on my project and come back with full realization soon (I hope so
!)

Francesco


Post a reply to this message

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