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
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    UVW coordinates in ShaderData.Output()

    Cinema 4D SDK
    r23 c++ python
    3
    12
    1.8k
    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.
    • rsodreR
      rsodre
      last edited by Manuel

      Hello,

      I need to access uvw coordinartes outside of the 0-1 boundary, in a ShaderData.
      In UV Edit mode, I scaled plane's uvw to go beyonx 1,1, but the coordinates passed to ShaderData.Output() always normalized to 1,1.

      How can I access the actual uvs I need?
      Maybe some trick on material tag?
      Some external renderers use this

      for UDIM textures, so it looks possible.

      My plugin is in C++ but, but I made a simple test plugin and it has the same issue...
      Py-ShaderUvw.pyp

      def Output(self, sh, cd):
      	c = c4d.Vector( cd.p.x, cd.p.y, 0 )
      	return c
      

      Here's how the UVW is setup, the viewport uvws are repeating...
      Screen Shot 2021-03-01 at 14.39.07.png

      Confirming that the UVW tag contains coordinates up to 2.0...
      Screen Shot 2021-03-01 at 14.11.17.png

      And the actual render is even stranger, it makes no sense...
      Screen Shot 2021-03-01 at 14.38.36.png

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

        hi,

        the V axis have been reverse in the UVs editor but not internally. So you have to introduce a 1-V operation.

        Float posX = cd->p.x;
        Float posY = 1 - cd->p.y;
        

        The same issue talked in this thread as you already pointed out

        Cheers,
        Manuel

        MAXON SDK Specialist

        MAXON Registered Developer

        rsodreR 1 Reply Last reply Reply Quote 0
        • rsodreR
          rsodre @Manuel
          last edited by rsodre

          @m_magalhaes Thank you, that works.
          It would be super useful to have this piece of information on the Output() reference.

          What about having the correct uvw on the viewport, is it possible?

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

            @rsodre said in UVW coordinates in ShaderData.Output():

            What about having the correct uvw on the viewport, is it possible?

            you mean the render ?

            MAXON SDK Specialist

            MAXON Registered Developer

            rsodreR 1 Reply Last reply Reply Quote 0
            • rsodreR
              rsodre @Manuel
              last edited by

              @m_magalhaes Difference between the viewport uvs and render uvs.

              This is the render, it is correct now, with uvs from 0..2:
              Screen Shot 2021-03-04 at 16.45.59.png

              But the material rendered at viewport does has normalized uvs (0...1):
              Screen Shot 2021-03-04 at 16.46.24.png

              1 Reply Last reply Reply Quote 0
              • M
                mp5gosu
                last edited by

                As far as I remember, Viewport drawing is handled in Draw() method.

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

                  hi,

                  I've opened a bug report for that.
                  The viewport should reflect as mush as we can the final render.

                  Cheers,
                  Manuel

                  MAXON SDK Specialist

                  MAXON Registered Developer

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

                    hi,

                    the Shader is limited to 0,1 uvs space in the viewport.
                    That's exactly what you can see for example with the noise shader. Except this shader have a special mode (HQ noise) so they can be displayed properly.
                    You can also see that with the brick shader. (HQ Noise doesn't help in that case)

                    Cheers,
                    Manuel

                    MAXON SDK Specialist

                    MAXON Registered Developer

                    rsodreR 1 Reply Last reply Reply Quote 0
                    • rsodreR
                      rsodre @Manuel
                      last edited by

                      @m_magalhaes Ok, is it going to be fixed on the bug report or is that a limitation we have to live with?

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

                        hi,

                        the bug report have been defined as a limitation.
                        It doesn't mean that it will never be fixed, but not now.

                        Cheers,
                        Manuel

                        MAXON SDK Specialist

                        MAXON Registered Developer

                        1 Reply Last reply Reply Quote 0
                        • M
                          mp5gosu
                          last edited by mp5gosu

                          And I'm still convinced that I had the same problem a while ago and managed to draw a custom preview via Draw() method. (There should be a BL entry)
                          But still, I don't know if I remember right.

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

                            hi,

                            I don't see how we could do it with the Draw Method in a efficient way.

                            Cheers,
                            Manuel

                            MAXON SDK Specialist

                            MAXON Registered Developer

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