diff options
Diffstat (limited to 'source/blender/draw/engines')
15 files changed, 105 insertions, 81 deletions
diff --git a/source/blender/draw/engines/basic/basic_engine.c b/source/blender/draw/engines/basic/basic_engine.c index 188e252a285..0dd1a4fd686 100644 --- a/source/blender/draw/engines/basic/basic_engine.c +++ b/source/blender/draw/engines/basic/basic_engine.c @@ -72,7 +72,6 @@ static struct { typedef struct BASIC_PrivateData { DRWShadingGroup *depth_shgrp; DRWShadingGroup *depth_shgrp_cull; - DRWShadingGroup *depth_shgrp_hair; } BASIC_PrivateData; /* Transient data */ /* Functions */ diff --git a/source/blender/draw/engines/eevee/eevee_effects.c b/source/blender/draw/engines/eevee/eevee_effects.c index 7df1c299454..d59d1f56e92 100644 --- a/source/blender/draw/engines/eevee/eevee_effects.c +++ b/source/blender/draw/engines/eevee/eevee_effects.c @@ -29,6 +29,7 @@ #include "eevee_private.h" #include "GPU_texture.h" #include "GPU_extensions.h" +#include "GPU_platform.h" #include "GPU_state.h" static struct { diff --git a/source/blender/draw/engines/eevee/eevee_lightprobes.c b/source/blender/draw/engines/eevee/eevee_lightprobes.c index 19f3983998e..4b0af273f7f 100644 --- a/source/blender/draw/engines/eevee/eevee_lightprobes.c +++ b/source/blender/draw/engines/eevee/eevee_lightprobes.c @@ -51,7 +51,6 @@ static struct { struct GPUTexture *planar_pool_placeholder; struct GPUTexture *depth_placeholder; struct GPUTexture *depth_array_placeholder; - struct GPUTexture *cube_face_minmaxz; struct GPUVertFormat *format_probe_display_cube; struct GPUVertFormat *format_probe_display_planar; diff --git a/source/blender/draw/engines/eevee/eevee_materials.c b/source/blender/draw/engines/eevee/eevee_materials.c index f01c6363ccb..701d73461fc 100644 --- a/source/blender/draw/engines/eevee/eevee_materials.c +++ b/source/blender/draw/engines/eevee/eevee_materials.c @@ -1588,7 +1588,9 @@ void EEVEE_materials_cache_populate(EEVEE_Data *vedata, /* Shadow Pass */ struct GPUMaterial *gpumat; - switch (ma_array[i]->blend_shadow) { + const bool use_gpumat = (ma_array[i]->use_nodes && ma_array[i]->nodetree); + char blend_shadow = use_gpumat ? ma_array[i]->blend_shadow : MA_BS_SOLID; + switch (blend_shadow) { case MA_BS_SOLID: EEVEE_shadows_caster_add(sldata, stl, mat_geom[i], ob); *cast_shadow = true; diff --git a/source/blender/draw/engines/eevee/eevee_occlusion.c b/source/blender/draw/engines/eevee/eevee_occlusion.c index 924b3d3b19b..48e9b5bcc13 100644 --- a/source/blender/draw/engines/eevee/eevee_occlusion.c +++ b/source/blender/draw/engines/eevee/eevee_occlusion.c @@ -33,6 +33,7 @@ #include "eevee_private.h" #include "GPU_extensions.h" +#include "GPU_platform.h" #include "GPU_state.h" static struct { @@ -40,7 +41,6 @@ static struct { struct GPUShader *gtao_sh; struct GPUShader *gtao_layer_sh; struct GPUShader *gtao_debug_sh; - struct GPUTexture *src_depth; struct GPUTexture *dummy_horizon_tx; } e_data = {NULL}; /* Engine data */ diff --git a/source/blender/draw/engines/eevee/eevee_screen_raytrace.c b/source/blender/draw/engines/eevee/eevee_screen_raytrace.c index 2daf2388d63..591ca31017c 100644 --- a/source/blender/draw/engines/eevee/eevee_screen_raytrace.c +++ b/source/blender/draw/engines/eevee/eevee_screen_raytrace.c @@ -46,7 +46,6 @@ static struct { /* These are just references, not actually allocated */ struct GPUTexture *depth_src; - struct GPUTexture *color_src; } e_data = {{NULL}}; /* Engine data */ extern char datatoc_ambient_occlusion_lib_glsl[]; diff --git a/source/blender/draw/engines/eevee/eevee_volumes.c b/source/blender/draw/engines/eevee/eevee_volumes.c index fac87bad41a..aaa351a1922 100644 --- a/source/blender/draw/engines/eevee/eevee_volumes.c +++ b/source/blender/draw/engines/eevee/eevee_volumes.c @@ -54,7 +54,6 @@ static struct { struct GPUShader *volumetric_integration_sh; struct GPUShader *volumetric_resolve_sh; - GPUTexture *color_src; GPUTexture *depth_src; GPUTexture *dummy_density; diff --git a/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl b/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl index 98012aea303..1f68935403c 100644 --- a/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl +++ b/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl @@ -918,14 +918,15 @@ void main() Closure cl = nodetree_exec(); float holdout = 1.0 - saturate(cl.holdout); + float transmit = saturate(avg(cl.transmittance)); + float alpha = 1.0 - transmit; # ifdef USE_ALPHA_BLEND vec2 uvs = gl_FragCoord.xy * volCoordScale.zw; vec3 vol_transmit, vol_scatter; volumetric_resolve(uvs, gl_FragCoord.z, vol_transmit, vol_scatter); - float transmit = saturate(avg(cl.transmittance)); - outRadiance = vec4(cl.radiance * vol_transmit + vol_scatter, (1.0 - transmit) * holdout); + outRadiance = vec4(cl.radiance * vol_transmit + vol_scatter, alpha * holdout); outTransmittance = vec4(cl.transmittance, transmit * holdout); # else outRadiance = vec4(cl.radiance, holdout); @@ -953,6 +954,15 @@ void main() outRadiance.rgb += cl.sss_irradiance.rgb * cl.sss_albedo.rgb * fac; # endif + +# ifndef USE_ALPHA_BLEND + float alpha_div = 1.0 / max(1e-8, alpha); + outRadiance *= alpha_div; + ssrData.rgb *= alpha_div; +# ifdef USE_SSS + sssAlbedo.rgb *= alpha_div; +# endif +# endif } # endif /* MESH_SHADER && !SHADOW_SHADER */ diff --git a/source/blender/draw/engines/gpencil/gpencil_cache_utils.c b/source/blender/draw/engines/gpencil/gpencil_cache_utils.c index 33e6d73eeeb..f9df1342bf8 100644 --- a/source/blender/draw/engines/gpencil/gpencil_cache_utils.c +++ b/source/blender/draw/engines/gpencil/gpencil_cache_utils.c @@ -50,10 +50,6 @@ static bool gpencil_has_noninstanced_object(Object *ob_instance) if (ob->type != OB_GPENCIL) { continue; } - /* object must be visible (invisible objects don't create VBO data) */ - if (!(DRW_object_visibility_in_active_context(ob) & OB_VISIBLE_SELF)) { - continue; - } /* is not duplicated and the name is equals */ if ((ob->base_flag & BASE_FROM_DUPLI) == 0) { if (STREQ(ob->id.name, ob_instance->id.name)) { diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c index ce5d8cbf732..0997568ed22 100644 --- a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c +++ b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c @@ -37,7 +37,6 @@ #include "DNA_gpencil_types.h" #include "DNA_material_types.h" #include "DNA_view3d_types.h" -#include "DNA_gpencil_modifier_types.h" /* If builtin shaders are needed */ #include "GPU_shader.h" @@ -141,13 +140,9 @@ static void gpencil_calc_vertex(GPENCIL_StorageList *stl, Object *ob = cache_ob->ob; const DRWContextState *draw_ctx = DRW_context_state_get(); - const bool main_onion = draw_ctx->v3d != NULL ? - (draw_ctx->v3d->gp_flag & V3D_GP_SHOW_ONION_SKIN) : - true; + const bool main_onion = stl->storage->is_main_onion; const bool playing = stl->storage->is_playing; - const bool overlay = draw_ctx->v3d != NULL ? - (bool)((draw_ctx->v3d->flag2 & V3D_HIDE_OVERLAYS) == 0) : - true; + const bool overlay = stl->storage->is_main_overlay; const bool do_onion = (bool)((gpd->flag & GP_DATA_STROKE_WEIGHTMODE) == 0) && overlay && main_onion && !playing && gpencil_onion_active(gpd); @@ -225,23 +220,6 @@ static void gpencil_calc_vertex(GPENCIL_StorageList *stl, cache->b_point.tot_vertex = cache_ob->tot_vertex; cache->b_edit.tot_vertex = cache_ob->tot_vertex; cache->b_edlin.tot_vertex = cache_ob->tot_vertex; - - /* some modifiers can change the number of points */ - int factor = 0; - GpencilModifierData *md; - for (md = ob->greasepencil_modifiers.first; md; md = md->next) { - const GpencilModifierTypeInfo *mti = BKE_gpencil_modifierType_getInfo(md->type); - /* only modifiers that change size */ - if (mti && mti->getDuplicationFactor) { - factor = mti->getDuplicationFactor(md); - - cache->b_fill.tot_vertex *= factor; - cache->b_stroke.tot_vertex *= factor; - cache->b_point.tot_vertex *= factor; - cache->b_edit.tot_vertex *= factor; - cache->b_edlin.tot_vertex *= factor; - } - } } /* Helper for doing all the checks on whether a stroke can be drawn */ @@ -1781,8 +1759,8 @@ static void gpencil_shgroups_create(GPENCIL_e_data *e_data, const bool overlay = draw_ctx->v3d != NULL ? (bool)((draw_ctx->v3d->flag2 & V3D_HIDE_OVERLAYS) == 0) : true; - const bool main_onion = v3d != NULL ? (v3d->gp_flag & V3D_GP_SHOW_ONION_SKIN) : true; - const bool do_onion = (bool)((gpd->flag & GP_DATA_STROKE_WEIGHTMODE) == 0) && main_onion && + const bool screen_onion = v3d != NULL ? (v3d->gp_flag & V3D_GP_SHOW_ONION_SKIN) : true; + const bool do_onion = (bool)((gpd->flag & GP_DATA_STROKE_WEIGHTMODE) == 0) && screen_onion && overlay && gpencil_onion_active(gpd); int start_stroke = 0; @@ -2062,13 +2040,9 @@ void gpencil_populate_datablock(GPENCIL_e_data *e_data, bGPdata *gpd_eval = (bGPdata *)ob->data; bGPdata *gpd = (bGPdata *)DEG_get_original_id(&gpd_eval->id); - const bool main_onion = draw_ctx->v3d != NULL ? - (draw_ctx->v3d->gp_flag & V3D_GP_SHOW_ONION_SKIN) : - true; + const bool main_onion = stl->storage->is_main_onion; const bool playing = stl->storage->is_playing; - const bool overlay = draw_ctx->v3d != NULL ? - (bool)((draw_ctx->v3d->flag2 & V3D_HIDE_OVERLAYS) == 0) : - true; + const bool overlay = stl->storage->is_main_overlay; const bool do_onion = (bool)((gpd->flag & GP_DATA_STROKE_WEIGHTMODE) == 0) && overlay && main_onion && !playing && gpencil_onion_active(gpd); diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c b/source/blender/draw/engines/gpencil/gpencil_engine.c index 7d9f2d1fdf3..aed6789fe26 100644 --- a/source/blender/draw/engines/gpencil/gpencil_engine.c +++ b/source/blender/draw/engines/gpencil/gpencil_engine.c @@ -24,11 +24,13 @@ #include "BKE_gpencil.h" #include "BKE_library.h" +#include "BKE_main.h" #include "BKE_object.h" #include "BKE_paint.h" #include "BKE_shader_fx.h" #include "DNA_gpencil_types.h" +#include "DNA_screen_types.h" #include "DNA_view3d_types.h" #include "draw_mode_engines.h" @@ -310,6 +312,43 @@ static void GPENCIL_engine_free(void) GPENCIL_delete_fx_shaders(&e_data); } +/* Helper: Check if the main overlay and onion switches are enabled in any screen. + * + * This is required to generate the onion skin and limit the times the cache is updated because the + * cache is generated only in the first screen and if the first screen has the onion disabled the + * cache for onion skin is not generated. The loop adds time, but always is faster than regenerate + * the cache all the times. + */ +static void gpencil_check_screen_switches(const DRWContextState *draw_ctx, + GPENCIL_StorageList *stl) +{ + stl->storage->is_main_overlay = false; + stl->storage->is_main_onion = false; + /* Check if main onion switch is enabled in any screen. */ + Main *bmain = CTX_data_main(draw_ctx->evil_C); + + for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { + for (const ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { + if (sa && sa->spacetype == SPACE_VIEW3D) { + View3D *v3d = sa->spacedata.first; + if (v3d == NULL) { + continue; + } + if ((v3d->flag2 & V3D_HIDE_OVERLAYS) == 0) { + stl->storage->is_main_overlay = true; + } + if (v3d->gp_flag & V3D_GP_SHOW_ONION_SKIN) { + stl->storage->is_main_onion = true; + } + } + /* If found, don't need loop more. */ + if ((stl->storage->is_main_overlay) && (stl->storage->is_main_onion)) { + return; + } + } + } +} + void GPENCIL_cache_init(void *vedata) { GPENCIL_PassList *psl = ((GPENCIL_Data *)vedata)->psl; @@ -320,6 +359,7 @@ void GPENCIL_cache_init(void *vedata) ToolSettings *ts = scene->toolsettings; View3D *v3d = draw_ctx->v3d; Brush *brush = BKE_paint_brush(&ts->gp_paint->paint); + const View3DCursor *cursor = &scene->cursor; /* Special handling for when active object is GP object (e.g. for draw mode) */ Object *obact = draw_ctx->obact; @@ -395,10 +435,15 @@ void GPENCIL_cache_init(void *vedata) stl->storage->reset_cache = true; } stl->storage->is_playing = playing; + + /* Found if main overlay and onion switches are enabled in any screen. */ + gpencil_check_screen_switches(draw_ctx, stl); } else { stl->storage->is_playing = false; stl->storage->reset_cache = false; + stl->storage->is_main_overlay = false; + stl->storage->is_main_onion = false; } /* save render state */ stl->storage->is_render = DRW_state_is_image_render(); @@ -546,11 +591,42 @@ void GPENCIL_cache_init(void *vedata) } /* grid pass */ - if (v3d) { + if ((v3d) && (obact) && (obact->type == OB_GPENCIL)) { psl->grid_pass = DRW_pass_create("GPencil Grid Pass", DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_ALPHA | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_ALWAYS); stl->g_data->shgrps_grid = DRW_shgroup_create(e_data.gpencil_line_sh, psl->grid_pass); + + /* define grid orientation */ + switch (ts->gp_sculpt.lock_axis) { + case GP_LOCKAXIS_VIEW: { + /* align always to view */ + invert_m4_m4(stl->storage->grid_matrix, draw_ctx->rv3d->viewmat); + /* copy ob location */ + copy_v3_v3(stl->storage->grid_matrix[3], obact->obmat[3]); + break; + } + case GP_LOCKAXIS_CURSOR: { + float scale[3] = {1.0f, 1.0f, 1.0f}; + loc_eul_size_to_mat4( + stl->storage->grid_matrix, cursor->location, cursor->rotation_euler, scale); + break; + } + default: { + copy_m4_m4(stl->storage->grid_matrix, obact->obmat); + break; + } + } + + /* Move the origin to Object or Cursor */ + if (ts->gpencil_v3d_align & GP_PROJECT_CURSOR) { + copy_v3_v3(stl->storage->grid_matrix[3], cursor->location); + } + else { + copy_v3_v3(stl->storage->grid_matrix[3], obact->obmat[3]); + } + DRW_shgroup_uniform_mat4( + stl->g_data->shgrps_grid, "gpModelMatrix", stl->storage->grid_matrix); } /* blend layers pass */ @@ -633,8 +709,6 @@ void GPENCIL_cache_populate(void *vedata, Object *ob) Scene *scene = draw_ctx->scene; ToolSettings *ts = scene->toolsettings; View3D *v3d = draw_ctx->v3d; - const View3DCursor *cursor = &scene->cursor; - float grid_matrix[4][4]; if (ob->type == OB_GPENCIL && ob->data) { bGPdata *gpd = (bGPdata *)ob->data; @@ -695,36 +769,7 @@ void GPENCIL_cache_populate(void *vedata, Object *ob) ((ts->gpencil_v3d_align & GP_PROJECT_DEPTH_STROKE) == 0)) { stl->g_data->batch_grid = gpencil_get_grid(ob); - - /* define grid orientation */ - switch (ts->gp_sculpt.lock_axis) { - case GP_LOCKAXIS_VIEW: { - /* align always to view */ - invert_m4_m4(grid_matrix, draw_ctx->rv3d->viewmat); - /* copy ob location */ - copy_v3_v3(grid_matrix[3], ob->obmat[3]); - break; - } - case GP_LOCKAXIS_CURSOR: { - float scale[3] = {1.0f, 1.0f, 1.0f}; - loc_eul_size_to_mat4(grid_matrix, cursor->location, cursor->rotation_euler, scale); - break; - } - default: { - copy_m4_m4(grid_matrix, ob->obmat); - break; - } - } - - /* Move the origin to Object or Cursor */ - if (ts->gpencil_v3d_align & GP_PROJECT_CURSOR) { - copy_v3_v3(grid_matrix[3], cursor->location); - } - else { - copy_v3_v3(grid_matrix[3], ob->obmat[3]); - } - - DRW_shgroup_call_obmat(stl->g_data->shgrps_grid, stl->g_data->batch_grid, grid_matrix); + DRW_shgroup_call(stl->g_data->shgrps_grid, stl->g_data->batch_grid, NULL); } } } diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.h b/source/blender/draw/engines/gpencil/gpencil_engine.h index c475c343d22..5638639cbf2 100644 --- a/source/blender/draw/engines/gpencil/gpencil_engine.h +++ b/source/blender/draw/engines/gpencil/gpencil_engine.h @@ -145,6 +145,8 @@ typedef struct GPENCIL_Storage { bool is_playing; bool is_render; bool is_mat_preview; + bool is_main_overlay; + bool is_main_onion; bool background_ready; int is_xray; bool is_ontop; @@ -155,6 +157,7 @@ typedef struct GPENCIL_Storage { int do_select_outline; float select_color[4]; short multisamples; + float grid_matrix[4][4]; short framebuffer_flag; /* flag what framebuffer need to create */ diff --git a/source/blender/draw/engines/workbench/workbench_deferred.c b/source/blender/draw/engines/workbench/workbench_deferred.c index 15522ba0dfb..2e8b952f234 100644 --- a/source/blender/draw/engines/workbench/workbench_deferred.c +++ b/source/blender/draw/engines/workbench/workbench_deferred.c @@ -78,7 +78,6 @@ static struct { struct GPUTexture *object_id_tx; /* ref only, not alloced */ struct GPUTexture *color_buffer_tx; /* ref only, not alloced */ struct GPUTexture *cavity_buffer_tx; /* ref only, not alloced */ - struct GPUTexture *metallic_buffer_tx; /* ref only, not alloced */ struct GPUTexture *normal_buffer_tx; /* ref only, not alloced */ struct GPUTexture *composite_buffer_tx; /* ref only, not alloced */ diff --git a/source/blender/draw/engines/workbench/workbench_studiolight.c b/source/blender/draw/engines/workbench/workbench_studiolight.c index ac27ff0b736..941a6741998 100644 --- a/source/blender/draw/engines/workbench/workbench_studiolight.c +++ b/source/blender/draw/engines/workbench/workbench_studiolight.c @@ -131,7 +131,7 @@ void studiolight_update_world(WORKBENCH_PrivateData *wpd, static void compute_parallel_lines_nor_and_dist(const float v1[2], const float v2[2], const float v3[2], - float r_line[2]) + float r_line[4]) { sub_v2_v2v2(r_line, v2, v1); /* Find orthogonal vector. */ diff --git a/source/blender/draw/engines/workbench/workbench_volume.c b/source/blender/draw/engines/workbench/workbench_volume.c index e017661b6cd..23f0898c138 100644 --- a/source/blender/draw/engines/workbench/workbench_volume.c +++ b/source/blender/draw/engines/workbench/workbench_volume.c @@ -46,8 +46,6 @@ enum { static struct { struct GPUShader *volume_sh[VOLUME_SH_MAX]; struct GPUShader *volume_coba_sh; - struct GPUShader *volume_slice_sh; - struct GPUShader *volume_slice_coba_sh; struct GPUTexture *dummy_tex; struct GPUTexture *dummy_coba_tex; } e_data = {{NULL}}; |