Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/engines/eevee/eevee_materials.c
| Show First 20 Lines • Show All 342 Lines • ▼ Show 20 Lines | static char *eevee_get_volume_defines(int options) | ||||
| return str; | return str; | ||||
| } | } | ||||
| /** | /** | ||||
| * ssr_id can be null to disable ssr contribution. | * ssr_id can be null to disable ssr contribution. | ||||
| **/ | **/ | ||||
| static void add_standard_uniforms( | static void add_standard_uniforms( | ||||
| DRWShadingGroup *shgrp, EEVEE_SceneLayerData *sldata, EEVEE_Data *vedata, | DRWShadingGroup *shgrp, EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, | ||||
| int *ssr_id, float *refract_depth, bool use_ssrefraction, bool use_alpha_blend) | int *ssr_id, float *refract_depth, bool use_ssrefraction, bool use_alpha_blend) | ||||
| { | { | ||||
| if (ssr_id == NULL || !vedata->stl->g_data->valid_double_buffer) { | if (ssr_id == NULL || !vedata->stl->g_data->valid_double_buffer) { | ||||
| static int no_ssr = -1.0f; | static int no_ssr = -1.0f; | ||||
| ssr_id = &no_ssr; | ssr_id = &no_ssr; | ||||
| } | } | ||||
| DRW_shgroup_uniform_block(shgrp, "probe_block", sldata->probe_ubo); | DRW_shgroup_uniform_block(shgrp, "probe_block", sldata->probe_ubo); | ||||
| DRW_shgroup_uniform_block(shgrp, "grid_block", sldata->grid_ubo); | DRW_shgroup_uniform_block(shgrp, "grid_block", sldata->grid_ubo); | ||||
| ▲ Show 20 Lines • Show All 399 Lines • ▼ Show 20 Lines | struct GPUMaterial *EEVEE_material_hair_get( | ||||
| return mat; | return mat; | ||||
| } | } | ||||
| /** | /** | ||||
| * Create a default shading group inside the given pass. | * Create a default shading group inside the given pass. | ||||
| **/ | **/ | ||||
| static struct DRWShadingGroup *EEVEE_default_shading_group_create( | static struct DRWShadingGroup *EEVEE_default_shading_group_create( | ||||
| EEVEE_SceneLayerData *sldata, EEVEE_Data *vedata, DRWPass *pass, | EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, DRWPass *pass, | ||||
| bool is_hair, bool is_flat_normal, bool use_blend, bool use_ssr, int shadow_method) | bool is_hair, bool is_flat_normal, bool use_blend, bool use_ssr, int shadow_method) | ||||
| { | { | ||||
| static int ssr_id; | static int ssr_id; | ||||
| ssr_id = (use_ssr) ? 1 : -1; | ssr_id = (use_ssr) ? 1 : -1; | ||||
| int options = VAR_MAT_MESH; | int options = VAR_MAT_MESH; | ||||
| if (is_hair) options |= VAR_MAT_HAIR; | if (is_hair) options |= VAR_MAT_HAIR; | ||||
| if (is_flat_normal) options |= VAR_MAT_FLAT; | if (is_flat_normal) options |= VAR_MAT_FLAT; | ||||
| Show All 11 Lines | static struct DRWShadingGroup *EEVEE_default_shading_group_create( | ||||
| return shgrp; | return shgrp; | ||||
| } | } | ||||
| /** | /** | ||||
| * Create a default shading group inside the default pass without standard uniforms. | * Create a default shading group inside the default pass without standard uniforms. | ||||
| **/ | **/ | ||||
| static struct DRWShadingGroup *EEVEE_default_shading_group_get( | static struct DRWShadingGroup *EEVEE_default_shading_group_get( | ||||
| EEVEE_SceneLayerData *sldata, EEVEE_Data *vedata, | EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, | ||||
| bool is_hair, bool is_flat_normal, bool use_ssr, int shadow_method) | bool is_hair, bool is_flat_normal, bool use_ssr, int shadow_method) | ||||
| { | { | ||||
| static int ssr_id; | static int ssr_id; | ||||
| ssr_id = (use_ssr) ? 1 : -1; | ssr_id = (use_ssr) ? 1 : -1; | ||||
| int options = VAR_MAT_MESH; | int options = VAR_MAT_MESH; | ||||
| if (is_hair) options |= VAR_MAT_HAIR; | if (is_hair) options |= VAR_MAT_HAIR; | ||||
| if (is_flat_normal) options |= VAR_MAT_FLAT; | if (is_flat_normal) options |= VAR_MAT_FLAT; | ||||
| Show All 17 Lines | |||||
| void EEVEE_materials_cache_init(EEVEE_Data *vedata) | void EEVEE_materials_cache_init(EEVEE_Data *vedata) | ||||
| { | { | ||||
| EEVEE_PassList *psl = ((EEVEE_Data *)vedata)->psl; | EEVEE_PassList *psl = ((EEVEE_Data *)vedata)->psl; | ||||
| EEVEE_StorageList *stl = ((EEVEE_Data *)vedata)->stl; | EEVEE_StorageList *stl = ((EEVEE_Data *)vedata)->stl; | ||||
| { | { | ||||
| const DRWContextState *draw_ctx = DRW_context_state_get(); | const DRWContextState *draw_ctx = DRW_context_state_get(); | ||||
| SceneLayer *scene_layer = draw_ctx->scene_layer; | ViewLayer *view_layer = draw_ctx->view_layer; | ||||
| IDProperty *props = BKE_scene_layer_engine_evaluated_get(scene_layer, COLLECTION_MODE_NONE, RE_engine_id_BLENDER_EEVEE); | IDProperty *props = BKE_view_layer_engine_evaluated_get(view_layer, COLLECTION_MODE_NONE, RE_engine_id_BLENDER_EEVEE); | ||||
| /* Global AO Switch*/ | /* Global AO Switch*/ | ||||
| stl->effects->use_ao = BKE_collection_engine_property_value_get_bool(props, "gtao_enable"); | stl->effects->use_ao = BKE_collection_engine_property_value_get_bool(props, "gtao_enable"); | ||||
| stl->effects->use_bent_normals = BKE_collection_engine_property_value_get_bool(props, "gtao_use_bent_normals"); | stl->effects->use_bent_normals = BKE_collection_engine_property_value_get_bool(props, "gtao_use_bent_normals"); | ||||
| /* SSR switch */ | /* SSR switch */ | ||||
| stl->effects->use_ssr = BKE_collection_engine_property_value_get_bool(props, "ssr_enable"); | stl->effects->use_ssr = BKE_collection_engine_property_value_get_bool(props, "ssr_enable"); | ||||
| /* Volumetrics */ | /* Volumetrics */ | ||||
| stl->effects->use_volumetrics = BKE_collection_engine_property_value_get_bool(props, "volumetric_enable"); | stl->effects->use_volumetrics = BKE_collection_engine_property_value_get_bool(props, "volumetric_enable"); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 119 Lines • ▼ Show 20 Lines | |||||
| typedef struct EeveeMaterialShadingGroups { | typedef struct EeveeMaterialShadingGroups { | ||||
| struct DRWShadingGroup *shading_grp; | struct DRWShadingGroup *shading_grp; | ||||
| struct DRWShadingGroup *depth_grp; | struct DRWShadingGroup *depth_grp; | ||||
| struct DRWShadingGroup *depth_clip_grp; | struct DRWShadingGroup *depth_clip_grp; | ||||
| } EeveeMaterialShadingGroups; | } EeveeMaterialShadingGroups; | ||||
| static void material_opaque( | static void material_opaque( | ||||
| Material *ma, GHash *material_hash, EEVEE_SceneLayerData *sldata, EEVEE_Data *vedata, | Material *ma, GHash *material_hash, EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, | ||||
| bool do_cull, bool use_flat_nor, struct GPUMaterial **gpumat, struct GPUMaterial **gpumat_depth, | bool do_cull, bool use_flat_nor, struct GPUMaterial **gpumat, struct GPUMaterial **gpumat_depth, | ||||
| struct DRWShadingGroup **shgrp, struct DRWShadingGroup **shgrp_depth, struct DRWShadingGroup **shgrp_depth_clip) | struct DRWShadingGroup **shgrp, struct DRWShadingGroup **shgrp_depth, struct DRWShadingGroup **shgrp_depth_clip) | ||||
| { | { | ||||
| const DRWContextState *draw_ctx = DRW_context_state_get(); | const DRWContextState *draw_ctx = DRW_context_state_get(); | ||||
| Scene *scene = draw_ctx->scene; | Scene *scene = draw_ctx->scene; | ||||
| EEVEE_StorageList *stl = ((EEVEE_Data *)vedata)->stl; | EEVEE_StorageList *stl = ((EEVEE_Data *)vedata)->stl; | ||||
| EEVEE_PassList *psl = ((EEVEE_Data *)vedata)->psl; | EEVEE_PassList *psl = ((EEVEE_Data *)vedata)->psl; | ||||
| EEVEE_LampsInfo *linfo = sldata->lamps; | EEVEE_LampsInfo *linfo = sldata->lamps; | ||||
| ▲ Show 20 Lines • Show All 114 Lines • ▼ Show 20 Lines | static void material_opaque( | ||||
| emsg = MEM_mallocN(sizeof("EeveeMaterialShadingGroups"), "EeveeMaterialShadingGroups"); | emsg = MEM_mallocN(sizeof("EeveeMaterialShadingGroups"), "EeveeMaterialShadingGroups"); | ||||
| emsg->shading_grp = *shgrp; | emsg->shading_grp = *shgrp; | ||||
| emsg->depth_grp = *shgrp_depth; | emsg->depth_grp = *shgrp_depth; | ||||
| emsg->depth_clip_grp = *shgrp_depth_clip; | emsg->depth_clip_grp = *shgrp_depth_clip; | ||||
| BLI_ghash_insert(material_hash, ma, emsg); | BLI_ghash_insert(material_hash, ma, emsg); | ||||
| } | } | ||||
| static void material_transparent( | static void material_transparent( | ||||
| Material *ma, EEVEE_SceneLayerData *sldata, EEVEE_Data *vedata, | Material *ma, EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, | ||||
| bool do_cull, bool use_flat_nor, struct GPUMaterial **gpumat, struct DRWShadingGroup **shgrp, struct DRWShadingGroup **shgrp_depth) | bool do_cull, bool use_flat_nor, struct GPUMaterial **gpumat, struct DRWShadingGroup **shgrp, struct DRWShadingGroup **shgrp_depth) | ||||
| { | { | ||||
| const DRWContextState *draw_ctx = DRW_context_state_get(); | const DRWContextState *draw_ctx = DRW_context_state_get(); | ||||
| Scene *scene = draw_ctx->scene; | Scene *scene = draw_ctx->scene; | ||||
| EEVEE_StorageList *stl = ((EEVEE_Data *)vedata)->stl; | EEVEE_StorageList *stl = ((EEVEE_Data *)vedata)->stl; | ||||
| EEVEE_PassList *psl = ((EEVEE_Data *)vedata)->psl; | EEVEE_PassList *psl = ((EEVEE_Data *)vedata)->psl; | ||||
| EEVEE_LampsInfo *linfo = sldata->lamps; | EEVEE_LampsInfo *linfo = sldata->lamps; | ||||
| ▲ Show 20 Lines • Show All 71 Lines • ▼ Show 20 Lines | if (use_prepass) { | ||||
| cur_state = DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS; | cur_state = DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS; | ||||
| cur_state |= (do_cull) ? DRW_STATE_CULL_BACK : 0; | cur_state |= (do_cull) ? DRW_STATE_CULL_BACK : 0; | ||||
| DRW_shgroup_state_disable(*shgrp_depth, all_state); | DRW_shgroup_state_disable(*shgrp_depth, all_state); | ||||
| DRW_shgroup_state_enable(*shgrp_depth, cur_state); | DRW_shgroup_state_enable(*shgrp_depth, cur_state); | ||||
| } | } | ||||
| } | } | ||||
| void EEVEE_materials_cache_populate(EEVEE_Data *vedata, EEVEE_SceneLayerData *sldata, Object *ob) | void EEVEE_materials_cache_populate(EEVEE_Data *vedata, EEVEE_ViewLayerData *sldata, Object *ob) | ||||
| { | { | ||||
| EEVEE_PassList *psl = ((EEVEE_Data *)vedata)->psl; | EEVEE_PassList *psl = ((EEVEE_Data *)vedata)->psl; | ||||
| EEVEE_StorageList *stl = ((EEVEE_Data *)vedata)->stl; | EEVEE_StorageList *stl = ((EEVEE_Data *)vedata)->stl; | ||||
| const DRWContextState *draw_ctx = DRW_context_state_get(); | const DRWContextState *draw_ctx = DRW_context_state_get(); | ||||
| Scene *scene = draw_ctx->scene; | Scene *scene = draw_ctx->scene; | ||||
| GHash *material_hash = stl->g_data->material_hash; | GHash *material_hash = stl->g_data->material_hash; | ||||
| IDProperty *ces_mode_ob = BKE_layer_collection_engine_evaluated_get(ob, COLLECTION_MODE_OBJECT, ""); | IDProperty *ces_mode_ob = BKE_layer_collection_engine_evaluated_get(ob, COLLECTION_MODE_OBJECT, ""); | ||||
| ▲ Show 20 Lines • Show All 246 Lines • Show Last 20 Lines | |||||