adding clip alpha (binary alpha) to the 3D view and game engine.

This commit is contained in:
Campbell Barton
2008-06-09 15:45:46 +00:00
parent 610b877f60
commit f39758cddc
5 changed files with 29 additions and 8 deletions

View File

@@ -229,14 +229,16 @@ typedef struct PartialVisibility {
#define TF_SHADOW 8192
#define TF_BMFONT 16384
/* mtface->transp */
/* mtface->transp, values 1-4 are used as flags in the GL, WARNING, TF_SUB cant work with this */
#define TF_SOLID 0
#define TF_ADD 1
#define TF_ALPHA 2
#define TF_CLIP 4 /* clipmap alpha/binary alpha all or nothing! */
/* sub is not available in the user interface anymore */
#define TF_SUB 3
/* mtface->unwrap */
#define TF_DEPRECATED1 1
#define TF_DEPRECATED2 2

View File

@@ -6235,6 +6235,7 @@ static void editing_panel_mesh_texface(void)
uiDefButC(block, ROW, REDRAWVIEW3D, "Opaque", 600,80,60,19, &tf->transp, 2.0, (float)TF_SOLID,0, 0, "Render color of textured face as color");
uiDefButC(block, ROW, REDRAWVIEW3D, "Add", 660,80,60,19, &tf->transp, 2.0, (float)TF_ADD, 0, 0, "Render face transparent and add color of face");
uiDefButC(block, ROW, REDRAWVIEW3D, "Alpha", 720,80,60,19, &tf->transp, 2.0, (float)TF_ALPHA,0, 0, "Render polygon transparent, depending on alpha channel of the texture");
uiDefButC(block, ROW, REDRAWVIEW3D, "Clip Alpha", 780,80,80,19, &tf->transp, 2.0, (float)TF_CLIP,0, 0, "Use the images alpha values clipped with no blending (binary alpha)");
}
else
uiDefBut(block,LABEL,B_NOP, "(No Active Face)", 10,200,150,19,0,0,0,0,0,"");

View File

@@ -228,13 +228,14 @@ int set_tpage(MTFace *tface)
alphamode= tface->transp;
if(alphamode) {
glEnable(GL_BLEND);
if(alphamode==TF_ADD) {
glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE);
glDisable ( GL_ALPHA_TEST );
/* glBlendEquationEXT(GL_FUNC_ADD_EXT); */
}
else if(alphamode==TF_ALPHA) {
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
/* added after 2.45 to clip alpha */
@@ -245,9 +246,12 @@ int set_tpage(MTFace *tface)
glEnable ( GL_ALPHA_TEST );
glAlphaFunc ( GL_GREATER, U.glalphaclip );
}
/* glBlendEquationEXT(GL_FUNC_ADD_EXT); */
} else if (alphamode==TF_CLIP){
glDisable(GL_BLEND);
glEnable ( GL_ALPHA_TEST );
glAlphaFunc(GL_GREATER, 0.5f);
}
/* glBlendEquationEXT(GL_FUNC_ADD_EXT); */
/* else { */
/* glBlendFunc(GL_ONE, GL_ONE); */
/* glBlendEquationEXT(GL_FUNC_REVERSE_SUBTRACT_EXT); */

View File

@@ -154,16 +154,23 @@ int set_tpage(MTFace *tface)
fAlphamode= tface->transp;
if(fAlphamode) {
glEnable(GL_BLEND);
if(fAlphamode==TF_ADD) {
glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE);
glDisable ( GL_ALPHA_TEST );
/* glBlendEquationEXT(GL_FUNC_ADD_EXT); */
}
else if(fAlphamode==TF_ALPHA) {
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDisable ( GL_ALPHA_TEST );
/* glBlendEquationEXT(GL_FUNC_ADD_EXT); */
}
else if (alphamode==TF_CLIP){
glDisable(GL_BLEND);
glEnable ( GL_ALPHA_TEST );
glAlphaFunc(GL_GREATER, 0.5f);
}
/* else { */
/* glBlendFunc(GL_ONE, GL_ONE); */
/* glBlendEquationEXT(GL_FUNC_REVERSE_SUBTRACT_EXT); */

View File

@@ -478,16 +478,23 @@ bool KX_BlenderMaterial::setDefaultBlending()
if( mMaterial->transp &TF_ADD) {
glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE);
glDisable ( GL_ALPHA_TEST );
return true;
}
if( mMaterial->transp & TF_ALPHA ) {
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDisable ( GL_ALPHA_TEST );
return true;
}
glDisable(GL_BLEND);
if( mMaterial->transp & TF_CLIP ) {
glDisable(GL_BLEND);
glEnable ( GL_ALPHA_TEST );
glAlphaFunc(GL_GREATER, 0.5f);
return true;
}
return false;
}