Fix T71050 EEVEE: Light Path Node broken in 2.81
Also fixes the sampling of hashed shadows.
This commit is contained in:
parent
d758a79557
commit
883e22a92c
Notes:
blender-bot
2024-01-16 18:05:25 +01:00
Referenced by issue #71050, Light Path Node broken in Eevee 2.81
|
@ -68,8 +68,6 @@ static struct {
|
|||
|
||||
uint sss_count;
|
||||
|
||||
float alpha_hash_offset;
|
||||
float alpha_hash_scale;
|
||||
float noise_offsets[3];
|
||||
} e_data = {NULL}; /* Engine data */
|
||||
|
||||
|
@ -609,14 +607,14 @@ void EEVEE_materials_init(EEVEE_ViewLayerData *sldata,
|
|||
}
|
||||
|
||||
if (!DRW_state_is_image_render() && ((stl->effects->enabled_effects & EFFECT_TAA) == 0)) {
|
||||
e_data.alpha_hash_offset = 0.0f;
|
||||
e_data.alpha_hash_scale = 1.0f;
|
||||
sldata->common_data.alpha_hash_offset = 0.0f;
|
||||
sldata->common_data.alpha_hash_scale = 1.0f;
|
||||
}
|
||||
else {
|
||||
double r;
|
||||
BLI_halton_1d(5, 0.0, stl->effects->taa_current_sample - 1, &r);
|
||||
e_data.alpha_hash_offset = (float)r;
|
||||
e_data.alpha_hash_scale = 0.01f;
|
||||
sldata->common_data.alpha_hash_offset = (float)r;
|
||||
sldata->common_data.alpha_hash_scale = 0.01f;
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -1218,14 +1216,6 @@ static void material_opaque(Material *ma,
|
|||
DRW_shgroup_uniform_float(*shgrp_depth, "alphaThreshold", &ma->alpha_threshold, 1);
|
||||
DRW_shgroup_uniform_float(*shgrp_depth_clip, "alphaThreshold", &ma->alpha_threshold, 1);
|
||||
}
|
||||
else if (ma->blend_method == MA_BM_HASHED) {
|
||||
DRW_shgroup_uniform_float(*shgrp_depth, "hashAlphaOffset", &e_data.alpha_hash_offset, 1);
|
||||
DRW_shgroup_uniform_float(
|
||||
*shgrp_depth_clip, "hashAlphaOffset", &e_data.alpha_hash_offset, 1);
|
||||
DRW_shgroup_uniform_float_copy(*shgrp_depth, "hashAlphaScale", e_data.alpha_hash_scale);
|
||||
DRW_shgroup_uniform_float_copy(
|
||||
*shgrp_depth_clip, "hashAlphaScale", e_data.alpha_hash_scale);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -665,9 +665,13 @@ typedef struct EEVEE_CommonUniformBuffer {
|
|||
float prb_lod_cube_max; /* float */
|
||||
float prb_lod_planar_max; /* float */
|
||||
/* Misc */
|
||||
int hiz_mip_offset; /* int */
|
||||
int ray_type; /* int */
|
||||
float ray_depth; /* float */
|
||||
int hiz_mip_offset; /* int */
|
||||
int ray_type; /* int */
|
||||
float ray_depth; /* float */
|
||||
float alpha_hash_offset; /* float */
|
||||
float alpha_hash_scale; /* float */
|
||||
float pad7; /* float */
|
||||
float pad8; /* float */
|
||||
} EEVEE_CommonUniformBuffer;
|
||||
|
||||
BLI_STATIC_ASSERT_ALIGN(EEVEE_CommonUniformBuffer, 16)
|
||||
|
|
|
@ -365,7 +365,7 @@ void EEVEE_shadows_draw(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, DRWView
|
|||
|
||||
/* Precompute all shadow/view test before rendering and trashing the culling cache. */
|
||||
BLI_bitmap *cube_visible = BLI_BITMAP_NEW_ALLOCA(MAX_SHADOW_CUBE);
|
||||
bool any_visible = false;
|
||||
bool any_visible = linfo->cascade_len > 0;
|
||||
for (int cube = 0; cube < linfo->cube_len; cube++) {
|
||||
if (DRW_culling_sphere_test(view, linfo->shadow_bounds + cube)) {
|
||||
BLI_BITMAP_ENABLE(cube_visible, cube);
|
||||
|
@ -373,7 +373,7 @@ void EEVEE_shadows_draw(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, DRWView
|
|||
}
|
||||
}
|
||||
|
||||
if (!any_visible && linfo->cascade_len == 0) {
|
||||
if (any_visible) {
|
||||
sldata->common_data.ray_type = EEVEE_RAY_SHADOW;
|
||||
DRW_uniformbuffer_update(sldata->common_ubo, &sldata->common_data);
|
||||
}
|
||||
|
@ -400,7 +400,7 @@ void EEVEE_shadows_draw(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, DRWView
|
|||
|
||||
DRW_uniformbuffer_update(sldata->shadow_ubo, &linfo->shadow_data); /* Update all data at once */
|
||||
|
||||
if (!any_visible && linfo->cascade_len == 0) {
|
||||
if (any_visible) {
|
||||
sldata->common_data.ray_type = saved_ray_type;
|
||||
DRW_uniformbuffer_update(sldata->common_ubo, &sldata->common_data);
|
||||
}
|
||||
|
|
|
@ -43,6 +43,10 @@ layout(std140) uniform common_block
|
|||
int hizMipOffset;
|
||||
int rayType;
|
||||
float rayDepth;
|
||||
float alphaHashOffset;
|
||||
float alphaHashScale;
|
||||
float pad7;
|
||||
float pad8;
|
||||
};
|
||||
|
||||
/* rayType (keep in sync with ray_type) */
|
||||
|
|
|
@ -12,14 +12,11 @@ float hash3d(vec3 a)
|
|||
return hash(vec2(hash(a.xy), a.z));
|
||||
}
|
||||
|
||||
uniform float hashAlphaOffset;
|
||||
uniform float hashAlphaScale = 1.0; /* Roughly in pixel */
|
||||
|
||||
float hashed_alpha_threshold(vec3 co)
|
||||
{
|
||||
/* Find the discretized derivatives of our coordinates. */
|
||||
float max_deriv = max(length(dFdx(co)), length(dFdy(co)));
|
||||
float pix_scale = 1.0 / (hashAlphaScale * max_deriv);
|
||||
float pix_scale = 1.0 / (alphaHashScale * max_deriv);
|
||||
|
||||
/* Find two nearest log-discretized noise scales. */
|
||||
float pix_scale_log = log2(pix_scale);
|
||||
|
@ -52,7 +49,7 @@ float hashed_alpha_threshold(vec3 co)
|
|||
threshold = clamp(threshold, 1.0e-6, 1.0);
|
||||
|
||||
/* Jitter the threshold for TAA accumulation. */
|
||||
return fract(threshold + hashAlphaOffset);
|
||||
return fract(threshold + alphaHashOffset);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue