Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

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

    Cinema 4D SDK
    2
    5
    706
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • RenatoTR
      RenatoT
      last edited by Manuel

      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.

      1 Reply Last reply Reply Quote 0
      • ManuelM
        Manuel
        last edited by Manuel

        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.

        • Q&A New Functionality.
        • How to Post Questions especially the tagging part.

        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.

        MAXON SDK Specialist

        MAXON Registered Developer

        1 Reply Last reply Reply Quote 1
        • RenatoTR
          RenatoT
          last edited by RenatoT

          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.

          1 Reply Last reply Reply Quote 0
          • ManuelM
            Manuel
            last edited by Manuel

            hello,

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

            Cheers,
            Manuel

            MAXON SDK Specialist

            MAXON Registered Developer

            1 Reply Last reply Reply Quote 0
            • RenatoTR
              RenatoT
              last edited by RenatoT

              @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 🙂

              1 Reply Last reply Reply Quote 0
              • First post
                Last post