adding layers to the render buffer
-
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-solvedwhere 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?
-
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 -
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 appearinside 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 }