Jump to content

renderImage2D with transparency


photo

Recommended Posts

I need to take picture of my 3D object, for that i use renderImage2D, but i want an image without background.

The background is the colorBackground of engine, may be it's possible to use or activate the alpha composant for the colorBackground.

 

May be, exist an other solution ???

Link to comment

before rendering via renderImage2D set a special background color value not present in your object rendering (e.g. magenta). Afer renderImage2D convert the returned image to matching RGBA format via Image::convertToFormat(). Then check each pixel xyz-component of the image via Image::get2D() for exact value match with your special background color. In case of match set image pixel RGBA color to vec4(0,0,0,0) via Image::set2D() to force transparency.

 

This is the way how normal Blue/green screen image composing works in movies/tv.

Link to comment

when the object have a transparent surfaces, this method generate artifacts because the blending between textures and background.

Link to comment

when the object have a transparent surfaces, this method generate artifacts because the blending between textures and background.

 

For proper handling of transparent surfaces where a desired background color (e.g. white) is partly visible through these surfaces you could use the following approach

 

  1. render scene with special mask background color (e.g. magenta) not used otherwise in scene rendering to mask image A
  2. render scene with desired background color (e.g. white) to image B so desired background color will be used for transparent surface blending
  3. convert image B to RGBA format for transparency masking
  4. set all pixels in image B to transparent where pixel value xyz in mask image A exactly matches used mask color

Link to comment

For proper handling of transparent surfaces where a desired background color (e.g. white) is partly visible through these surfaces you could use the following approach

 

  1. render scene with special mask background color (e.g. magenta) not used otherwise in scene rendering to mask image A
  2. render scene with desired background color (e.g. white) to image B so desired background color will be used for transparent surface blending
  3. convert image B to RGBA format for transparency masking
  4. set all pixels in image B to transparent where pixel value xyz in mask image A exactly matches used mask color

 

ich danke Ihnen sehr für Ihre Hilfe

 

Thanks a lot for you help

Link to comment
×
×
  • Create New...