[Bf-blender-cvs] [a3c998e4f30] greasepencil-refactor: GPencil: Refactor: Implement Layer Masking

2019-12-13 Thread Clément Foucault
Commit: a3c998e4f30ba9ed88c5f8c4cb46d44b98e31e64
Author: Clément Foucault
Date:   Sat Dec 14 03:21:50 2019 +0100
Branches: greasepencil-refactor
https://developer.blender.org/rBa3c998e4f30ba9ed88c5f8c4cb46d44b98e31e64

GPencil: Refactor: Implement Layer Masking

===

M   source/blender/draw/engines/gpencil/gpencil_cache_utils.c
M   source/blender/draw/engines/gpencil/gpencil_engine.c

===

diff --git a/source/blender/draw/engines/gpencil/gpencil_cache_utils.c 
b/source/blender/draw/engines/gpencil/gpencil_cache_utils.c
index a22a4741f3c..293fd306721 100644
--- a/source/blender/draw/engines/gpencil/gpencil_cache_utils.c
+++ b/source/blender/draw/engines/gpencil/gpencil_cache_utils.c
@@ -74,6 +74,14 @@ GPENCIL_tLayer 
*gpencil_layer_cache_add_new(GPENCIL_PrivateData *pd, Object *ob,
   /* We render all strokes with uniform depth (increasing with stroke id). 
*/
   state |= DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_GREATER;
 }
