Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/engines/eevee/eevee_mist.c
| Show All 34 Lines | |||||
| void EEVEE_mist_output_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata) | void EEVEE_mist_output_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata) | ||||
| { | { | ||||
| const DRWContextState *draw_ctx = DRW_context_state_get(); | const DRWContextState *draw_ctx = DRW_context_state_get(); | ||||
| EEVEE_FramebufferList *fbl = vedata->fbl; | EEVEE_FramebufferList *fbl = vedata->fbl; | ||||
| DefaultTextureList *dtxl = DRW_viewport_texture_list_get(); | DefaultTextureList *dtxl = DRW_viewport_texture_list_get(); | ||||
| 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_PrivateData *g_data = stl->g_data; | EEVEE_PrivateData *g_data = stl->g_data; | ||||
| Scene *scene = draw_ctx->scene; | Scene *scene = draw_ctx->scene; | ||||
| const float clear[4] = {0.0f, 0.0f, 0.0f, 0.0f}; | |||||
| /* Create FrameBuffer. */ | /* Create FrameBuffer. */ | ||||
| /* Should be enough precision for many samples. */ | /* Should be enough precision for many samples. */ | ||||
| DRW_texture_ensure_fullscreen_2d(&txl->mist_accum, GPU_R32F, 0); | DRW_texture_ensure_fullscreen_2d(&txl->mist_accum, GPU_R32F, 0); | ||||
| GPU_framebuffer_ensure_config(&fbl->mist_accum_fb, | GPU_framebuffer_ensure_config(&fbl->mist_accum_fb, | ||||
| {GPU_ATTACHMENT_NONE, GPU_ATTACHMENT_TEXTURE(txl->mist_accum)}); | {GPU_ATTACHMENT_NONE, GPU_ATTACHMENT_TEXTURE(txl->mist_accum)}); | ||||
| /* Clear texture. */ | |||||
| if (effects->taa_current_sample == 1) { | |||||
| GPU_framebuffer_bind(fbl->mist_accum_fb); | |||||
| GPU_framebuffer_clear_color(fbl->mist_accum_fb, clear); | |||||
| } | |||||
| /* Mist settings. */ | /* Mist settings. */ | ||||
| if (scene && scene->world) { | if (scene && scene->world) { | ||||
| g_data->mist_start = scene->world->miststa; | g_data->mist_start = scene->world->miststa; | ||||
| g_data->mist_inv_dist = (scene->world->mistdist > 0.0f) ? 1.0f / scene->world->mistdist : 0.0f; | g_data->mist_inv_dist = (scene->world->mistdist > 0.0f) ? 1.0f / scene->world->mistdist : 0.0f; | ||||
| switch (scene->world->mistype) { | switch (scene->world->mistype) { | ||||
| case WO_MIST_QUADRATIC: | case WO_MIST_QUADRATIC: | ||||
| g_data->mist_falloff = 2.0f; | g_data->mist_falloff = 2.0f; | ||||
| Show All 28 Lines | void EEVEE_mist_output_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata) | ||||
| DRW_shgroup_uniform_vec3(grp, "mistSettings", &g_data->mist_start, 1); | DRW_shgroup_uniform_vec3(grp, "mistSettings", &g_data->mist_start, 1); | ||||
| DRW_shgroup_call(grp, DRW_cache_fullscreen_quad_get(), NULL); | DRW_shgroup_call(grp, DRW_cache_fullscreen_quad_get(), NULL); | ||||
| } | } | ||||
| void EEVEE_mist_output_accumulate(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *vedata) | void EEVEE_mist_output_accumulate(EEVEE_ViewLayerData *UNUSED(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->mist_accum_fb != NULL) { | if (fbl->mist_accum_fb != NULL) { | ||||
| GPU_framebuffer_bind(fbl->mist_accum_fb); | GPU_framebuffer_bind(fbl->mist_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->mist_accum_fb, clear); | |||||
| } | |||||
| DRW_draw_pass(psl->mist_accum_ps); | DRW_draw_pass(psl->mist_accum_ps); | ||||
| /* Restore */ | /* Restore */ | ||||
| GPU_framebuffer_bind(fbl->main_fb); | GPU_framebuffer_bind(fbl->main_fb); | ||||
| } | } | ||||
| } | } | ||||