Welcome, Guest. Please login or register.

Author Topic: Raytracer Math Question  (Read 1459 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline JetRacerTopic starter

  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 501
    • Show only replies by JetRacer
Raytracer Math Question
« on: November 16, 2003, 12:00:17 PM »
When a raytracer inside/outside (object) test is performed, a positive or negative float is returned, right?

Is this float the exact distance between the surface and the ray?
*Zap! Zap!* Ha! Take that! *Kabooom!* Hey, that\'s not fair!
 

Offline Rogue

  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 566
    • Show only replies by Rogue
    • http://www.hyperion-entertainment.com
Re: Raytracer Math Question
« Reply #1 on: November 16, 2003, 12:20:20 PM »
Quote

JetRacer wrote:
When a raytracer inside/outside (object) test is performed, a positive or negative float is returned, right?

Is this float the exact distance between the surface and the ray?


I'm not sure I understand what you mean with inside/outside tests...

Most tests assume that the ray is given as

r = P + t*d

with P being the origin point of the ray (eye or previous intersection), d being the direction vector, and t being a parameter in the range [0..+inf]. Most intersection tests will return the t of the intersection. Thus you can calculate the point of intercept by replacing the returned t in the above equation.

Is that what you mean?
Look out, I\'ve got a gun
 

Offline JetRacerTopic starter

  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 501
    • Show only replies by JetRacer
Re: Raytracer Math Question
« Reply #2 on: November 16, 2003, 12:41:51 PM »
Sorry, I should have been more specific.

In the case of a native object, I shoot a ray and give it's coordinates (as distance equals object distance from camera) to the native formula which then return a float. This float is positive if the ray miss, or negative if ray hits.

Is this float reflecting distance; ray vs surface?

*Zap! Zap!* Ha! Take that! *Kabooom!* Hey, that\'s not fair!
 

Offline Rogue

  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 566
    • Show only replies by Rogue
    • http://www.hyperion-entertainment.com
Re: Raytracer Math Question
« Reply #3 on: November 16, 2003, 03:24:00 PM »
Quote

JetRacer wrote:
Sorry, I should have been more specific.

In the case of a native object, I shoot a ray and give it's coordinates (as distance equals object distance from camera) to the native formula which then return a float. This float is positive if the ray miss, or negative if ray hits.

Is this float reflecting distance; ray vs surface?



What do you mean with "native formula"? Can you give an example of the type of primitive and the formula you are using?
Look out, I\'ve got a gun
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16882
  • Country: gb
  • Thanked: 6 times
    • Show only replies by Karlos
Re: Raytracer Math Question
« Reply #4 on: November 17, 2003, 04:36:09 AM »
Quote

JetRacer wrote:
When a raytracer inside/outside (object) test is performed, a positive or negative float is returned, right?

Is this float the exact distance between the surface and the ray?


Are you saying that the value returned is the (scalar) distance of 'current' position along the ray, from the point on the surface that the ray intersects?

Thats the only logical way I can see that the value would have a different sign on different sides of the surface.
int p; // A