Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/engines/eevee/eevee_subsurface.c
| Show First 20 Lines • Show All 61 Lines • ▼ Show 20 Lines | |||||
| int EEVEE_subsurface_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata) | int EEVEE_subsurface_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata) | ||||
| { | { | ||||
| EEVEE_CommonUniformBuffer *common_data = &sldata->common_data; | EEVEE_CommonUniformBuffer *common_data = &sldata->common_data; | ||||
| EEVEE_StorageList *stl = vedata->stl; | EEVEE_StorageList *stl = vedata->stl; | ||||
| EEVEE_EffectsInfo *effects = stl->effects; | EEVEE_EffectsInfo *effects = stl->effects; | ||||
| EEVEE_FramebufferList *fbl = vedata->fbl; | EEVEE_FramebufferList *fbl = vedata->fbl; | ||||
| EEVEE_TextureList *txl = vedata->txl; | EEVEE_TextureList *txl = vedata->txl; | ||||
| DefaultTextureList *dtxl = DRW_viewport_texture_list_get(); | DefaultTextureList *dtxl = DRW_viewport_texture_list_get(); | ||||
| const float *viewport_size = DRW_viewport_size_get(); | const float *viewport_size = DRW_viewport_render_size_get(); | ||||
| const int fs_size[2] = {(int)viewport_size[0], (int)viewport_size[1]}; | const int fs_size[2] = {(int)viewport_size[0], (int)viewport_size[1]}; | ||||
| const DRWContextState *draw_ctx = DRW_context_state_get(); | const DRWContextState *draw_ctx = DRW_context_state_get(); | ||||
| const Scene *scene_eval = DEG_get_evaluated_scene(draw_ctx->depsgraph); | const Scene *scene_eval = DEG_get_evaluated_scene(draw_ctx->depsgraph); | ||||
| if (scene_eval->eevee.flag & SCE_EEVEE_SSS_ENABLED) { | if (scene_eval->eevee.flag & SCE_EEVEE_SSS_ENABLED) { | ||||
| effects->sss_sample_count = 1 + scene_eval->eevee.sss_samples * 2; | effects->sss_sample_count = 1 + scene_eval->eevee.sss_samples * 2; | ||||
| effects->sss_separate_albedo = (scene_eval->eevee.flag & SCE_EEVEE_SSS_SEPARATE_ALBEDO) != 0; | effects->sss_separate_albedo = (scene_eval->eevee.flag & SCE_EEVEE_SSS_SEPARATE_ALBEDO) != 0; | ||||
| Show All 19 Lines | if (scene_eval->eevee.flag & SCE_EEVEE_SSS_ENABLED) { | ||||
| if (GPU_depth_blitting_workaround()) { | if (GPU_depth_blitting_workaround()) { | ||||
| /* Blitting stencil buffer does not work on macOS + Radeon Pro. | /* Blitting stencil buffer does not work on macOS + Radeon Pro. | ||||
| * Blit depth instead and use sss_stencil's depth as depth texture, | * Blit depth instead and use sss_stencil's depth as depth texture, | ||||
| * and dtxl->depth as stencil mask. */ | * and dtxl->depth as stencil mask. */ | ||||
| GPU_framebuffer_ensure_config( | GPU_framebuffer_ensure_config( | ||||
| &fbl->sss_blit_fb, {GPU_ATTACHMENT_TEXTURE(effects->sss_stencil), GPU_ATTACHMENT_NONE}); | &fbl->sss_blit_fb, {GPU_ATTACHMENT_TEXTURE(effects->sss_stencil), GPU_ATTACHMENT_NONE}); | ||||
| stencil_tex = dtxl->depth; | stencil_tex = txl->depth ? txl->depth : dtxl->depth; | ||||
| } | } | ||||
| GPU_framebuffer_ensure_config( | GPU_framebuffer_ensure_config( | ||||
| &fbl->sss_blur_fb, | &fbl->sss_blur_fb, | ||||
| {GPU_ATTACHMENT_TEXTURE(stencil_tex), GPU_ATTACHMENT_TEXTURE(effects->sss_blur)}); | {GPU_ATTACHMENT_TEXTURE(stencil_tex), GPU_ATTACHMENT_TEXTURE(effects->sss_blur)}); | ||||
| GPU_framebuffer_ensure_config( | GPU_framebuffer_ensure_config( | ||||
| &fbl->sss_resolve_fb, | &fbl->sss_resolve_fb, | ||||
| Show All 35 Lines | void EEVEE_subsurface_output_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *vedata) | ||||
| EEVEE_StorageList *stl = vedata->stl; | EEVEE_StorageList *stl = vedata->stl; | ||||
| EEVEE_EffectsInfo *effects = stl->effects; | EEVEE_EffectsInfo *effects = stl->effects; | ||||
| DefaultTextureList *dtxl = DRW_viewport_texture_list_get(); | DefaultTextureList *dtxl = DRW_viewport_texture_list_get(); | ||||
| const DRWContextState *draw_ctx = DRW_context_state_get(); | const DRWContextState *draw_ctx = DRW_context_state_get(); | ||||
| const Scene *scene_eval = DEG_get_evaluated_scene(draw_ctx->depsgraph); | const Scene *scene_eval = DEG_get_evaluated_scene(draw_ctx->depsgraph); | ||||
| if (scene_eval->eevee.flag & SCE_EEVEE_SSS_ENABLED) { | if (scene_eval->eevee.flag & SCE_EEVEE_SSS_ENABLED) { | ||||
| DRW_texture_ensure_fullscreen_2d(&txl->sss_dir_accum, GPU_RGBA16F, 0); | DRW_texture_ensure_render_fullscreen_2d(&txl->sss_dir_accum, GPU_RGBA16F, 0); | ||||
| DRW_texture_ensure_fullscreen_2d(&txl->sss_col_accum, GPU_RGBA16F, 0); | DRW_texture_ensure_render_fullscreen_2d(&txl->sss_col_accum, GPU_RGBA16F, 0); | ||||
| GPUTexture *stencil_tex = effects->sss_stencil; | GPUTexture *stencil_tex = effects->sss_stencil; | ||||
| if (GPU_depth_blitting_workaround()) { | if (GPU_depth_blitting_workaround()) { | ||||
| /* Blitting stencil buffer does not work on macOS + Radeon Pro. | /* Blitting stencil buffer does not work on macOS + Radeon Pro. | ||||
| * Blit depth instead and use sss_stencil's depth as depth texture, | * Blit depth instead and use sss_stencil's depth as depth texture, | ||||
| * and dtxl->depth as stencil mask. */ | * and dtxl->depth as stencil mask. */ | ||||
| stencil_tex = dtxl->depth; | stencil_tex = txl->depth ? txl->depth : dtxl->depth; | ||||
| } | } | ||||
| GPU_framebuffer_ensure_config(&fbl->sss_accum_fb, | GPU_framebuffer_ensure_config(&fbl->sss_accum_fb, | ||||
| {GPU_ATTACHMENT_TEXTURE(stencil_tex), | {GPU_ATTACHMENT_TEXTURE(stencil_tex), | ||||
| GPU_ATTACHMENT_TEXTURE(txl->sss_dir_accum), | GPU_ATTACHMENT_TEXTURE(txl->sss_dir_accum), | ||||
| GPU_ATTACHMENT_TEXTURE(txl->sss_col_accum)}); | GPU_ATTACHMENT_TEXTURE(txl->sss_col_accum)}); | ||||
| /* Clear texture. */ | /* Clear texture. */ | ||||
| Show All 35 Lines | |||||
| } | } | ||||
| void EEVEE_subsurface_add_pass(EEVEE_ViewLayerData *sldata, | void EEVEE_subsurface_add_pass(EEVEE_ViewLayerData *sldata, | ||||
| EEVEE_Data *vedata, | EEVEE_Data *vedata, | ||||
| uint sss_id, | uint sss_id, | ||||
| struct GPUUniformBuffer *sss_profile) | struct GPUUniformBuffer *sss_profile) | ||||
| { | { | ||||
| DefaultTextureList *dtxl = DRW_viewport_texture_list_get(); | DefaultTextureList *dtxl = DRW_viewport_texture_list_get(); | ||||
| EEVEE_TextureList *txl = vedata->txl; | |||||
| EEVEE_PassList *psl = vedata->psl; | EEVEE_PassList *psl = vedata->psl; | ||||
| EEVEE_StorageList *stl = vedata->stl; | EEVEE_StorageList *stl = vedata->stl; | ||||
| EEVEE_EffectsInfo *effects = stl->effects; | EEVEE_EffectsInfo *effects = stl->effects; | ||||
| struct GPUBatch *quad = DRW_cache_fullscreen_quad_get(); | struct GPUBatch *quad = DRW_cache_fullscreen_quad_get(); | ||||
| GPUTexture **depth_src = GPU_depth_blitting_workaround() ? &effects->sss_stencil : &dtxl->depth; | GPUTexture **depth_src = GPU_depth_blitting_workaround() ? | ||||
| &effects->sss_stencil : | |||||
| txl->depth ? &txl->depth : &dtxl->depth; | |||||
| DRWShadingGroup *grp = DRW_shgroup_create(e_data.sss_sh[0], psl->sss_blur_ps); | DRWShadingGroup *grp = DRW_shgroup_create(e_data.sss_sh[0], psl->sss_blur_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, "depthBuffer", depth_src); | DRW_shgroup_uniform_texture_ref(grp, "depthBuffer", depth_src); | ||||
| DRW_shgroup_uniform_texture_ref(grp, "sssData", &effects->sss_data); | DRW_shgroup_uniform_texture_ref(grp, "sssData", &effects->sss_data); | ||||
| DRW_shgroup_uniform_block(grp, "sssProfile", sss_profile); | DRW_shgroup_uniform_block(grp, "sssProfile", sss_profile); | ||||
| DRW_shgroup_uniform_block(grp, "common_block", sldata->common_ubo); | DRW_shgroup_uniform_block(grp, "common_block", sldata->common_ubo); | ||||
| DRW_shgroup_stencil_mask(grp, sss_id); | DRW_shgroup_stencil_mask(grp, sss_id); | ||||
| ▲ Show 20 Lines • Show All 132 Lines • Show Last 20 Lines | |||||