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

    Implementing bump in a channel shader

    Scheduled Pinned Locked Moved SDK Help
    3 Posts 0 Posters 288 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 21/10/2010 at 08:50, xxxxxxxx wrote:

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

      ---------
      Some here may remember the old 'Dark Tree' shader system which was implemented on C4D through a third-party library and a shader plugin. These were great shaders (IMO anyway) but sadly the plugins were never updated for R9 or upwards.

      My current project is an attempt to resurrect these and I've almost got the channel shader working, but I've run into a problem with bump. The old shader used the CHANNEL_DIRECTBUMP_EX method and I've got this working for R11. However, this won't work on R11.5+ so I need to switch to the 4-sample bump method with CHANNEL_BUMP_SUPPORT. Below is the relevant section of code from the Output() function:

      //get bump value if we are rendering a bump channel   
      if(GET_TEX_CHANNEL(cd->texflag) == CHANNEL_BUMP)   
      {   
          dtrenderstate.point[0] = p.x;   
          dtrenderstate.point[1] = p.y;   
          dtrenderstate.point[2] = p.z;   
          dtrenderstate.evaluateAs = DSdte::DTE_EVAL_BUMP;   
          // convert class to a struct for the C function   
          state = RenderStateToStruct(dtrenderstate);   
          result = DSdte::Evaluate(theSim.bumpdte, &state;);   
          if(cd->vd)   
          {   
              cd->vd->bumpn.x = result.n[0];   
              cd->vd->bumpn.y = result.n[1];   
              cd->vd->bumpn.z = result.n[2];   
          }   
      }
      

      In order to understand what's going on, the system works by loading a number of variables into a 'dtrenderstate' class which is converted into a struct before calling the actual library function, as this is written in C rather than C++. In the code 'p' is the point being evaluated and DSdte::Evaluate is the call to the library function, which returns a vector. For the color channel this is returned as a color, but for bump the code (which is derived from the original plugin code) directly modifies the bump normal in the VolumeData structure.

      This works fine when using CHANNEL_DIRECTBUMP_EX but when using CHANNEL_BUMP_SUPPORT the rendered bump looks completely wrong. What I'd like to do is convert this to using the CHANNEL_BUMP_SUPPORT for compatibility with R11.5+, but I can't see how to do it. I've searched here and seen Matthias' example of a turbulence shader, but I still don't understand how to implement that with the values I have to work with.

      Does anyone have any comments or suggestions about how to get this to work?

      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 27/10/2010 at 06:08, xxxxxxxx wrote:

        In this case wouldn't it be better to output the color coded normals and load the shader into the Normal channel of the material?

        cheers,
        Matthias

        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 27/10/2010 at 08:08, xxxxxxxx wrote:

          Rather than use the bump channel, you mean? That's an interesting thought, I'll see what happens.

          Thank you!

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