[Bf-blender-cvs] [0c5b197447] blender2.8: Edit Mesh overlay: remove one extra buffer.

Clément Foucault noreply at git.blender.org
Fri Mar 3 13:46:28 CET 2017


Commit: 0c5b197447dec23033bfab3b84fb9dadf4ffd8e1
Author: Clément Foucault
Date:   Fri Mar 3 13:51:59 2017 +0100
Branches: blender2.8
https://developer.blender.org/rB0c5b197447dec23033bfab3b84fb9dadf4ffd8e1

Edit Mesh overlay: remove one extra buffer.

===================================================================

M	source/blender/draw/modes/edit_mesh_mode.c
M	source/blender/draw/modes/shaders/edit_overlay_mix_frag.glsl

===================================================================

diff --git a/source/blender/draw/modes/edit_mesh_mode.c b/source/blender/draw/modes/edit_mesh_mode.c
index c9a998df9a..691c967f28 100644
--- a/source/blender/draw/modes/edit_mesh_mode.c
+++ b/source/blender/draw/modes/edit_mesh_mode.c
@@ -49,14 +49,12 @@ typedef struct EDIT_MESH_PassList {
 /* keep it under MAX_BUFFERS */
 typedef struct EDIT_MESH_FramebufferList {
 	struct GPUFrameBuffer *occlude_wire_fb;
-	struct GPUFrameBuffer *occlude_face_fb;
 } EDIT_MESH_FramebufferList;
 
 /* keep it under MAX_TEXTURES */
 typedef struct EDIT_MESH_TextureList {
 	struct GPUTexture *occlude_wire_depth_tx;
 	struct GPUTexture *occlude_wire_color_tx;
-	struct GPUTexture *occlude_face_color_tx;
 } EDIT_MESH_TextureList;
 
 static DRWShadingGroup *depth_shgrp_hidden_wire;
@@ -110,11 +108,6 @@ void EDIT_MESH_init(void)
 	                     (int)viewport_size[0], (int)viewport_size[1],
 	                     tex, 2);
 
-	DRWFboTexture tex2 = {&txl->occlude_face_color_tx, DRW_BUF_RGBA_8};
-	DRW_framebuffer_init(&fbl->occlude_face_fb,
-	                     (int)viewport_size[0], (int)viewport_size[1],
-	                     &tex2, 1);
-
 	if (!overlay_tri_sh) {
 		overlay_tri_sh = DRW_shader_create(datatoc_edit_overlay_vert_glsl,
 		                                   datatoc_edit_overlay_geom_tri_glsl,
@@ -244,7 +237,7 @@ void EDIT_MESH_cache_init(void)
 
 		/* however we loose the front faces value (because we need the depth of occluded wires and
 		 * faces are alpha blended ) so we recover them in a new pass. */
-		psl->facefill_occlude_pass = DRW_pass_create("Front Face Color", DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS);
+		psl->facefill_occlude_pass = DRW_pass_create("Front Face Color", DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS | DRW_STATE_BLEND);
 		facefill_occluded_shgrp = DRW_shgroup_create(overlay_facefill_sh, psl->facefill_occlude_pass);
 		DRW_shgroup_uniform_block(facefill_occluded_shgrp, "globalsBlock", globals_ubo, 0);
 
@@ -260,7 +253,6 @@ void EDIT_MESH_cache_init(void)
 		DRW_shgroup_call_add(mix_shgrp, quad, mat);
 		DRW_shgroup_uniform_float(mix_shgrp, "alpha", &backwire_opacity, 1);
 		DRW_shgroup_uniform_buffer(mix_shgrp, "wireColor", &txl->occlude_wire_color_tx, 0);
-		DRW_shgroup_uniform_buffer(mix_shgrp, "faceColor", &txl->occlude_face_color_tx, 1);
 		DRW_shgroup_uniform_buffer(mix_shgrp, "wireDepth", &txl->occlude_wire_depth_tx, 2);
 		DRW_shgroup_uniform_buffer(mix_shgrp, "sceneDepth", &dtxl->depth, 3);
 	}
@@ -366,12 +358,7 @@ void EDIT_MESH_draw(void)
 	if (psl->edit_face_occluded_pass) {
 		float clearcol[4] = {0.0f, 0.0f, 0.0f, 0.0f};
 		/* render facefill */
-		DRW_framebuffer_texture_detach(dtxl->depth);
-		DRW_framebuffer_texture_attach(fbl->occlude_face_fb, dtxl->depth, 0);
-		DRW_framebuffer_bind(fbl->occlude_face_fb);
-		DRW_framebuffer_clear(true, false, clearcol);
 		DRW_draw_pass(psl->facefill_occlude_pass);
-		DRW_framebuffer_texture_detach(dtxl->depth);
 		
 		/* Render wires on a separate framebuffer */
 		DRW_framebuffer_bind(fbl->occlude_wire_fb);
diff --git a/source/blender/draw/modes/shaders/edit_overlay_mix_frag.glsl b/source/blender/draw/modes/shaders/edit_overlay_mix_frag.glsl
index 67687c7fc2..c63579ebc3 100644
--- a/source/blender/draw/modes/shaders/edit_overlay_mix_frag.glsl
+++ b/source/blender/draw/modes/shaders/edit_overlay_mix_frag.glsl
@@ -3,38 +3,22 @@ out vec4 FragColor;
 
 uniform sampler2D wireColor;
 uniform sampler2D wireDepth;
-uniform sampler2D faceColor;
 uniform sampler2D sceneDepth;
 uniform float alpha;
 
-vec4 linear(vec4 col)
-{
-	const float fac = 0.45454545;
-	return vec4(pow(col.r,fac), pow(col.g,fac), pow(col.b,fac), col.a);
-}
-
-vec4 srgb(vec4 col)
-{
-	const float fac = 2.2;
-	return vec4(pow(col.r,fac), pow(col.g,fac), pow(col.b,fac), col.a);
-}
-
 void main()
 {
 	ivec2 co = ivec2(gl_FragCoord.xy);
 	float wire_depth = texelFetch(wireDepth, co, 0).r;
 	float scene_depth = texelFetch(sceneDepth, co, 0).r;
 	vec4 wire_color = texelFetch(wireColor, co, 0).rgba;
-	vec4 face_color = texelFetch(faceColor, co, 0).rgba;
+
+	FragColor = wire_color;
 
 	/* this works because not rendered depth is 1.0 and the
 	 * following test is always true even when no wires */
-	if (wire_depth > scene_depth) {
-		wire_color.a *= alpha;
-		FragColor.rgb = mix(face_color.rgb, wire_color.rgb, wire_color.a);
-		FragColor.a = face_color.a + wire_color.a;
-	}
-	else {
-		FragColor = wire_color;
+	if ((wire_depth > scene_depth) && (wire_color.a > 0)) {
+		/* Note : Using wire_color.a * alpha produce unwanted result */
+		FragColor.a = alpha;
 	}
 }




More information about the Bf-blender-cvs mailing list