Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

Thread: ray/triangle intersection + uv calculation

  1. #1
    Junior Member Regular Contributor
    Join Date
    Jan 2002
    Location
    France
    Posts
    134

    ray/triangle intersection + uv calculation

    Hello,

    What is the most direct way to intersect a ray with a triangle and compute the associated uv coordinates at this point ?

    (something less consuming than matrix operations if possible)

  2. #2
    Junior Member Newbie
    Join Date
    Aug 2005
    Posts
    4

    Re: ray/triangle intersection + uv calculation

    Google a little about barycentric coordinate and I think that you can find all you want about this.

  3. #3
    Junior Member Newbie
    Join Date
    Aug 2005
    Posts
    4

    Re: ray/triangle intersection + uv calculation

    Or more simple (but not really more speed) if you have already your proper algorithm for to find the point of intersection (say P) of a triangle ABC and a line from P0 to P1 ...

    First, you compute distances from P to A, B and C:

    dA = distance from A to P
    dB = distance from B to P
    dC = distance from C to B

    sum = dA + dB + dC
    coefA = dA / sum
    coefB = dB / sum
    coefC = dC / sum

    So, the texture coordinate at point P is :

    uP = uA * coefA + uB * coefB + uC * coefC
    vP = vA * coefA + vB * coefB + vC * coefC

    Note too that you can apply this to alls points P into the triangle ABC and to be applied to another style of coordinates such as color componants for example ...

  4. #4
    Junior Member Regular Contributor
    Join Date
    Jan 2002
    Location
    France
    Posts
    134

    Re: ray/triangle intersection + uv calculation

    Thanks !
    I first calculated my own barycentric formulas, however it requires far more operations than yours. But yours involve square roots operation, so.. Well I have to give it a try

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •