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.
This commit is contained in:
parent
cf1a945e5a
commit
0819013eb4
Notes:
blender-bot
2023-02-14 10:21:11 +01:00
Referenced by issue #67081, Backface Culling missing from LookDev
|
@ -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")
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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 */
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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]);
|
||||
|
|
|
@ -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),
|
||||
};
|
||||
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Reference in New Issue