Fix T89777 EEVEE: Contact Shadows causes wrong shading in Reflection Plane
The planar reflections being rendered at the same resolution as the HiZ max buffer, do not need any uv correction during raytracing. However, the GTAO horizon buffer being at output resolution do need the uv factors in order to match the pixels visible on screen. To avoid many complication, we increase the size of the GTAO texture up to the hiz buffer size. This way, if planar reflections need GTAO the texture is big enough. We change the viewport of the GTAO framebuffer for the main view in order to not have to modify Uvs in many places.
This commit is contained in:
@@ -94,6 +94,10 @@ void EEVEE_effects_init(EEVEE_ViewLayerData *sldata,
|
||||
|
||||
effects = stl->effects;
|
||||
|
||||
int div = 1 << MAX_SCREEN_BUFFERS_LOD_LEVEL;
|
||||
effects->hiz_size[0] = divide_ceil_u(size_fs[0], div) * div;
|
||||
effects->hiz_size[1] = divide_ceil_u(size_fs[1], div) * div;
|
||||
|
||||
effects->enabled_effects = 0;
|
||||
effects->enabled_effects |= (G.debug_value == 9) ? EFFECT_VELOCITY_BUFFER : 0;
|
||||
effects->enabled_effects |= EEVEE_motion_blur_init(sldata, vedata);
|
||||
@@ -118,9 +122,6 @@ void EEVEE_effects_init(EEVEE_ViewLayerData *sldata,
|
||||
/**
|
||||
* MinMax Pyramid
|
||||
*/
|
||||
int div = 1 << MAX_SCREEN_BUFFERS_LOD_LEVEL;
|
||||
effects->hiz_size[0] = divide_ceil_u(size_fs[0], div) * div;
|
||||
effects->hiz_size[1] = divide_ceil_u(size_fs[1], div) * div;
|
||||
|
||||
if (GPU_type_matches(GPU_DEVICE_INTEL, GPU_OS_ANY, GPU_DRIVER_ANY)) {
|
||||
/* Intel gpu seems to have problem rendering to only depth hiz_format */
|
||||
|
@@ -1203,6 +1203,8 @@ void EEVEE_lightprobes_refresh_planar(EEVEE_ViewLayerData *sldata, EEVEE_Data *v
|
||||
return;
|
||||
}
|
||||
|
||||
float hiz_uv_scale_prev[2] = {UNPACK2(common_data->hiz_uv_scale)};
|
||||
|
||||
/* Temporary Remove all planar reflections (avoid lag effect). */
|
||||
common_data->prb_num_planar = 0;
|
||||
/* Turn off ssr to avoid black specular */
|
||||
@@ -1212,6 +1214,9 @@ void EEVEE_lightprobes_refresh_planar(EEVEE_ViewLayerData *sldata, EEVEE_Data *v
|
||||
|
||||
common_data->ray_type = EEVEE_RAY_GLOSSY;
|
||||
common_data->ray_depth = 1.0f;
|
||||
/* Planar reflections are rendered at the hiz resolution, so no need to scalling. */
|
||||
copy_v2_fl(common_data->hiz_uv_scale, 1.0f);
|
||||
|
||||
GPU_uniformbuf_update(sldata->common_ubo, &sldata->common_data);
|
||||
|
||||
/* Rendering happens here! */
|
||||
@@ -1227,6 +1232,7 @@ void EEVEE_lightprobes_refresh_planar(EEVEE_ViewLayerData *sldata, EEVEE_Data *v
|
||||
common_data->ssr_toggle = true;
|
||||
common_data->ssrefract_toggle = true;
|
||||
common_data->sss_toggle = true;
|
||||
copy_v2_v2(common_data->hiz_uv_scale, hiz_uv_scale_prev);
|
||||
|
||||
/* Prefilter for SSR */
|
||||
if ((vedata->stl->effects->enabled_effects & EFFECT_SSR) != 0) {
|
||||
|
@@ -77,14 +77,14 @@ int EEVEE_occlusion_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
|
||||
common_data->ao_bounce_fac = (scene_eval->eevee.flag & SCE_EEVEE_GTAO_BOUNCE) ? 1.0f : 0.0f;
|
||||
|
||||
effects->gtao_horizons_renderpass = DRW_texture_pool_query_2d(
|
||||
fs_size[0], fs_size[1], GPU_RGBA8, &draw_engine_eevee_type);
|
||||
UNPACK2(effects->hiz_size), GPU_RGBA8, &draw_engine_eevee_type);
|
||||
GPU_framebuffer_ensure_config(
|
||||
&fbl->gtao_fb,
|
||||
{GPU_ATTACHMENT_NONE, GPU_ATTACHMENT_TEXTURE(effects->gtao_horizons_renderpass)});
|
||||
|
||||
if (G.debug_value == 6) {
|
||||
effects->gtao_horizons_debug = DRW_texture_pool_query_2d(
|
||||
fs_size[0], fs_size[1], GPU_RGBA8, &draw_engine_eevee_type);
|
||||
UNPACK2(fs_size), GPU_RGBA8, &draw_engine_eevee_type);
|
||||
GPU_framebuffer_ensure_config(
|
||||
&fbl->gtao_debug_fb,
|
||||
{GPU_ATTACHMENT_NONE, GPU_ATTACHMENT_TEXTURE(effects->gtao_horizons_debug)});
|
||||
@@ -188,20 +188,32 @@ void EEVEE_occlusion_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
|
||||
}
|
||||
}
|
||||
|
||||
void EEVEE_occlusion_compute(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *vedata)
|
||||
void EEVEE_occlusion_compute(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
|
||||
{
|
||||
EEVEE_PassList *psl = vedata->psl;
|
||||
EEVEE_FramebufferList *fbl = vedata->fbl;
|
||||
EEVEE_StorageList *stl = vedata->stl;
|
||||
EEVEE_EffectsInfo *effects = stl->effects;
|
||||
EEVEE_CommonUniformBuffer *common_data = &sldata->common_data;
|
||||
|
||||
if ((effects->enabled_effects & EFFECT_GTAO) != 0) {
|
||||
DRW_stats_group_start("GTAO Horizon Scan");
|
||||
|
||||
/** NOTE(fclem): Kind of fragile. We need this to make sure everything lines up
|
||||
* nicely during planar reflection. */
|
||||
if (common_data->ray_type != EEVEE_RAY_GLOSSY) {
|
||||
const float *viewport_size = DRW_viewport_size_get();
|
||||
GPU_framebuffer_viewport_set(fbl->gtao_fb, 0, 0, UNPACK2(viewport_size));
|
||||
}
|
||||
|
||||
GPU_framebuffer_bind(fbl->gtao_fb);
|
||||
|
||||
DRW_draw_pass(psl->ao_horizon_search);
|
||||
|
||||
if (common_data->ray_type != EEVEE_RAY_GLOSSY) {
|
||||
GPU_framebuffer_viewport_reset(fbl->gtao_fb);
|
||||
}
|
||||
|
||||
if (GPU_mip_render_workaround() ||
|
||||
GPU_type_matches(GPU_DEVICE_INTEL_UHD, GPU_OS_WIN, GPU_DRIVER_ANY)) {
|
||||
/* Fix dot corruption on intel HD5XX/HD6XX series. */
|
||||
|
Reference in New Issue
Block a user