diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2021-02-03 19:14:04 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2021-02-03 19:14:04 +0300 |
commit | d02e644060bba0cab0111fdfa8b049f7d9cce443 (patch) | |
tree | 4211ea4de9959277866f9429ba15d54d4ba4e0fb /source/blender/draw | |
parent | 54d6e071ab6b89dd26ff652666f56bad161f4634 (diff) | |
parent | e49b702527440997ef32967ef368c1212a2311f9 (diff) |
Merge branch 'master' into eevee-dof-refactor
Diffstat (limited to 'source/blender/draw')
14 files changed, 64 insertions, 34 deletions
diff --git a/source/blender/draw/engines/eevee/eevee_cryptomatte.c b/source/blender/draw/engines/eevee/eevee_cryptomatte.c index 31e54e371b1..13a3f1766a9 100644 --- a/source/blender/draw/engines/eevee/eevee_cryptomatte.c +++ b/source/blender/draw/engines/eevee/eevee_cryptomatte.c @@ -503,7 +503,7 @@ static void eevee_cryptomatte_postprocess_weights(EEVEE_Data *vedata) volumetric_transmittance_buffer = GPU_texture_read( txl->volume_transmittance_accum, GPU_DATA_FLOAT, 0); } - const int num_samples = effects->taa_current_sample; + const int num_samples = effects->taa_current_sample - 1; int accum_pixel_index = 0; int accum_pixel_stride = eevee_cryptomatte_pixel_stride(view_layer); diff --git a/source/blender/draw/engines/eevee/eevee_materials.c b/source/blender/draw/engines/eevee/eevee_materials.c index c7a8f7729eb..273521b0b28 100644 --- a/source/blender/draw/engines/eevee/eevee_materials.c +++ b/source/blender/draw/engines/eevee/eevee_materials.c @@ -856,7 +856,7 @@ void EEVEE_materials_cache_populate(EEVEE_Data *vedata, ADD_SHGROUP_CALL(matcache[i].shading_grp, ob, mat_geom[i], oedata); ADD_SHGROUP_CALL_SAFE(matcache[i].depth_grp, ob, mat_geom[i], oedata); ADD_SHGROUP_CALL_SAFE(matcache[i].shadow_grp, ob, mat_geom[i], oedata); - *cast_shadow = (matcache[i].shadow_grp != NULL); + *cast_shadow = *cast_shadow || (matcache[i].shadow_grp != NULL); } } } diff --git a/source/blender/draw/engines/eevee/eevee_motion_blur.c b/source/blender/draw/engines/eevee/eevee_motion_blur.c index 530becfe771..8dcab579603 100644 --- a/source/blender/draw/engines/eevee/eevee_motion_blur.c +++ b/source/blender/draw/engines/eevee/eevee_motion_blur.c @@ -376,6 +376,19 @@ void EEVEE_motion_blur_cache_populate(EEVEE_ViewLayerData *UNUSED(sldata), } } +static void motion_blur_remove_vbo_reference_from_batch(GPUBatch *batch, + GPUVertBuf *vbo1, + GPUVertBuf *vbo2) +{ + + for (int i = 0; i < GPU_BATCH_VBO_MAX_LEN; i++) { + if (ELEM(batch->verts[i], vbo1, vbo2)) { + /* Avoid double reference of the VBOs. */ + batch->verts[i] = NULL; + } + } +} + void EEVEE_motion_blur_cache_finish(EEVEE_Data *vedata) { EEVEE_StorageList *stl = vedata->stl; @@ -446,6 +459,9 @@ void EEVEE_motion_blur_cache_finish(EEVEE_Data *vedata) } if (mb_geom->use_deform == false) { + motion_blur_remove_vbo_reference_from_batch( + batch, mb_geom->vbo[MB_PREV], mb_geom->vbo[MB_NEXT]); + GPU_VERTBUF_DISCARD_SAFE(mb_geom->vbo[MB_PREV]); GPU_VERTBUF_DISCARD_SAFE(mb_geom->vbo[MB_NEXT]); break; @@ -457,9 +473,6 @@ void EEVEE_motion_blur_cache_finish(EEVEE_Data *vedata) } else { GPUVertBuf *vbo = mb_geom->vbo[mb_step]; - /* If this assert fails, it means that different EEVEE_GeometryMotionDatas - * has been used for each motion blur step. */ - BLI_assert(vbo); if (vbo) { /* Use the vbo to perform the copy on the GPU. */ GPU_vertbuf_use(vbo); @@ -470,6 +483,10 @@ void EEVEE_motion_blur_cache_finish(EEVEE_Data *vedata) int attrib_id = GPU_vertformat_attr_id_get(format, "pos"); GPU_vertformat_attr_rename(format, attrib_id, (mb_step == MB_PREV) ? "prv" : "nxt"); } + else { + /* This might happen if the object visibility has been animated. */ + mb_geom->use_deform = false; + } } break; @@ -515,23 +532,22 @@ void EEVEE_motion_blur_swap_data(EEVEE_Data *vedata) DRW_TEXTURE_FREE_SAFE(mb_hair->psys[i].hair_pos_tx[MB_PREV]); mb_hair->psys[i].hair_pos[MB_PREV] = mb_hair->psys[i].hair_pos[MB_NEXT]; mb_hair->psys[i].hair_pos_tx[MB_PREV] = mb_hair->psys[i].hair_pos_tx[MB_NEXT]; + mb_hair->psys[i].hair_pos[MB_NEXT] = NULL; + mb_hair->psys[i].hair_pos_tx[MB_NEXT] = NULL; } break; case EEVEE_MOTION_DATA_MESH: if (mb_geom->batch != NULL) { - for (int i = 0; i < GPU_BATCH_VBO_MAX_LEN; i++) { - if (ELEM(mb_geom->batch->verts[i], mb_geom->vbo[MB_PREV], mb_geom->vbo[MB_NEXT])) { - /* Avoid double reference of the VBOs. */ - mb_geom->batch->verts[i] = NULL; - } - } + motion_blur_remove_vbo_reference_from_batch( + mb_geom->batch, mb_geom->vbo[MB_PREV], mb_geom->vbo[MB_NEXT]); } GPU_VERTBUF_DISCARD_SAFE(mb_geom->vbo[MB_PREV]); mb_geom->vbo[MB_PREV] = mb_geom->vbo[MB_NEXT]; + mb_geom->vbo[MB_NEXT] = NULL; - if (mb_geom->vbo[MB_NEXT]) { - GPUVertBuf *vbo = mb_geom->vbo[MB_NEXT]; + if (mb_geom->vbo[MB_PREV]) { + GPUVertBuf *vbo = mb_geom->vbo[MB_PREV]; GPUVertFormat *format = (GPUVertFormat *)GPU_vertbuf_get_format(vbo); int attrib_id = GPU_vertformat_attr_id_get(format, "nxt"); GPU_vertformat_attr_rename(format, attrib_id, "prv"); diff --git a/source/blender/draw/engines/eevee/eevee_renderpasses.c b/source/blender/draw/engines/eevee/eevee_renderpasses.c index ce5292fbbb0..52160248d75 100644 --- a/source/blender/draw/engines/eevee/eevee_renderpasses.c +++ b/source/blender/draw/engines/eevee/eevee_renderpasses.c @@ -282,7 +282,9 @@ void EEVEE_renderpasses_postprocess(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_PrivateData *g_data = stl->g_data; EEVEE_EffectsInfo *effects = stl->effects; - const int current_sample = effects->taa_current_sample; + /* Compensate for taa_current_sample being incremented after last drawing in + * EEVEE_temporal_sampling_draw. */ + const int current_sample = effects->taa_current_sample - 1; g_data->renderpass_current_sample = current_sample; g_data->renderpass_type = renderpass_type; g_data->renderpass_postprocess = PASS_POST_UNDEFINED; diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c b/source/blender/draw/engines/gpencil/gpencil_engine.c index cecaefa0ca8..6627d38366f 100644 --- a/source/blender/draw/engines/gpencil/gpencil_engine.c +++ b/source/blender/draw/engines/gpencil/gpencil_engine.c @@ -629,6 +629,14 @@ void GPENCIL_cache_populate(void *ved, Object *ob) } } + /* When render in background the active frame could not be properly set due thread priority + * better set again. This is not required in viewport. */ + if (txl->render_depth_tx) { + LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) { + gpl->actframe = BKE_gpencil_layer_frame_get(gpl, pd->cfra, GP_GETFRAME_USE_PREV); + } + } + BKE_gpencil_visible_stroke_iter(is_final_render ? pd->view_layer : NULL, ob, gpencil_layer_cache_populate, diff --git a/source/blender/draw/engines/gpencil/gpencil_render.c b/source/blender/draw/engines/gpencil/gpencil_render.c index b18013d742a..9ac9a4dc078 100644 --- a/source/blender/draw/engines/gpencil/gpencil_render.c +++ b/source/blender/draw/engines/gpencil/gpencil_render.c @@ -213,7 +213,7 @@ static void GPENCIL_render_result_z(struct RenderLayer *rl, rp->rect[i] = 1e10f; /* Background */ } else { - rp->rect[i] = -rp->rect[i] * range + near; + rp->rect[i] = rp->rect[i] * range - near; } } } diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_depth_merge_frag.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_depth_merge_frag.glsl index 71597197bd8..2f711f6a2c5 100644 --- a/source/blender/draw/engines/gpencil/shaders/gpencil_depth_merge_frag.glsl +++ b/source/blender/draw/engines/gpencil/shaders/gpencil_depth_merge_frag.glsl @@ -1,13 +1,10 @@ uniform sampler2D depthBuf; -uniform float strokeDepth2d; uniform bool strokeOrder3d; -noperspective in vec4 uvcoordsvar; - void main() { - float depth = textureLod(depthBuf, uvcoordsvar.xy, 0).r; + float depth = textureLod(depthBuf, gl_FragCoord.xy / vec2(textureSize(depthBuf, 0)), 0).r; if (strokeOrder3d) { gl_FragDepth = depth; } diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_depth_merge_vert.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_depth_merge_vert.glsl index 1e5a900f486..0c5260a9ec4 100644 --- a/source/blender/draw/engines/gpencil/shaders/gpencil_depth_merge_vert.glsl +++ b/source/blender/draw/engines/gpencil/shaders/gpencil_depth_merge_vert.glsl @@ -1,8 +1,6 @@ uniform vec4 gpModelMatrix[4]; -noperspective out vec4 uvcoordsvar; - void main() { mat4 model_matrix = mat4(gpModelMatrix[0], gpModelMatrix[1], gpModelMatrix[2], gpModelMatrix[3]); @@ -10,5 +8,4 @@ void main() float x = -1.0 + float((v & 1) << 2); float y = -1.0 + float((v & 2) << 1); gl_Position = ViewProjectionMatrix * (model_matrix * vec4(x, y, 0.0, 1.0)); - uvcoordsvar = vec4((gl_Position.xy / gl_Position.w + 1.0) * 0.5, 0.0, 0.0); } diff --git a/source/blender/draw/engines/overlay/overlay_edit_mesh.c b/source/blender/draw/engines/overlay/overlay_edit_mesh.c index 728b3d510fa..38e171cb5e2 100644 --- a/source/blender/draw/engines/overlay/overlay_edit_mesh.c +++ b/source/blender/draw/engines/overlay/overlay_edit_mesh.c @@ -110,12 +110,6 @@ void OVERLAY_edit_mesh_cache_init(OVERLAY_Data *vedata) float face_alpha = (do_occlude_wire || !pd->edit_mesh.do_faces) ? 0.0f : 1.0f; GPUTexture **depth_tex = (pd->edit_mesh.do_zbufclip) ? &dtxl->depth : &txl->dummy_depth_tx; - if (select_face && !pd->edit_mesh.do_faces && pd->edit_mesh.do_edges) { - /* Force display of face centers in this case because that's - * the only way to see if a face is selected. */ - show_face_dots = true; - } - /* Run Twice for in-front passes. */ for (int i = 0; i < 2; i++) { /* Complementary Depth Pass */ diff --git a/source/blender/draw/engines/overlay/overlay_engine.c b/source/blender/draw/engines/overlay/overlay_engine.c index fc9ec7ecc22..e9736402ae7 100644 --- a/source/blender/draw/engines/overlay/overlay_engine.c +++ b/source/blender/draw/engines/overlay/overlay_engine.c @@ -598,6 +598,11 @@ static void OVERLAY_draw_scene(void *vedata) OVERLAY_xray_depth_infront_copy(vedata); + if (pd->ctx_mode == CTX_MODE_PAINT_WEIGHT) { + /* Fix weird case where weightpaint mode needs to draw before xray bones. */ + OVERLAY_paint_draw(vedata); + } + if (DRW_state_is_fbo()) { GPU_framebuffer_bind(fbl->overlay_in_front_fb); } @@ -648,7 +653,6 @@ static void OVERLAY_draw_scene(void *vedata) OVERLAY_paint_draw(vedata); OVERLAY_pose_draw(vedata); break; - case CTX_MODE_PAINT_WEIGHT: case CTX_MODE_PAINT_VERTEX: case CTX_MODE_PAINT_TEXTURE: OVERLAY_paint_draw(vedata); diff --git a/source/blender/draw/engines/overlay/overlay_grid.c b/source/blender/draw/engines/overlay/overlay_grid.c index 988c35e387a..87aa013f03a 100644 --- a/source/blender/draw/engines/overlay/overlay_grid.c +++ b/source/blender/draw/engines/overlay/overlay_grid.c @@ -232,7 +232,7 @@ void OVERLAY_grid_cache_init(OVERLAY_Data *vedata) DRW_shgroup_uniform_vec3(grp, "gridSize", shd->grid_size, 1); DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo); DRW_shgroup_uniform_texture_ref(grp, "depthBuffer", &dtxl->depth); - if (shd->zneg_flag) { + if (shd->zneg_flag & SHOW_AXIS_Z) { DRW_shgroup_call(grp, geom, NULL); } @@ -251,7 +251,7 @@ void OVERLAY_grid_cache_init(OVERLAY_Data *vedata) DRW_shgroup_uniform_vec3(grp, "planeAxes", shd->zplane_axes, 1); DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo); DRW_shgroup_uniform_texture_ref(grp, "depthBuffer", &dtxl->depth); - if (shd->zpos_flag) { + if (shd->zpos_flag & SHOW_AXIS_Z) { DRW_shgroup_call(grp, geom, NULL); } diff --git a/source/blender/draw/engines/overlay/overlay_wireframe.c b/source/blender/draw/engines/overlay/overlay_wireframe.c index 617dda56421..7ba5fb3a426 100644 --- a/source/blender/draw/engines/overlay/overlay_wireframe.c +++ b/source/blender/draw/engines/overlay/overlay_wireframe.c @@ -20,6 +20,7 @@ * \ingroup draw_engine */ +#include "DNA_collection_types.h" #include "DNA_mesh_types.h" #include "DNA_particle_types.h" #include "DNA_view3d_types.h" @@ -141,7 +142,12 @@ static void wireframe_hair_cache_populate(OVERLAY_Data *vedata, Object *ob, Part float dupli_mat[4][4]; if ((dupli_parent != NULL) && (dupli_object != NULL)) { if (dupli_object->type & OB_DUPLICOLLECTION) { - copy_m4_m4(dupli_mat, dupli_parent->obmat); + unit_m4(dupli_mat); + Collection *collection = dupli_parent->instance_collection; + if (collection != NULL) { + sub_v3_v3(dupli_mat[3], collection->instance_offset); + } + mul_m4_m4m4(dupli_mat, dupli_parent->obmat, dupli_mat); } else { copy_m4_m4(dupli_mat, dupli_object->ob->obmat); diff --git a/source/blender/draw/engines/workbench/workbench_render.c b/source/blender/draw/engines/workbench/workbench_render.c index cec372ba732..47592578c34 100644 --- a/source/blender/draw/engines/workbench/workbench_render.c +++ b/source/blender/draw/engines/workbench/workbench_render.c @@ -155,7 +155,7 @@ static void workbench_render_result_z(struct RenderLayer *rl, rp->rect[i] = 1e10f; /* Background */ } else { - rp->rect[i] = -rp->rect[i] * range + near; + rp->rect[i] = rp->rect[i] * range - near; } } } diff --git a/source/blender/draw/intern/draw_hair.c b/source/blender/draw/intern/draw_hair.c index cc0aa09ed97..86f1b0e0ebb 100644 --- a/source/blender/draw/intern/draw_hair.c +++ b/source/blender/draw/intern/draw_hair.c @@ -28,6 +28,7 @@ #include "BLI_string_utils.h" #include "BLI_utildefines.h" +#include "DNA_collection_types.h" #include "DNA_customdata_types.h" #include "DNA_modifier_types.h" #include "DNA_particle_types.h" @@ -195,7 +196,12 @@ void DRW_hair_duplimat_get(Object *object, if (psys) { if ((dupli_parent != NULL) && (dupli_object != NULL)) { if (dupli_object->type & OB_DUPLICOLLECTION) { - copy_m4_m4(dupli_mat, dupli_parent->obmat); + unit_m4(dupli_mat); + Collection *collection = dupli_parent->instance_collection; + if (collection != NULL) { + sub_v3_v3(dupli_mat[3], collection->instance_offset); + } + mul_m4_m4m4(dupli_mat, dupli_parent->obmat, dupli_mat); } else { copy_m4_m4(dupli_mat, dupli_object->ob->obmat); |