Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/blender/editors/space_image/space_image.c5
-rw-r--r--source/blender/editors/uvedit/uvedit_draw.c65
-rw-r--r--source/blender/gpu/GPU_framebuffer.h1
-rw-r--r--source/blender/gpu/intern/gpu_framebuffer.c5
-rw-r--r--source/blender/gpu/shaders/gpu_shader_2D_edituvs_edges_vert.glsl5
5 files changed, 38 insertions, 43 deletions
diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c
index 341a162c840..931142d2925 100644
--- a/source/blender/editors/space_image/space_image.c
+++ b/source/blender/editors/space_image/space_image.c
@@ -590,18 +590,17 @@ static void image_main_region_draw(const bContext *C, ARegion *ar)
* olg context since we now use it for drawing the entire area */
gpu_batch_presets_reset();
- /* TODO(fclem) port to draw manager and remove the depth buffer allocation. */
GPUViewport *viewport =
ar->draw_buffer->viewport[ar->draw_buffer->stereo ? sima->iuser.multiview_eye : 0];
DefaultFramebufferList *fbl = GPU_viewport_framebuffer_list_get(viewport);
- GPU_framebuffer_bind(fbl->color_only_fb);
+ GPU_framebuffer_bind(fbl->default_fb);
/* XXX not supported yet, disabling for now */
scene->r.scemode &= ~R_COMP_CROP;
/* clear and setup matrix */
UI_GetThemeColor3fv(TH_BACK, col);
- GPU_clear_color(col[0], col[1], col[2], 0.0);
+ GPU_clear_color(col[0], col[1], col[2], 0.0f);
GPU_clear(GPU_COLOR_BIT);
image_user_refresh_scene(C, sima);
diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c
index 93cef1861d9..fa2a7eb9812 100644
--- a/source/blender/editors/uvedit/uvedit_draw.c
+++ b/source/blender/editors/uvedit/uvedit_draw.c
@@ -52,6 +52,7 @@
#include "DEG_depsgraph_query.h"
#include "GPU_batch.h"
+#include "GPU_framebuffer.h"
#include "GPU_immediate.h"
#include "GPU_immediate_util.h"
#include "GPU_matrix.h"
@@ -300,8 +301,6 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit, Depsgraph *
uvedit_get_batches(eval_ob, sima, ts, &faces, &edges, &verts, &facedots);
bool interpedges;
- bool do_elem_order_fix = (ts->uv_flag & UV_SYNC_SELECTION) && (ts->selectmode & SCE_SELECT_FACE);
- bool do_selected_edges = ((sima->flag & SI_NO_DRAWEDGES) == 0);
bool draw_stretch = (sima->flag & SI_DRAW_STRETCH) != 0;
if (ts->uv_flag & UV_SYNC_SELECTION) {
interpedges = (ts->selectmode & SCE_SELECT_VERTEX) != 0;
@@ -378,37 +377,28 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit, Depsgraph *
break;
}
case SI_UVDT_OUTLINE: {
- GPU_line_width(3.0f);
- GPU_batch_program_set_builtin(edges, GPU_SHADER_2D_UNIFORM_COLOR);
- GPU_batch_uniform_4f(edges, "color", 0.0f, 0.0f, 0.0f, 1.0f);
- GPU_batch_draw(edges);
-
- UI_GetThemeColor4fv(TH_WIRE_EDIT, col1);
- UI_GetThemeColor4fv(TH_EDGE_SELECT, col2);
-
/* We could modify the vbo's data filling
* instead of modifying the provoking vert. */
glProvokingVertex(GL_FIRST_VERTEX_CONVENTION);
- GPU_line_width(1.0f);
+ UI_GetThemeColor4fv(TH_WIRE_EDIT, col1);
+ UI_GetThemeColor4fv(TH_EDGE_SELECT, col2);
+
GPU_batch_program_set_builtin(
edges, (interpedges) ? GPU_SHADER_2D_UV_EDGES_SMOOTH : GPU_SHADER_2D_UV_EDGES);
+ /* Black Outline. */
+ GPU_line_width(3.0f);
+ GPU_batch_uniform_4f(edges, "edgeColor", 0.0f, 0.0f, 0.0f, 1.0f);
+ GPU_batch_uniform_4f(edges, "selectColor", 0.0f, 0.0f, 0.0f, 1.0f);
+ GPU_batch_draw(edges);
+ /* Inner Line. Use depth test to insure selection is drawn on top. */
+ GPU_depth_test(true);
+ GPU_line_width(1.0f);
GPU_batch_uniform_4fv(edges, "edgeColor", col1);
- GPU_batch_uniform_4fv(edges, "selectColor", do_selected_edges ? col2 : col1);
+ GPU_batch_uniform_4fv(edges, "selectColor", col2);
GPU_batch_draw(edges);
+ GPU_depth_test(false);
- if (do_elem_order_fix && do_selected_edges) {
- /* We have problem in this mode when face order make some edges
- * appear unselected because an adjacent face is not selected and
- * render after the selected face.
- * So, to avoid sorting edges by state we just render selected edges
- * on top. A bit overkill but it's simple. */
- GPU_blend(true);
- GPU_batch_uniform_4fv(edges, "edgeColor", transparent);
- GPU_batch_uniform_4fv(edges, "selectColor", col2);
- GPU_batch_draw(edges);
- GPU_blend(false);
- }
glProvokingVertex(GL_LAST_VERTEX_CONVENTION);
break;
}
@@ -429,25 +419,20 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit, Depsgraph *
GPU_batch_program_set_builtin(verts, GPU_SHADER_2D_UV_VERTS);
GPU_batch_uniform_4f(verts, "vertColor", col1[0], col1[1], col1[2], 1.0f);
- GPU_batch_uniform_4fv(verts, "selectColor", (do_elem_order_fix) ? transparent : col2);
+ GPU_batch_uniform_4fv(verts, "selectColor", transparent);
GPU_batch_uniform_4fv(verts, "pinnedColor", pinned_col);
GPU_batch_uniform_1f(verts, "pointSize", (pointsize + 1.5f) * M_SQRT2);
GPU_batch_uniform_1f(verts, "outlineWidth", 0.75f);
GPU_batch_draw(verts);
- if (do_elem_order_fix) {
- /* We have problem in this mode when face order make some verts
- * appear unselected because an adjacent face is not selected and
- * render after the selected face.
- * So, to avoid sorting verts by state we just render selected verts
- * on top. A bit overkill but it's simple. */
- GPU_batch_uniform_4fv(verts, "vertColor", transparent);
- GPU_batch_uniform_4fv(verts, "selectColor", col2);
- GPU_batch_uniform_4fv(verts, "pinnedColor", pinned_col);
- GPU_batch_uniform_1f(verts, "pointSize", (pointsize + 1.5f) * M_SQRT2);
- GPU_batch_uniform_1f(verts, "outlineWidth", 0.75f);
- GPU_batch_draw(verts);
- }
+ /* We have problem in this mode when face order make some verts
+ * appear unselected because an adjacent face is not selected and
+ * render after the selected face.
+ * So, to avoid sorting verts by state we just render selected verts
+ * on top. A bit overkill but it's simple. */
+ GPU_batch_uniform_4fv(verts, "vertColor", transparent);
+ GPU_batch_uniform_4fv(verts, "selectColor", col2);
+ GPU_batch_draw(verts);
GPU_blend(false);
GPU_program_point_size(false);
@@ -502,6 +487,10 @@ void ED_uvedit_draw_main(SpaceImage *sima,
uint objects_len = 0;
Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(
view_layer, ((View3D *)NULL), &objects_len);
+ if (objects_len > 0) {
+ GPU_clear_depth(1.0f);
+ GPU_clear(GPU_DEPTH_BIT);
+ }
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *ob_iter = objects[ob_index];
draw_uvs(sima, scene, ob_iter, depsgraph);
diff --git a/source/blender/gpu/GPU_framebuffer.h b/source/blender/gpu/GPU_framebuffer.h
index 3cc972fabfb..b919a3dd8f3 100644
--- a/source/blender/gpu/GPU_framebuffer.h
+++ b/source/blender/gpu/GPU_framebuffer.h
@@ -209,6 +209,7 @@ void GPU_offscreen_viewport_data_get(GPUOffScreen *ofs,
struct GPUTexture **r_depth);
void GPU_clear_color(float red, float green, float blue, float alpha);
+void GPU_clear_depth(float depth);
void GPU_clear(eGPUFrameBufferBits flags);
#ifdef __cplusplus
diff --git a/source/blender/gpu/intern/gpu_framebuffer.c b/source/blender/gpu/intern/gpu_framebuffer.c
index 5950027a103..27a088fa922 100644
--- a/source/blender/gpu/intern/gpu_framebuffer.c
+++ b/source/blender/gpu/intern/gpu_framebuffer.c
@@ -1041,6 +1041,11 @@ void GPU_clear_color(float red, float green, float blue, float alpha)
glClearColor(red, green, blue, alpha);
}
+void GPU_clear_depth(float depth)
+{
+ glClearDepth(depth);
+}
+
void GPU_clear(eGPUFrameBufferBits flags)
{
glClear(convert_buffer_bits_to_gl(flags));
diff --git a/source/blender/gpu/shaders/gpu_shader_2D_edituvs_edges_vert.glsl b/source/blender/gpu/shaders/gpu_shader_2D_edituvs_edges_vert.glsl
index 5c6b8f0a1a1..02bbe545436 100644
--- a/source/blender/gpu/shaders/gpu_shader_2D_edituvs_edges_vert.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_2D_edituvs_edges_vert.glsl
@@ -19,13 +19,14 @@ flat out vec4 finalColor;
void main()
{
- gl_Position = ModelViewProjectionMatrix * vec4(pos, 0.0, 1.0);
-
#ifdef SMOOTH_COLOR
bool is_select = (flag & VERT_UV_SELECT) != 0;
#else
bool is_select = (flag & EDGE_UV_SELECT) != 0;
#endif
+ gl_Position = ModelViewProjectionMatrix * vec4(pos, 0.0, 1.0);
+ gl_Position.z = float(!is_select);
+
finalColor = (is_select) ? selectColor : edgeColor;
}