support transparency in material's diffa

This commit is contained in:
David Rose 2012-01-06 21:58:36 +00:00
parent 11189c99b7
commit 2d0fb30fd6
3 changed files with 22 additions and 7 deletions

View File

@ -184,6 +184,13 @@ ConfigVariableInt egg_vertex_max_num_joints
"more than this number of joints, the joints with the lesser membership "
"value are ignored. Set this to -1 to allow any number of joints."));
ConfigVariableBool egg_implicit_alpha_binary
("egg-implicit-alpha-binary", false,
PRC_DESC("If this is true, then a <Scalar> alpha value appearing in an egg "
"file that appears to specify only a binary (0 or 1) value for alpha "
"will automatically be downgraded to alpha type \"binary\" instead of "
"whatever appears in the egg file."));
ConfigureFn(config_egg2pg) {
init_libegg2pg();
}

View File

@ -54,6 +54,7 @@ extern EXPCL_PANDAEGG ConfigVariableBool egg_emulate_bface;
extern EXPCL_PANDAEGG ConfigVariableBool egg_preload_simple_textures;
extern EXPCL_PANDAEGG ConfigVariableDouble egg_vertex_membership_quantize;
extern EXPCL_PANDAEGG ConfigVariableInt egg_vertex_max_num_joints;
extern EXPCL_PANDAEGG ConfigVariableBool egg_implicit_alpha_binary;
extern EXPCL_PANDAEGG void init_libegg2pg();

View File

@ -247,10 +247,15 @@ fill_state(EggPrimitive *egg_prim) {
}
if (egg_prim->has_material()) {
PT(EggMaterial) material = egg_prim->get_material();
CPT(RenderAttrib) mt =
get_material_attrib(egg_prim->get_material(),
egg_prim->get_bface_flag());
get_material_attrib(material, egg_prim->get_bface_flag());
add_attrib(mt);
if (material->has_diff() && material->get_diff()[3] != 1.0) {
implicit_alpha = true;
binary_alpha_only = false;
}
}
@ -294,11 +299,13 @@ fill_state(EggPrimitive *egg_prim) {
case EggRenderMode::AM_ms:
case EggRenderMode::AM_ms_mask:
case EggRenderMode::AM_dual:
// Any of these modes gets implicitly downgraded to AM_binary, if
// all of the alpha sources only contribute a binary value to
// alpha.
if (binary_alpha_only) {
am = EggRenderMode::AM_binary;
if (egg_implicit_alpha_binary) {
// Any of these modes gets implicitly downgraded to AM_binary, if
// all of the alpha sources only contribute a binary value to
// alpha.
if (binary_alpha_only) {
am = EggRenderMode::AM_binary;
}
}
break;