How the render target texture looks like on the mirror itself (disabling the second layer):
I also tried to load from disk some texture, in my case containing a gloss for the mirror and replaced the IImage in the second layer to that (I selected the semitransparent one purposely to see what's in the background):
The result is almost fine, except the oerkki character is drawn atop the gloss texture:
Ideally it should be vice versa because of the order of the texture layers set for the material.
My code:
Code: Select all
// int main()
core::dimension2du img_size(256, 256);
video::ITexture *overlay_tex = vdrv->addTexture(img_size, "overlay", video::ECF_A8R8G8B8);
-----------------------------------------------------------------------------
// Set two texture layers (first is rtt, second is dynamic texture with red line)
mat.setTexture(0, colorRT);
mat.setTexture(1, overlay_tex);
-----------------------------------------------------------------------------
video::IImage *overlay_img = vdrv->createImageFromData(
overlay_tex->getColorFormat(),
overlay_tex->getSize(),
overlay_tex->lock(),
true
);
// Draw the red line at the center
for (int x = 0; x < img_size.Height; x++)
for (int y = 0; y < img_size.Width; y++)
overlay_img->setPixel(128, y, video::SColor(255, 255, 0, 0));
overlay_tex->unlock();