Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python 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
    • Recent
    • Tags
    • Users
    • Login

    Shader plugin - polygons

    Scheduled Pinned Locked Moved PYTHON Development
    9 Posts 0 Posters 655 Views
    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.
    • H Offline
      Helper
      last edited by

      On 15/01/2015 at 06:28, xxxxxxxx wrote:

      I read that a shader plugin calculates the output for each visible point.

      Now, what if I want to perform the output on polygons.
      For example, put (render) a given texture on every polygon?

      Can I read polygon data inside the shader?

      Or should I use uvw data? 
      If so, how to read the uvw data in the shader?

      -Pim

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        On 15/01/2015 at 07:28, xxxxxxxx wrote:

        Hello,

        what do you mean with "perform the output on polygons"? A shader is used to shade visible fragments.

        To vary for each polygon of an object you would need to know the polygon index. Currently both RayObject [URL-REMOVED]and RayHitID[URL-REMOVED] are not supported in the Python implementation, so this may not be possible in Python.

        The UVW data for the given fragment is stored in the "uvw[URL-REMOVED]" element of the VolumeData[URL-REMOVED] member of   the given ChannelData[URL-REMOVED] structure.

        best wishes,
        Sebastian


        [URL-REMOVED] @maxon: This section contained a non-resolving link which has been removed.

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          On 15/01/2015 at 08:16, xxxxxxxx wrote:

          Originally posted by xxxxxxxx

          what do you mean with "perform the output on polygons"?

          What I mean is for example to put (render) a given texture on every polygon?

          So, I need to use raycollision to determine in which polygon the current point is?

          When you use a selection, the shader seems to know that (and thus the polygon)?

          -Pim

          1 Reply Last reply Reply Quote 0
          • H Offline
            Helper
            last edited by

            On 16/01/2015 at 09:36, xxxxxxxx wrote:

            Hello,

            as said before, a Shader works on fragment level, it shades a (part of a) surface, not a whole polygon. If you want to apply a texture you can use the given UV-coordinates to sample the texture and apply the color to the current fragment.

            When ShaderData.Output[URL-REMOVED] is called you are already inside the render process. The "current point" is described by the data found in BaseVolumeData[URL-REMOVED]. Since a shader may be called many times during the render process, ShaderData.Output should be as fast as possible. So GeRayCollider should not be used.

            The desired information you need is only available in the C++ SDK by accessing the surface identity[URL-REMOVED] of the BaseVolumeData[URL-REMOVED].

            In Cinema 4D selections are typically not assigned to shaders but to materials.

            best wishes,
            Sebastian


            [URL-REMOVED] @maxon: This section contained a non-resolving link which has been removed.

            1 Reply Last reply Reply Quote 0
            • H Offline
              Helper
              last edited by

              On 17/01/2015 at 07:32, xxxxxxxx wrote:

              Thanks for the explanation.
              I indeed mixed up shaders and textures / materials. Only textures / materials have selections.

              What I want to do is to scale a texture inside every polygon. Thus the texture is shown and fits in every polygon.
              I can do it with Mograph and a python effector, but I was wondering if I can do it in another way (shader, material, ...)?

              -Pim

              1 Reply Last reply Reply Quote 0
              • H Offline
                Helper
                last edited by

                On 19/01/2015 at 01:16, xxxxxxxx wrote:

                Hello,

                could you tell us how you can do it using a python effector?

                best wishes,
                Sebastian

                1 Reply Last reply Reply Quote 0
                • H Offline
                  Helper
                  last edited by

                  On 19/01/2015 at 02:27, xxxxxxxx wrote:

                  Using a mograph cloner, I put clones on the polygon center of an object.
                  With a python effector I calculate the surface area (the size) of each polygon and set the size of the clone accordingly. I offset the clone a little and put a texture on it.
                  This way I get the texture on all polygones sized to the sizeof the polygon.

                  I will make a short tutorial for this python effector on my blog.

                  Initially I thought this was best done using a shader, but based on your answer this is not so easy.
                  That is why I used this "workaround" .

                  -Pim

                  1 Reply Last reply Reply Quote 0
                  • H Offline
                    Helper
                    last edited by

                    On 19/01/2015 at 05:19, xxxxxxxx wrote:

                    Instead of a workaround using MoGraph and a PolysizeEffector, you could simply set the Projection of your texture to UVW Mapping, and do a Max UV on all the UV Polygons.
                    "This scales each selected UV polygon to fit the texture. On the mapped object, each selected polygon will display the entire texture."

                    https://dl.dropboxusercontent.com/u/37341180/douwe-max-uv.c4d

                    1 Reply Last reply Reply Quote 0
                    • H Offline
                      Helper
                      last edited by

                      On 19/01/2015 at 06:27, xxxxxxxx wrote:

                      Thanks, brilliant solution.
                      By the way, parts of the polygon effector I created are based on your D-Polysize Effector.

                      -Pim

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