Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/engines/eevee/eevee_materials.c
| Show First 20 Lines • Show All 1,152 Lines • ▼ Show 20 Lines | |||||
| #else | #else | ||||
| /* For now just force fully shaded with eevee when supported. */ | /* For now just force fully shaded with eevee when supported. */ | ||||
| const bool is_sculpt_mode_draw = | const bool is_sculpt_mode_draw = | ||||
| is_sculpt_mode && | is_sculpt_mode && | ||||
| ((ob->sculpt && ob->sculpt->pbvh) && (BKE_pbvh_type(ob->sculpt->pbvh) != PBVH_FACES)); | ((ob->sculpt && ob->sculpt->pbvh) && (BKE_pbvh_type(ob->sculpt->pbvh) != PBVH_FACES)); | ||||
| #endif | #endif | ||||
| const bool is_default_mode_shader = is_sculpt_mode; | const bool is_default_mode_shader = is_sculpt_mode; | ||||
| const bool is_visible = (ob->base_flag & BASE_VISIBLED) != 0; | |||||
| /* First get materials for this mesh. */ | /* First get materials for this mesh. */ | ||||
| if (ELEM(ob->type, OB_MESH)) { | if (ELEM(ob->type, OB_MESH)) { | ||||
| const int materials_len = MAX2(1, (is_sculpt_mode_draw ? 1 : ob->totcol)); | const int materials_len = MAX2(1, (is_sculpt_mode_draw ? 1 : ob->totcol)); | ||||
| struct DRWShadingGroup **shgrp_array = BLI_array_alloca(shgrp_array, materials_len); | struct DRWShadingGroup **shgrp_array = BLI_array_alloca(shgrp_array, materials_len); | ||||
| struct DRWShadingGroup **shgrp_depth_array = BLI_array_alloca(shgrp_depth_array, materials_len); | struct DRWShadingGroup **shgrp_depth_array = BLI_array_alloca(shgrp_depth_array, materials_len); | ||||
| struct DRWShadingGroup **shgrp_depth_clip_array = BLI_array_alloca(shgrp_depth_clip_array, materials_len); | struct DRWShadingGroup **shgrp_depth_clip_array = BLI_array_alloca(shgrp_depth_clip_array, materials_len); | ||||
| ▲ Show 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | if (ELEM(ob->type, OB_MESH)) { | ||||
| struct Gwn_Batch **mat_geom = DRW_cache_object_surface_material_get(ob, gpumat_array, materials_len); | struct Gwn_Batch **mat_geom = DRW_cache_object_surface_material_get(ob, gpumat_array, materials_len); | ||||
| if (mat_geom) { | if (mat_geom) { | ||||
| for (int i = 0; i < materials_len; ++i) { | for (int i = 0; i < materials_len; ++i) { | ||||
| Material *ma = give_current_material(ob, i + 1); | Material *ma = give_current_material(ob, i + 1); | ||||
| if (ma == NULL) | if (ma == NULL) | ||||
| ma = &defmaterial; | ma = &defmaterial; | ||||
| if (is_visible) { | |||||
| /* Shading pass */ | /* Shading pass */ | ||||
| ADD_SHGROUP_CALL(shgrp_array[i], ob, mat_geom[i]); | ADD_SHGROUP_CALL(shgrp_array[i], ob, mat_geom[i]); | ||||
| /* Depth Prepass */ | /* Depth Prepass */ | ||||
| ADD_SHGROUP_CALL_SAFE(shgrp_depth_array[i], ob, mat_geom[i]); | ADD_SHGROUP_CALL_SAFE(shgrp_depth_array[i], ob, mat_geom[i]); | ||||
| ADD_SHGROUP_CALL_SAFE(shgrp_depth_clip_array[i], ob, mat_geom[i]); | ADD_SHGROUP_CALL_SAFE(shgrp_depth_clip_array[i], ob, mat_geom[i]); | ||||
| } | |||||
| /* Shadow Pass */ | /* Shadow Pass */ | ||||
| if (ma->use_nodes && ma->nodetree && (ma->blend_method != MA_BM_SOLID)) { | if (ma->use_nodes && ma->nodetree && (ma->blend_method != MA_BM_SOLID)) { | ||||
| struct GPUMaterial *gpumat; | struct GPUMaterial *gpumat; | ||||
| switch (ma->blend_shadow) { | switch (ma->blend_shadow) { | ||||
| case MA_BS_SOLID: | case MA_BS_SOLID: | ||||
| EEVEE_lights_cache_shcaster_add(sldata, psl, mat_geom[i], ob->obmat); | EEVEE_lights_cache_shcaster_add(sldata, psl, mat_geom[i], ob->obmat); | ||||
| break; | break; | ||||
| Show All 12 Lines | if (mat_geom) { | ||||
| } | } | ||||
| else { | else { | ||||
| EEVEE_lights_cache_shcaster_add(sldata, psl, mat_geom[i], ob->obmat); | EEVEE_lights_cache_shcaster_add(sldata, psl, mat_geom[i], ob->obmat); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| if (ob->type == OB_MESH) { | if (is_visible && (ob->type == OB_MESH)) { | ||||
| if (ob != draw_ctx->scene->obedit) { | if (ob != draw_ctx->scene->obedit) { | ||||
| material_hash = stl->g_data->hair_material_hash; | material_hash = stl->g_data->hair_material_hash; | ||||
| for (ModifierData *md = ob->modifiers.first; md; md = md->next) { | for (ModifierData *md = ob->modifiers.first; md; md = md->next) { | ||||
| if (md->type == eModifierType_ParticleSystem) { | if (md->type == eModifierType_ParticleSystem) { | ||||
| ParticleSystem *psys = ((ParticleSystemModifierData *)md)->psys; | ParticleSystem *psys = ((ParticleSystemModifierData *)md)->psys; | ||||
| if (psys_check_enabled(ob, psys, false)) { | if (psys_check_enabled(ob, psys, false)) { | ||||
| ▲ Show 20 Lines • Show All 100 Lines • Show Last 20 Lines | |||||