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

    Combine UV and worldposition while shader rendering

    Cinema 4D SDK
    python
    3
    4
    780
    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.
    • P
      pyr
      last edited by pyr

      I have a shader with a UV based texture and a 3d gradient in it the shader effector works as espected but i have no idea how to relicate this behavior with a python effector / python plugin

      I builded a simple example scene to show what i need to do: uvSpaces.c4d

      The shader effector works as desired but i need this behavior into one of my plugins.

      The Python effector use the same technique as my plugin does and I also add a toggle for uv and worldspace

      Shader Effector:
      shader.JPG
      Python Effector:
      python.JPG

      1 Reply Last reply Reply Quote 0
      • ferdinandF
        ferdinand
        last edited by ferdinand

        Hi,

        the short answer is: You cannot do that in Python. The long answer is:

        1. The first problem is with your file is that the (somewhat misnamed) shader effector is actually a material (tag) effector, i.e. it samples a material channel based on a material tag (which can apply transforms to the shader sampling). You are completely ignoring that in your Python effector.
        2. The second problem is that the shader effector does sample in the uvw space of the object the material tag is assigned to, while your code does sample in the uvw space of the mograph particle array.
        3. The third and crucial problem is that even when you would compensate for all that, by making up the correct uvw coordinates for each particle on your own, you would not be able to sample a shader correctly.
          To sample a volumetric shader, e.g. a "3D-Gradient", the VolumeData of the ChannelData passed to BaseShader.Sample would have to be populated. Or more specifically the BaseVolumeData.p attribute has to be populated with the sample position in object space. The attribute ChannelData,p you are writing to, is intrinsically being interpreted as a two dimensional texture space coordinate. The problem is: You cannot instantiate VolumeData in Python, so there is no way to do that.

        Cheers,
        zipit

        MAXON SDK Specialist
        developers.maxon.net

        1 Reply Last reply Reply Quote 1
        • P
          pyr
          last edited by

          Ok - than i need to use fields for 3d gradients and other scene based stuff. Thank you for the explantation.

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

            hi,

            I had a look but as @zipit said, there's not way in python.

            Cheers,
            Manuel

            MAXON SDK Specialist

            MAXON Registered Developer

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