+
+if (gpl->flag & GP_LAYER_USE_MASK) {
+  state |= DRW_STATE_STENCIL_EQUAL;
+}
+else {
+  state |= DRW_STATE_WRITE_STENCIL | DRW_STATE_STENCIL_ALWAYS;
+}
+
 tgp_layer->geom_ps = DRW_pass_create("GPencil Layer", state);
   }
 
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c 
b/source/blender/draw/engines/gpencil/gpencil_engine.c
index 47755bcc43a..f0bc2b91bea 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.c
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.c
@@ -830,6 +830,7 @@ static void gp_layer_cache_populate(bGPDlayer *gpl,
   DRW_shgroup_uniform_float_copy(iter->grp, "thicknessWorldScale", 
thickness_scale);
   DRW_shgroup_uniform_float_copy(iter->grp, "vertexColorOpacity", 
gpl->vertex_paint_opacity);
   DRW_shgroup_uniform_vec4_copy(iter->grp, "layerTint", gpl->tintcolor);
+  DRW_shgroup_stencil_mask(iter->grp, 0xFF);
 }
 
 static void gp_stroke_cache_populate(bGPDlayer *UNUSED(gpl),
@@ -1049,7 +1050,7 @@ static void GPENCIL_cache_finish_new(void *ved)
 
 const float *size = DRW_viewport_size_get();
 pd->depth_tx = DRW_texture_pool_query_2d(
-size[0], size[1], GPU_DEPTH_COMPONENT24, _engine_gpencil_type);
+size[0], size[1], GPU_DEPTH24_STENCIL8, _engine_gpencil_type);
 pd->color_tx = DRW_texture_pool_query_2d(
 size[0], size[1], GPU_R11F_G11F_B10F, _engine_gpencil_type);
 pd->reveal_tx = DRW_texture_pool_query_2d(
@@ -1303,7 +1304,7 @@ static void GPENCIL_draw_scene_new(void *ved)
 DRW_stats_group_start("GPencil Object");
 
 GPU_framebuffer_bind(fbl->gpencil_fb);
-GPU_framebuffer_clear_depth(fbl->gpencil_fb, ob->is_drawmode3d ? 1.0f : 
0.0f);
+GPU_framebuffer_clear_depth_stencil(fbl->gpencil_fb, ob->is_drawmode3d ? 
1.0f : 0.0f, 0x00);
 
 if (ob->vfx.first) {
   /* TODO vfx */

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [8ea92115f3d] greasepencil-refactor: GPencil: Refactor: Speedup: Only blend pixels rendered in the layer

2019-12-13 Thread Clément Foucault
Commit: 8ea92115f3dc33d8e67f3f467f7525911e418e7d
Author: Clément Foucault
Date:   Sat Dec 14 03:31:10 2019 +0100
Branches: greasepencil-refactor
https://developer.blender.org/rB8ea92115f3dc33d8e67f3f467f7525911e418e7d

GPencil: Refactor: Speedup: Only blend pixels rendered in the layer

===

M   source/blender/draw/engines/gpencil/gpencil_cache_utils.c

===

diff --git a/source/blender/draw/engines/gpencil/gpencil_cache_utils.c 
b/source/blender/draw/engines/gpencil/gpencil_cache_utils.c
index 293fd306721..81ed4f1cab0 100644
--- a/source/blender/draw/engines/gpencil/gpencil_cache_utils.c
+++ b/source/blender/draw/engines/gpencil/gpencil_cache_utils.c
@@ -86,7 +86,7 @@ GPENCIL_tLayer 
*gpencil_layer_cache_add_new(GPENCIL_PrivateData *pd, Object *ob,
   }
 
   if ((gpl->blend_mode != eGplBlendMode_Regular) || (gpl->opacity < 1.0f)) {
-DRWState state = DRW_STATE_WRITE_COLOR;
+DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_STENCIL_EQUAL;
 switch (gpl->blend_mode) {
   case eGplBlendMode_Regular:
 state |= DRW_STATE_BLEND_ALPHA_PREMUL;
@@ -119,6 +119,7 @@ GPENCIL_tLayer 
*gpencil_layer_cache_add_new(GPENCIL_PrivateData *pd, Object *ob,
 DRW_shgroup_uniform_float_copy(grp, "blendOpacity", gpl->opacity);
 DRW_shgroup_uniform_texture_ref(grp, "colorBuf", >color_layer_tx);
 DRW_shgroup_uniform_texture_ref(grp, "revealBuf", >reveal_layer_tx);
+DRW_shgroup_stencil_mask(grp, 0xFF);
 /* TODO only blend pixels that have been rendered. */
 DRW_shgroup_call_procedural_triangles(grp, NULL, 1);
 
@@ -130,7 +131,6 @@ GPENCIL_tLayer 
*gpencil_layer_cache_add_new(GPENCIL_PrivateData *pd, Object *ob,
   DRW_shgroup_state_enable(grp, DRW_STATE_BLEND_ADD);
   DRW_shgroup_uniform_int_copy(grp, "blendMode", 999);
   DRW_shgroup_uniform_texture_ref(grp, "colorBuf", >color_layer_tx);
-  DRW_shgroup_uniform_texture_ref(grp, "revealBuf", >reveal_layer_tx);
   /* TODO only blend pixels that have been rendered. */
   DRW_shgroup_call_procedural_triangles(grp, NULL, 1);
 }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [fd548dea3cb] greasepencil-refactor: GPencil: Refactor: Fix Overlay Blend mode

2019-12-13 Thread Clément Foucault
Commit: fd548dea3cb82add6befac809d53e8a3b2debba0
Author: Clément Foucault
Date:   Sat Dec 14 03:21:29 2019 +0100
Branches: greasepencil-refactor
https://developer.blender.org/rBfd548dea3cb82add6befac809d53e8a3b2debba0

GPencil: Refactor: Fix Overlay Blend mode

There was a mistake in the implementation. The step were reversed and
alpha was affecting the blend result.

===

M   source/blender/draw/engines/gpencil/gpencil_cache_utils.c
M   
source/blender/draw/engines/gpencil/shaders/gpencil_layer_blend_frag.glsl

===

diff --git a/source/blender/draw/engines/gpencil/gpencil_cache_utils.c 
b/source/blender/draw/engines/gpencil/gpencil_cache_utils.c
index 47c87fb2559..a22a4741f3c 100644
--- a/source/blender/draw/engines/gpencil/gpencil_cache_utils.c
+++ b/source/blender/draw/engines/gpencil/gpencil_cache_utils.c
@@ -84,7 +84,7 @@ GPENCIL_tLayer 
*gpencil_layer_cache_add_new(GPENCIL_PrivateData *pd, Object *ob,
 state |= DRW_STATE_BLEND_ALPHA_PREMUL;
 break;
   case eGplBlendMode_Add:
-state |= DRW_STATE_BLEND_ADD;
+state |= DRW_STATE_BLEND_ADD_FULL;
 break;
   case eGplBlendMode_Subtract:
 /* Caveat. This effect only propagates if target buffer has
diff --git 
a/source/blender/draw/engines/gpencil/shaders/gpencil_layer_blend_frag.glsl 
b/source/blender/draw/engines/gpencil/shaders/gpencil_layer_blend_frag.glsl
index 88d700ac3f4..ed3a6c53b4b 100644
--- a/source/blender/draw/engines/gpencil/shaders/gpencil_layer_blend_frag.glsl
+++ b/source/blender/draw/engines/gpencil/shaders/gpencil_layer_blend_frag.glsl
@@ -63,13 +63,13 @@ void main()
* rtn = (- 1 + 2 * src) + dst * (2 - 2 * src);
**/
   color = mix(vec4(0.5), color, color.a * blendOpacity);
-  vec4 s = step(0.5, color);
+  vec4 s = step(-0.5, -color);
   fragRevealage = fragColor = 2.0 * s + 2.0 * color * (1.0 - s * 2.0);
   break;
 case MODE_OVERLAY_SECOND_PASS:
   /* Reminder: Blending func is additive blend (dst.rgba + src.rgba).*/
   color = mix(vec4(0.5), color, color.a * blendOpacity);
-  fragRevealage = fragColor = (-1.0 + 2.0 * color) * step(0.5, color);
+  fragRevealage = fragColor = (-1.0 + 2.0 * color) * step(-0.5, -color);
   break;
 case MODE_SUB:
 case MODE_ADD:

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [dc2cc35a7b6] greasepencil-refactor: Cleanup: GPencil: CamelCase for uniforms

2019-12-13 Thread Clément Foucault
Commit: dc2cc35a7b6752b85a06ff71b77d647239c2f400
Author: Clément Foucault
Date:   Sat Dec 14 02:39:21 2019 +0100
Branches: greasepencil-refactor
https://developer.blender.org/rBdc2cc35a7b6752b85a06ff71b77d647239c2f400

Cleanup: GPencil: CamelCase for uniforms

===

M   source/blender/draw/engines/gpencil/gpencil_engine.c
M   source/blender/draw/engines/gpencil/shaders/gpencil_vert.glsl

===

diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c 
b/source/blender/draw/engines/gpencil/gpencil_engine.c
index 5b50dfc3a8a..c5278e54ee9 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.c
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.c
@@ -792,7 +792,7 @@ static void gp_layer_cache_populate(bGPDlayer *gpl,
   GPUUniformBuffer *ubo_mat;
   gpencil_material_resources_get(iter->matpool, 0, NULL, NULL, _mat);
 
-  const bool is_stroke_order_3D = (gpd->draw_mode == GP_DRAWMODE_3D);
+  const bool is_stroke_order_3d = (gpd->draw_mode == GP_DRAWMODE_3D);
   const bool is_screenspace = (gpd->flag & GP_DATA_STROKE_KEEPTHICKNESS) != 0;
 
   float object_scale = mat4_to_scale(iter->ob->obmat);
@@ -806,7 +806,7 @@ static void gp_layer_cache_populate(bGPDlayer *gpl,
   DRW_shgroup_uniform_texture(iter->grp, "gpFillTexture", iter->tex_fill);
   DRW_shgroup_uniform_texture(iter->grp, "gpStrokeTexture", iter->tex_stroke);
   DRW_shgroup_uniform_texture(iter->grp, "gpSceneDepthTexture", 
iter->pd->scene_depth_tx);
-  DRW_shgroup_uniform_bool_copy(iter->grp, "strokeOrder3D", 
is_stroke_order_3D);
+  DRW_shgroup_uniform_bool_copy(iter->grp, "strokeOrder3d", 
is_stroke_order_3d);
   DRW_shgroup_uniform_vec4_copy(iter->grp, "gpModelMatrix[0]", 
iter->ob->obmat[0]);
   DRW_shgroup_uniform_vec4_copy(iter->grp, "gpModelMatrix[1]", 
iter->ob->obmat[1]);
   DRW_shgroup_uniform_vec4_copy(iter->grp, "gpModelMatrix[2]", 
iter->ob->obmat[2]);
diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_vert.glsl 
b/source/blender/draw/engines/gpencil/shaders/gpencil_vert.glsl
index d07a0df6c06..cc0ffaff3c8 100644
--- a/source/blender/draw/engines/gpencil/shaders/gpencil_vert.glsl
+++ b/source/blender/draw/engines/gpencil/shaders/gpencil_vert.glsl
@@ -5,7 +5,7 @@ uniform vec2 sizeViewportInv;
 
 /* Per Object */
 uniform vec4 gpModelMatrix[4];
-uniform bool strokeOrder3D;
+uniform bool strokeOrder3d;
 uniform float thicknessScale;
 uniform float thicknessWorldScale;
 #define thicknessIsScreenSpace (thicknessWorldScale < 0.0)
@@ -213,7 +213,7 @@ void stroke_vertex()
 finalUvs.x = (use_curr) ? uv1.z : uv2.z;
   }
 
-  if (strokeOrder3D) {
+  if (strokeOrder3d) {
 /* Use the fragment depth (see fragment shader). */
 depth = -1.0;
 /* We still offset the fills a little to avoid overlaps */
@@ -254,7 +254,7 @@ void fill_vertex()
   mat2x2 rot_scale = mat2x2(materials[m].fill_uv_rot_scale.xy, 
materials[m].fill_uv_rot_scale.zw);
   finalUvs = rot_scale * uv1.xy + loc;
 
-  if (strokeOrder3D) {
+  if (strokeOrder3d) {
 /* Use the fragment depth (see fragment shader). */
 depth = -1.0;
 /* We still offset the fills a little to avoid overlaps */

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [2cef0182fb7] greasepencil-refactor: GPencil: Refactor: Add depth merge pass

2019-12-13 Thread Clément Foucault
Commit: 2cef0182fb76b6e5f594f9253d076b4cfbc1e6a7
Author: Clément Foucault
Date:   Sat Dec 14 02:44:53 2019 +0100
Branches: greasepencil-refactor
https://developer.blender.org/rB2cef0182fb76b6e5f594f9253d076b4cfbc1e6a7

GPencil: Refactor: Add depth merge pass

This pass merge the stroke depth to the 3D depth buffer. This makes GP objs
to mask overlays correctly.

2D objects depth is using the object center depth only. This is to be
improved.

===

M   source/blender/draw/CMakeLists.txt
M   source/blender/draw/engines/gpencil/gpencil_engine.c
M   source/blender/draw/engines/gpencil/gpencil_engine.h
M   source/blender/draw/engines/gpencil/gpencil_shader.c
A   
source/blender/draw/engines/gpencil/shaders/gpencil_depth_merge_frag.glsl

===

diff --git a/source/blender/draw/CMakeLists.txt 
b/source/blender/draw/CMakeLists.txt
index 1783d26b9e2..52476f9a6e2 100644
--- a/source/blender/draw/CMakeLists.txt
+++ b/source/blender/draw/CMakeLists.txt
@@ -280,6 +280,7 @@ data_to_c_simple(engines/gpencil/shaders/gpencil_vert.glsl 
SRC)
 data_to_c_simple(engines/gpencil/shaders/gpencil_common_lib.glsl SRC)
 data_to_c_simple(engines/gpencil/shaders/gpencil_composite_frag.glsl SRC)
 data_to_c_simple(engines/gpencil/shaders/gpencil_layer_blend_frag.glsl SRC)
+data_to_c_simple(engines/gpencil/shaders/gpencil_depth_merge_frag.glsl SRC)
 
 data_to_c_simple(engines/gpencil/shaders/gpencil_fill_vert.glsl SRC)
 data_to_c_simple(engines/gpencil/shaders/gpencil_fill_frag.glsl SRC)
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c 
b/source/blender/draw/engines/gpencil/gpencil_engine.c
index c5278e54ee9..47755bcc43a 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.c
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.c
@@ -314,6 +314,7 @@ static void GPENCIL_engine_init_new(void *ved)
   float viewmatinv[4][4];
   DRW_view_viewmat_get(NULL, viewmatinv, true);
   copy_v3_v3(stl->pd->camera_z_axis, viewmatinv[2]);
+  stl->pd->camera_z_offset = dot_v3v3(viewmatinv[3], viewmatinv[2]);
 }
 
 void GPENCIL_engine_init(void *vedata)
@@ -355,6 +356,7 @@ static void GPENCIL_engine_free(void)
   DRW_SHADER_FREE_SAFE(e_data.gpencil_sh);
   DRW_SHADER_FREE_SAFE(e_data.composite_sh);
   DRW_SHADER_FREE_SAFE(e_data.layer_blend_sh);
+  DRW_SHADER_FREE_SAFE(e_data.depth_merge_sh);
 
   DRW_TEXTURE_FREE_SAFE(e_data.gpencil_blank_texture);
 
@@ -413,7 +415,6 @@ static void GPENCIL_cache_init_new(void *ved)
 
   {
 DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_CUSTOM;
-
 DRW_PASS_CREATE(psl->composite_ps, state);
 
 GPUShader *sh = GPENCIL_shader_composite_get(_data);
@@ -422,6 +423,17 @@ static void GPENCIL_cache_init_new(void *ved)
 DRW_shgroup_uniform_texture_ref(grp, "revealBuf", >reveal_tx);
 DRW_shgroup_call_procedural_triangles(grp, NULL, 1);
   }
+  {
+DRWState state = DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS;
+DRW_PASS_CREATE(psl->merge_depth_ps, state);
+
+GPUShader *sh = GPENCIL_shader_depth_merge_get(_data);
+grp = DRW_shgroup_create(sh, psl->merge_depth_ps);
+DRW_shgroup_uniform_texture_ref(grp, "depthBuf", >depth_tx);
+DRW_shgroup_uniform_float(grp, "strokeDepth2d", >object_depth, 1);
+DRW_shgroup_uniform_bool(grp, "strokeOrder3d", >is_stroke_order_3d, 1);
+DRW_shgroup_call_procedural_triangles(grp, NULL, 1);
+  }
 }
 
 void GPENCIL_cache_init(void *vedata)
@@ -1290,6 +1302,7 @@ static void GPENCIL_draw_scene_new(void *ved)
   for (GPENCIL_tObject *ob = pd->tobjects.first; ob; ob = ob->next) {
 DRW_stats_group_start("GPencil Object");
 
+GPU_framebuffer_bind(fbl->gpencil_fb);
 GPU_framebuffer_clear_depth(fbl->gpencil_fb, ob->is_drawmode3d ? 1.0f : 
0.0f);
 
 if (ob->vfx.first) {
@@ -1315,6 +1328,12 @@ static void GPENCIL_draw_scene_new(void *ved)
   /* TODO vfx */
 }
 
+pd->object_depth = ob->camera_z - pd->camera_z_offset;
+pd->is_stroke_order_3d = ob->is_drawmode3d;
+
+GPU_framebuffer_bind(dfbl->depth_only_fb);
+DRW_draw_pass(psl->merge_depth_ps);
+
 DRW_stats_group_end();
   }
 
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.h 
b/source/blender/draw/engines/gpencil/gpencil_engine.h
index 8f8eb9289c4..ae074021138 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.h
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.h
@@ -313,6 +313,8 @@ typedef struct GPENCIL_PassList {
 
   /* Composite the main GPencil buffer onto the rendered image. */
   struct DRWPass *composite_ps;
+  /* Composite the object depth to the default depth buffer to occlude 
overlays. */
+  struct DRWPass *merge_depth_ps;
 } GPENCIL_PassList;
 
 typedef struct GPENCIL_FramebufferList {
@@ -422,8 +424,11 @@ typedef struct GPENCIL_PrivateData {
   GPUTexture *scene_depth_tx;
   /* Current frame */
   int cfra;
+  /* Used by the depth merge step. 

[Bf-blender-cvs] [fc239df81cb] greasepencil-refactor: GPU: Framebuffer: Fix missing color mask

2019-12-13 Thread Clément Foucault
Commit: fc239df81cbb5cff6ca52f1f0c4bffabcc96141f
Author: Clément Foucault
Date:   Sat Dec 14 02:36:59 2019 +0100
Branches: greasepencil-refactor
https://developer.blender.org/rBfc239df81cbb5cff6ca52f1f0c4bffabcc96141f

GPU: Framebuffer: Fix missing color mask

===

M   source/blender/gpu/intern/gpu_framebuffer.c

===

diff --git a/source/blender/gpu/intern/gpu_framebuffer.c 
b/source/blender/gpu/intern/gpu_framebuffer.c
index 9da842f6409..b04cce095b7 100644
--- a/source/blender/gpu/intern/gpu_framebuffer.c
+++ b/source/blender/gpu/intern/gpu_framebuffer.c
@@ -617,6 +617,8 @@ void GPU_framebuffer_multi_clear(GPUFrameBuffer *fb, const 
float (*clear_cols)[4
 {
   CHECK_FRAMEBUFFER_IS_BOUND(fb);
 
+  glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
+
   GPUAttachmentType type = GPU_FB_COLOR_ATTACHMENT0;
   for (int i = 0; type < GPU_FB_MAX_ATTACHEMENT; i++, type++) {
 if (fb->attachments[type].tex != NULL) {

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [9b871683b1d] master: Fix T72412: Weld Modifier: Merged edges not displayed in wireframe

2019-12-13 Thread mano-wii
Commit: 9b871683b1d1bfbcb2e9f2bc57a3065206240191
Author: mano-wii
Date:   Fri Dec 13 21:47:42 2019 -0300
Branches: master
https://developer.blender.org/rB9b871683b1d1bfbcb2e9f2bc57a3065206240191

Fix T72412: Weld Modifier: Merged edges not displayed in wireframe

===

M   source/blender/modifiers/intern/MOD_weld.c

===

diff --git a/source/blender/modifiers/intern/MOD_weld.c 
b/source/blender/modifiers/intern/MOD_weld.c
index 7c2754a5fce..b393cedbd37 100644
--- a/source/blender/modifiers/intern/MOD_weld.c
+++ b/source/blender/modifiers/intern/MOD_weld.c
@@ -1477,7 +1477,7 @@ static void customdata_weld(
 #endif
   uint crease = 0;
   uint bweight = 0;
-  char flag = 0;
+  short flag = 0;
 
   /* interpolates a layer at a time */
   dest_i = 0;
@@ -1569,7 +1569,7 @@ static void customdata_weld(
   mv_no[2] = (short)no[2];
 #endif
 
-  mv->flag = flag;
+  mv->flag = (char)flag;
   mv->bweight = (char)bweight;
 }
 else if (type == CD_MEDGE) {
@@ -1581,6 +1581,7 @@ static void customdata_weld(
 
   me->crease = (char)crease;
   me->bweight = (char)bweight;
+  me->flag = flag;
 }
   }
 }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [c6ba9413393] master: Fix T72409: Remove references to Unified use_pressure_size and use_pressure_strength

2019-12-13 Thread Pablo Dobarro
Commit: c6ba9413393465a5ca336d053723a63b9ee76e45
Author: Pablo Dobarro
Date:   Fri Dec 13 03:55:15 2019 +0100
Branches: master
https://developer.blender.org/rBc6ba9413393465a5ca336d053723a63b9ee76e45

Fix T72409: Remove references to Unified use_pressure_size and 
use_pressure_strength

This was causing errors to show in the terminal.

Reviewed By: campbellbarton

Maniphest Tasks: T72409

Differential Revision: https://developer.blender.org/D6407

===

M   release/scripts/startup/bl_ui/space_image.py

===

diff --git a/release/scripts/startup/bl_ui/space_image.py 
b/release/scripts/startup/bl_ui/space_image.py
index 5af9fed83f8..da1df5bd660 100644
--- a/release/scripts/startup/bl_ui/space_image.py
+++ b/release/scripts/startup/bl_ui/space_image.py
@@ -605,11 +605,11 @@ class _draw_tool_settings_context_mode:
 
 row = layout.row(align=True)
 UnifiedPaintPanel.prop_unified_size(row, context, brush, 
"size", slider=True)
-UnifiedPaintPanel.prop_unified_size(row, context, brush, 
"use_pressure_size", text="")
+row.prop(brush, "use_pressure_size", text="")
 
 row = layout.row(align=True)
 UnifiedPaintPanel.prop_unified_strength(row, context, 
brush, "strength", slider=True)
-UnifiedPaintPanel.prop_unified_strength(row, context, 
brush, "use_pressure_strength", text="")
+row.prop(brush, "use_pressure_strength", text="")
 
 @staticmethod
 def PAINT(context, layout, tool):

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [ecfb0b12732] greasepencil-refactor: GPencil: Refactor: Fix 3D stroke offset

2019-12-13 Thread Clément Foucault
Commit: ecfb0b12732c229e12db543669a49e0f8c647373
Author: Clément Foucault
Date:   Fri Dec 13 21:25:07 2019 +0100
Branches: greasepencil-refactor
https://developer.blender.org/rBecfb0b12732c229e12db543669a49e0f8c647373

GPencil: Refactor: Fix 3D stroke offset

The offset was way too big.

===

M   source/blender/draw/engines/gpencil/shaders/gpencil_vert.glsl

===

diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_vert.glsl 
b/source/blender/draw/engines/gpencil/shaders/gpencil_vert.glsl
index 8d3a34d545d..d07a0df6c06 100644
--- a/source/blender/draw/engines/gpencil/shaders/gpencil_vert.glsl
+++ b/source/blender/draw/engines/gpencil/shaders/gpencil_vert.glsl
@@ -216,6 +216,8 @@ void stroke_vertex()
   if (strokeOrder3D) {
 /* Use the fragment depth (see fragment shader). */
 depth = -1.0;
+/* We still offset the fills a little to avoid overlaps */
+gl_Position.z -= (stroke_id1 + 1) * 0.02;
   }
   else if (GP_FLAG_TEST(materials[m].flag, GP_STROKE_OVERLAP)) {
 /* Use the index of the point as depth.
@@ -238,7 +240,6 @@ void fill_vertex()
 
   vec3 wpos = transform_point(model_mat, pos1.xyz);
   gl_Position = point_world_to_ndc(wpos);
-  gl_Position.z += 1e-2;
 
   int m = int(ma1.x);
 
@@ -256,6 +257,8 @@ void fill_vertex()
   if (strokeOrder3D) {
 /* Use the fragment depth (see fragment shader). */
 depth = -1.0;
+/* We still offset the fills a little to avoid overlaps */
+gl_Position.z -= stroke_id1 * 0.02;
   }
   else {
 /* Use the index of first point of the stroke as depth. */

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [b9bcc12eb9d] greasepencil-refactor: GPencil: Refactor: Add depth test in the fragment shader

2019-12-13 Thread Clément Foucault
Commit: b9bcc12eb9d6ca646350f80bfdfdd7c2714e96d0
Author: Clément Foucault
Date:   Fri Dec 13 21:24:12 2019 +0100
Branches: greasepencil-refactor
https://developer.blender.org/rBb9bcc12eb9d6ca646350f80bfdfdd7c2714e96d0

GPencil: Refactor: Add depth test in the fragment shader

Now the GPencil object can correctly intersect the scene.

Previously (old implementation) 2D GPencil objects would poke through
in front meshes in certain situations (depending on stroke order). This is
now fixed.

This does not fix the intersection with the overlays.

===

M   source/blender/draw/engines/gpencil/gpencil_engine.c
M   source/blender/draw/engines/gpencil/gpencil_engine.h
M   source/blender/draw/engines/gpencil/shaders/gpencil_frag.glsl

===

diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c 
b/source/blender/draw/engines/gpencil/gpencil_engine.c
index ff2f7e883fe..5b50dfc3a8a 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.c
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.c
@@ -281,6 +281,7 @@ static void GPENCIL_engine_init_new(void *ved)
   GPENCIL_Data *vedata = (GPENCIL_Data *)ved;
   GPENCIL_StorageList *stl = vedata->stl;
   GPENCIL_TextureList *txl = vedata->txl;
+  DefaultTextureList *dtxl = DRW_viewport_texture_list_get();
 
   if (!stl->pd) {
 stl->pd = MEM_callocN(sizeof(GPENCIL_PrivateData), "GPENCIL_PrivateData");
@@ -308,6 +309,7 @@ static void GPENCIL_engine_init_new(void *ved)
   stl->pd->last_material_pool = NULL;
   stl->pd->tobjects.first = NULL;
   stl->pd->tobjects.last = NULL;
+  stl->pd->scene_depth_tx = dtxl->depth;
 
   float viewmatinv[4][4];
   DRW_view_viewmat_get(NULL, viewmatinv, true);
@@ -803,6 +805,7 @@ static void gp_layer_cache_populate(bGPDlayer *gpl,
   DRW_shgroup_uniform_block(iter->grp, "gpMaterialBlock", ubo_mat);
   DRW_shgroup_uniform_texture(iter->grp, "gpFillTexture", iter->tex_fill);
   DRW_shgroup_uniform_texture(iter->grp, "gpStrokeTexture", iter->tex_stroke);
+  DRW_shgroup_uniform_texture(iter->grp, "gpSceneDepthTexture", 
iter->pd->scene_depth_tx);
   DRW_shgroup_uniform_bool_copy(iter->grp, "strokeOrder3D", 
is_stroke_order_3D);
   DRW_shgroup_uniform_vec4_copy(iter->grp, "gpModelMatrix[0]", 
iter->ob->obmat[0]);
   DRW_shgroup_uniform_vec4_copy(iter->grp, "gpModelMatrix[1]", 
iter->ob->obmat[1]);
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.h 
b/source/blender/draw/engines/gpencil/gpencil_engine.h
index d4ee4260f6d..8f8eb9289c4 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.h
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.h
@@ -418,6 +418,8 @@ typedef struct GPENCIL_PrivateData {
   GPUTexture *reveal_tx;
   GPUTexture *reveal_layer_tx;
   GPUTexture *reveal_object_tx;
+  /* Pointer to dtxl->depth */
+  GPUTexture *scene_depth_tx;
   /* Current frame */
   int cfra;
   /* Used for computing object distance to camera. */
diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_frag.glsl 
b/source/blender/draw/engines/gpencil/shaders/gpencil_frag.glsl
index bb84d0fe930..56adb099af1 100644
--- a/source/blender/draw/engines/gpencil/shaders/gpencil_frag.glsl
+++ b/source/blender/draw/engines/gpencil/shaders/gpencil_frag.glsl
@@ -1,6 +1,7 @@
 
 uniform sampler2D gpFillTexture;
 uniform sampler2D gpStrokeTexture;
+uniform sampler2D gpSceneDepthTexture;
 
 in vec4 finalColorMul;
 in vec4 finalColorAdd;
@@ -53,6 +54,12 @@ void main()
 discard;
   }
 
+  /* Manual depth test */
+  float scene_depth = texelFetch(gpSceneDepthTexture, ivec2(gl_FragCoord.xy), 
0).r;
+  if (gl_FragCoord.z > scene_depth) {
+discard;
+  }
+
   /* We override the fragment depth using the fragment shader to ensure a 
constant value.
* This has a cost as the depth test cannot happen early.
* We could do this in the vertex shader but then perspective interpolation 
of uvs and

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [29b4dc1d162] greasepencil-refactor: GPencil: Refactor: Fix overlay blending math

2019-12-13 Thread Clément Foucault
Commit: 29b4dc1d162868e384fdc0d7c383f2c9c44912a9
Author: Clément Foucault
Date:   Fri Dec 13 20:18:29 2019 +0100
Branches: greasepencil-refactor
https://developer.blender.org/rB29b4dc1d162868e384fdc0d7c383f2c9c44912a9

GPencil: Refactor: Fix overlay blending math

A sign error in optimized code.

===

M   
source/blender/draw/engines/gpencil/shaders/gpencil_layer_blend_frag.glsl

===

diff --git 
a/source/blender/draw/engines/gpencil/shaders/gpencil_layer_blend_frag.glsl 
b/source/blender/draw/engines/gpencil/shaders/gpencil_layer_blend_frag.glsl
index e0f1ac30827..88d700ac3f4 100644
--- a/source/blender/draw/engines/gpencil/shaders/gpencil_layer_blend_frag.glsl
+++ b/source/blender/draw/engines/gpencil/shaders/gpencil_layer_blend_frag.glsl
@@ -64,7 +64,7 @@ void main()
**/
   color = mix(vec4(0.5), color, color.a * blendOpacity);
   vec4 s = step(0.5, color);
-  fragRevealage = fragColor = 2.0 * s + 2.0 * color * (s * 2.0 - 1.0);
+  fragRevealage = fragColor = 2.0 * s + 2.0 * color * (1.0 - s * 2.0);
   break;
 case MODE_OVERLAY_SECOND_PASS:
   /* Reminder: Blending func is additive blend (dst.rgba + src.rgba).*/

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [436696b087c] greasepencil-refactor: Cleanup: GPencil: Remove duplicated code

2019-12-13 Thread Clément Foucault
Commit: 436696b087c07d0efdfffd9eed7a56fc55541b4b
Author: Clément Foucault
Date:   Fri Dec 13 19:38:41 2019 +0100
Branches: greasepencil-refactor
https://developer.blender.org/rB436696b087c07d0efdfffd9eed7a56fc55541b4b

Cleanup: GPencil: Remove duplicated code

===

M   source/blender/draw/engines/gpencil/shaders/gpencil_vert.glsl

===

diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_vert.glsl 
b/source/blender/draw/engines/gpencil/shaders/gpencil_vert.glsl
index ddb73d56981..8d3a34d545d 100644
--- a/source/blender/draw/engines/gpencil/shaders/gpencil_vert.glsl
+++ b/source/blender/draw/engines/gpencil/shaders/gpencil_vert.glsl
@@ -171,23 +171,18 @@ void stroke_vertex()
 vec2 y_axis;
 int alignement = materials[m].flag & GP_STROKE_ALIGNMENT;
 if (alignement == GP_STROKE_ALIGNMENT_STROKE) {
-  /* TODO case where ndc1 & ndc2 is behind camera */
-  vec2 ss1 = project_to_screenspace(ndc1);
-  vec2 ss2 = project_to_screenspace(ndc2);
-  /* Screenspace Lines tangents. */
-  x_axis = safe_normalize(ss2 - ss1);
-  y_axis = rotate_90deg(x_axis);
+  x_axis = line;
 }
 else if (alignement == GP_STROKE_ALIGNMENT_OBJECT) {
   /* TODO */
   x_axis = vec2(1.0, 0.0);
-  y_axis = vec2(0.0, 1.0);
 }
 else /* GP_STROKE_ALIGNMENT_FIXED*/ {
   x_axis = vec2(1.0, 0.0);
-  y_axis = vec2(0.0, 1.0);
 }
 
+y_axis = rotate_90deg(x_axis);
+
 gl_Position.xy += (x * x_axis + y * y_axis) * sizeViewportInv.xy * 
thickness;
   }
   else {

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [db21312bfb3] greasepencil-refactor: GPU: Framebuffer: Add GPU_framebuffer_multi_clear

2019-12-13 Thread Clément Foucault
Commit: db21312bfb310db2c935d2e45897ea167ff12d77
Author: Clément Foucault
Date:   Fri Dec 13 19:28:37 2019 +0100
Branches: greasepencil-refactor
https://developer.blender.org/rBdb21312bfb310db2c935d2e45897ea167ff12d77

GPU: Framebuffer: Add GPU_framebuffer_multi_clear

This is to clear individual targets using a different color.

===

M   source/blender/gpu/GPU_framebuffer.h
M   source/blender/gpu/intern/gpu_framebuffer.c

===

diff --git a/source/blender/gpu/GPU_framebuffer.h 
b/source/blender/gpu/GPU_framebuffer.h
index 7d0f8b0bcbf..213cbe30794 100644
--- a/source/blender/gpu/GPU_framebuffer.h
+++ b/source/blender/gpu/GPU_framebuffer.h
@@ -173,6 +173,8 @@ void GPU_framebuffer_clear(GPUFrameBuffer *fb,
 #define GPU_framebuffer_clear_color_depth_stencil(fb, col, depth, stencil) \
   GPU_framebuffer_clear(fb, GPU_COLOR_BIT | GPU_DEPTH_BIT | GPU_STENCIL_BIT, 
col, depth, stencil)
 
+void GPU_framebuffer_multi_clear(GPUFrameBuffer *fb, const float 
(*clear_cols)[4]);
+
 void GPU_framebuffer_read_depth(GPUFrameBuffer *fb, int x, int y, int w, int 
h, float *data);
 void GPU_framebuffer_read_color(
 GPUFrameBuffer *fb, int x, int y, int w, int h, int channels, int slot, 
float *data);
diff --git a/source/blender/gpu/intern/gpu_framebuffer.c 
b/source/blender/gpu/intern/gpu_framebuffer.c
index a531c22365c..9da842f6409 100644
--- a/source/blender/gpu/intern/gpu_framebuffer.c
+++ b/source/blender/gpu/intern/gpu_framebuffer.c
@@ -612,6 +612,19 @@ void GPU_framebuffer_clear(GPUFrameBuffer *fb,
   glClear(mask);
 }
 
+/* Clear all textures bound to this framebuffer with a different color. */
+void GPU_framebuffer_multi_clear(GPUFrameBuffer *fb, const float 
(*clear_cols)[4])
+{
+  CHECK_FRAMEBUFFER_IS_BOUND(fb);
+
+  GPUAttachmentType type = GPU_FB_COLOR_ATTACHMENT0;
+  for (int i = 0; type < GPU_FB_MAX_ATTACHEMENT; i++, type++) {
+if (fb->attachments[type].tex != NULL) {
+  glClearBufferfv(GL_COLOR, i, clear_cols[i]);
+}
+  }
+}
+
 void GPU_framebuffer_read_depth(GPUFrameBuffer *fb, int x, int y, int w, int 
h, float *data)
 {
   CHECK_FRAMEBUFFER_IS_BOUND(fb);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [347a097a627] greasepencil-refactor: GPU: Texture: Fix mistake in format classification

2019-12-13 Thread Clément Foucault
Commit: 347a097a627d7233fcc9fe47ee30f46e71f465ab
Author: Clément Foucault
Date:   Fri Dec 13 19:40:22 2019 +0100
Branches: greasepencil-refactor
https://developer.blender.org/rB347a097a627d7233fcc9fe47ee30f46e71f465ab

GPU: Texture: Fix mistake in format classification

sRGBA format is well defined for use with framebuffers (based on 3.3 spec).

===

M   source/blender/gpu/GPU_texture.h

===

diff --git a/source/blender/gpu/GPU_texture.h b/source/blender/gpu/GPU_texture.h
index a8e8ca72023..0d9c6785206 100644
--- a/source/blender/gpu/GPU_texture.h
+++ b/source/blender/gpu/GPU_texture.h
@@ -94,6 +94,7 @@ typedef enum eGPUTextureFormat {
 #if 0
   GPU_RGB10_A2,
   GPU_RGB10_A2UI,
+  GPU_SRGB8_A8,
 #endif
   GPU_R11F_G11F_B10F,
   GPU_DEPTH32F_STENCIL8,
@@ -123,7 +124,6 @@ typedef enum eGPUTextureFormat {
 
 /* Special formats texture only */
 #if 0
-  GPU_SRGB8_A8,
   GPU_SRGB8,
   GPU_RGB9_E5,
   GPU_COMPRESSED_RG_RGTC2,

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [170680b5448] greasepencil-refactor: GPencil: Refactor: Add support for layer blending

2019-12-13 Thread Clément Foucault
Commit: 170680b5448aabf2aa67258258ef88c998a8046d
Author: Clément Foucault
Date:   Fri Dec 13 19:38:08 2019 +0100
Branches: greasepencil-refactor
https://developer.blender.org/rB170680b5448aabf2aa67258258ef88c998a8046d

GPencil: Refactor: Add support for layer blending

This break the compatibility of old blend files as the old implementation
was done incorrectly.

With new implementation, the layer blending can affect multiple object
and in certain case affect even the rendered background. Old implementation
was only affecting the layers beneath, not other objects.

This implementation is also ready to support vfx on top.

Some blend modes (divide and subtract) have some limitations. They cannot
be propagated to other objects. This is because we would need to use
signed float buffers everywhere (for background render) so that fixed
function blending does not clamp the blending values.

===

M   source/blender/draw/CMakeLists.txt
M   source/blender/draw/engines/gpencil/gpencil_cache_utils.c
M   source/blender/draw/engines/gpencil/gpencil_engine.c
M   source/blender/draw/engines/gpencil/gpencil_engine.h
M   source/blender/draw/engines/gpencil/gpencil_shader.c
M   source/blender/draw/engines/gpencil/shaders/gpencil_composite_frag.glsl
M   source/blender/draw/engines/gpencil/shaders/gpencil_frag.glsl
A   
source/blender/draw/engines/gpencil/shaders/gpencil_layer_blend_frag.glsl

===

diff --git a/source/blender/draw/CMakeLists.txt 
b/source/blender/draw/CMakeLists.txt
index 896149443d4..1783d26b9e2 100644
--- a/source/blender/draw/CMakeLists.txt
+++ b/source/blender/draw/CMakeLists.txt
@@ -279,6 +279,7 @@ data_to_c_simple(engines/gpencil/shaders/gpencil_frag.glsl 
SRC)
 data_to_c_simple(engines/gpencil/shaders/gpencil_vert.glsl SRC)
 data_to_c_simple(engines/gpencil/shaders/gpencil_common_lib.glsl SRC)
 data_to_c_simple(engines/gpencil/shaders/gpencil_composite_frag.glsl SRC)
+data_to_c_simple(engines/gpencil/shaders/gpencil_layer_blend_frag.glsl SRC)
 
 data_to_c_simple(engines/gpencil/shaders/gpencil_fill_vert.glsl SRC)
 data_to_c_simple(engines/gpencil/shaders/gpencil_fill_frag.glsl SRC)
diff --git a/source/blender/draw/engines/gpencil/gpencil_cache_utils.c 
b/source/blender/draw/engines/gpencil/gpencil_cache_utils.c
index c9c8ec77720..47c87fb2559 100644
--- a/source/blender/draw/engines/gpencil/gpencil_cache_utils.c
+++ b/source/blender/draw/engines/gpencil/gpencil_cache_utils.c
@@ -59,22 +59,77 @@ GPENCIL_tObject 
*gpencil_object_cache_add_new(GPENCIL_PrivateData *pd, Object *o
 }
 
 /* TODO remove the _new suffix. */
-GPENCIL_tLayer *gpencil_layer_cache_add_new(GPENCIL_PrivateData *pd,
-Object *ob,
-bGPDlayer *UNUSED(layer))
+GPENCIL_tLayer *gpencil_layer_cache_add_new(GPENCIL_PrivateData *pd, Object 
*ob, bGPDlayer *gpl)
 {
   bGPdata *gpd = (bGPdata *)ob->data;
   GPENCIL_tLayer *tgp_layer = BLI_memblock_alloc(pd->gp_layer_pool);
 
-  DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_ALPHA_PREMUL;
-  /* TODO better 3D mode. */
-  if (GPENCIL_3D_DRAWMODE(ob, gpd)) {
-state |= DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL;
+  {
+DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_ALPHA_PREMUL;
+if (GPENCIL_3D_DRAWMODE(ob, gpd)) {
+  /* TODO better 3D mode. */
+  state |= DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL;
+}
+else {
+  /* We render all strokes with uniform depth (increasing with stroke id). 
*/
+  state |= DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_GREATER;
+}
+tgp_layer->geom_ps = DRW_pass_create("GPencil Layer", state);
+  }
+
+  if ((gpl->blend_mode != eGplBlendMode_Regular) || (gpl->opacity < 1.0f)) {
+DRWState state = DRW_STATE_WRITE_COLOR;
+switch (gpl->blend_mode) {
+  case eGplBlendMode_Regular:
+state |= DRW_STATE_BLEND_ALPHA_PREMUL;
+break;
+  case eGplBlendMode_Add:
+state |= DRW_STATE_BLEND_ADD;
+break;
+  case eGplBlendMode_Subtract:
+/* Caveat. This effect only propagates if target buffer has
+ * a signed floating point color buffer.
+ * i.e: This will not be conserved after this blending step.
+ * TODO(fclem) To make things consistent, we might create a dummy vfx
+ * for objects that use this blend type to always avoid the subtract
+ * affecting other objects. */
+state |= DRW_STATE_BLEND_SUB;
+break;
+  case eGplBlendMode_Multiply:
+  case eGplBlendMode_Divide:
+/* Same Caveat as Subtract. This is conserved until there is a blend 
with a LDR buffer. */
+  case eGplBlendMode_Overlay:
+state |= DRW_STATE_BLEND_MUL;
+break;
+}
+
+tgp_layer->blend_ps = DRW_pass_create("GPencil Blend Layer", state);
+
+GPUShader 

[Bf-blender-cvs] [18c4fcb9a34] greasepencil-refactor: DRW: Add subtract blend logic

2019-12-13 Thread Clément Foucault
Commit: 18c4fcb9a34b05da4854b34509b3641b793eda6b
Author: Clément Foucault
Date:   Fri Dec 13 19:31:02 2019 +0100
Branches: greasepencil-refactor
https://developer.blender.org/rB18c4fcb9a34b05da4854b34509b3641b793eda6b

DRW: Add subtract blend logic

This is to support subtract blending with Multiple Render Targets

===

M   source/blender/draw/intern/DRW_render.h
M   source/blender/draw/intern/draw_manager_exec.c

===

diff --git a/source/blender/draw/intern/DRW_render.h 
b/source/blender/draw/intern/DRW_render.h
index f00bf61cbb7..d84a8a66810 100644
--- a/source/blender/draw/intern/DRW_render.h
+++ b/source/blender/draw/intern/DRW_render.h
@@ -305,8 +305,9 @@ typedef enum {
   DRW_STATE_BLEND_ALPHA_UNDER_PREMUL = (1 << 20),
   DRW_STATE_BLEND_OIT = (1 << 21),
   DRW_STATE_BLEND_MUL = (1 << 22),
+  DRW_STATE_BLEND_SUB = (1 << 23),
   /** Use dual source blending. WARNING: Only one color buffer allowed. */
-  DRW_STATE_BLEND_CUSTOM = (1 << 23),
+  DRW_STATE_BLEND_CUSTOM = (1 << 24),
 
   DRW_STATE_IN_FRONT_SELECT = (1 << 25),
   DRW_STATE_LOGIC_INVERT = (1 << 26),
diff --git a/source/blender/draw/intern/draw_manager_exec.c 
b/source/blender/draw/intern/draw_manager_exec.c
index 977bec92cba..bd378d78780 100644
--- a/source/blender/draw/intern/draw_manager_exec.c
+++ b/source/blender/draw/intern/draw_manager_exec.c
@@ -233,11 +233,11 @@ void drw_state_set(DRWState state)
   /* Blending (all buffer) */
   {
 int test;
-if (CHANGED_ANY_STORE_VAR(DRW_STATE_BLEND_ALPHA | 
DRW_STATE_BLEND_ALPHA_PREMUL |
-  DRW_STATE_BLEND_ADD | DRW_STATE_BLEND_MUL |
-  DRW_STATE_BLEND_ADD_FULL | 
DRW_STATE_BLEND_OIT |
-  DRW_STATE_BLEND_ALPHA_UNDER_PREMUL | 
DRW_STATE_BLEND_CUSTOM,
-  test)) {
+if (CHANGED_ANY_STORE_VAR(
+DRW_STATE_BLEND_ALPHA | DRW_STATE_BLEND_ALPHA_PREMUL | 
DRW_STATE_BLEND_ADD |
+DRW_STATE_BLEND_MUL | DRW_STATE_BLEND_ADD_FULL | 
DRW_STATE_BLEND_OIT |
+DRW_STATE_BLEND_ALPHA_UNDER_PREMUL | DRW_STATE_BLEND_CUSTOM | 
DRW_STATE_BLEND_SUB,
+test)) {
   if (test) {
 glEnable(GL_BLEND);
 
@@ -273,6 +273,9 @@ void drw_state_set(DRWState state)
   /* Let alpha accumulate. */
   glBlendFunc(GL_ONE, GL_ONE);
 }
+else if ((state & DRW_STATE_BLEND_SUB) != 0) {
+  glBlendFunc(GL_ONE, GL_ONE);
+}
 else if ((state & DRW_STATE_BLEND_CUSTOM) != 0) {
   /* Custom blend parameters using dual source blending.
* Can only be used with one Draw Buffer. */
@@ -281,6 +284,13 @@ void drw_state_set(DRWState state)
 else {
   BLI_assert(0);
 }
+
+if ((state & DRW_STATE_BLEND_SUB) != 0) {
+  glBlendEquation(GL_FUNC_REVERSE_SUBTRACT);
+}
+else {
+  glBlendEquation(GL_FUNC_ADD);
+}
   }
   else {
 glDisable(GL_BLEND);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [4ba94091be0] greasepencil-refactor: GPencil: Refactor: Add offscreen compositing foundation

2019-12-13 Thread Clément Foucault
Commit: 4ba94091be0baf992ab73e2514c8651ca676030c
Author: Clément Foucault
Date:   Fri Dec 13 14:31:55 2019 +0100
Branches: greasepencil-refactor
https://developer.blender.org/rB4ba94091be0baf992ab73e2514c8651ca676030c

GPencil: Refactor: Add offscreen compositing foundation

This put all Grease pencil drawing into a separate buffer that is then
composited on top of the rendered image.

This framebuffer has 2 RGB color target (one color and one alpha) to be
able to record any color blend types.

Moreover these buffers are floating point (R11_G11_B10) which will allow
the use of linear colors.

===

M   source/blender/draw/CMakeLists.txt
M   source/blender/draw/engines/gpencil/gpencil_cache_utils.c
M   source/blender/draw/engines/gpencil/gpencil_engine.c
M   source/blender/draw/engines/gpencil/gpencil_engine.h
M   source/blender/draw/engines/gpencil/gpencil_shader.c
A   source/blender/draw/engines/gpencil/shaders/gpencil_composite_frag.glsl
M   source/blender/draw/engines/gpencil/shaders/gpencil_frag.glsl

===

diff --git a/source/blender/draw/CMakeLists.txt 
b/source/blender/draw/CMakeLists.txt
index 9d5231e5e00..896149443d4 100644
--- a/source/blender/draw/CMakeLists.txt
+++ b/source/blender/draw/CMakeLists.txt
@@ -278,6 +278,7 @@ data_to_c_simple(intern/shaders/common_fullscreen_vert.glsl 
SRC)
 data_to_c_simple(engines/gpencil/shaders/gpencil_frag.glsl SRC)
 data_to_c_simple(engines/gpencil/shaders/gpencil_vert.glsl SRC)
 data_to_c_simple(engines/gpencil/shaders/gpencil_common_lib.glsl SRC)
+data_to_c_simple(engines/gpencil/shaders/gpencil_composite_frag.glsl SRC)
 
 data_to_c_simple(engines/gpencil/shaders/gpencil_fill_vert.glsl SRC)
 data_to_c_simple(engines/gpencil/shaders/gpencil_fill_frag.glsl SRC)
diff --git a/source/blender/draw/engines/gpencil/gpencil_cache_utils.c 
b/source/blender/draw/engines/gpencil/gpencil_cache_utils.c
index db84f4e044e..c9c8ec77720 100644
--- a/source/blender/draw/engines/gpencil/gpencil_cache_utils.c
+++ b/source/blender/draw/engines/gpencil/gpencil_cache_utils.c
@@ -45,11 +45,13 @@
 /* TODO remove the _new suffix. */
 GPENCIL_tObject *gpencil_object_cache_add_new(GPENCIL_PrivateData *pd, Object 
*ob)
 {
+  bGPdata *gpd = (bGPdata *)ob->data;
   GPENCIL_tObject *tgp_ob = BLI_memblock_alloc(pd->gp_object_pool);
 
   tgp_ob->layers.first = tgp_ob->layers.last = NULL;
   tgp_ob->vfx.first = tgp_ob->vfx.last = NULL;
   tgp_ob->camera_z = dot_v3v3(pd->camera_z_axis, ob->obmat[3]);
+  tgp_ob->is_drawmode3d = (gpd->draw_mode == GP_DRAWMODE_3D);
 
   BLI_LINKS_APPEND(>tobjects, tgp_ob);
 
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c 
b/source/blender/draw/engines/gpencil/gpencil_engine.c
index 05de8a888f7..d3ffa0bb1f4 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.c
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.c
@@ -400,10 +400,24 @@ static void gpencil_check_screen_switches(const 
DRWContextState *draw_ctx,
 static void GPENCIL_cache_init_new(void *ved)
 {
   GPENCIL_Data *vedata = (GPENCIL_Data *)ved;
+  GPENCIL_PassList *psl = vedata->psl;
   GPENCIL_PrivateData *pd = vedata->stl->pd;
+  DRWShadingGroup *grp;
 
   const DRWContextState *draw_ctx = DRW_context_state_get();
   pd->cfra = (int)DEG_get_ctime(draw_ctx->depsgraph);
+
+  {
+DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_CUSTOM;
+
+DRW_PASS_CREATE(psl->composite_ps, state);
+
+GPUShader *sh = GPENCIL_shader_composite_get(_data);
+grp = DRW_shgroup_create(sh, psl->composite_ps);
+DRW_shgroup_uniform_texture_ref(grp, "colorBuf", >color);
+DRW_shgroup_uniform_texture_ref(grp, "alphaBuf", >alpha);
+DRW_shgroup_call_procedural_triangles(grp, NULL, 1);
+  }
 }
 
 void GPENCIL_cache_init(void *vedata)
@@ -799,9 +813,6 @@ static void gp_layer_cache_populate(bGPDlayer *gpl,
   DRW_shgroup_uniform_float_copy(iter->grp, "thicknessWorldScale", 
thickness_scale);
   DRW_shgroup_uniform_float_copy(iter->grp, "vertexColorOpacity", 
gpl->vertex_paint_opacity);
   DRW_shgroup_uniform_vec4_copy(iter->grp, "layerTint", gpl->tintcolor);
-  /* Should do this clear for the whole object. */
-  float clear_depth = is_stroke_order_3D ? 1.0f : 0.0f;
-  DRW_shgroup_clear_framebuffer(iter->grp, GPU_DEPTH_BIT, 0, 0, 0, 0, 
clear_depth, 0);
 }
 
 static void gp_stroke_cache_populate(bGPDlayer *UNUSED(gpl),
@@ -999,6 +1010,7 @@ static void GPENCIL_cache_finish_new(void *ved)
 {
   GPENCIL_Data *vedata = (GPENCIL_Data *)ved;
   GPENCIL_PrivateData *pd = vedata->stl->pd;
+  GPENCIL_FramebufferList *fbl = vedata->fbl;
 
   /* Upload UBO data. */
   BLI_memblock_iter iter;
@@ -1011,6 +1023,24 @@ static void GPENCIL_cache_finish_new(void *ved)
 
   /* Sort object by distance to the camera. */
   pd->tobjects.first = gpencil_tobject_sort_fn_r(pd->tobjects.first, 
gpencil_tobject_dist_sort);
+
+  if 

[Bf-blender-cvs] [764857eb370] functions: fix: find IDs used by output sockets as well

2019-12-13 Thread Jacques Lucke
Commit: 764857eb370c4910902c80d157ada6c4e00ebaa4
Author: Jacques Lucke
Date:   Fri Dec 13 19:42:49 2019 +0100
Branches: functions
https://developer.blender.org/rB764857eb370c4910902c80d157ada6c4e00ebaa4

fix: find IDs used by output sockets as well

===

M   source/blender/functions/FN_multi_function_dependencies.h
M   source/blender/modifiers/intern/MOD_functiondeform_cxx.cc
M   source/blender/modifiers/intern/MOD_functionpoints_cxx.cc
M   source/blender/simulations/bparticles/node_frontend.cpp

===

diff --git a/source/blender/functions/FN_multi_function_dependencies.h 
b/source/blender/functions/FN_multi_function_dependencies.h
index af4a7b308b3..2086e33bdc5 100644
--- a/source/blender/functions/FN_multi_function_dependencies.h
+++ b/source/blender/functions/FN_multi_function_dependencies.h
@@ -15,10 +15,10 @@ using BKE::XGroupInput;
 using BKE::XInputSocket;
 using BLI::Set;
 
-inline Set get_objects_used_by_inputs(const InlinedNodeTree 
_tree)
+inline Set get_objects_used_by_sockets(const InlinedNodeTree 
_tree)
 {
   Set objects;
-  for (const XInputSocket *xsocket : inlined_tree.all_input_sockets()) {
+  for (const XSocket *xsocket : inlined_tree.all_sockets()) {
 if (xsocket->idname() == "fn_ObjectSocket") {
   Object *object = (Object *)RNA_pointer_get(xsocket->rna(), "value").data;
   if (object != nullptr) {
@@ -37,10 +37,10 @@ inline Set get_objects_used_by_inputs(const 
InlinedNodeTree _t
   return objects;
 }
 
-inline Set get_images_used_by_inputs(const InlinedNodeTree 
_tree)
+inline Set get_images_used_by_sockets(const InlinedNodeTree 
_tree)
 {
   Set images;
-  for (const XInputSocket *xsocket : inlined_tree.all_input_sockets()) {
+  for (const XSocket *xsocket : inlined_tree.all_sockets()) {
 if (xsocket->idname() == "fn_ImageSocket") {
   Image *image = (Image *)RNA_pointer_get(xsocket->rna(), "value").data;
   if (image != nullptr) {
@@ -59,13 +59,13 @@ inline Set get_images_used_by_inputs(const 
InlinedNodeTree _tre
   return images;
 }
 
-inline void add_ids_used_by_inputs(IDHandleLookup _handle_lookup,
-   const InlinedNodeTree _tree)
+inline void add_ids_used_by_nodes(IDHandleLookup _handle_lookup,
+  const InlinedNodeTree _tree)
 {
-  for (Object *object : get_objects_used_by_inputs(inlined_tree)) {
+  for (Object *object : get_objects_used_by_sockets(inlined_tree)) {
 id_handle_lookup.add(object->id);
   }
-  for (Image *image : get_images_used_by_inputs(inlined_tree)) {
+  for (Image *image : get_images_used_by_sockets(inlined_tree)) {
 id_handle_lookup.add(image->id);
   }
 }
diff --git a/source/blender/modifiers/intern/MOD_functiondeform_cxx.cc 
b/source/blender/modifiers/intern/MOD_functiondeform_cxx.cc
index 8c48ecff1cb..77cc00d17af 100644
--- a/source/blender/modifiers/intern/MOD_functiondeform_cxx.cc
+++ b/source/blender/modifiers/intern/MOD_functiondeform_cxx.cc
@@ -67,7 +67,7 @@ void MOD_functiondeform_do(FunctionDeformModifierData *fdmd,
   vertex_positions_context.positions = ArrayRef((float3 *)vertexCos, 
numVerts);
 
   BKE::IDHandleLookup id_handle_lookup;
-  FN::add_ids_used_by_inputs(id_handle_lookup, inlined_tree);
+  FN::add_ids_used_by_nodes(id_handle_lookup, inlined_tree);
 
   MFContextBuilder context_builder;
   context_builder.add_global_context(id_handle_lookup);
diff --git a/source/blender/modifiers/intern/MOD_functionpoints_cxx.cc 
b/source/blender/modifiers/intern/MOD_functionpoints_cxx.cc
index c6f0a8e2630..d0d59628b8a 100644
--- a/source/blender/modifiers/intern/MOD_functionpoints_cxx.cc
+++ b/source/blender/modifiers/intern/MOD_functionpoints_cxx.cc
@@ -58,7 +58,7 @@ Mesh *MOD_functionpoints_do(FunctionPointsModifierData *fpmd,
   time_context.time = DEG_get_ctime(ctx->depsgraph);
 
   BKE::IDHandleLookup id_handle_lookup;
-  FN::add_ids_used_by_inputs(id_handle_lookup, inlined_tree);
+  FN::add_ids_used_by_nodes(id_handle_lookup, inlined_tree);
 
   FN::MFContextBuilder context_builder;
   context_builder.add_global_context(id_handle_lookup);
diff --git a/source/blender/simulations/bparticles/node_frontend.cpp 
b/source/blender/simulations/bparticles/node_frontend.cpp
index 047e1b48ebf..3d6593de83f 100644
--- a/source/blender/simulations/bparticles/node_frontend.cpp
+++ b/source/blender/simulations/bparticles/node_frontend.cpp
@@ -78,7 +78,7 @@ class InlinedTreeData {
   InlinedTreeData(InlinedTreeMFNetwork _tree_data)
   : m_inlined_tree_data_graph(inlined_tree_data)
   {
-FN::add_ids_used_by_inputs(m_id_handle_lookup, 
inlined_tree_data.inlined_tree());
+FN::add_ids_used_by_nodes(m_id_handle_lookup, 
inlined_tree_data.inlined_tree());
   }
 
   const InlinedNodeTree _tree()

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org

[Bf-blender-cvs] [dc0d0d39360] functions: Merge branch 'master' into functions

2019-12-13 Thread Jacques Lucke
Commit: dc0d0d39360eff98037b87af9edef7a7010d634c
Author: Jacques Lucke
Date:   Fri Dec 13 19:40:19 2019 +0100
Branches: functions
https://developer.blender.org/rBdc0d0d39360eff98037b87af9edef7a7010d634c

Merge branch 'master' into functions

===



===



___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [c4203ef17d7] master: USD: disabled unit test that fails on the buildbot

2019-12-13 Thread Sybren A. Stüvel
Commit: c4203ef17d773898b76393e52795c01e8cb2ed6f
Author: Sybren A. Stüvel
Date:   Fri Dec 13 18:57:48 2019 +0100
Branches: master
https://developer.blender.org/rBc4203ef17d773898b76393e52795c01e8cb2ed6f

USD: disabled unit test that fails on the buildbot

I can't fix this quickly right now, so I'd rather drop the entire test
for now.

===

M   tests/gtests/usd/CMakeLists.txt

===

diff --git a/tests/gtests/usd/CMakeLists.txt b/tests/gtests/usd/CMakeLists.txt
index 8dbfb93f0f1..21bd2aba07f 100644
--- a/tests/gtests/usd/CMakeLists.txt
+++ b/tests/gtests/usd/CMakeLists.txt
@@ -64,11 +64,12 @@ set(SRC
   hierarchy_context_order_test.cc
 )
 
-if(NOT APPLE)
-  # TODO(Sybren): This unit test has only been tested on Linux, and should 
possibly be
-  # restructured to support other platforms as well.
-  list(APPEND SRC usd_stage_creation_test.cc)
-endif()
+# TODO(Sybren): re-enable this unit test.
+# if(NOT APPLE)
+#   # TODO(Sybren): This unit test has only been tested on Linux, and should 
possibly be
+#   # restructured to support other platforms as well.
+#   list(APPEND SRC usd_stage_creation_test.cc)
+# endif()
 
 
 if(WITH_BUILDINFO)
@@ -91,8 +92,10 @@ BLENDER_SRC_GTEST_EX(
   EXTRA_LIBS "${LIB}"
   COMMAND_ARGS
 --test-assets-dir "${CMAKE_SOURCE_DIR}/../lib/tests"
---test-usd-datafiles-dir "${_usd_DATAFILES_DIR}"
 )
+# TODO(Sybren): add the below CLI argument to the test when the 
usd_stage_creation_test.cc
+# test is reenabled.
+# --test-usd-datafiles-dir "${_usd_DATAFILES_DIR}"
 unset(_usd_DATAFILES_DIR)
 
 setup_liblinks(usd_test)

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [e6c40bc9e1f] master: USD: Simplified unit test and made it work on Windows as well

2019-12-13 Thread Sybren A. Stüvel
Commit: e6c40bc9e1f11e306977e5a5090501b8c922fb98
Author: Sybren A. Stüvel
Date:   Fri Dec 13 18:56:55 2019 +0100
Branches: master
https://developer.blender.org/rBe6c40bc9e1f11e306977e5a5090501b8c922fb98

USD: Simplified unit test and made it work on Windows as well

===

M   tests/gtests/usd/CMakeLists.txt
M   tests/gtests/usd/usd_stage_creation_test.cc

===

diff --git a/tests/gtests/usd/CMakeLists.txt b/tests/gtests/usd/CMakeLists.txt
index e2768509ec4..8dbfb93f0f1 100644
--- a/tests/gtests/usd/CMakeLists.txt
+++ b/tests/gtests/usd/CMakeLists.txt
@@ -64,7 +64,7 @@ set(SRC
   hierarchy_context_order_test.cc
 )
 
-if(UNIX AND NOT APPLE)
+if(NOT APPLE)
   # TODO(Sybren): This unit test has only been tested on Linux, and should 
possibly be
   # restructured to support other platforms as well.
   list(APPEND SRC usd_stage_creation_test.cc)
@@ -75,13 +75,24 @@ if(WITH_BUILDINFO)
   list(APPEND SRC "$")
 endif()
 
+# get_cmake_property(_variableNames VARIABLES)
+# list (SORT _variableNames)
+# foreach (_variableName ${_variableNames})
+# message(STATUS "${_variableName}=${${_variableName}}")
+# endforeach()
+
+# Works on Linux, not on Windows:
+# set(_usd_DATAFILES_DIR 
"${CMAKE_INSTALL_PREFIX}/${BLENDER_VERSION}/datafiles/usd")
+set(_usd_DATAFILES_DIR 
"$/${BLENDER_VERSION}/datafiles/usd")
+
 BLENDER_SRC_GTEST_EX(
   NAME usd
   SRC "${SRC}"
   EXTRA_LIBS "${LIB}"
   COMMAND_ARGS
 --test-assets-dir "${CMAKE_SOURCE_DIR}/../lib/tests"
---test-blender-executable-dir "${EXECUTABLE_OUTPUT_PATH}"
+--test-usd-datafiles-dir "${_usd_DATAFILES_DIR}"
 )
+unset(_usd_DATAFILES_DIR)
 
 setup_liblinks(usd_test)
diff --git a/tests/gtests/usd/usd_stage_creation_test.cc 
b/tests/gtests/usd/usd_stage_creation_test.cc
index 9d76b42371d..b262e21f053 100644
--- a/tests/gtests/usd/usd_stage_creation_test.cc
+++ b/tests/gtests/usd/usd_stage_creation_test.cc
@@ -31,43 +31,24 @@ extern "C" {
 void usd_initialise_plugin_path(const char *datafiles_usd_path);
 }
 
-DEFINE_string(test_blender_executable_dir, "", "Blender's installation 
directory.");
+DEFINE_string(test_usd_datafiles_dir, "", "The 
bin/{BLENDER_VERSION}/datafiles/usd directory.");
 
 class USDStageCreationTest : public testing::Test {
 };
 
 TEST_F(USDStageCreationTest, JSONFileLoadingTest)
 {
-  std::string filename = "usd-stage-creation-test.usdc";
-
-  if (FLAGS_test_blender_executable_dir.empty()) {
-FAIL() << "Pass the --test-blender-executable-dir flag";
-  }
-
-  /* Required on Linux to make BKE_appdir_folder_id() find the datafiles.
-   * Without going to this directory, Blender looks for the datafiles in
-   * .../bin/tests instead of .../bin */
-  const char *blender_executable_dir = 
FLAGS_test_blender_executable_dir.c_str();
-  if (chdir(blender_executable_dir) < 0) {
-FAIL() << "unable to change directory to " << 
FLAGS_test_blender_executable_dir;
+  if (FLAGS_test_usd_datafiles_dir.empty()) {
+FAIL() << "Pass the --test-usd-datafiles-dir flag";
   }
 
-  const char *usd_datafiles_relpath = BKE_appdir_folder_id(BLENDER_DATAFILES, 
"usd");
-  EXPECT_NE(usd_datafiles_relpath, nullptr) << "Unable to find datafiles/usd";
-
-  char usd_datafiles_abspath[FILE_MAX];
-  BLI_path_join(usd_datafiles_abspath,
-sizeof(usd_datafiles_abspath),
-blender_executable_dir,
-usd_datafiles_relpath,
-NULL);
-
-  usd_initialise_plugin_path(usd_datafiles_abspath);
+  usd_initialise_plugin_path(FLAGS_test_usd_datafiles_dir.c_str());
 
   /* Simply the ability to create a USD Stage for a specific filename means 
that the extension
* has been recognised by the USD library, and that a USD plugin has been 
loaded to write such
* files. Practically, this is a test to see whether the USD JSON files can 
be found and
* loaded. */
+  std::string filename = "usd-stage-creation-test.usdc";
   pxr::UsdStageRefPtr usd_stage = pxr::UsdStage::CreateNew(filename);
   if (usd_stage != nullptr) {
 /* Even though we don't call usd_stage->SaveFile(), a file is still 
created on the filesystem

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [fd95e3275a1] vr_scene_inspection: Fix memory leak when closing Blender while VR session runs

2019-12-13 Thread Julian Eisel
Commit: fd95e3275a1eacc99c3b78fb7ee0384a4cf5ff2e
Author: Julian Eisel
Date:   Fri Dec 13 17:48:54 2019 +0100
Branches: vr_scene_inspection
https://developer.blender.org/rBfd95e3275a1eacc99c3b78fb7ee0384a4cf5ff2e

Fix memory leak when closing Blender while VR session runs

===

M   source/blender/windowmanager/intern/wm.c

===

diff --git a/source/blender/windowmanager/intern/wm.c 
b/source/blender/windowmanager/intern/wm.c
index 8cf08bf42bb..2583a246cd2 100644
--- a/source/blender/windowmanager/intern/wm.c
+++ b/source/blender/windowmanager/intern/wm.c
@@ -354,6 +354,11 @@ void wm_close_and_free(bContext *C, wmWindowManager *wm)
 wm_autosave_timer_ended(wm);
   }
 
+#ifdef WITH_OPENXR
+  /* May send notifier, so do before freeing notifier queue. */
+  wm_xr_data_destroy(wm);
+#endif
+
   while ((win = BLI_pophead(>windows))) {
 /* prevent draw clear to use screen */
 BKE_workspace_active_set(win->workspace_hook, NULL);
@@ -374,10 +379,6 @@ void wm_close_and_free(bContext *C, wmWindowManager *wm)
 WM_msgbus_destroy(wm->message_bus);
   }
 
-#ifdef WITH_OPENXR
-  wm_xr_data_destroy(wm);
-#endif
-
   BLI_freelistN(>paintcursors);
 
   WM_drag_free_list(>drags);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [6b496ca687e] vr_scene_inspection: Fix crash on undo or file load with running VR session

2019-12-13 Thread Julian Eisel
Commit: 6b496ca687edd121864346f530d9bc3d4efccd82
Author: Julian Eisel
Date:   Fri Dec 13 17:40:05 2019 +0100
Branches: vr_scene_inspection
https://developer.blender.org/rB6b496ca687edd121864346f530d9bc3d4efccd82

Fix crash on undo or file load with running VR session

===

M   source/blender/blenloader/intern/readfile.c

===

diff --git a/source/blender/blenloader/intern/readfile.c 
b/source/blender/blenloader/intern/readfile.c
index a81092be51b..38f38935387 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -7740,7 +7740,9 @@ static void direct_link_windowmanager(FileData *fd, 
wmWindowManager *wm)
   wm->undo_stack = NULL;
 
   wm->message_bus = NULL;
+
   wm->xr.context = NULL;
+  wm->xr.session_state = NULL;
 
   BLI_listbase_clear(>jobs);
   BLI_listbase_clear(>drags);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [4fbf78996bc] greasepencil-refactor: Merge branch 'greasepencil-object' into greasepencil-refactor

2019-12-13 Thread Antonio Vazquez
Commit: 4fbf78996bc0f7bc557257407f68b11caca1afbe
Author: Antonio Vazquez
Date:   Fri Dec 13 16:29:05 2019 +0100
Branches: greasepencil-refactor
https://developer.blender.org/rB4fbf78996bc0f7bc557257407f68b11caca1afbe

Merge branch 'greasepencil-object' into greasepencil-refactor

 Conflicts:
source/blender/blenloader/intern/versioning_280.c

===



===

diff --cc source/blender/blenloader/intern/versioning_280.c
index e39b512e2dd,c4dae5fdd8a..c59b4a27b9f
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@@ -4320,34 -4320,29 +4320,59 @@@ void blo_do_versions_280(FileData *fd, 
}
  }
  
+ /* Add primary tile to images. */
+ if (!DNA_struct_elem_find(fd->filesdna, "Image", "ListBase", "tiles")) {
+   for (Image *ima = bmain->images.first; ima; ima = ima->id.next) {
+ ImageTile *tile = MEM_callocN(sizeof(ImageTile), "Image Tile");
+ tile->ok = 1;
+ tile->tile_number = 1001;
+ BLI_addtail(>tiles, tile);
+   }
+ }
+ 
+ /* UDIM Image Editor change. */
+ if (!DNA_struct_elem_find(fd->filesdna, "SpaceImage", "int", 
"tile_grid_shape[2]")) {
+   for (bScreen *screen = bmain->screens.first; screen; screen = 
screen->id.next) {
+ for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+   for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_IMAGE) {
+   SpaceImage *sima = (SpaceImage *)sl;
+   sima->tile_grid_shape[0] = 1;
+   sima->tile_grid_shape[1] = 1;
+ }
+   }
+ }
+   }
+ }
++
 +/* Update Grease Pencil Materials */
 +{
 +  for (Material *mat = bmain->materials.first; mat; mat = mat->id.next) {
 +MaterialGPencilStyle *gp_style = mat->gp_style;
 +if (gp_style == NULL) {
 +  continue;
 +}
 +/* Set Checker material as Solid. This fill mode has been removed and 
replaced
 + * by textures. */
 +if (gp_style->fill_style == GP_STYLE_FILL_STYLE_CHECKER) {
 +  gp_style->fill_style = GP_STYLE_FILL_STYLE_SOLID;
 +}
 +/* Update Alpha channel for texture opacity. */
 +if (gp_style->fill_style == GP_STYLE_FILL_STYLE_TEXTURE) {
 +  gp_style->fill_rgba[3] *= gp_style->texture_opacity;
 +}
 +/* Stroke stencil mask to mix = 1. */
 +if (gp_style->flag & GP_STYLE_STROKE_PATTERN) {
 +  gp_style->mix_stroke_factor = 1.0f;
 +#if 0 /* TODO: This is disabled for testing only. */
 +  gp_style->flag &= ~GP_STYLE_STROKE_PATTERN;
 +#endif
 +}
 +/* Mix disabled, set mix factor to 0. */
 +else if ((gp_style->flag & GP_STYLE_STROKE_TEX_MIX) == 0) {
 +  gp_style->mix_stroke_factor = 0.0f;
 +}
 +  }
 +}
}
  }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [200d8a17329] greasepencil-object: Merge branch 'master' into greasepencil-object

2019-12-13 Thread Antonio Vazquez
Commit: 200d8a1732901ba769b30670dadafb6ad3a89ba2
Author: Antonio Vazquez
Date:   Fri Dec 13 16:27:29 2019 +0100
Branches: greasepencil-object
https://developer.blender.org/rB200d8a1732901ba769b30670dadafb6ad3a89ba2

Merge branch 'master' into greasepencil-object

===



===

diff --cc release/scripts/startup/bl_ui/space_topbar.py
index 166c93efd20,e69a28d69bf..ab79d0483cb
--- a/release/scripts/startup/bl_ui/space_topbar.py
+++ b/release/scripts/startup/bl_ui/space_topbar.py
@@@ -768,8 -815,10 +793,9 @@@ classes = 
  TOPBAR_MT_window,
  TOPBAR_MT_help,
  TOPBAR_PT_tool_fallback,
+ TOPBAR_PT_tool_settings_extra,
  TOPBAR_PT_gpencil_layers,
  TOPBAR_PT_gpencil_primitive,
 -TOPBAR_PT_gpencil_fill,
  TOPBAR_PT_name,
  )

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [735469fea36] codesign: Codesign: Implement buildbot worker side DMG bundling

2019-12-13 Thread Sergey Sharybin
Commit: 735469fea36d98281af33f3f08b1931bbf80
Author: Sergey Sharybin
Date:   Fri Dec 13 15:58:07 2019 +0100
Branches: codesign
https://developer.blender.org/rB735469fea36d98281af33f3f08b1931bbf80

Codesign: Implement buildbot worker side DMG bundling

Is based on bundle.sh but is adopted to an environment where
codesigning is happening in a dedicated VM.

Also fixed some code from previous commits:

- Removed debug only early output when running commands
- Ensured that path to git is always valid
  (wasn't a case when __file__ is relative to current directory).
- Fixed simple code signer which couldn't have imported util.

===

M   build_files/buildbot/codesign/base_code_signer.py
M   build_files/buildbot/codesign/config_builder.py
M   build_files/buildbot/codesign/config_common.py
M   build_files/buildbot/codesign/config_server_template.py
A   build_files/buildbot/slave_bundle_dmg.py

===

diff --git a/build_files/buildbot/codesign/base_code_signer.py 
b/build_files/buildbot/codesign/base_code_signer.py
index 0481bcf2564..0505905c6f4 100644
--- a/build_files/buildbot/codesign/base_code_signer.py
+++ b/build_files/buildbot/codesign/base_code_signer.py
@@ -410,7 +410,7 @@ class BaseCodeSigner(metaclass=abc.ABCMeta):
 to verify logic of the code signing process.
 """
 
-if platform != self.platform or True:
+if platform != self.platform:
 logger_server.info(
 f'Will run command for {platform}: {command}')
 return
diff --git a/build_files/buildbot/codesign/config_builder.py 
b/build_files/buildbot/codesign/config_builder.py
index 0cb83aba41e..1fa725ed28b 100644
--- a/build_files/buildbot/codesign/config_builder.py
+++ b/build_files/buildbot/codesign/config_builder.py
@@ -25,7 +25,7 @@ import sys
 
 from pathlib import Path
 
-import util
+import codesign.util as util
 
 from codesign.config_common import *
 
@@ -34,6 +34,8 @@ if platform == util.Platform.LINUX:
 SHARED_STORAGE_DIR = Path('/data/codesign')
 elif platform == util.Platform.WINDOWS:
 SHARED_STORAGE_DIR = Path('Z:\\codesign')
+elif platform == util.Platform.MACOS:
+SHARED_STORAGE_DIR = Path('/Users/sergey/Developer/blender/codesign')
 
 # 
https://docs.python.org/3/library/logging.config.html#configuration-dictionary-schema
 LOGGING = {
diff --git a/build_files/buildbot/codesign/config_common.py 
b/build_files/buildbot/codesign/config_common.py
index 3710286c777..a37bc731dc0 100644
--- a/build_files/buildbot/codesign/config_common.py
+++ b/build_files/buildbot/codesign/config_common.py
@@ -24,7 +24,10 @@ from pathlib import Path
 #
 # This is how long buildbot packing step will wait signing server to
 # perform signing.
-TIMEOUT_IN_SECONDS = 240
+#
+# NOTE: Notarization could take a long time, hence the rather high value
+# here. Might consider using different timeout for different platforms.
+TIMEOUT_IN_SECONDS = 45 * 60 * 60
 
 # Directory which is shared across buildbot worker and signing server.
 #
diff --git a/build_files/buildbot/codesign/config_server_template.py 
b/build_files/buildbot/codesign/config_server_template.py
index 1d6ddc54380..ff97ed15fa5 100644
--- a/build_files/buildbot/codesign/config_server_template.py
+++ b/build_files/buildbot/codesign/config_server_template.py
@@ -27,7 +27,7 @@ from pathlib import Path
 
 from codesign.config_common import *
 
-CODESIGN_DIRECTORY = Path(__file__).parent
+CODESIGN_DIRECTORY = Path(__file__).absolute().parent
 BLENDER_GIT_ROOT_DIRECTORY = CODESIGN_DIRECTORY.parent.parent.parent
 
 

diff --git a/build_files/buildbot/slave_bundle_dmg.py 
b/build_files/buildbot/slave_bundle_dmg.py
new file mode 100755
index 000..8a632d2ff3b
--- /dev/null
+++ b/build_files/buildbot/slave_bundle_dmg.py
@@ -0,0 +1,529 @@
+#!/usr/bin/env python3
+
+# # BEGIN GPL LICENSE BLOCK #
+#
+#  This program is free software; you can redistribute it and/or
+#  modify it under the terms of the GNU General Public License
+#  as published by the Free Software Foundation; either version 2
+#  of the License, or (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program; if not, write to the Free Software Foundation,
+#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# # END GPL LICENSE BLOCK #
+
+import argparse
+import re
+import shutil
+import subprocess
+import sys
+import time
+
+from pathlib import Path
+from tempfile import 

[Bf-blender-cvs] [38ad1c4d339] master: Image Editor: Increase size of Add Tile popup

2019-12-13 Thread Lukas Stockner
Commit: 38ad1c4d339da67bd494cb9a26b9dc315fbfad26
Author: Lukas Stockner
Date:   Fri Dec 13 15:22:06 2019 +0100
Branches: master
https://developer.blender.org/rB38ad1c4d339da67bd494cb9a26b9dc315fbfad26

Image Editor: Increase size of Add Tile popup

===

M   source/blender/editors/space_image/image_ops.c

===

diff --git a/source/blender/editors/space_image/image_ops.c 
b/source/blender/editors/space_image/image_ops.c
index 4404f904891..c0c66a28ad9 100644
--- a/source/blender/editors/space_image/image_ops.c
+++ b/source/blender/editors/space_image/image_ops.c
@@ -4258,7 +4258,7 @@ static int tile_add_invoke(bContext *C, wmOperator *op, 
const wmEvent *UNUSED(ev
   RNA_int_set(op->ptr, "number", next_number);
   RNA_string_set(op->ptr, "label", "");
 
-  return WM_operator_props_dialog_popup(C, op, 5 * UI_UNIT_X, 5 * UI_UNIT_Y);
+  return WM_operator_props_dialog_popup(C, op, 10 * UI_UNIT_X, 5 * UI_UNIT_Y);
 }
 
 static void tile_add_draw(bContext *UNUSED(C), wmOperator *op)

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [322555faa31] master: USD: Remove file created in unit test after the test is done

2019-12-13 Thread Sybren A. Stüvel
Commit: 322555faa31de2e5bbfa062e9bf132a8d69b3ca6
Author: Sybren A. Stüvel
Date:   Fri Dec 13 14:33:25 2019 +0100
Branches: master
https://developer.blender.org/rB322555faa31de2e5bbfa062e9bf132a8d69b3ca6

USD: Remove file created in unit test after the test is done

No functional changes in the USD exporter, just some cleanup code added
to the unit test.

===

M   tests/gtests/usd/usd_stage_creation_test.cc

===

diff --git a/tests/gtests/usd/usd_stage_creation_test.cc 
b/tests/gtests/usd/usd_stage_creation_test.cc
index fcf1e93ea7d..9d76b42371d 100644
--- a/tests/gtests/usd/usd_stage_creation_test.cc
+++ b/tests/gtests/usd/usd_stage_creation_test.cc
@@ -41,7 +41,7 @@ TEST_F(USDStageCreationTest, JSONFileLoadingTest)
   std::string filename = "usd-stage-creation-test.usdc";
 
   if (FLAGS_test_blender_executable_dir.empty()) {
-FAIL() << "Pass the flag";
+FAIL() << "Pass the --test-blender-executable-dir flag";
   }
 
   /* Required on Linux to make BKE_appdir_folder_id() find the datafiles.
@@ -64,9 +64,18 @@ TEST_F(USDStageCreationTest, JSONFileLoadingTest)
 
   usd_initialise_plugin_path(usd_datafiles_abspath);
 
-  /* Simply the ability to create a USD Stage for a specific filename means 
that the extension has
-   * been recognised by the USD library, and that a USD plugin has been loaded 
to write such files.
-   * Practically, this is a test to see whether the USD JSON files can be 
found and loaded. */
+  /* Simply the ability to create a USD Stage for a specific filename means 
that the extension
+   * has been recognised by the USD library, and that a USD plugin has been 
loaded to write such
+   * files. Practically, this is a test to see whether the USD JSON files can 
be found and
+   * loaded. */
   pxr::UsdStageRefPtr usd_stage = pxr::UsdStage::CreateNew(filename);
-  EXPECT_TRUE(usd_stage) << "unable to find suitable USD plugin to write " << 
filename;
+  if (usd_stage != nullptr) {
+/* Even though we don't call usd_stage->SaveFile(), a file is still 
created on the filesystem
+ * when we call CreateNew(). It's immediately closed, though, so we can 
safely call unlink()
+ * here. */
+unlink(filename.c_str());
+  }
+  else {
+FAIL() << "unable to find suitable USD plugin to write " << filename;
+  }
 }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [f5e00f73510] master: USD: more efficient mesh & curve writing

2019-12-13 Thread Sybren A. Stüvel
Commit: f5e00f735106b5ec635806a4c795a2bc46ae8369
Author: Sybren A. Stüvel
Date:   Fri Dec 13 13:00:41 2019 +0100
Branches: master
https://developer.blender.org/rBf5e00f735106b5ec635806a4c795a2bc46ae8369

USD: more efficient mesh & curve writing

- The default value of USD attributes is now only set on the first sample.
  Previously this was done for every sample (so the final default was the
  last value, rather than the first value).
- More use of the sparse value writer, now also for UV coordinates, mesh
  normals, and curve points.

===

M   source/blender/usd/intern/usd_writer_hair.cc
M   source/blender/usd/intern/usd_writer_mesh.cc

===

diff --git a/source/blender/usd/intern/usd_writer_hair.cc 
b/source/blender/usd/intern/usd_writer_hair.cc
index d09922be908..9251425c0b8 100644
--- a/source/blender/usd/intern/usd_writer_hair.cc
+++ b/source/blender/usd/intern/usd_writer_hair.cc
@@ -66,8 +66,14 @@ void USDHairWriter::do_write(HierarchyContext )
 }
   }
 
-  curves.CreatePointsAttr().Set(points, timecode);
-  curves.CreateCurveVertexCountsAttr().Set(curve_point_counts, timecode);
+  pxr::UsdAttribute attr_points = curves.CreatePointsAttr(pxr::VtValue(), 
true);
+  pxr::UsdAttribute attr_vertex_counts = 
curves.CreateCurveVertexCountsAttr(pxr::VtValue(), true);
+  if (!attr_points.HasValue()) {
+attr_points.Set(points, pxr::UsdTimeCode::Default());
+attr_vertex_counts.Set(curve_point_counts, pxr::UsdTimeCode::Default());
+  }
+  usd_value_writer_.SetAttribute(attr_points, pxr::VtValue(points), timecode);
+  usd_value_writer_.SetAttribute(attr_vertex_counts, 
pxr::VtValue(curve_point_counts), timecode);
 
   if (psys->totpart > 0) {
 pxr::VtArray colors;
diff --git a/source/blender/usd/intern/usd_writer_mesh.cc 
b/source/blender/usd/intern/usd_writer_mesh.cc
index ca0171fd60e..28e13013cfd 100644
--- a/source/blender/usd/intern/usd_writer_mesh.cc
+++ b/source/blender/usd/intern/usd_writer_mesh.cc
@@ -153,13 +153,19 @@ void USDGenericMeshWriter::write_uv_maps(const Mesh 
*mesh, pxr::UsdGeomMesh usd_
 for (int loop_idx = 0; loop_idx < mesh->totloop; loop_idx++) {
   uv_coords.push_back(pxr::GfVec2f(mloopuv[loop_idx].uv));
 }
-uv_coords_primvar.Set(uv_coords, timecode);
+
+if (!uv_coords_primvar.HasValue()) {
+  uv_coords_primvar.Set(uv_coords, pxr::UsdTimeCode::Default());
+}
+const pxr::UsdAttribute _coords_attr = uv_coords_primvar.GetAttr();
+usd_value_writer_.SetAttribute(uv_coords_attr, pxr::VtValue(uv_coords), 
timecode);
   }
 }
 
 void USDGenericMeshWriter::write_mesh(HierarchyContext , Mesh *mesh)
 {
   pxr::UsdTimeCode timecode = get_export_time_code();
+  pxr::UsdTimeCode defaultTime = pxr::UsdTimeCode::Default();
   pxr::UsdStageRefPtr stage = usd_export_context_.stage;
   const pxr::SdfPath _path = usd_export_context_.usd_path;
 
@@ -194,9 +200,19 @@ void USDGenericMeshWriter::write_mesh(HierarchyContext 
, Mesh *mesh)
 return;
   }
 
-  pxr::UsdAttribute attr_points = usd_mesh.CreatePointsAttr();
-  pxr::UsdAttribute attr_face_vertex_counts = 
usd_mesh.CreateFaceVertexCountsAttr();
-  pxr::UsdAttribute attr_face_vertex_indices = 
usd_mesh.CreateFaceVertexIndicesAttr();
+  pxr::UsdAttribute attr_points = usd_mesh.CreatePointsAttr(pxr::VtValue(), 
true);
+  pxr::UsdAttribute attr_face_vertex_counts = 
usd_mesh.CreateFaceVertexCountsAttr(pxr::VtValue(),
+   
   true);
+  pxr::UsdAttribute attr_face_vertex_indices = 
usd_mesh.CreateFaceVertexIndicesAttr(pxr::VtValue(),
+   
 true);
+
+  if (!attr_points.HasValue()) {
+// Provide the initial value as default. This makes USD write the value as 
constant if they
+// don't change over time.
+attr_points.Set(usd_mesh_data.points, defaultTime);
+attr_face_vertex_counts.Set(usd_mesh_data.face_vertex_counts, defaultTime);
+attr_face_vertex_indices.Set(usd_mesh_data.face_indices, defaultTime);
+  }
 
   usd_value_writer_.SetAttribute(attr_points, 
pxr::VtValue(usd_mesh_data.points), timecode);
   usd_value_writer_.SetAttribute(
@@ -205,9 +221,16 @@ void USDGenericMeshWriter::write_mesh(HierarchyContext 
, Mesh *mesh)
   attr_face_vertex_indices, pxr::VtValue(usd_mesh_data.face_indices), 
timecode);
 
   if (!usd_mesh_data.crease_lengths.empty()) {
-pxr::UsdAttribute attr_crease_lengths = usd_mesh.CreateCreaseLengthsAttr();
-pxr::UsdAttribute attr_crease_indices = usd_mesh.CreateCreaseIndicesAttr();
-pxr::UsdAttribute attr_crease_sharpness = 
usd_mesh.CreateCreaseSharpnessesAttr();
+pxr::UsdAttribute attr_crease_lengths = 
usd_mesh.CreateCreaseLengthsAttr(pxr::VtValue(), true);
+pxr::UsdAttribute attr_crease_indices = 
usd_mesh.CreateCreaseIndicesAttr(pxr::VtValue(), 

[Bf-blender-cvs] [02f23ab685c] master: Cycles: Fix compilation of the Render Graph test

2019-12-13 Thread Lukas Stockner
Commit: 02f23ab685cc22682b114086ce423cc2b94e43df
Author: Lukas Stockner
Date:   Fri Dec 13 15:00:22 2019 +0100
Branches: master
https://developer.blender.org/rB02f23ab685cc22682b114086ce423cc2b94e43df

Cycles: Fix compilation of the Render Graph test

===

M   intern/cycles/test/render_graph_finalize_test.cpp

===

diff --git a/intern/cycles/test/render_graph_finalize_test.cpp 
b/intern/cycles/test/render_graph_finalize_test.cpp
index ace4f29913b..ca93f8b02d0 100644
--- a/intern/cycles/test/render_graph_finalize_test.cpp
+++ b/intern/cycles/test/render_graph_finalize_test.cpp
@@ -158,11 +158,10 @@ class RenderGraph : public testing::Test {
   Device *device_cpu;
   SceneParams scene_params;
   Scene *scene;
-  Shader shader;
   ShaderGraph graph;
   ShaderGraphBuilder builder;
 
-  RenderGraph() : testing::Test(), graph(), builder()
+  RenderGraph() : testing::Test(), builder()
   {
   }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [e951f4becf5] vr_scene_inspection: Allow querying VR session viewer location from Python

2019-12-13 Thread Julian Eisel
Commit: e951f4becf51b748a5a415474eb2fbe65b93195a
Author: Julian Eisel
Date:   Fri Dec 13 13:08:33 2019 +0100
Branches: vr_scene_inspection
https://developer.blender.org/rBe951f4becf51b748a5a415474eb2fbe65b93195a

Allow querying VR session viewer location from Python

Not 100% sure if the output coordinates are correct, only did quick
testing of that. I'm just slowly working towards the virtual camera
feature for a regular viewport.

Also fix compile in Windows error with previous commit.

===

M   intern/ghost/intern/GHOST_XrGraphicsBinding.cpp
M   source/blender/makesrna/intern/rna_xr.c
M   source/blender/windowmanager/WM_api.h
M   source/blender/windowmanager/intern/wm_xr.c

===

diff --git a/intern/ghost/intern/GHOST_XrGraphicsBinding.cpp 
b/intern/ghost/intern/GHOST_XrGraphicsBinding.cpp
index dd3d477ef8c..ff1c8cc4b62 100644
--- a/intern/ghost/intern/GHOST_XrGraphicsBinding.cpp
+++ b/intern/ghost/intern/GHOST_XrGraphicsBinding.cpp
@@ -116,6 +116,8 @@ class GHOST_XrGraphicsBindingOpenGL : public 
GHOST_IXrGraphicsBinding {
 oxr_binding.glx.glxDrawable = ctx_glx->m_window;
 oxr_binding.glx.glxContext = ctx_glx->m_context;
 oxr_binding.glx.visualid = visual_info->visualid;
+
+XFree(visual_info);
 #elif defined(WIN32)
 GHOST_ContextWGL *ctx_wgl = static_cast(ghost_ctx);
 
@@ -126,8 +128,6 @@ class GHOST_XrGraphicsBindingOpenGL : public 
GHOST_IXrGraphicsBinding {
 
 /* Generate a framebuffer to use for blitting into the texture. */
 glGenFramebuffers(1, _fbo);
-
-XFree(visual_info);
   }
 
   bool chooseSwapchainFormat(const std::vector _formats,
diff --git a/source/blender/makesrna/intern/rna_xr.c 
b/source/blender/makesrna/intern/rna_xr.c
index c57f8b92f52..705aaf92c37 100644
--- a/source/blender/makesrna/intern/rna_xr.c
+++ b/source/blender/makesrna/intern/rna_xr.c
@@ -42,6 +42,16 @@ static bool rna_XrSessionState_is_running(bContext *C)
   return WM_xr_is_session_running(>xr);
 }
 
+static void rna_XrSessionState_viewer_location_get(PointerRNA *ptr, float 
*values)
+{
+  /* Could also get bXrSessionState pointer through ptr->data, but prefer if 
we just consistently
+   * pass wmXrData pointers to the WM_xr_xxx() API. */
+  const wmWindowManager *wm = (wmWindowManager *)ptr->owner_id;
+  BLI_assert(wm && (GS(wm->id.name) == ID_WM));
+
+  WM_xr_session_state_viewer_location_get(>xr, values);
+}
+
 #else /* RNA_RUNTIME */
 
 static void rna_def_xr_session_settings(BlenderRNA *brna)
@@ -92,7 +102,7 @@ static void rna_def_xr_session_state(BlenderRNA *brna)
 {
   StructRNA *srna;
   FunctionRNA *func;
-  PropertyRNA *parm;
+  PropertyRNA *parm, *prop;
 
   srna = RNA_def_struct(brna, "XrSessionState", NULL);
   RNA_def_struct_clear_flag(srna, STRUCT_UNDO);
@@ -105,6 +115,15 @@ static void rna_def_xr_session_state(BlenderRNA *brna)
   RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
   parm = RNA_def_boolean(func, "result", 0, "Result", "");
   RNA_def_function_return(func, parm);
+
+  prop = RNA_def_property(srna, "viewer_location", PROP_FLOAT, 
PROP_TRANSLATION);
+  RNA_def_property_array(prop, 3);
+  RNA_def_property_float_funcs(prop, "rna_XrSessionState_viewer_location_get", 
NULL, NULL);
+  RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+  RNA_def_property_ui_text(
+  prop,
+  "Viewer Location",
+  "Last known location of the viewer (centroid of the eyes) in world 
space");
 }
 
 void RNA_def_xr(BlenderRNA *brna)
diff --git a/source/blender/windowmanager/WM_api.h 
b/source/blender/windowmanager/WM_api.h
index 16e70dcbad5..71ba33bcf90 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -850,7 +850,8 @@ void WM_generic_user_data_free(struct wmGenericUserData 
*user_data);
 
 #ifdef WITH_OPENXR
 /* wm_xr.c */
-bool WM_xr_is_session_running(const struct wmXrData *xr);
+bool WM_xr_is_session_running(const wmXrData *xr);
+void WM_xr_session_state_viewer_location_get(const wmXrData *xr, float 
location[3]);
 #endif
 
 #ifdef __cplusplus
diff --git a/source/blender/windowmanager/intern/wm_xr.c 
b/source/blender/windowmanager/intern/wm_xr.c
index 831403b6731..158f9d33523 100644
--- a/source/blender/windowmanager/intern/wm_xr.c
+++ b/source/blender/windowmanager/intern/wm_xr.c
@@ -75,6 +75,9 @@ typedef struct bXrRuntimeSessionState {
* it also contains a location delta from the moment the option was toggled. 
*/
   GHOST_XrPose final_reference_pose;
 
+  /** Last known viewer location (centroid of eyes, in world space) stored for 
queries. */
+  GHOST_XrPose viewer_pose;
+
   /** Copy of bXrSessionSettings.flag created on the last draw call,  */
   int prev_settings_flag;
 } bXrRuntimeSessionState;
@@ -216,6 +219,7 @@ static void 
wm_xr_runtime_session_state_update(bXrRuntimeSessionState *state,
   const bool position_tracking_toggled = 

[Bf-blender-cvs] [82755f51370] master: Gizmo: add gizmos for UV transform translate/rotate/scale

2019-12-13 Thread Campbell Barton
Commit: 82755f5137061bbd1b41096946881052a5dae802
Author: Campbell Barton
Date:   Fri Dec 13 19:33:49 2019 +1100
Branches: master
https://developer.blender.org/rB82755f5137061bbd1b41096946881052a5dae802

Gizmo: add gizmos for UV transform translate/rotate/scale

===

M   release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
M   source/blender/editors/gizmo_library/gizmo_types/arrow2d_gizmo.c
M   source/blender/editors/include/ED_transform.h
M   source/blender/editors/space_image/space_image.c
M   source/blender/editors/transform/transform_gizmo_2d.c

===

diff --git a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py 
b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
index 639fb2a31a4..bbcc7097d7c 100644
--- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
@@ -1203,7 +1203,7 @@ class _defs_image_uv_transform:
 idname="builtin.move",
 label="Move",
 icon="ops.transform.translate",
-# widget="VIEW3D_GGT_xform_gizmo",
+widget="IMAGE_GGT_gizmo2d_translate",
 operator="transform.translate",
 keymap="Image Editor Tool: Uv, Move",
 )
@@ -1214,7 +1214,7 @@ class _defs_image_uv_transform:
 idname="builtin.rotate",
 label="Rotate",
 icon="ops.transform.rotate",
-# widget="VIEW3D_GGT_xform_gizmo",
+widget="IMAGE_GGT_gizmo2d_rotate",
 operator="transform.rotate",
 keymap="Image Editor Tool: Uv, Rotate",
 )
@@ -1225,7 +1225,7 @@ class _defs_image_uv_transform:
 idname="builtin.scale",
 label="Scale",
 icon="ops.transform.resize",
-# widget="VIEW3D_GGT_xform_gizmo",
+widget="IMAGE_GGT_gizmo2d_resize",
 operator="transform.resize",
 keymap="Image Editor Tool: Uv, Scale",
 )
diff --git a/source/blender/editors/gizmo_library/gizmo_types/arrow2d_gizmo.c 
b/source/blender/editors/gizmo_library/gizmo_types/arrow2d_gizmo.c
index 24571f67fdb..1c8c46a2bad 100644
--- a/source/blender/editors/gizmo_library/gizmo_types/arrow2d_gizmo.c
+++ b/source/blender/editors/gizmo_library/gizmo_types/arrow2d_gizmo.c
@@ -52,6 +52,7 @@
 
 static void arrow2d_draw_geom(wmGizmo *gz, const float matrix[4][4], const 
float color[4])
 {
+  const int draw_style = RNA_enum_get(gz->ptr, "draw_style");
   const float size = 0.11f;
   const float size_breadth = size / 2.0f;
   const float size_length = size * 1.7f;
@@ -74,11 +75,21 @@ static void arrow2d_draw_geom(wmGizmo *gz, const float 
matrix[4][4], const float
   immVertex2f(pos, 0.0f, arrow_length);
   immEnd();
 
-  immBegin(GPU_PRIM_TRIS, 3);
-  immVertex2f(pos, size_breadth, arrow_length);
-  immVertex2f(pos, -size_breadth, arrow_length);
-  immVertex2f(pos, 0.0f, arrow_length + size_length);
-  immEnd();
+  if (draw_style == ED_GIZMO_ARROW_STYLE_BOX) {
+immBegin(GPU_PRIM_TRI_FAN, 4);
+immVertex2f(pos, -size / 2, arrow_length);
+immVertex2f(pos, size / 2, arrow_length);
+immVertex2f(pos, size / 2, arrow_length + size);
+immVertex2f(pos, -size / 2, arrow_length + size);
+immEnd();
+  }
+  else {
+immBegin(GPU_PRIM_TRIS, 3);
+immVertex2f(pos, size_breadth, arrow_length);
+immVertex2f(pos, -size_breadth, arrow_length);
+immVertex2f(pos, 0.0f, arrow_length + size_length);
+immEnd();
+  }
 
   immUnbindProgram();
 
@@ -197,6 +208,11 @@ static void GIZMO_GT_arrow_2d(wmGizmoType *gzt)
   gzt->struct_size = sizeof(wmGizmo);
 
   /* rna */
+  static EnumPropertyItem rna_enum_draw_style_items[] = {
+  {ED_GIZMO_ARROW_STYLE_NORMAL, "NORMAL", 0, "Normal", ""},
+  {ED_GIZMO_ARROW_STYLE_BOX, "BOX", 0, "Box", ""},
+  {0, NULL, 0, NULL, NULL},
+  };
   RNA_def_float(gzt->srna, "length", 1.0f, 0.0f, FLT_MAX, "Arrow Line Length", 
"", 0.0f, FLT_MAX);
   RNA_def_float_rotation(gzt->srna,
  "angle",
@@ -208,6 +224,12 @@ static void GIZMO_GT_arrow_2d(wmGizmoType *gzt)
  "",
  DEG2RADF(-360.0f),
  DEG2RADF(360.0f));
+  RNA_def_enum(gzt->srna,
+   "draw_style",
+   rna_enum_draw_style_items,
+   ED_GIZMO_ARROW_STYLE_NORMAL,
+   "Draw Style",
+   "");
 }
 
 void ED_gizmotypes_arrow_2d(void)
diff --git a/source/blender/editors/include/ED_transform.h 
b/source/blender/editors/include/ED_transform.h
index 0771f39f905..5f7730a94e3 100644
--- a/source/blender/editors/include/ED_transform.h
+++ b/source/blender/editors/include/ED_transform.h
@@ -168,10 +168,28 @@ void VIEW3D_GGT_xform_shear(struct wmGizmoGroupType 
*gzgt);
 /* *** transform_gizmo_extrude_3d.c *** */
 void VIEW3D_GGT_xform_extrude(struct 

[Bf-blender-cvs] [5409b0b0be7] vr_scene_inspection: Fix two memory leaks in OpenGL Linux (X11) graphics binding

2019-12-13 Thread Julian Eisel
Commit: 5409b0b0be7ce1c7b97d360dfd935f4b24a18093
Author: Julian Eisel
Date:   Fri Dec 13 11:31:45 2019 +0100
Branches: vr_scene_inspection
https://developer.blender.org/rB5409b0b0be7ce1c7b97d360dfd935f4b24a18093

Fix two memory leaks in OpenGL Linux (X11) graphics binding

===

M   intern/ghost/intern/GHOST_IXrGraphicsBinding.h
M   intern/ghost/intern/GHOST_XrGraphicsBinding.cpp

===

diff --git a/intern/ghost/intern/GHOST_IXrGraphicsBinding.h 
b/intern/ghost/intern/GHOST_IXrGraphicsBinding.h
index 4cc71d19f21..7ad7e7935c8 100644
--- a/intern/ghost/intern/GHOST_IXrGraphicsBinding.h
+++ b/intern/ghost/intern/GHOST_IXrGraphicsBinding.h
@@ -41,6 +41,8 @@ class GHOST_IXrGraphicsBinding {
 #endif
   } oxr_binding;
 
+  virtual ~GHOST_IXrGraphicsBinding() = default;
+
   /**
* Does __not__ require this object is initialized (can be called prior to
* #initFromGhostContext). It's actually meant to be called first.
diff --git a/intern/ghost/intern/GHOST_XrGraphicsBinding.cpp 
b/intern/ghost/intern/GHOST_XrGraphicsBinding.cpp
index 87cc2ddd899..dd3d477ef8c 100644
--- a/intern/ghost/intern/GHOST_XrGraphicsBinding.cpp
+++ b/intern/ghost/intern/GHOST_XrGraphicsBinding.cpp
@@ -126,6 +126,8 @@ class GHOST_XrGraphicsBindingOpenGL : public 
GHOST_IXrGraphicsBinding {
 
 /* Generate a framebuffer to use for blitting into the texture. */
 glGenFramebuffers(1, _fbo);
+
+XFree(visual_info);
   }
 
   bool chooseSwapchainFormat(const std::vector _formats,

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [ec62413f803] master: USD: Introducing a simple USD Exporter

2019-12-13 Thread Sybren A. Stüvel
Commit: ec62413f803ee506633f0e52d1e52b0980c0ed0d
Author: Sybren A. Stüvel
Date:   Fri Dec 13 10:27:40 2019 +0100
Branches: master
https://developer.blender.org/rBec62413f803ee506633f0e52d1e52b0980c0ed0d

USD: Introducing a simple USD Exporter

This commit introduces the first version of an exporter to Pixar's
Universal Scene Description (USD) format.

Reviewed By: sergey, LazyDodo

Differential Revision: https://developer.blender.org/D6287

- The USD libraries are built by `make deps`, but not yet built by
  install_deps.sh.
- Only experimental support for instancing; by default all duplicated
  objects are made real in the USD file. This is fine for exporting a
  linked-in posed character, not so much for thousands of pebbles etc.
- The way materials and UV coordinates and Normals are exported is going
  to change soon.
- This patch contains LazyDodo's fixes for building on Windows in D5359.

== Meshes ==

USD seems to support neither per-material nor per-face-group
double-sidedness, so we just use the flag from the first non-empty
material slot. If there is no material we default to double-sidedness.

Each UV map is stored on the mesh in a separate primvar. Materials can
refer to these UV maps, but this is not yet exported by Blender. The
primvar name is the same as the UV Map name. This is to allow the
standard name "st" for texture coordinates by naming the UV Map as such,
without having to guess which UV Map is the "standard" one.

Face-varying mesh normals are written to USD. When the mesh has custom
loop normals those are written. Otherwise the poly flag `ME_SMOOTH` is
inspected to determine the normals.

The UV maps and mesh normals take up a significant amount of space, so
exporting them is optional. They're still enabled by default, though.
For comparison: a shot of Spring (03_035_A) is 1.2 GiB when exported
with UVs and normals, and 262 MiB without. We probably have room for
optimisation of written UVs and normals.

The mesh subdivision scheme isn't using the default value 'Catmull
Clark', but uses 'None', indicating we're exporting a polygonal mesh.
This is necessary for USD to understand our normals; otherwise the mesh
is always rendered smooth. In the future we may want to expose this
choice of subdivision scheme to the user, or auto-detect it when we
actually support exporting pre-subdivision meshes.

A possible optimisation could be to inspect whether all polygons are
smooth or flat, and mark the USD mesh as such. This can be added when
needed.

== Animation ==

Mesh and transform animation are now written when passing
`animation=True` to the export operator. There is no inspection of
whether an object is actually animated or not; USD can handle
deduplication of static values for us.

The administration of which timecode to use for the export is left to
the file-format-specific concrete subclasses of
`AbstractHierarchyIterator`; the abstract iterator itself doesn't know
anything about the passage of time. This will allow subclasses for the
frame-based USD format and time-based Alembic format.

== Support for simple preview materials ==

Very simple versions of the materials are now exported, using only the
viewport diffuse RGB, metallic, and roughness.

When there are multiple materials, the mesh faces are stored as geometry
subset and each material is assigned to the appropriate subset. If there
is only one material this is skipped.

The first material if any) is always applied to the mesh itself
(regardless of the existence of geometry subsets), because the Hydra
viewport doesn't support materials on subsets. See
https://github.com/PixarAnimationStudios/USD/issues/542 for more info.

Note that the geometry subsets are not yet time-sampled, so it may break
when an animated mesh changes topology.

Materials are exported as a flat list under a top-level '/_materials'
namespace. This inhibits instancing of the objects using those
materials, so this is subject to change.

== Hair ==

Only the parent strands are exported, and only with a constant colour.
No UV coordinates, no information about the normals.

== Camera ==

Only perspective cameras are supported for now.

== Particles ==

Particles are only written when they are alive, which means that they
are always visible (there is currently no code that deals with marking
them as invisible outside their lifespan).

Particle-system-instanced objects are exported by suffixing the object
name with the particle's persistent ID, giving each particle XForm a
unique name.

== Instancing/referencing ==

This exporter has experimental support for instancing/referencing.

Dupli-object meshes are now written to USD as references to the original
mesh. This is still very limited in correctness, as there are issues
referencing to materials from a referenced mesh.

I am still committing this, as it gives us a place to start when
continuing the quest for proper instancing in USD.

== Lights ==

USD does not directly support spot lights, so those aren't