Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/engines/eevee/eevee_occlusion.c
| Show First 20 Lines • Show All 114 Lines • ▼ Show 20 Lines | void EEVEE_occlusion_output_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, uint tot_samples) | ||||
| EEVEE_TextureList *txl = vedata->txl; | EEVEE_TextureList *txl = vedata->txl; | ||||
| EEVEE_StorageList *stl = vedata->stl; | EEVEE_StorageList *stl = vedata->stl; | ||||
| EEVEE_PassList *psl = vedata->psl; | EEVEE_PassList *psl = vedata->psl; | ||||
| EEVEE_EffectsInfo *effects = stl->effects; | EEVEE_EffectsInfo *effects = stl->effects; | ||||
| const eGPUTextureFormat texture_format = (tot_samples > 128) ? GPU_R32F : GPU_R16F; | const eGPUTextureFormat texture_format = (tot_samples > 128) ? GPU_R32F : GPU_R16F; | ||||
| DefaultTextureList *dtxl = DRW_viewport_texture_list_get(); | DefaultTextureList *dtxl = DRW_viewport_texture_list_get(); | ||||
| const float clear[4] = {0.0f, 0.0f, 0.0f, 0.0f}; | |||||
| /* Should be enough precision for many samples. */ | /* Should be enough precision for many samples. */ | ||||
| DRW_texture_ensure_fullscreen_2d(&txl->ao_accum, texture_format, 0); | DRW_texture_ensure_fullscreen_2d(&txl->ao_accum, texture_format, 0); | ||||
| GPU_framebuffer_ensure_config(&fbl->ao_accum_fb, | GPU_framebuffer_ensure_config(&fbl->ao_accum_fb, | ||||
| {GPU_ATTACHMENT_NONE, GPU_ATTACHMENT_TEXTURE(txl->ao_accum)}); | {GPU_ATTACHMENT_NONE, GPU_ATTACHMENT_TEXTURE(txl->ao_accum)}); | ||||
| /* Clear texture. */ | |||||
| if (effects->taa_current_sample == 1) { | |||||
| GPU_framebuffer_bind(fbl->ao_accum_fb); | |||||
| GPU_framebuffer_clear_color(fbl->ao_accum_fb, clear); | |||||
| } | |||||
| /* Accumulation pass */ | /* Accumulation pass */ | ||||
| DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_ADD; | DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_ADD; | ||||
| DRW_PASS_CREATE(psl->ao_accum_ps, state); | DRW_PASS_CREATE(psl->ao_accum_ps, state); | ||||
| DRWShadingGroup *grp = DRW_shgroup_create(EEVEE_shaders_effect_ambient_occlusion_debug_sh_get(), | DRWShadingGroup *grp = DRW_shgroup_create(EEVEE_shaders_effect_ambient_occlusion_debug_sh_get(), | ||||
| psl->ao_accum_ps); | psl->ao_accum_ps); | ||||
| DRW_shgroup_uniform_texture(grp, "utilTex", EEVEE_materials_get_util_tex()); | DRW_shgroup_uniform_texture(grp, "utilTex", EEVEE_materials_get_util_tex()); | ||||
| DRW_shgroup_uniform_texture_ref(grp, "maxzBuffer", &txl->maxzbuffer); | DRW_shgroup_uniform_texture_ref(grp, "maxzBuffer", &txl->maxzbuffer); | ||||
| DRW_shgroup_uniform_texture_ref(grp, "depthBuffer", &dtxl->depth); | DRW_shgroup_uniform_texture_ref(grp, "depthBuffer", &dtxl->depth); | ||||
| ▲ Show 20 Lines • Show All 96 Lines • ▼ Show 20 Lines | if (((effects->enabled_effects & EFFECT_GTAO) != 0) && (G.debug_value == 6)) { | ||||
| DRW_stats_group_end(); | DRW_stats_group_end(); | ||||
| } | } | ||||
| } | } | ||||
| void EEVEE_occlusion_output_accumulate(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata) | void EEVEE_occlusion_output_accumulate(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata) | ||||
| { | { | ||||
| EEVEE_FramebufferList *fbl = vedata->fbl; | EEVEE_FramebufferList *fbl = vedata->fbl; | ||||
| EEVEE_PassList *psl = vedata->psl; | EEVEE_PassList *psl = vedata->psl; | ||||
| EEVEE_EffectsInfo *effects = vedata->stl->effects; | |||||
| if (fbl->ao_accum_fb != NULL) { | if (fbl->ao_accum_fb != NULL) { | ||||
| DefaultTextureList *dtxl = DRW_viewport_texture_list_get(); | DefaultTextureList *dtxl = DRW_viewport_texture_list_get(); | ||||
| /* Update the min_max/horizon buffers so the refraction materials appear in it. */ | /* Update the min_max/horizon buffers so the refraction materials appear in it. */ | ||||
| EEVEE_create_minmax_buffer(vedata, dtxl->depth, -1); | EEVEE_create_minmax_buffer(vedata, dtxl->depth, -1); | ||||
| EEVEE_occlusion_compute(sldata, vedata); | EEVEE_occlusion_compute(sldata, vedata); | ||||
| GPU_framebuffer_bind(fbl->ao_accum_fb); | GPU_framebuffer_bind(fbl->ao_accum_fb); | ||||
| /* Clear texture. */ | |||||
| if (effects->taa_current_sample == 1) { | |||||
| const float clear[4] = {0.0f, 0.0f, 0.0f, 0.0f}; | |||||
| GPU_framebuffer_clear_color(fbl->ao_accum_fb, clear); | |||||
| } | |||||
| DRW_draw_pass(psl->ao_accum_ps); | DRW_draw_pass(psl->ao_accum_ps); | ||||
| /* Restore */ | /* Restore */ | ||||
| GPU_framebuffer_bind(fbl->main_fb); | GPU_framebuffer_bind(fbl->main_fb); | ||||
| } | } | ||||
| } | } | ||||
| void EEVEE_occlusion_free(void) | void EEVEE_occlusion_free(void) | ||||
| { | { | ||||
| DRW_TEXTURE_FREE_SAFE(e_data.dummy_horizon_tx); | DRW_TEXTURE_FREE_SAFE(e_data.dummy_horizon_tx); | ||||
| } | } | ||||