Rendering into Multipassbitmap a "Depth Matte" Layer

I have a follow-up question to this. I can't see the link between making a MultipassBitmap (MPB) and having a depth matte render.

For example; when I hit the render button, it renders with a depth matte and it displays in the picture viewer. But if I do it myself (C++) using the same render settings, I don't get any depth matte. I'm guessing it has something to do with setting up layers in the MPB. But I can't see how this is done. I know how to make a layer. But I don't know how to say "this layer is for the depth matte".

For however it's done, is there an example of this somewhere?


edit by @ferdinand : Forked from Render settings Multi-Pass flag. Please open new topics for new questions, your follow up questions were too broad to be put into the same topic.

I may have resolved this. It seems like I have to use SetParameter() with the flags MPBTYPE_USERID and VPBUFFER_DEPTH. This wasn't clear in the docs (my docs at least).

Just a suggestion, it might be useful to have an example reference somewhere of how to setup a MultipassBitmap for rendering with all the layers needed as per the render settings. Something like how the Render To Picture Viewer button might do it behind the scenes.


Hello @WickedP,

Thank you for reaching out to us. It is great to hear that you did find your solution.

Regarding your request for adding a code example: I do not fully understand what you were trying to do?

For example; when I hit the render button, it renders with a depth matte and it displays in the picture viewer. But if I do it myself (C++) using the same render settings, I don't get any depth matte.

What does constitute 'do[ing] it myself' for you here? When one implements a renderer, one usually does not have to deal with render bitmaps and instead operates on render buffers. When using RenderDocument or the things like the render queue, one does not have to manage bitmaps either.

I assume you mean that you want to mimic the output of a renderer with a depth pass/channel. I am not totally against adding such an example, but what would be the content of it? Create an RGBA channel and an alpha channel for that? Recreating the whole structure of a multipass render output bitmap with all the layers unfortunately does not have a good relevance/effort ratio. So, I cannot do 'everything'.


MAXON SDK Specialist

Thanks @ferdinand, I don't expect you to do everything :)

But I've reached a point where I've tried everything I can think of. I've spent too long going around in circles at this point. Here's what I'd like to get:

A MultipassBitmap that I can pass to RenderDocument() that will give me

  • 1 layer for RGB (32bit)
  • 1 layer for alpha (32bit) <-- yes, I want a separate alpha layer
  • 1 layer for depth (32bit)

for use with the standard renderer. For now, I must have these 3 layers.

Here's some code I've experimented with to try and show you where I've been:

MultipassBitmap *multi = MultipassBitmap::Alloc(width,height,COLORMODE_RGBf);

	MultipassBitmap *colourMap = multi->GetLayerNum(0);

	MultipassBitmap *alphaMap = multi->AddAlpha(nullptr,COLORMODE_GRAYf);

	MultipassBitmap *depthMap = multi->AddAlpha(alphaMap,COLORMODE_GRAYf,FALSE);


	if(RenderDocument(doc,rdata,nullptr,nullptr,multi,RENDERFLAGS_0,nullptr) == RENDERRESULT_OK)

I've tried all sorts of variations of this, none of which produce the same as the Render to Picture Viewer command. Which is why I mentioned having that as an example would be useful.

How do we do this?


Hey @wickedp,

thank your for your reply. First of all,

I don't expect you to do everything

in case my answer gave the impression that I am unwilling to add such an example - that is not the case. I just must play a bit the gatekeeper for not letting our code examples become too convoluted and fringe. So, this was less a "ugh, we do not have time for this" than a "what demonstrates the general relevance of such example/information for most users?" thing.

First of all, thank you for sharing what you would like to have documented as an example and your code. I personally would still say that this is an extremely specific example of a use case most users probably will never encounter. Which makes it a not so good example case. But we also have many fringe examples in our code base, and in the case one needs such example, it is quite helpful, as the parameter handling of bitmaps is a bit cryptic.

I have added a task to our task pool to add such an example. I will add it in one of the next releases.


MAXON SDK Specialist