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

    Pass-Through MaterialData Plugin

    SDK Help
    0
    3
    333
    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
      Helper
      last edited by

      On 25/07/2014 at 14:54, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:   15 
      Platform:   Windows  ;   
      Language(s) :     C++  ;

      ---------
      Hi there,

      I want to create a material that has some options and can be dragged onto objects. C4D evaluates materials from right to left, so if multiple materials are used I would have to select an appropriate blend mode, right? I would like my material to do absolutely nothing, just a complete pass-through for all channels/shaders/options/etc. It should behave like it is actually not there at all, so that the user does not have to select blend modes and such things. You could see this material more like a tag, but it feels like a material for the user.

      What functions do I have to override or is this not even necessary at all? If I have to override functions like CalcSurface, what do they have to do? Simply copy the content from source to destination? In an ideal case my material should not use any resources.

      Thanks a lot. By the way, this forum is great and has very short response times. Have a nice day! 🙂

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

        On 29/07/2014 at 01:09, xxxxxxxx wrote:

        Ok, I got something:

        MyMaterial overrides the following functions:

        VOLUMEINFO MyMaterial::GetRenderInfo(BaseMaterial* mat)
        {
        	return VOLUMEINFO_ALPHA;
        }
          
        void MyMaterial::CalcSurface(BaseMaterial* mat, VolumeData* vd)
        {
        	vd->col = Vector(0.0f, 1.0f, 0.0f);
        }
          
        void MyMaterial::CalcAlpha(BaseMaterial* mat, VolumeData* vd)
        {
        	vd->alpha = 0.0f;
        }
        

        CalcSuface is called automatically and my material appears green in the editor as well as in a rendering. 
        CalcAlpha is not called automatically so I tell C4D that my material/shader needs alpha computations in the GetRenderInfo method. 
        Now CalcAlpha is called when I render the scene but it is not called in the editor.

        Here are two images form C4D:

        When I use a C4D-Material with alpha, then everything works as expected, even in the editor, see here:

        Remember, that I want my material to be invisible nevertheless where it is in the material hierarchy. Therefore I thought that alpha might be the best way of doing this 🙂

        So what do I have to do to tell C4D to call CalcAlpha in the editor as well?

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

          On 31/07/2014 at 10:29, xxxxxxxx wrote:

          Since my question became more precise, I have it reposted here:
          https://developers.maxon.net/forum/topic/8059/10474_calcalpha-of-materialplugin-not-called-in-editor

          If anyone knows another way of making a "pass-through" material (other than alpha-blending), please post it here 🙂

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