Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/engines/workbench/workbench_materials.c
| Show First 20 Lines • Show All 204 Lines • ▼ Show 20 Lines | case V3D_SHADING_MATERIAL_COLOR: { | ||||
| uint32_t mat_id, id = wpd->material_index++; | uint32_t mat_id, id = wpd->material_index++; | ||||
| workbench_material_chunk_select(wpd, id, &mat_id); | workbench_material_chunk_select(wpd, id, &mat_id); | ||||
| workbench_material_ubo_data(wpd, ob, ma, &wpd->material_ubo_data_curr[mat_id], color_type); | workbench_material_ubo_data(wpd, ob, ma, &wpd->material_ubo_data_curr[mat_id], color_type); | ||||
| DRWShadingGroup *grp = prepass->common_shgrp; | DRWShadingGroup *grp = prepass->common_shgrp; | ||||
| *grp_mat = grp = DRW_shgroup_create_sub(grp); | *grp_mat = grp = DRW_shgroup_create_sub(grp); | ||||
| DRW_shgroup_uniform_block(grp, "material_block", wpd->material_ubo_curr); | DRW_shgroup_uniform_block(grp, "materials_data", wpd->material_ubo_curr); | ||||
| DRW_shgroup_uniform_int_copy(grp, "materialIndex", mat_id); | DRW_shgroup_uniform_int_copy(grp, "materialIndex", mat_id); | ||||
| return grp; | return grp; | ||||
| } | } | ||||
| case V3D_SHADING_VERTEX_COLOR: { | case V3D_SHADING_VERTEX_COLOR: { | ||||
| const bool transp = wpd->shading.xray_alpha < 1.0f; | const bool transp = wpd->shading.xray_alpha < 1.0f; | ||||
| DRWShadingGroup *grp = wpd->prepass[transp][infront][datatype].vcol_shgrp; | DRWShadingGroup *grp = wpd->prepass[transp][infront][datatype].vcol_shgrp; | ||||
| return grp; | return grp; | ||||
| } | } | ||||
| default: { | default: { | ||||
| /* For now, we use the same ubo for material and object coloring but with different indices. | /* For now, we use the same ubo for material and object coloring but with different indices. | ||||
| * This means they are mutually exclusive. */ | * This means they are mutually exclusive. */ | ||||
| BLI_assert( | BLI_assert( | ||||
| !ELEM(wpd->shading.color_type, V3D_SHADING_MATERIAL_COLOR, V3D_SHADING_TEXTURE_COLOR)); | !ELEM(wpd->shading.color_type, V3D_SHADING_MATERIAL_COLOR, V3D_SHADING_TEXTURE_COLOR)); | ||||
| uint32_t mat_id, id = DRW_object_resource_id_get(ob); | uint32_t mat_id, id = DRW_object_resource_id_get(ob); | ||||
| bool resource_changed = workbench_material_chunk_select(wpd, id, &mat_id); | bool resource_changed = workbench_material_chunk_select(wpd, id, &mat_id); | ||||
| workbench_material_ubo_data(wpd, ob, NULL, &wpd->material_ubo_data_curr[mat_id], color_type); | workbench_material_ubo_data(wpd, ob, NULL, &wpd->material_ubo_data_curr[mat_id], color_type); | ||||
| const bool transp = wpd->shading.xray_alpha < 1.0f || ob->color[3] < 1.0f; | const bool transp = wpd->shading.xray_alpha < 1.0f || ob->color[3] < 1.0f; | ||||
| DRWShadingGroup **grp = &wpd->prepass[transp][infront][datatype].common_shgrp; | DRWShadingGroup **grp = &wpd->prepass[transp][infront][datatype].common_shgrp; | ||||
| if (resource_changed) { | if (resource_changed) { | ||||
| *grp = DRW_shgroup_create_sub(*grp); | *grp = DRW_shgroup_create_sub(*grp); | ||||
| DRW_shgroup_uniform_block(*grp, "material_block", wpd->material_ubo_curr); | DRW_shgroup_uniform_block(*grp, "materials_data", wpd->material_ubo_curr); | ||||
| } | } | ||||
| if (r_transp && transp) { | if (r_transp && transp) { | ||||
| *r_transp = true; | *r_transp = true; | ||||
| } | } | ||||
| return *grp; | return *grp; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 52 Lines • Show Last 20 Lines | |||||