Workbench: Make Material transparency part of the rgba color picker

It is only used for solid mode for now but could be used by eevee in the
future.
This commit is contained in:
Clément Foucault 2019-01-29 20:33:51 +01:00
parent 43150b02a0
commit 1a61c209a0
Notes: blender-bot 2023-02-14 19:21:02 +01:00
Referenced by issue blender/blender-addons#61017, Material.diffuse_color rgba introduced issues
5 changed files with 11 additions and 13 deletions

View File

@ -258,7 +258,6 @@ class MATERIAL_PT_viewport(MaterialButtonsPanel, Panel):
col.prop(mat, "diffuse_color", text="Color")
col.prop(mat, "metallic")
col.prop(mat, "roughness")
col.prop(mat, "transparency")
def draw(self, context):
self.draw_shared(self, context.material)

View File

@ -2790,5 +2790,11 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
{
/* Versioning code until next subversion bump goes here. */
if (!DNA_struct_elem_find(fd->filesdna, "Material", "float", "a")) {
for (Material *mat = bmain->mat.first; mat; mat = mat->id.next) {
mat->a = 1.0f;
}
}
}
}

View File

@ -943,6 +943,7 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob)
if ((ob->col[3] < 1.0f) &&
(wpd->shading.color_type == V3D_SHADING_OBJECT_COLOR))
{
/* Hack */
wpd->shading.xray_alpha = ob->col[3];
material = workbench_forward_get_or_create_material_data(vedata, ob, NULL, NULL, wpd->shading.color_type, 0);
has_transp_mat = true;
@ -978,10 +979,9 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob)
for (int i = 0; i < materials_len; ++i) {
if (geoms != NULL && geoms[i] != NULL) {
Material *mat = give_current_material(ob, i + 1);
if (mat != NULL && mat->transparency > 0.0) {
if (mat != NULL && mat->a < 1.0f) {
/* Hack */
wpd->shading.xray_alpha = 1.0f - mat->transparency;
CLAMP(wpd->shading.xray_alpha, 0.0, 1.0);
wpd->shading.xray_alpha = mat->a;
material = workbench_forward_get_or_create_material_data(vedata, ob, mat, NULL, V3D_SHADING_MATERIAL_COLOR, 0);
has_transp_mat = true;
}

View File

@ -145,7 +145,7 @@ typedef struct Material {
short flag, pad1[7];
/* Colors from Blender Internal that we are still using. */
float r, g, b;
float r, g, b, a;
float specr, specg, specb;
float alpha DNA_DEPRECATED;
float ray_mirror DNA_DEPRECATED;
@ -154,7 +154,6 @@ typedef struct Material {
float gloss_mir DNA_DEPRECATED;
float roughness;
float metallic;
float transparency;
float pad4;
/* Ror buttons and render. */

View File

@ -354,7 +354,7 @@ static void rna_def_material_display(StructRNA *srna)
prop = RNA_def_property(srna, "diffuse_color", PROP_FLOAT, PROP_COLOR);
RNA_def_property_float_sdna(prop, NULL, "r");
RNA_def_property_array(prop, 3);
RNA_def_property_array(prop, 4);
RNA_def_property_ui_text(prop, "Diffuse Color", "Diffuse color of the material");
RNA_def_property_update(prop, 0, "rna_Material_draw_update");
@ -384,12 +384,6 @@ static void rna_def_material_display(StructRNA *srna)
RNA_def_property_ui_text(prop, "Metallic", "Amount of mirror reflection for raytrace");
RNA_def_property_update(prop, 0, "rna_Material_update");
prop = RNA_def_property(srna, "transparency", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "transparency");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Transparency", "Amount of transparency in solid mode");
RNA_def_property_update(prop, 0, "rna_Material_draw_update");
/* Freestyle line color */
prop = RNA_def_property(srna, "line_color", PROP_FLOAT, PROP_COLOR);
RNA_def_property_float_sdna(prop, NULL, "line_col");