Alpha Channel
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 28/03/2008 at 00:55, xxxxxxxx wrote:
The bitmaps in InitGLImage are special 16bit bitmaps and can be only filled with SetPixel/GetPixel and some other few functions. Here a working example that fills the alpha channel of the bitmap. You have to make sure that it exists, otherwise you have to create one of your own.
>
\> Bool SimpleMaterial::InitGLImage(PluginMaterial \*mat, BaseDocument \*doc, BaseThread \*th, BaseBitmap \*bmp) \> { \> if(bmp) \> { \> AlphaBitmap \*alpha = bmp->GetInternalChannel(); \> if(!alpha) alpha = bmp->AddChannel(TRUE, FALSE); \> \> LONG bw = bmp->GetBw(); \> LONG bh = bmp->GetBh(); \> LONG x,y; \> \> for(y=0; y<bh; y++) \> { \> for(x=0; x<bw; x++) \> { \> bmp->SetPixel(x, y, 255, 0, 0); \> bmp->SetAlphaPixel(alpha, x, y, 128); \> } \> } \> } \> \> return TRUE; \> } \>
cheers,
Matthias -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 28/03/2008 at 06:15, xxxxxxxx wrote:
Hello Matthias,
thanks for this but is exactly what i done the first time..
but what i need is to Call:RenderDocument before fill this 16bit bitmap.
so inside the InitGLImage i need to call renderdocument.. and get back the ALPHA.
thanks for now
renato -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 28/03/2008 at 06:22, xxxxxxxx wrote:
Please remember to set the PLUGINFLAG_MATERIAL_GLIMAGE flag in the RegisterMaterialPlugin() function.
cheers,
Matthias -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 28/03/2008 at 06:24, xxxxxxxx wrote:
Yes, PLUGINFLAG_MATERIAL_GLIMAGE is set.
cheers
Renato -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 28/03/2008 at 06:26, xxxxxxxx wrote:
Hm, then I don't know what went wrong, it works fine here.
cheers,
Matthias -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 28/03/2008 at 06:27, xxxxxxxx wrote:
I will check if RenderDocument can be called in InitGLImage().
cheers,
Matthias -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 28/03/2008 at 06:28, xxxxxxxx wrote:
Here is working good.. except that alpha is stored in a Unknown place.
Renato
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 28/03/2008 at 06:59, xxxxxxxx wrote:
So is this now workng for you or do you still need some help? What you mean with unkown place?
cheers,
Matthias -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 28/03/2008 at 07:10, xxxxxxxx wrote:
Hello Matthias,
i mean that i can't get the alpha channel from the bitmap passed in the renderdocumennt.
The RGB is correct and transferred to the 16bit image with setpixel, like you wrote... but nothing about alpha.
cheers
Renato -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 31/03/2008 at 05:22, xxxxxxxx wrote:
can you access the alpha at all?
cheers,
Matthias -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 31/03/2008 at 05:52, xxxxxxxx wrote:
Hello Matthias,
No, i can't get the Alpha.. If i provide a BMP + Alpha to renderdocument.. the alpha is always empty.. this is my problem.
thanks
renato -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 31/03/2008 at 06:18, xxxxxxxx wrote:
What does the document you send to RenderDocument()look like, just a plane with texture? Maybe you can provide a scene.
cheers,
Matthias -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 31/03/2008 at 06:47, xxxxxxxx wrote:
yes Matthias, it's a 4 point polygon with a light and camera.. just this.
www.danieleficini.com/temp/prova2.rar
cheers
renato -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 31/03/2008 at 14:35, xxxxxxxx wrote:
Youhave to use a MultipassBitmap to access the Alpha of RenderDocument().
Here a working InitGLImage() function:
>
\> Bool SimpleMaterial::InitGLImage(PluginMaterial \*mat, BaseDocument \*doc, BaseThread \*th, BaseBitmap \*bmp) \> { \> if(bmp) \> { \> LONG bw = bmp->GetBw(); \> LONG bh = bmp->GetBh(); \> \> MultipassBitmap \*tmp = MultipassBitmap::Alloc(bw,bh,MODE_RGB); \> if(!bmp) return FALSE; \> \> AutoAlloc<BaseDocument> rdoc; \> if(!rdoc) return FALSE; \> \> BaseObject \*plane = BaseObject::Alloc(Oplane); \> if(!plane) return FALSE; \> \> Material \*mat = Material::Alloc(); \> if(!mat) return FALSE; \> \> mat->SetChannelState(CHANNEL_ALPHA,TRUE); \> BaseChannel \*ch = mat->GetChannel(CHANNEL_ALPHA); \> \> BaseContainer cdata; \> cdata.SetLong(BASECHANNEL_SHADERID, 1001162); \> ch->SetData(cdata); \> \> rdoc->InsertMaterial(mat, NULL, FALSE); \> \> TextureTag \*ttag = TextureTag::Alloc(); \> if(!ttag) return FALSE; \> \> ttag->SetMaterial(mat); \> \> GeData d(TEXTURETAG_PROJECTION_UVW); \> ttag->SetParameter(DescLevel(TEXTURETAG_PROJECTION),d,NULL); \> \> plane->InsertTag(ttag, NULL); \> \> BaseContainer \*data = plane->GetDataInstance(); \> data->SetReal(PRIM_PLANE_WIDTH, 100.0); \> data->SetReal(PRIM_PLANE_HEIGHT, 100.0); \> data->SetLong(PRIM_PLANE_SUBW, 1); \> data->SetLong(PRIM_PLANE_SUBH, 1); \> \> rdoc->InsertObject(plane, NULL, NULL, FALSE); \> \> BaseObject \*camera = rdoc->GetRenderBaseDraw()->GetEditorCamera(); \> if(!camera) return FALSE; \> \> camera->SetPos(Vector(0.0,100.0,0.0)); \> camera->SetRot(Vector(0.0,-pi/2.0,0.0)); \> \> BaseContainer rdata = rdoc->GetActiveRenderData()->GetData(); \> rdata.SetLong(RDATA_XRES, bw); \> rdata.SetLong(RDATA_YRES, bh); \> rdata.SetBool(RDATA_ALPHACHANNEL, TRUE); \> rdata.SetLong(RDATA_ANTIALIASING, ANTI_BEST); \> \> if(RenderDocument(rdoc, rdata, NULL, NULL, tmp, RENDERFLAG_EXTERNAL, th) == RAY_OK) \> { \> LONG x,y; \> for(y=0; y<bh; y++) \> { \> for(x=0; x<bw; x++) \> { \> AlphaBitmap \*alpha = bmp->GetInternalChannel(); \> if(!alpha) alpha = bmp->AddChannel(TRUE,FALSE); \> \> UWORD value = 0; \> tmp->GetAlphaPixel(tmp->GetChannelNum(0),x,y,&value;); \> bmp->SetAlphaPixel(alpha,x,y,value); \> } \> } \> } \> \> MultipassBitmap::Free(tmp); \> } \> \> return TRUE; \> } \>
cheers,
Matthias -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 01/04/2008 at 07:22, xxxxxxxx wrote:
Hello Matthias,
i'm sorry but tmp->GetChannelNum(0)
always return 0x00000000...
any suggestion?
cheers
Renato -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 01/04/2008 at 07:31, xxxxxxxx wrote:
Try to allocate an alpha for the MultipassBitmap tmp.
Otherwsie I would need some source code example to help you further.
>
\> tmp->AddChannel(TRUE,TRUE); \>
cheers,
Matthias -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 01/04/2008 at 10:19, xxxxxxxx wrote:
seem to work.. let me see.
Cheers
Renato -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 06/04/2008 at 08:33, xxxxxxxx wrote:
Ok thanks,
was easy.. at last ..
With multipass bitmap it work like i expect.
thanks for your support
renato