diff options
Diffstat (limited to 'source/blender/draw')
3 files changed, 9 insertions, 10 deletions
diff --git a/source/blender/draw/engines/basic/basic_engine.c b/source/blender/draw/engines/basic/basic_engine.c index 86c565371c1..eee6a5a7cb5 100644 --- a/source/blender/draw/engines/basic/basic_engine.c +++ b/source/blender/draw/engines/basic/basic_engine.c @@ -85,8 +85,7 @@ static void basic_cache_init(void *vedata) DRW_PASS_CREATE(psl->depth_pass[i], state | clip_state | infront_state); stl->g_data->depth_shgrp[i] = grp = DRW_shgroup_create(sh, psl->depth_pass[i]); - DRW_shgroup_uniform_vec2(grp, "sizeViewport", DRW_viewport_size_get(), 1); - DRW_shgroup_uniform_vec2(grp, "sizeViewportInv", DRW_viewport_invert_size_get(), 1); + DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo); sh = DRW_state_is_select() ? BASIC_shaders_pointcloud_depth_conservative_sh_get(draw_ctx->sh_cfg) : @@ -94,22 +93,22 @@ static void basic_cache_init(void *vedata) DRW_PASS_CREATE(psl->depth_pass_pointcloud[i], state | clip_state | infront_state); stl->g_data->depth_pointcloud_shgrp[i] = grp = DRW_shgroup_create( sh, psl->depth_pass_pointcloud[i]); - DRW_shgroup_uniform_vec2(grp, "sizeViewport", DRW_viewport_size_get(), 1); - DRW_shgroup_uniform_vec2(grp, "sizeViewportInv", DRW_viewport_invert_size_get(), 1); + DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo); stl->g_data->depth_hair_shgrp[i] = grp = DRW_shgroup_create( BASIC_shaders_depth_sh_get(draw_ctx->sh_cfg), psl->depth_pass[i]); + DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo); stl->g_data->depth_curves_shgrp[i] = grp = DRW_shgroup_create( BASIC_shaders_curves_depth_sh_get(draw_ctx->sh_cfg), psl->depth_pass[i]); + DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo); sh = DRW_state_is_select() ? BASIC_shaders_depth_conservative_sh_get(draw_ctx->sh_cfg) : BASIC_shaders_depth_sh_get(draw_ctx->sh_cfg); state |= DRW_STATE_CULL_BACK; DRW_PASS_CREATE(psl->depth_pass_cull[i], state | clip_state | infront_state); stl->g_data->depth_shgrp_cull[i] = grp = DRW_shgroup_create(sh, psl->depth_pass_cull[i]); - DRW_shgroup_uniform_vec2(grp, "sizeViewport", DRW_viewport_size_get(), 1); - DRW_shgroup_uniform_vec2(grp, "sizeViewportInv", DRW_viewport_invert_size_get(), 1); + DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo); } } diff --git a/source/blender/draw/engines/basic/shaders/basic_conservative_depth_geom.glsl b/source/blender/draw/engines/basic/shaders/basic_conservative_depth_geom.glsl index 1a90a2f57c0..73b171e5cb6 100644 --- a/source/blender/draw/engines/basic/shaders/basic_conservative_depth_geom.glsl +++ b/source/blender/draw/engines/basic/shaders/basic_conservative_depth_geom.glsl @@ -19,7 +19,7 @@ void main() /* Compute NDC bound box. */ vec4 bbox = vec4(min(min(pos0.xy, pos1.xy), pos2.xy), max(max(pos0.xy, pos1.xy), pos2.xy)); /* Convert to pixel space. */ - bbox = (bbox * 0.5 + 0.5) * drw_view.viewport_size.xyxy; + bbox = (bbox * 0.5 + 0.5) * sizeViewport.xyxy; /* Detect failure cases where triangles would produce no fragments. */ bvec2 is_subpixel = lessThan(bbox.zw - bbox.xy, vec2(1.0)); /* View aligned triangle. */ @@ -31,13 +31,13 @@ void main() if (all(is_subpixel)) { vec2 ofs = (i == 0) ? vec2(-1.0) : ((i == 1) ? vec2(2.0, -1.0) : vec2(-1.0, 2.0)); /* HACK: Fix cases where the triangle is too small make it cover at least one pixel. */ - gl_Position.xy += drw_view.viewport_size_inverse * gl_Position.w * ofs; + gl_Position.xy += sizeViewportInv * gl_Position.w * ofs; } /* Test if the triangle is almost parallel with the view to avoid precision issues. */ else if (any(is_subpixel) || is_coplanar) { /* HACK: Fix cases where the triangle is Parallel to the view by deforming it slightly. */ vec2 ofs = (i == 0) ? vec2(-1.0) : ((i == 1) ? vec2(1.0, -1.0) : vec2(1.0)); - gl_Position.xy += drw_view.viewport_size_inverse * gl_Position.w * ofs; + gl_Position.xy += sizeViewportInv * gl_Position.w * ofs; } else { /* Triangle expansion should happen here, but we decide to not implement it for diff --git a/source/blender/draw/engines/basic/shaders/infos/basic_depth_info.hh b/source/blender/draw/engines/basic/shaders/infos/basic_depth_info.hh index 561cef0e442..e275d208c7a 100644 --- a/source/blender/draw/engines/basic/shaders/infos/basic_depth_info.hh +++ b/source/blender/draw/engines/basic/shaders/infos/basic_depth_info.hh @@ -60,6 +60,6 @@ GPU_SHADER_CREATE_INFO(basic_curves) GPU_SHADER_CREATE_INFO(basic_depth).fragment_source("basic_depth_frag.glsl"); -BASIC_OBTYPE_VARIATIONS(basic_depth, "basic_depth"); +BASIC_OBTYPE_VARIATIONS(basic_depth, "basic_depth", "draw_globals"); /** \} */ |