8bit transparency
8bit transparency
Hi!
Can you tell me how i can make a material in Irrlicht with 8bit transparency? This should be completely normal for a game engine... but somehow it seems that it's not possible with irrlicht materials:
What i want is to use an 8bit grayscale picture or an 8bit channel of a 32bit RGBA picture as alphatransparency.
Irrlicht provides the following materials for transparency:
EMIT_TRANSPARENT_ADD_COLOR
EMIT_TRANSPARENT_ALPHA_CHANNEL
EMIT_TRANSPARENT_VERTEX_ALPHA
We can ignore transparent_vertex_alpha because it creates transparency from vertexalpha and this is not what i want.
EMIT_TRANSPARENT_ADD_COLOR just add's the color values of the texture to the colorvalues of the background/backgroundobjects - so this is as well not what i'm searching for.
EMIT_TRANSPARENT_ALPHA_CHANNEL creates transparency from alpha channel, but only 1BIT transparency. Means black is transparent and everything else is opaque.
But i need gradual, 8bit transparency! I tried to achieve it by making an own material type. I set the following flags:
pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
pID3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
pID3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
pID3DDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CW);
pID3DDevice->SetRenderState(D3DRS_ZWRITEENALBE, TRUE);
But it's still not working!
Please help me!
Thx!
Can you tell me how i can make a material in Irrlicht with 8bit transparency? This should be completely normal for a game engine... but somehow it seems that it's not possible with irrlicht materials:
What i want is to use an 8bit grayscale picture or an 8bit channel of a 32bit RGBA picture as alphatransparency.
Irrlicht provides the following materials for transparency:
EMIT_TRANSPARENT_ADD_COLOR
EMIT_TRANSPARENT_ALPHA_CHANNEL
EMIT_TRANSPARENT_VERTEX_ALPHA
We can ignore transparent_vertex_alpha because it creates transparency from vertexalpha and this is not what i want.
EMIT_TRANSPARENT_ADD_COLOR just add's the color values of the texture to the colorvalues of the background/backgroundobjects - so this is as well not what i'm searching for.
EMIT_TRANSPARENT_ALPHA_CHANNEL creates transparency from alpha channel, but only 1BIT transparency. Means black is transparent and everything else is opaque.
But i need gradual, 8bit transparency! I tried to achieve it by making an own material type. I set the following flags:
pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
pID3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
pID3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
pID3DDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CW);
pID3DDevice->SetRenderState(D3DRS_ZWRITEENALBE, TRUE);
But it's still not working!
Please help me!
Thx!
EMT_TRANSPARENT_ALPHA_CHANNEL is what you need anyway, just try
before loading texture with alpha channel.
Code: Select all
driver->setTextureCreationFlag(video::ETCF_ALWAYS_32_BIT, true);
Because if a texture is being converted from 32 bit to 16 bit it just can't still have 8 bit alpha chanell, no place for that, it uses 1 bit instead and 15 for a color definition.
I think there wouldn't be slowing down on any modern computer, if you use all the textures 32bit, at least I didn't noticed that. Modern cards should be now optimized to display them properly, but nothing stops you from create opaque textures as 16 bit and transparent as 32 bit, just switch the flags.
I think there wouldn't be slowing down on any modern computer, if you use all the textures 32bit, at least I didn't noticed that. Modern cards should be now optimized to display them properly, but nothing stops you from create opaque textures as 16 bit and transparent as 32 bit, just switch the flags.
-
- Posts: 370
- Joined: Mon Aug 29, 2005 10:54 pm
- Location: http://web.utk.edu/~pfox1
If you know much about pixelformats (and I don't btw...) you know they can be a real bitch, especially 16 bit color. There are like 5 or 6 different ways to repesent 16 bits as a rgb color, and almost none of them correlate with each other. Now, in the modern age, we have 32bit color, which not only provides a lot of colors, but provides an even 8 bits per color, making it easier to mess with colors, I highly recomend setting the ETCF_ALWAYS_32_BIT flag to true.
-
- Posts: 370
- Joined: Mon Aug 29, 2005 10:54 pm
- Location: http://web.utk.edu/~pfox1
genesys: yeah, you're right, you would halve the ammount of memory being used, but really, how many textures are you using? Do you think it can max out a 16MB video card? How about a 32MB one? Mine's got 64MB, I'd be impressed if I managed to max that out with a game that I wrote If you really want to manage texture memory, you can turn the flag on and off for different textures. At the very least, turn it on for transparent textures and off afterwards.
if you use half resolution your videomemory will reduce to a quater... since your' changing 2 dimension at once..genesys wrote:But if you set all the textures to 32bit, this means also that you can use only half the textures you coul'd use with 16bit's (according to videocard memory) - or half the resolution...
128x128x32=524288
128x128x16=262144
64x64x32=131072
common mistake but if your really intrested in saving video memory its pretty important.
athlon2400xp+,geforce4200ti, 0.2Tb hd+64mb extern, 512mb ram, linux FC5 2.6.16-1.2096, 100%gates-free system
-
- Posts: 31
- Joined: Mon Sep 05, 2005 4:47 pm
- Contact:
Hello. I am having the same problem. I used the steps above, but it still doesnt work properly.
My targa is 32-bit, so that's not the problem. I seem to be having the problem of it either being fully opaque or fully transparent (1-bit). I do, however, have the flag enabled. I can tell, becuase if i make my alpha dark, it is invisible, but when its light grey, its still there.
Here's my code:
(its for an explosion, if you cant tell) I need this flare to be translucent, not either on or off.
Any ideas?
My targa is 32-bit, so that's not the problem. I seem to be having the problem of it either being fully opaque or fully transparent (1-bit). I do, however, have the flag enabled. I can tell, becuase if i make my alpha dark, it is invisible, but when its light grey, its still there.
Here's my code:
Code: Select all
flare[i].billboardData = CGraphicsGlobal::smgr->addBillboardSceneNode(0, core::dimension2d<f32>(flare[i].size, flare[i].size*20));
CGraphicsGlobal::driver->setTextureCreationFlag(video::ETCF_ALWAYS_32_BIT, true);
flare[i].billboardData->setMaterialTexture(0,CGraphicsGlobal::driver->getTexture("Graphics\\Explosion\\flare.tga"));
flare[i].billboardData->setMaterialFlag(video::EMF_LIGHTING, false);
flare[i].billboardData->setMaterialType(video::EMT_TRANSPARENT_ALPHA_CHANNEL);
flare[i].billboardData->setVisible(true);
Any ideas?
GMan
Black Ninja Games
Black Ninja Games