On 04/04/2017 at 09:22, xxxxxxxx wrote:
Hi WickedP with reference to the first question I confirm that you have to do your own layering when drawing in the final bitmap.
With reference to the second point, there's a relevant different the pictures attached: on the left (the one pointed as 'render to PV') shows a multipass bitmap with two layers: the first named as "Background", the second name "Alpha". On the right side instead you have a multipass bitmap with three layers each of which comes with its own two alpha channels.
Whilst alpha "channels" are added to a specific layer in a MultipassBitmap by using the MultipassBitmap::AddAlpha() invoked from the layer instance, adding an alpha layer to root of the MultipassBitmap requires the AddAlpha() to be invoked from the root instance as shown in the example below (picture)
...
MultipassBitmap* res = MultipassBitmap::Alloc(width, height, mode);
if (!res)
return nullptr;
// add a alpha layer to the root of the Multipass bitmap
MultipassBitmap* alphaLayer = res->AddAlpha(nullptr, COLORMODE_GRAY);
alphaLayer->SetParameter(MPBTYPE_NAME, "alpha");
alphaLayer->SetParameter(MPBTYPE_SAVE, true);
alphaLayer->SetParameter(MPBTYPE_SHOW, true);
// get the first layer which is automatically created at the res allocation time and fill it
MultipassBitmap* layer = res->GetLayerNum(0);
if (!layer)
return res;
layer->SetParameter(MPBTYPE_NAME, "checker_R-Y");
layer->SetParameter(MPBTYPE_SAVE, true);
layer->SetParameter(MPBTYPE_SHOW, true);
// fill the first layer with red/yellow checkerboard
// FillRGBChannel is a dummy custom-made function to fill a bitmap with a checkboard pattern
if (!FillRGBChannel((BaseBitmap* )layer, 8, 8, Vector(255, 0, 0), Vector(255, 255, 0)))
{
MultipassBitmap::Free(res);
return nullptr;
}
// add an alpha channels to the first layer
alphaLayer = layer->AddAlpha(nullptr, COLORMODE_GRAY);
alphaLayer->SetParameter(MPBTYPE_SAVE, true);
alphaLayer->SetParameter(MPBTYPE_SHOW, true);
alphaLayer->SetParameter(MPBTYPE_NAME, "alpha_8x8");
// fill the added alpha layer with checkerboard mask
// FillAlphaChannel is a dummy custom-made function to fill a bitmap with a checkboard mask pattern
if (!FillAlphaChannel(layer, 0, 32, 32, 255, 0, false))
{
MultipassBitmap::Free(res);
return nullptr;
}
...
Best, Riccardo