Jump to content


How to determine which triangles are in shadow ?


8 replies to this topic

#1 broli86

    Member

  • Members
  • PipPip
  • 81 posts

Posted 15 April 2008 - 05:38 PM

What is the usual method ? btw I'm forward tracing so I actually need to determine if the triangle that the ray from source has hit is visible to the receiver or not. please help

#2 Reedbeta

    DevMaster Staff

  • Administrators
  • 4782 posts
  • LocationBellevue, WA

Posted 15 April 2008 - 05:53 PM

Google for shadow rays. In your case you'll send a ray from the hit point to the receiver rather than to a light source but it's the same technique.
reedbeta.com - developer blog, OpenGL demos, and other projects

#3 broli86

    Member

  • Members
  • PipPip
  • 81 posts

Posted 15 April 2008 - 06:40 PM

Reedbeta said:

Google for shadow rays. In your case you'll send a ray from the hit point to the receiver rather than to a light source but it's the same technique.

yeah, i understand but i have a slight problem with that. do you check the shadow ray against all triangles ? What if the itnersection point is on one side of an object and the receiver is on the other side in such a way that there is nothing but object material in between them. Now how will the shadow ray technique work ? Here the shadow ray will be occluded by object at the intersection point itself. Also, the shadow ray would definetely pass through the intersection point in all situations ? How to differentiate between all these situations ? I have also thought of taking the dot product of ray direction with the normal of triangle to determine a reflection coefficient. IF the reflection coefficient is below some tolerance, consider that triangle to be in shadow.

#4 Reedbeta

    DevMaster Staff

  • Administrators
  • 4782 posts
  • LocationBellevue, WA

Posted 15 April 2008 - 07:06 PM

Usually you move the origin of the shadow ray away from the hit point in the direction of the surface normal (on the side facing the primary ray source). That helps avoid self-intersections when you don't want them and ensure you do get self-intersections when you do want them. Yes, you do check the shadow ray against all triangles.

Quote

I have also thought of taking the dot product of ray direction with the normal of triangle to determine a reflection coefficient. IF the reflection coefficient is below some tolerance, consider that triangle to be in shadow.

That sounds like just plain old diffuse lighting. It will make triangles dark when they face away from the light source, but that is not the same thing as actually casting shadows.
reedbeta.com - developer blog, OpenGL demos, and other projects

#5 broli86

    Member

  • Members
  • PipPip
  • 81 posts

Posted 16 April 2008 - 03:32 AM

Reedbeta said:

Usually you move the origin of the shadow ray away from the hit point in the direction of the surface normal (on the side facing the primary ray source). That helps avoid self-intersections when you don't want them and ensure you do get self-intersections when you do want them. Yes, you do check the shadow ray against all triangles.



That sounds like just plain old diffuse lighting. It will make triangles dark when they face away from the light source, but that is not the same thing as actually casting shadows.

by how much distance do you think one should shift the origin of shadow ray ?
I presume it must be quite small.

#6 Reedbeta

    DevMaster Staff

  • Administrators
  • 4782 posts
  • LocationBellevue, WA

Posted 16 April 2008 - 03:53 AM

Yes, I usually use about 0.0001, assuming the objects in the scene have a scale of approximately 1 unit. However the size of the shift sometimes must be tweaked for the particular scene.
reedbeta.com - developer blog, OpenGL demos, and other projects

#7 broli86

    Member

  • Members
  • PipPip
  • 81 posts

Posted 16 April 2008 - 04:15 AM

Reedbeta said:

Yes, I usually use about 0.0001, assuming the objects in the scene have a scale of approximately 1 unit. However the size of the shift sometimes must be tweaked for the particular scene.

How about using some backface culling ? We can find the set of triangles which are visible to both the source as well as receiver and consider only those set of triangles for all ray tracing operations ? Since I'm doing radar wave propogation I'm thinking of precalculating a huge number of uniformly distributed random points on a triangle and then calculating the direction vectors of rays based on these points and the source location. Is this a good idea in your opinion ?

#8 Reedbeta

    DevMaster Staff

  • Administrators
  • 4782 posts
  • LocationBellevue, WA

Posted 16 April 2008 - 07:36 AM

If all objects in the scene are closed meshes, then intersecting rays only with triangles that face the ray (so dot(triangle normal, ray direction) < 0) would probably work; at least, I can't think of a situation off the top of my head where it wouldn't. The offset is a proven technique, though.

BTW, can you really simulate radar accurately using ray-tracing? Doesn't radar operate at a low enough frequency that you need to take into account the wave nature of the signal, and effects like diffraction and polarization?
reedbeta.com - developer blog, OpenGL demos, and other projects

#9 broli86

    Member

  • Members
  • PipPip
  • 81 posts

Posted 16 April 2008 - 02:16 PM

Reedbeta said:

If all objects in the scene are closed meshes, then intersecting rays only with triangles that face the ray (so dot(triangle normal, ray direction) < 0) would probably work; at least, I can't think of a situation off the top of my head where it wouldn't. The offset is a proven technique, though.

BTW, can you really simulate radar accurately using ray-tracing? Doesn't radar operate at a low enough frequency that you need to take into account the wave nature of the signal, and effects like diffraction and polarization?

The radars which are used for analysis in stealth detection etc are very high frequency waves. But yes, I do need to take care of diffraction in my project as well. I have heard its possible to do it using Geometrical theory of diffraction which allows you to ray trace diffraction as well as creeping rays (rays which run along curved surface before leaving the target).

For calculating rays, what I did is calculate a minimal bounding sphere for an object and then using speherical coordinates, I calculated many points on the sphere. I remove those points on sphere which are not facing the source using the culling technique. These points are also facing the back side of the object so no point in dealing with them. What I get after this is a set of points on the sphere which are facing the source. These points also represent the side of the object which is facing the source. I use these points and the location of source to calculate my direction points. This is how the radars usually transmit the rays, focusing on the object to be detected rather than shooting in all directions like a spherical radiator.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users