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

    Gradient Shader

    Scheduled Pinned Locked Moved SDK Help
    11 Posts 0 Posters 969 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

      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

      On 02/09/2012 at 17:01, xxxxxxxx wrote:

      I'm using Python but maybe you need to use something like InitRenderStructure()
      and InitRender(gr) ?
      Then possibly get the pixel at UVW x,y.
      Haven't done it with a gradient shader but rather a Color Gradient Userdata.

      Cheers
      Lennart

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

        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

        On 03/09/2012 at 00:53, xxxxxxxx wrote:

        Hello Klaus,

        BaseContainer::GetCustomDataType() accepts two arguments. The first one is the ID of the description element, the second the ID of the data-type.

        Gradient* gr = (Gradient* ) d.GetCustomDataType(MY_GRADIENT_ID, CUSTOMDATATYPE_GRADIENT);
        

        If the gradient is part of your own description for your plugin, you need to initialize it in NodeData::Init().

        -Niklas

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

          THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

          On 03/09/2012 at 01:08, xxxxxxxx wrote:

          Originally posted by xxxxxxxx

          Hello Klaus, BaseContainer::GetCustomDataType() accepts two arguments. The first one is the ID of the description element, the second the ID of the data-type.

          Gradient* gr = (Gradient* ) d.GetCustomDataType(MY_GRADIENT_ID, CUSTOMDATATYPE_GRADIENT);
          

          I think the 'd' in this case is a GeData, not a BaseContainer, and so there's only one argument. I would check the value in the DescID() call, is 1000 really correct?

          Steve

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

            THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

            On 03/09/2012 at 02:01, xxxxxxxx wrote:

            Hi Steve,

            yes, d is GeData d. I'm going this way successfully to get the gradient type :

              
            GeData     d;   
            LONG     type = 0;   
              
            if (sh->GetParameter(DescLevel(1001), d, DESCFLAGS_GET_0)) // SLA_GRADIENT_TYPE 1001   
            {        
                 type = (LONG)d.GetLong(); // => e.g. 2000 for SLA_GRADIENT_TYPE_2D_U   
            }   
              
            

            So I assume the way to get the data is pricipally right.

            @Niklas: no it's not my plugin using the gradient. I want to get it from a material.

            Here are the IDs of Xs**gradient.h

              
            Xs**gradient                          = 1000,   
              
            SLA_GRADIENT_TYPE                     = 1001,   // LONG   
                SLA_GRADIENT_TYPE_2D_U              = 2000,   
                SLA_GRADIENT_TYPE_2D_V,   
                SLA_GRADIENT_TYPE_2D_DIAG,   
                SLA_GRADIENT_TYPE_2D_RAD,   
                SLA_GRADIENT_TYPE_2D_CIRC,   
                SLA_GRADIENT_TYPE_2D_BOX,   
                SLA_GRADIENT_TYPE_2D_STAR,   
                SLA_GRADIENT_TYPE_2D_FOUR_CORNER,   
                SLA_GRADIENT_TYPE_3D_LINEAR,   
                SLA_GRADIENT_TYPE_3D_CYLINDRICAL,   
                SLA_GRADIENT_TYPE_3D_SPHERICAL,   
              
            SLA_GRADIENT_CYCLE                    = 1002,   // Bool   
            SLA_GRADIENT_START                    = 1003,   // Vector   
            SLA_GRADIENT_END                      = 1004,   // Vector   
            SLA_GRADIENT_RADIUS                   = 1005,   // Real   
            SLA_GRADIENT_SPACE                    = 1006,   // LONG   
                SLA_GRADIENT_SPACE_TEXTURE          = 2020,   
                SLA_GRADIENT_SPACE_OBJECT,   
                SLA_GRADIENT_SPACE_WORLD,   
                SLA_GRADIENT_SPACE_CAMERA,   
                SLA_GRADIENT_SPACE_SCREEN,   
                SLA_GRADIENT_SPACE_RASTER,   
              
            SLA_GRADIENT_TURBULENCE               = 1011, // real   
            ...   
            
            1 Reply Last reply Reply Quote 0
            • H Offline
              Helper
              last edited by

              THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

              On 03/09/2012 at 02:23, xxxxxxxx wrote:

              I tried the code from Niklas using a base container. That's also the way the gradient sdk eample uses. Type is correct, but the gradient pointer is NULL!

                
              BaseContainer *bc = sh->GetDataInstance();   
              Gradient *gr = (Gradient* )bc->GetCustomDataType(1000, CUSTOMDATATYPE_GRADIENT); // => NULL   
              LONG type = bc->GetLong(1001); => correct values   
              
              1 Reply Last reply Reply Quote 0
              • H Offline
                Helper
                last edited by

                THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                On 03/09/2012 at 07:09, xxxxxxxx wrote:

                Right, 1001 does indeed work as the gradient type. However, the actual colour gradient is not 1000 but 1007 (defined as SLA_GRADIENT_GRADIENT) - try that and see if it works.

                Steve

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

                  THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                  On 03/09/2012 at 08:09, xxxxxxxx wrote:

                  Yep! That's it. Don't understand, how I could miss it in the h file.

                    
                  SLA_GRADIENT_GRADIENT                 = 1007,   // Gradient   
                  
                  1 Reply Last reply Reply Quote 0
                  • H Offline
                    Helper
                    last edited by

                    THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                    On 03/09/2012 at 12:24, xxxxxxxx wrote:

                    Easily done, I've achieved that error many times 🙂

                    Steve

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

                      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                      On 03/09/2012 at 13:12, xxxxxxxx wrote:

                      Hi Klaus,

                      why are you not using the actual symbols in the code?

                      -Nik

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

                        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                        On 04/09/2012 at 02:27, xxxxxxxx wrote:

                        you mean the resource IDs? I do so normally, but xs**gradient.h couldn't be found by the compiler. So I would have to setup a path, but I wasn't sure until now, that it is the right file.

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