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

    adding layers to the render buffer

    SDK Help
    0
    3
    754
    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 20/08/2015 at 13:06, xxxxxxxx wrote:

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

      ---------
      this question may be related to an old thread, https://developers.maxon.net/forum/topic/8414/10991_q-about-renderdocument-custom-renderer-solved

      where Joey said:
      "the bitmap passed as "image->pDest" to RenderDocument() becomes the internal render bitmap of type MultipassBitmap.  When you call "vps->render->GetBuffer(VPBUFFER_RGBA, NOTOK)", you get the renderer's MultipassBitmap pointer.  As stated in the documentation, a VPBuffer is represents the same class internally as a MultipassBitmap, so a VPBuffer can be cast to the latter, and vice versa.  Therefore, you should be able to fill the bitmap to view the results in the material preview window."

      so what I try to do is adding a new layer to the VPBuffer* when rendering, it may be illegal the way I do, so may be some advice..
      a code snippet:

        
                      //header
              	VPBuffer* m_rgba;
              	MultipassBitmap* m_test_;  
        
                      //cpp
      		m_rgba = vps->render->GetBuffer(VPBUFFER_RGBA, NOTOK);
      		MultipassBitmap *rgba = (MultipassBitmap* )m_rgba;
      		m_test_ = rgba->AddLayer(rgba, COLORMODE_ARGBf);
      
        
              //writing  
      	for (int yy = y; yy < y + h; ++yy)
      	{			
      		m_rgba->SetLine(x, (y2 - y1) - yy, w, &pData[(yy - y) * w * 4], 32, true);
      		VPBuffer* m_test = (VPBuffer* )m_test_;
      		m_test->SetLine(x, (y2 - y1) - yy, w, &pData[(yy - y) * w * 4], 32, true);
      	}
      

      this crashes, didn't check where it crashes "at creation of m_test_ or at writing, whatever it fails", so what should I do?

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

        On 21/08/2015 at 02:03, xxxxxxxx wrote:

        Hello,

        you can create custom render buffers using AllocateBuffers() using Render::AllocateBuffer(). You find an example on how to create standard buffers in the Colorize example.

        You can also create a custom post effect buffer using Render::AllocateBufferFX(). Then you can access this buffer later with Render::GetBuffer(). Please note that you must enable "Multi-Pass" and add the "Post Effects" pass to enable custom post effect buffers.

        Best wishes,
        Sebastian

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

          On 21/08/2015 at 07:21, xxxxxxxx wrote:

          Hi Sebastian,
          thanks a lot for the help, it works to some extent, but there are problems "which I don't know why they happen., I searched and found most examples of AllocateBufferFX() did the same as I did"

          I activated mutlipass, post effects.
          problems:
          1- weird image...
          2- layers don't appear

          inside AllocateBuffers()

            
          	Int32 needbitdepth = 32;	//8, also 16 and 32 are possible
          	m_test = render->AllocateBufferFX(VPBUFFER_POSTEFFECT, String("atestbuffer"), needbitdepth, TRUE);
          

          inside (vps->vp==VIDEOPOSTCALL_INNER && vps->open)

            
                  m_test_ = vps->render->GetBuffer(VPBUFFER_POSTEFFECT, m_test);  
          

          filling buffers

            
          	for (int yy = y; yy < y + h; ++yy)
          	{			
          		m_rgba->SetLine(x, (y2 - y1) - yy, w, &pData[(yy - y) * w * 4], 32, TRUE);
          		m_test_->SetLine(x, yy, w, &pData[(yy - y) * w * 4], 32, TRUE);//did it upside down to check
          	}
          


          undefined

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