Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/engines/eevee/eevee_cryptomatte.c
| Show First 20 Lines • Show All 259 Lines • ▼ Show 20 Lines | static void eevee_cryptomatte_hair_cache_populate(EEVEE_Data *vedata, | ||||
| DRW_shgroup_hair_create_sub(ob, psys, md, grp); | DRW_shgroup_hair_create_sub(ob, psys, md, grp); | ||||
| } | } | ||||
| void EEVEE_cryptomatte_object_hair_cache_populate(EEVEE_Data *vedata, | void EEVEE_cryptomatte_object_hair_cache_populate(EEVEE_Data *vedata, | ||||
| EEVEE_ViewLayerData *sldata, | EEVEE_ViewLayerData *sldata, | ||||
| Object *ob) | Object *ob) | ||||
| { | { | ||||
| BLI_assert(ob->type == OB_HAIR); | BLI_assert(ob->type == OB_HAIR); | ||||
| Hair *hair = ob->data; | Material *material = BKE_object_material_get_eval(ob, HAIR_MATERIAL_NR); | ||||
| Material *material = hair->mat ? hair->mat[HAIR_MATERIAL_NR - 1] : NULL; | |||||
| eevee_cryptomatte_hair_cache_populate(vedata, sldata, ob, NULL, NULL, material); | eevee_cryptomatte_hair_cache_populate(vedata, sldata, ob, NULL, NULL, material); | ||||
| } | } | ||||
| void EEVEE_cryptomatte_particle_hair_cache_populate(EEVEE_Data *vedata, | void EEVEE_cryptomatte_particle_hair_cache_populate(EEVEE_Data *vedata, | ||||
| EEVEE_ViewLayerData *sldata, | EEVEE_ViewLayerData *sldata, | ||||
| Object *ob) | Object *ob) | ||||
| { | { | ||||
| const DRWContextState *draw_ctx = DRW_context_state_get(); | const DRWContextState *draw_ctx = DRW_context_state_get(); | ||||
| if (ob->type == OB_MESH) { | if (ob->type == OB_MESH) { | ||||
| if (ob != draw_ctx->object_edit) { | if (ob != draw_ctx->object_edit) { | ||||
| LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) { | LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) { | ||||
| if (md->type != eModifierType_ParticleSystem) { | if (md->type != eModifierType_ParticleSystem) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| ParticleSystem *psys = ((ParticleSystemModifierData *)md)->psys; | ParticleSystem *psys = ((ParticleSystemModifierData *)md)->psys; | ||||
| if (!DRW_object_is_visible_psys_in_active_context(ob, psys)) { | if (!DRW_object_is_visible_psys_in_active_context(ob, psys)) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| ParticleSettings *part = psys->part; | ParticleSettings *part = psys->part; | ||||
| const int draw_as = (part->draw_as == PART_DRAW_REND) ? part->ren_as : part->draw_as; | const int draw_as = (part->draw_as == PART_DRAW_REND) ? part->ren_as : part->draw_as; | ||||
| if (draw_as != PART_DRAW_PATH) { | if (draw_as != PART_DRAW_PATH) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| Mesh *mesh = ob->data; | Material *material = BKE_object_material_get_eval(ob, part->omat); | ||||
| Material *material = part->omat - 1 < mesh->totcol ? NULL : mesh->mat[part->omat - 1]; | |||||
| eevee_cryptomatte_hair_cache_populate(vedata, sldata, ob, psys, md, material); | eevee_cryptomatte_hair_cache_populate(vedata, sldata, ob, psys, md, material); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| void EEVEE_cryptomatte_cache_populate(EEVEE_Data *vedata, EEVEE_ViewLayerData *sldata, Object *ob) | void EEVEE_cryptomatte_cache_populate(EEVEE_Data *vedata, EEVEE_ViewLayerData *sldata, Object *ob) | ||||
| { | { | ||||
| Show All 9 Lines | if ((cryptomatte_layers & VIEW_LAYER_CRYPTOMATTE_MATERIAL) != 0) { | ||||
| struct GPUBatch **geoms = DRW_cache_object_surface_material_get( | struct GPUBatch **geoms = DRW_cache_object_surface_material_get( | ||||
| ob, gpumat_array, materials_len); | ob, gpumat_array, materials_len); | ||||
| if (geoms) { | if (geoms) { | ||||
| for (int i = 0; i < materials_len; i++) { | for (int i = 0; i < materials_len; i++) { | ||||
| struct GPUBatch *geom = geoms[i]; | struct GPUBatch *geom = geoms[i]; | ||||
| if (geom == NULL) { | if (geom == NULL) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| Material *material = BKE_object_material_get(ob, i + 1); | Material *material = BKE_object_material_get_eval(ob, i + 1); | ||||
| DRWShadingGroup *grp = eevee_cryptomatte_shading_group_create( | DRWShadingGroup *grp = eevee_cryptomatte_shading_group_create( | ||||
| vedata, sldata, ob, material, false); | vedata, sldata, ob, material, false); | ||||
| DRW_shgroup_call(grp, geom, ob); | DRW_shgroup_call(grp, geom, ob); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| GPUBatch *geom = DRW_cache_object_surface_get(ob); | GPUBatch *geom = DRW_cache_object_surface_get(ob); | ||||
| ▲ Show 20 Lines • Show All 397 Lines • Show Last 20 Lines | |||||