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

    How to output BaseBitmap with ShaderData plugin

    Cinema 4D SDK
    python
    2
    2
    525
    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.
    • merkvilsonM
      merkvilson
      last edited by

      Hello PluginCafe! 🙂

      I hope the title is self-explanatory.
      Unfortunately, there is almost 0 info about ShaderData plugins on the forum.

      It is worth mentioning that I already figured out how to load textures into Xbitmap from the disk, but this is not exactly what I need.
      Currently, I'm trying to somehow load Pre-Defined Bitmap image Xbitmap (or maybe I have to load it into Xbase) but with no luck.

          def InitRender(self, sh, irs) :
      
              bmp = (c4d.bitmaps.InitResourceBitmap(c4d.RESOURCEIMAGE_OK))
              self.texture = c4d.BaseShader(c4d.Xbitmap)
      
              # Not sure but if I'm doing this correctly but probably here I need to somehow load my bmp.
      
              self.texture.InitRender(irs)
              return c4d.INITRENDERRESULT_OK
      
          def FreeRender(self, sh) :
              self.texture.FreeRender()
              self.texture = None
      
          def Output(self, sh, cd) :
              res = self.texture.Sample(cd)
              return res
      
      1 Reply Last reply Reply Quote 0
      • r_giganteR
        r_gigante
        last edited by r_gigante

        Hi Merkvilson, thanks for reaching out us.

        If the final intent is to simply get BaseBitmapinformation to be returned by your shader, rather than sampling a Xbitmap shader I suggest instead to simply query the color information by using BaseBitmap::GetPixel and eventually apply color space transformation.

            def Output(self, sh, cd) :
                x = int(cd.p.x * self.bitmap.GetBw())
                y = int(cd.p.y * self.bitmap.GetBh())
                col = self.bitmap.GetPixel(x, y)
                return c4d.Vector(float(col[0]/256.0), float(col[1]/256.0), float(col[2]/256.0))
        

        Best, Riccardo

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