Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2019-05-15 13:03:26 +0300
committerClément Foucault <foucault.clem@gmail.com>2019-05-15 13:03:49 +0300
commit0819013eb45532e2ac26c725d09a4c74478e85d7 (patch)
tree008428ac7ef93d078bbdea1c7319aa0ba0387fc2
parentcf1a945e5ad570e9ae159b569a2a3cfc11874f98 (diff)
Eevee: Add per material option to cull backfaces
This is in order to have more flexibility and to have an explicit option for final renders.
-rw-r--r--release/scripts/startup/bl_ui/properties_material.py1
-rw-r--r--release/scripts/startup/bl_ui/space_view3d.py7
-rw-r--r--source/blender/blenloader/intern/versioning_280.c2
-rw-r--r--source/blender/draw/engines/eevee/eevee_materials.c8
-rw-r--r--source/blender/makesdna/DNA_material_types.h2
-rw-r--r--source/blender/makesrna/intern/rna_material.c6
6 files changed, 17 insertions, 9 deletions
diff --git a/release/scripts/startup/bl_ui/properties_material.py b/release/scripts/startup/bl_ui/properties_material.py
index 79efd92f222..dde67e27f37 100644
--- a/release/scripts/startup/bl_ui/properties_material.py
+++ b/release/scripts/startup/bl_ui/properties_material.py
@@ -212,6 +212,7 @@ class EEVEE_MATERIAL_PT_settings(MaterialButtonsPanel, Panel):
mat = context.material
+ layout.prop(mat, "use_backface_culling")
layout.prop(mat, "blend_method")
layout.prop(mat, "shadow_method")
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index 88a6f0b9b9a..1b833d0a8c3 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -5082,6 +5082,11 @@ class VIEW3D_PT_shading_options(Panel):
bl_label = "Options"
bl_parent_id = 'VIEW3D_PT_shading'
+ @classmethod
+ def poll(cls, context):
+ shading = VIEW3D_PT_shading.get_shading(context)
+ return shading.type in {'WIREFRAME', 'SOLID'}
+
def draw(self, context):
layout = self.layout
@@ -5089,7 +5094,7 @@ class VIEW3D_PT_shading_options(Panel):
col = layout.column()
- if shading.type != 'WIREFRAME':
+ if shading.type == 'SOLID':
col.prop(shading, "show_backface_culling")
row = col.row(align=True)
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index d6eff5ff901..4ca8c24dca0 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -2850,7 +2850,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
for (Material *mat = bmain->materials.first; mat; mat = mat->id.next) {
- mat->blend_flag &= ~(MA_BL_FLAG_UNUSED_2);
+ mat->blend_flag &= ~(1 << 2); /* UNUSED */
}
}
diff --git a/source/blender/draw/engines/eevee/eevee_materials.c b/source/blender/draw/engines/eevee/eevee_materials.c
index 3f6cc306c97..c6b228c29d3 100644
--- a/source/blender/draw/engines/eevee/eevee_materials.c
+++ b/source/blender/draw/engines/eevee/eevee_materials.c
@@ -1208,7 +1208,6 @@ static void material_opaque(Material *ma,
GHash *material_hash,
EEVEE_ViewLayerData *sldata,
EEVEE_Data *vedata,
- bool do_cull,
struct GPUMaterial **gpumat,
struct GPUMaterial **gpumat_depth,
struct DRWShadingGroup **shgrp,
@@ -1228,6 +1227,7 @@ static void material_opaque(Material *ma,
float *spec_p = &ma->spec;
float *rough_p = &ma->roughness;
+ const bool do_cull = (ma->blend_flag & MA_BL_CULL_BACKFACE) != 0;
const bool use_gpumat = (ma->use_nodes && ma->nodetree);
const bool use_ssrefract = ((ma->blend_flag & MA_BL_SS_REFRACTION) != 0) &&
((effects->enabled_effects & EFFECT_REFRACT) != 0);
@@ -1460,7 +1460,6 @@ static void material_opaque(Material *ma,
static void material_transparent(Material *ma,
EEVEE_ViewLayerData *sldata,
EEVEE_Data *vedata,
- bool do_cull,
struct GPUMaterial **gpumat,
struct DRWShadingGroup **shgrp,
struct DRWShadingGroup **shgrp_depth)
@@ -1471,6 +1470,7 @@ static void material_transparent(Material *ma,
EEVEE_PassList *psl = ((EEVEE_Data *)vedata)->psl;
EEVEE_LightsInfo *linfo = sldata->lights;
+ const bool do_cull = (ma->blend_flag & MA_BL_CULL_BACKFACE) != 0;
const bool use_ssrefract = (((ma->blend_flag & MA_BL_SS_REFRACTION) != 0) &&
((stl->effects->enabled_effects & EFFECT_REFRACT) != 0));
float *color_p = &ma->r;
@@ -1604,8 +1604,6 @@ void EEVEE_materials_cache_populate(EEVEE_Data *vedata,
Scene *scene = draw_ctx->scene;
GHash *material_hash = stl->g_data->material_hash;
- const bool do_cull = (draw_ctx->v3d &&
- (draw_ctx->v3d->shading.flag & V3D_SHADING_BACKFACE_CULLING));
bool is_sculpt_mode = DRW_object_use_pbvh_drawing(ob);
/* For now just force fully shaded with eevee when supported. */
is_sculpt_mode = is_sculpt_mode &&
@@ -1641,7 +1639,6 @@ void EEVEE_materials_cache_populate(EEVEE_Data *vedata,
material_hash,
sldata,
vedata,
- do_cull,
&gpumat_array[i],
&gpumat_depth_array[i],
&shgrp_array[i],
@@ -1654,7 +1651,6 @@ void EEVEE_materials_cache_populate(EEVEE_Data *vedata,
material_transparent(ma_array[i],
sldata,
vedata,
- do_cull,
&gpumat_array[i],
&shgrp_array[i],
&shgrp_depth_array[i]);
diff --git a/source/blender/makesdna/DNA_material_types.h b/source/blender/makesdna/DNA_material_types.h
index cbfe88a6ca3..d65a4896758 100644
--- a/source/blender/makesdna/DNA_material_types.h
+++ b/source/blender/makesdna/DNA_material_types.h
@@ -316,7 +316,7 @@ enum {
enum {
MA_BL_HIDE_BACKFACE = (1 << 0),
MA_BL_SS_REFRACTION = (1 << 1),
- MA_BL_FLAG_UNUSED_2 = (1 << 2), /* cleared */
+ MA_BL_CULL_BACKFACE = (1 << 2),
MA_BL_TRANSLUCENCY = (1 << 3),
};
diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c
index 4a449463d4d..edfdbe293a3 100644
--- a/source/blender/makesrna/intern/rna_material.c
+++ b/source/blender/makesrna/intern/rna_material.c
@@ -791,6 +791,12 @@ void RNA_def_material(BlenderRNA *brna)
"(avoids transparency sorting problems)");
RNA_def_property_update(prop, 0, "rna_Material_draw_update");
+ prop = RNA_def_property(srna, "use_backface_culling", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "blend_flag", MA_BL_CULL_BACKFACE);
+ RNA_def_property_ui_text(
+ prop, "Backface Culling", "Use back face culling to hide the back side of faces");
+ RNA_def_property_update(prop, 0, "rna_Material_draw_update");
+
prop = RNA_def_property(srna, "use_screen_refraction", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "blend_flag", MA_BL_SS_REFRACTION);
RNA_def_property_ui_text(