Showing results for

- Intel Community
- Visual Computing (Graphics and Gaming)
- Intel® Embree Ray Tracing Kernels
- Barycentric coordinates u, v

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Highlighted
##

ritwik_d_

Beginner

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

08-03-2014
09:36 PM

66 Views

Barycentric coordinates u, v

Hi,

After intersecting a ray with a scene, what is the proper way to use the u, v coordinates to calculate the world coordinates (x, y, z) of the hit? I believe from the geomID and primID, I can identify the triangle which is hit and its corresponding v0, v1, v2. But now what do I do?

9 Replies

Highlighted
##

SvennW_Intel

Moderator

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

08-03-2014
11:39 PM

66 Views

Just calculate ray.org + ray.tfar * ray.dir to get the hit point in world coordinates.

Highlighted
##

sidenote: calculating it from uv coordinates is MUCH more precise and will drastically reduce amount of selfintersections from subsequent secondary rays.

Ondra_K_

Beginner

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

08-04-2014
01:58 AM

66 Views

Highlighted
##

I agree, the accuracy can be much higher when you use the u/v coordinates to calculate the hit point.You can do this the following way: Ph = (1.0f-ray.u-ray.v)*p0 + ray.u*p1 + ray.v*p2

SvennW_Intel

Moderator

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

08-04-2014
02:16 AM

66 Views

Highlighted
##

ritwik_d_

Beginner

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

08-04-2014
09:24 AM

66 Views

Hi Sven,

In your example p0, p1 and p2 are 3 vertices of the triangle right?

Another question: I am trying to iteratively shoot a ray until it escapes the triangle mesh. So basically what I am doing is, I will shoot a ray and if it hits a geometry I will shoot another ray from the hit in the same direction and I will keep doing this untill the ray does not hit anything. In this case, I am constructing a ray only once and at every iteration I am just changing the ray.tnear to the previous value of ray.tfar. Is this a good way to do this? or should I calculate the exact coordinates of the hit and then shoot the next ray?

Thanks

Highlighted
##

SvennW_Intel

Moderator

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

08-04-2014
11:10 AM

66 Views

Yes, these are the triangle vertices.

What you describe is one way of finding all hits along the ray. However, depending on your application, a more efficient way of doing this is to use the intersection filter feature of the newer Embree versions.

Highlighted
##

But even using intersection filter functions, I would still have to update the ray after every hit inside the filter function right? In that case should I use u,v coordinates or just update ray.tnear for the new ray? Which is a better way of doing it?

ritwik_d_

Beginner

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

08-04-2014
01:37 PM

66 Views

Highlighted
##

Inside the filter function you would only reject the hit by setting ray.geomID to -1. You would further put the hit into some list. However, you will gather the hits in some unspecified order.

SvennW_Intel

Moderator

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

08-04-2014
10:45 PM

66 Views

Highlighted
##

ritwik_d_

Beginner

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

08-05-2014
12:04 AM

66 Views

So that means I call rtcIntersect() only once and as long as I keep rejecting the hit, the ray keeps going through?

Also, once I call rtcSetIntersectionFilterFunction(), the filter function is set, after that how do I revert back to normal behaviour, i.e. how to I detach the callback filter function?

Highlighted
##

SvennW_Intel

Moderator

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

08-05-2014
12:23 AM

66 Views

Yes, you call rtcIntersect only once and get all hits reported.

Setting back the filter function can be done in two ways:

1) reset the filter function by using the rtcSetIntersectionFilterFunction call with NULL as filter function

2) or register one global wrapper filter function, which reads a function pointer out of the ray (you can extend the ray at the end with your own data) and call this function pointer if it is not NULL. This way the feature can essentially be enabled per ray.

For more complete information about compiler optimizations, see our Optimization Notice.