Blend Question( alpha )
Blend Question( alpha )
In opengl I can do like this to change alpha on models:
glEnable(GL_TEXTURE_2D);
glEnable( GL_ALPHA_TEST );
glEnable( GL_BLEND );
glColor4f( 1.0f, 1.0f, 1.0f, pAlpha );
RenderModel.
glDisable( GL_BLEND );
what is the best way in irrlicht engine? Already exist some function to do this to apply on a animated node?
glEnable(GL_TEXTURE_2D);
glEnable( GL_ALPHA_TEST );
glEnable( GL_BLEND );
glColor4f( 1.0f, 1.0f, 1.0f, pAlpha );
RenderModel.
glDisable( GL_BLEND );
what is the best way in irrlicht engine? Already exist some function to do this to apply on a animated node?
Yes I have tryed to set the materialType to EMT_TRANSPARENT_VERTEX_ALPHA and reduse the alpha, but it seems it does not work as it should, I can post some screen when I get home. I use 1.4.2 version.
Anyway, I have been trying to use alpha channels on the GUI Image and it works perfekt, Does it not exist that sort of alpha channel option on normal node textures on models?
Anyway, I have been trying to use alpha channels on the GUI Image and it works perfekt, Does it not exist that sort of alpha channel option on normal node textures on models?
so can I do like this?
Material Options.
node->setMaterialFlag( EMF_LIGHTING, false );
node->setMaterialType( video::EMT_TRANSPARENT_VERTEX_ALPHA );
Disable BackfaceCulling.
node->getMaterial(0).BackfaceCulling = false;
Scene Options.
pSmgr->getParameters()->setAttribute( scene::ALLOW_ZWRITE_ON_TRANSPARENT, true );
pSmgr->getMeshManipulator()->setVertexColorAlpha( node->getMesh(), 50.0f );
Material Options.
node->setMaterialFlag( EMF_LIGHTING, false );
node->setMaterialType( video::EMT_TRANSPARENT_VERTEX_ALPHA );
Disable BackfaceCulling.
node->getMaterial(0).BackfaceCulling = false;
Scene Options.
pSmgr->getParameters()->setAttribute( scene::ALLOW_ZWRITE_ON_TRANSPARENT, true );
pSmgr->getMeshManipulator()->setVertexColorAlpha( node->getMesh(), 50.0f );
Ok Result.
This is with no parameters at all and I want to make the black transparent, Textures is .png and it works just fine to make them transparent in the GUI Editor and option enable alpha channel.
This is the result using the parameters:
node->setMaterialFlag( EMF_LIGHTING, false );
node->setMaterialType( video::EMT_TRANSPARENT_VERTEX_ALPHA );
node->getMaterial(0).BackfaceCulling = false;
pSmgr->getParameters()->setAttribute( scene::ALLOW_ZWRITE_ON_TRANSPARENT, true );
pSmgr->getMeshManipulator()->setVertexColorAlpha( node->getMesh(), 50 );
Maybe use some shaders then? Im not good at using them but something like this maybe?
float4 gl_FragColor;
gl_FragColor.rgb = tex2D(Texture, i.TexCoord0.xy);
gl_FragColor.a = fadeParameter;
Duno maybe someone else can explain.
This is with no parameters at all and I want to make the black transparent, Textures is .png and it works just fine to make them transparent in the GUI Editor and option enable alpha channel.
This is the result using the parameters:
node->setMaterialFlag( EMF_LIGHTING, false );
node->setMaterialType( video::EMT_TRANSPARENT_VERTEX_ALPHA );
node->getMaterial(0).BackfaceCulling = false;
pSmgr->getParameters()->setAttribute( scene::ALLOW_ZWRITE_ON_TRANSPARENT, true );
pSmgr->getMeshManipulator()->setVertexColorAlpha( node->getMesh(), 50 );
Maybe use some shaders then? Im not good at using them but something like this maybe?
float4 gl_FragColor;
gl_FragColor.rgb = tex2D(Texture, i.TexCoord0.xy);
gl_FragColor.a = fadeParameter;
Duno maybe someone else can explain.
Last edited by xsocom on Fri Dec 05, 2008 5:11 pm, edited 1 time in total.
-
- Posts: 43
- Joined: Mon Dec 01, 2008 6:35 pm
-
- Posts: 43
- Joined: Mon Dec 01, 2008 6:35 pm
Ok seems to almost work
the result with:
Where is the body ?
If I dont set the MaterialTypeParam to 0.01f then the body does not show up at all, How can I get full alpha on this part?
It made the first texture almost invisible, the body texture is the first one on the model.
the result with:
Code: Select all
pSmgr->getParameters()->setAttribute( scene::ALLOW_ZWRITE_ON_TRANSPARENT, true );
node->setMaterialType(video::EMT_TRANSPARENT_ALPHA_CHANNEL);
for( int i=0; i < (int)node->getMaterialCount(); i++ )
{
node->getMaterial(i).BackfaceCulling = false;
node->getMaterial(i).MaterialTypeParam = 0.01f;
}
Where is the body ?
If I dont set the MaterialTypeParam to 0.01f then the body does not show up at all, How can I get full alpha on this part?
It made the first texture almost invisible, the body texture is the first one on the model.
Last edited by xsocom on Fri Dec 05, 2008 5:12 pm, edited 1 time in total.