Retrieve the Surface Point of current RayObject from an arbitrary UV value.



  • Hi All,

    I have a particular need. I'm inside the Output() of my custom shader.
    I need to retrieve, from a particular UV (cd->p), the corresponding surface point of current RayObject. Maybe there is something that i don't know to do that while rendering is in progress.

    Thanks in advance :)
    Renato T.

    EDIT: I'm sorry, i meant from a particular UV not the current cd->p. So, inside the Output() would be great to ask for any UV value and get the surface coordinate.



  • Hello,

    For your next threads, please help us keeping things organised and clean. I know it's not your priority but it really simplify our work here.

    I've added the tags and marked this thread as a question so when you considered it as solved, please change the state :)

    Regarding your question, there's no "one solution".

    If you have the uvw position, you have to check every polygon if they are overlapping this uvw coordinates. Depending on how your uvs are done, you can have several polygons overlapping.

    For each polygons, you have to calculate the barycentric coordinate. Once you have this, you can retrieve the 3D coordinates. We have functions that can help you CalculateBarycentricCoordinate.
    This manual about Geometry Utility can be very helpful also (Barycentric Coordinates, Intersection, Points Inside etc.).

    The Output function is not the right place to do everything. You have probably to prepare a KDtree to help you to retrieve the polygon overlapping a uvw coordinate. This can be prepared in the InitRender function.

    I'm not sure what you are trying to do, but reacting for 3D position can be bad on the case of polygon having their UVs overlapping. (think about a cube where all faces have their uvs maximized and overlapping)

    Cheers,
    Manuel.



  • Hi Manuel,

    in the while I already made exactly what you said using the Hash2DGrid instead the KDTree.
    I just hoped to a something internal in Cinema already prepared without caching uvw structures in initrender.

    Thanks anyway
    Renato.

    Edit: Thanks for the links you provided.. but i already learned from that. Very useful of course.



  • hello,

    yes, sadly there no solution in the API for that, feel free to mark this thread as "solved" :)

    Cheers,
    Manuel



  • @m_magalhaes said in Retrieve the Surface Point of current RayObject from an arbitrary UV value.:

    feel free to mark this thread as "solved"

    how? :)

    Edit: Solved done :)