|
|
|
@@ -360,7 +360,9 @@ static char *eevee_get_volume_defines(int options)
|
|
|
|
|
**/
|
|
|
|
|
static void add_standard_uniforms(
|
|
|
|
|
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_diffuse, bool use_glossy, bool use_refract,
|
|
|
|
|
bool use_ssrefraction, bool use_alpha_blend)
|
|
|
|
|
{
|
|
|
|
|
LightCache *lcache = vedata->stl->g_data->light_cache;
|
|
|
|
|
|
|
|
|
@@ -377,13 +379,13 @@ static void add_standard_uniforms(
|
|
|
|
|
DRW_shgroup_uniform_block(shgrp, "common_block", sldata->common_ubo);
|
|
|
|
|
DRW_shgroup_uniform_block(shgrp, "clip_block", sldata->clip_ubo);
|
|
|
|
|
|
|
|
|
|
/* TODO if glossy or diffuse bsdf */
|
|
|
|
|
if (true) {
|
|
|
|
|
if (use_diffuse || use_glossy || use_refract) {
|
|
|
|
|
DRW_shgroup_uniform_texture(shgrp, "utilTex", e_data.util_tex);
|
|
|
|
|
DRW_shgroup_uniform_texture_ref(shgrp, "shadowCubeTexture", &sldata->shadow_cube_pool);
|
|
|
|
|
DRW_shgroup_uniform_texture_ref(shgrp, "shadowCascadeTexture", &sldata->shadow_cascade_pool);
|
|
|
|
|
DRW_shgroup_uniform_texture_ref(shgrp, "maxzBuffer", &vedata->txl->maxzbuffer);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if ((use_diffuse || use_glossy) && !use_refract) {
|
|
|
|
|
if ((vedata->stl->effects->enabled_effects & EFFECT_GTAO) != 0) {
|
|
|
|
|
DRW_shgroup_uniform_texture_ref(shgrp, "horizonBuffer", &vedata->stl->effects->gtao_horizons);
|
|
|
|
|
}
|
|
|
|
@@ -392,15 +394,13 @@ static void add_standard_uniforms(
|
|
|
|
|
DRW_shgroup_uniform_texture_ref(shgrp, "horizonBuffer", &vedata->txl->maxzbuffer);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* TODO if diffuse bsdf */
|
|
|
|
|
if (true) {
|
|
|
|
|
if (use_diffuse) {
|
|
|
|
|
DRW_shgroup_uniform_texture_ref(shgrp, "irradianceGrid", &lcache->grid_tx.tex);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* TODO if glossy bsdf */
|
|
|
|
|
if (true) {
|
|
|
|
|
if (use_glossy || use_refract) {
|
|
|
|
|
DRW_shgroup_uniform_texture_ref(shgrp, "probeCubes", &lcache->cube_tx.tex);
|
|
|
|
|
}
|
|
|
|
|
if (use_glossy) {
|
|
|
|
|
DRW_shgroup_uniform_texture_ref(shgrp, "probePlanars", &vedata->txl->planar_pool);
|
|
|
|
|
DRW_shgroup_uniform_int(shgrp, "outputSsrId", ssr_id, 1);
|
|
|
|
|
}
|
|
|
|
@@ -851,7 +851,7 @@ static struct DRWShadingGroup *EEVEE_default_shading_group_create(
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DRWShadingGroup *shgrp = DRW_shgroup_create(e_data.default_lit[options], pass);
|
|
|
|
|
add_standard_uniforms(shgrp, sldata, vedata, &ssr_id, NULL, false, use_blend);
|
|
|
|
|
add_standard_uniforms(shgrp, sldata, vedata, &ssr_id, NULL, true, true, false, false, use_blend);
|
|
|
|
|
|
|
|
|
|
return shgrp;
|
|
|
|
|
}
|
|
|
|
@@ -888,7 +888,7 @@ static struct DRWShadingGroup *EEVEE_default_shading_group_get(
|
|
|
|
|
* EDIT: THIS IS NOT THE CASE FOR HAIRS !!! DUMMY!!! */
|
|
|
|
|
if (!is_hair) {
|
|
|
|
|
DRWShadingGroup *shgrp = DRW_shgroup_create(e_data.default_lit[options], vedata->psl->default_pass[options]);
|
|
|
|
|
add_standard_uniforms(shgrp, sldata, vedata, &ssr_id, NULL, false, false);
|
|
|
|
|
add_standard_uniforms(shgrp, sldata, vedata, &ssr_id, NULL, true, true, false, false, false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -896,7 +896,7 @@ static struct DRWShadingGroup *EEVEE_default_shading_group_get(
|
|
|
|
|
DRWShadingGroup *shgrp = DRW_shgroup_hair_create(ob, psys, md,
|
|
|
|
|
vedata->psl->default_pass[options],
|
|
|
|
|
e_data.default_lit[options]);
|
|
|
|
|
add_standard_uniforms(shgrp, sldata, vedata, &ssr_id, NULL, false, false);
|
|
|
|
|
add_standard_uniforms(shgrp, sldata, vedata, &ssr_id, NULL, true, true, false, false, false);
|
|
|
|
|
return shgrp;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
@@ -928,7 +928,7 @@ static struct DRWShadingGroup *EEVEE_lookdev_shading_group_get(
|
|
|
|
|
DRWShadingGroup *shgrp = DRW_shgroup_create(e_data.default_lit[options], vedata->psl->lookdev_pass);
|
|
|
|
|
/* XXX / WATCH: This creates non persistent binds for the ubos and textures.
|
|
|
|
|
* But it's currently OK because the following shgroups does not add any bind. */
|
|
|
|
|
add_standard_uniforms(shgrp, sldata, vedata, &ssr_id, NULL, false, false);
|
|
|
|
|
add_standard_uniforms(shgrp, sldata, vedata, &ssr_id, NULL, true, true, false, false, false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return DRW_shgroup_create(e_data.default_lit[options], vedata->psl->lookdev_pass);
|
|
|
|
@@ -1116,6 +1116,7 @@ static void material_opaque(
|
|
|
|
|
EEVEE_StorageList *stl = ((EEVEE_Data *)vedata)->stl;
|
|
|
|
|
EEVEE_PassList *psl = ((EEVEE_Data *)vedata)->psl;
|
|
|
|
|
EEVEE_LampsInfo *linfo = sldata->lamps;
|
|
|
|
|
bool use_diffuse, use_glossy, use_refract;
|
|
|
|
|
|
|
|
|
|
float *color_p = &ma->r;
|
|
|
|
|
float *metal_p = &ma->metallic;
|
|
|
|
@@ -1123,7 +1124,7 @@ static void material_opaque(
|
|
|
|
|
float *rough_p = &ma->roughness;
|
|
|
|
|
|
|
|
|
|
const bool use_gpumat = (ma->use_nodes && ma->nodetree);
|
|
|
|
|
const bool use_refract = ((ma->blend_flag & MA_BL_SS_REFRACTION) != 0) &&
|
|
|
|
|
const bool use_ssrefract = ((ma->blend_flag & MA_BL_SS_REFRACTION) != 0) &&
|
|
|
|
|
((effects->enabled_effects & EFFECT_REFRACT) != 0);
|
|
|
|
|
const bool use_sss = ((ma->blend_flag & MA_BL_SS_SUBSURFACE) != 0) &&
|
|
|
|
|
((effects->enabled_effects & EFFECT_SSS) != 0);
|
|
|
|
@@ -1138,7 +1139,7 @@ static void material_opaque(
|
|
|
|
|
|
|
|
|
|
/* This will have been created already, just perform a lookup. */
|
|
|
|
|
*gpumat = (use_gpumat) ? EEVEE_material_mesh_get(
|
|
|
|
|
scene, ma, vedata, false, false, use_refract, use_sss, use_translucency, linfo->shadow_method) : NULL;
|
|
|
|
|
scene, ma, vedata, false, false, use_ssrefract, use_sss, use_translucency, linfo->shadow_method) : NULL;
|
|
|
|
|
*gpumat_depth = (use_gpumat) ? EEVEE_material_mesh_depth_get(
|
|
|
|
|
scene, ma, (ma->blend_method == MA_BM_HASHED), false) : NULL;
|
|
|
|
|
return;
|
|
|
|
@@ -1151,7 +1152,7 @@ static void material_opaque(
|
|
|
|
|
|
|
|
|
|
/* Shading */
|
|
|
|
|
*gpumat = EEVEE_material_mesh_get(
|
|
|
|
|
scene, ma, vedata, false, false, use_refract,
|
|
|
|
|
scene, ma, vedata, false, false, use_ssrefract,
|
|
|
|
|
use_sss, use_translucency, linfo->shadow_method);
|
|
|
|
|
|
|
|
|
|
GPUMaterialStatus status_mat_surface = GPU_material_status(*gpumat);
|
|
|
|
@@ -1167,7 +1168,7 @@ static void material_opaque(
|
|
|
|
|
* the surface shader. */
|
|
|
|
|
status_mat_surface = status_mat_depth;
|
|
|
|
|
}
|
|
|
|
|
else if (use_refract) {
|
|
|
|
|
else if (use_ssrefract) {
|
|
|
|
|
*shgrp_depth = DRW_shgroup_material_create(
|
|
|
|
|
*gpumat_depth, (do_cull) ? psl->refract_depth_pass_cull : psl->refract_depth_pass);
|
|
|
|
|
*shgrp_depth_clip = DRW_shgroup_material_create(
|
|
|
|
@@ -1181,8 +1182,14 @@ static void material_opaque(
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (*shgrp_depth != NULL) {
|
|
|
|
|
add_standard_uniforms(*shgrp_depth, sldata, vedata, NULL, NULL, false, false);
|
|
|
|
|
add_standard_uniforms(*shgrp_depth_clip, sldata, vedata, NULL, NULL, false, false);
|
|
|
|
|
use_diffuse = GPU_material_flag_get(*gpumat_depth, GPU_MATFLAG_DIFFUSE);
|
|
|
|
|
use_glossy = GPU_material_flag_get(*gpumat_depth, GPU_MATFLAG_GLOSSY);
|
|
|
|
|
use_refract = GPU_material_flag_get(*gpumat_depth, GPU_MATFLAG_REFRACT);
|
|
|
|
|
|
|
|
|
|
add_standard_uniforms(*shgrp_depth, sldata, vedata, NULL, NULL,
|
|
|
|
|
use_diffuse, use_glossy, use_refract, false, false);
|
|
|
|
|
add_standard_uniforms(*shgrp_depth_clip, sldata, vedata, NULL, NULL,
|
|
|
|
|
use_diffuse, use_glossy, use_refract, false, false);
|
|
|
|
|
|
|
|
|
|
if (ma->blend_method == MA_BM_CLIP) {
|
|
|
|
|
DRW_shgroup_uniform_float(*shgrp_depth, "alphaThreshold", &ma->alpha_threshold, 1);
|
|
|
|
@@ -1200,13 +1207,18 @@ static void material_opaque(
|
|
|
|
|
{
|
|
|
|
|
static int no_ssr = -1;
|
|
|
|
|
static int first_ssr = 1;
|
|
|
|
|
int *ssr_id = (((effects->enabled_effects & EFFECT_SSR) != 0) && !use_refract) ? &first_ssr : &no_ssr;
|
|
|
|
|
int *ssr_id = (((effects->enabled_effects & EFFECT_SSR) != 0) && !use_ssrefract) ? &first_ssr : &no_ssr;
|
|
|
|
|
use_diffuse = GPU_material_flag_get(*gpumat, GPU_MATFLAG_DIFFUSE);
|
|
|
|
|
use_glossy = GPU_material_flag_get(*gpumat, GPU_MATFLAG_GLOSSY);
|
|
|
|
|
use_refract = GPU_material_flag_get(*gpumat, GPU_MATFLAG_REFRACT);
|
|
|
|
|
|
|
|
|
|
*shgrp = DRW_shgroup_material_create(
|
|
|
|
|
*gpumat,
|
|
|
|
|
(use_refract) ? psl->refract_pass :
|
|
|
|
|
(use_ssrefract) ? psl->refract_pass :
|
|
|
|
|
(use_sss) ? psl->sss_pass : psl->material_pass);
|
|
|
|
|
add_standard_uniforms(*shgrp, sldata, vedata, ssr_id, &ma->refract_depth, use_refract, false);
|
|
|
|
|
|
|
|
|
|
add_standard_uniforms(*shgrp, sldata, vedata, ssr_id, &ma->refract_depth,
|
|
|
|
|
use_diffuse, use_glossy, use_refract, use_ssrefract, false);
|
|
|
|
|
|
|
|
|
|
if (use_sss) {
|
|
|
|
|
struct GPUTexture *sss_tex_profile = NULL;
|
|
|
|
@@ -1237,7 +1249,6 @@ static void material_opaque(
|
|
|
|
|
}
|
|
|
|
|
case GPU_MAT_QUEUED:
|
|
|
|
|
{
|
|
|
|
|
/* TODO Bypass probe compilation. */
|
|
|
|
|
color_p = compile_col;
|
|
|
|
|
metal_p = spec_p = rough_p = ½
|
|
|
|
|
break;
|
|
|
|
@@ -1264,7 +1275,7 @@ static void material_opaque(
|
|
|
|
|
|
|
|
|
|
/* Fallback default depth prepass */
|
|
|
|
|
if (*shgrp_depth == NULL) {
|
|
|
|
|
if (use_refract) {
|
|
|
|
|
if (use_ssrefract) {
|
|
|
|
|
*shgrp_depth = (do_cull) ? stl->g_data->refract_depth_shgrp_cull : stl->g_data->refract_depth_shgrp;
|
|
|
|
|
*shgrp_depth_clip = (do_cull) ? stl->g_data->refract_depth_shgrp_clip_cull : stl->g_data->refract_depth_shgrp_clip;
|
|
|
|
|
}
|
|
|
|
@@ -1292,7 +1303,7 @@ static void material_transparent(
|
|
|
|
|
EEVEE_PassList *psl = ((EEVEE_Data *)vedata)->psl;
|
|
|
|
|
EEVEE_LampsInfo *linfo = sldata->lamps;
|
|
|
|
|
|
|
|
|
|
const bool use_refract = (
|
|
|
|
|
const bool use_ssrefract = (
|
|
|
|
|
((ma->blend_flag & MA_BL_SS_REFRACTION) != 0) &&
|
|
|
|
|
((stl->effects->enabled_effects & EFFECT_REFRACT) != 0)
|
|
|
|
|
);
|
|
|
|
@@ -1308,7 +1319,7 @@ static void material_transparent(
|
|
|
|
|
|
|
|
|
|
/* Shading */
|
|
|
|
|
*gpumat = EEVEE_material_mesh_get(
|
|
|
|
|
scene, ma, vedata, true, (ma->blend_method == MA_BM_MULTIPLY), use_refract,
|
|
|
|
|
scene, ma, vedata, true, (ma->blend_method == MA_BM_MULTIPLY), use_ssrefract,
|
|
|
|
|
false, false, linfo->shadow_method);
|
|
|
|
|
|
|
|
|
|
switch (GPU_material_status(*gpumat)) {
|
|
|
|
@@ -1318,7 +1329,13 @@ static void material_transparent(
|
|
|
|
|
bool use_blend = (ma->blend_method & MA_BM_BLEND) != 0;
|
|
|
|
|
|
|
|
|
|
*shgrp = DRW_shgroup_material_create(*gpumat, psl->transparent_pass);
|
|
|
|
|
add_standard_uniforms(*shgrp, sldata, vedata, &ssr_id, &ma->refract_depth, use_refract, use_blend);
|
|
|
|
|
|
|
|
|
|
bool use_diffuse = GPU_material_flag_get(*gpumat, GPU_MATFLAG_DIFFUSE);
|
|
|
|
|
bool use_glossy = GPU_material_flag_get(*gpumat, GPU_MATFLAG_GLOSSY);
|
|
|
|
|
bool use_refract = GPU_material_flag_get(*gpumat, GPU_MATFLAG_REFRACT);
|
|
|
|
|
|
|
|
|
|
add_standard_uniforms(*shgrp, sldata, vedata, &ssr_id, &ma->refract_depth,
|
|
|
|
|
use_diffuse, use_glossy, use_refract, use_ssrefract, use_blend);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case GPU_MAT_QUEUED:
|
|
|
|
@@ -1643,11 +1660,17 @@ void EEVEE_hair_cache_populate(EEVEE_Data *vedata, EEVEE_ViewLayerData *sldata,
|
|
|
|
|
switch (GPU_material_status(gpumat)) {
|
|
|
|
|
case GPU_MAT_SUCCESS:
|
|
|
|
|
{
|
|
|
|
|
bool use_diffuse = GPU_material_flag_get(gpumat, GPU_MATFLAG_DIFFUSE);
|
|
|
|
|
bool use_glossy = GPU_material_flag_get(gpumat, GPU_MATFLAG_GLOSSY);
|
|
|
|
|
bool use_refract = GPU_material_flag_get(gpumat, GPU_MATFLAG_REFRACT);
|
|
|
|
|
|
|
|
|
|
shgrp = DRW_shgroup_material_hair_create(
|
|
|
|
|
ob, psys, md,
|
|
|
|
|
psl->material_pass,
|
|
|
|
|
gpumat);
|
|
|
|
|
add_standard_uniforms(shgrp, sldata, vedata, &ssr_id, NULL, false, false);
|
|
|
|
|
|
|
|
|
|
add_standard_uniforms(shgrp, sldata, vedata, &ssr_id, NULL,
|
|
|
|
|
use_diffuse, use_glossy, use_refract, false, false);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case GPU_MAT_QUEUED:
|
|
|
|
|