[Bf-blender-cvs] [85d36aebf4d] soc-2019-npr: LANPR: able to toggle two background colors.

YimingWu noreply at git.blender.org
Mon Jul 8 08:58:29 CEST 2019


Commit: 85d36aebf4d9da1b414dad6e481149caa75f0efa
Author: YimingWu
Date:   Mon Jul 8 14:58:09 2019 +0800
Branches: soc-2019-npr
https://developer.blender.org/rB85d36aebf4d9da1b414dad6e481149caa75f0efa

LANPR: able to toggle two background colors.

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

M	source/blender/draw/engines/lanpr/lanpr_dpix.c
M	source/blender/draw/engines/lanpr/lanpr_ops.c

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

diff --git a/source/blender/draw/engines/lanpr/lanpr_dpix.c b/source/blender/draw/engines/lanpr/lanpr_dpix.c
index 65a5bccf881..a4ac78a659b 100644
--- a/source/blender/draw/engines/lanpr/lanpr_dpix.c
+++ b/source/blender/draw/engines/lanpr/lanpr_dpix.c
@@ -476,6 +476,7 @@ void lanpr_dpix_draw_scene(LANPR_TextureList *txl,
   float clear_depth = 1.0f;
   uint clear_stencil = 0xFF;
   int is_persp = 1;
+  float use_background_color[4] = {0.0f ,0.0f,0.0f,1.0f};;
 
   if (!lanpr->active_layer) {
     return; /* return early in case we don't have line layers. DPIX only use the first layer. */
@@ -516,6 +517,13 @@ void lanpr_dpix_draw_scene(LANPR_TextureList *txl,
   pd->dpix_znear = camera ? ((Camera *)camera->data)->clip_start : v3d->clip_start;
   pd->dpix_zfar = camera ? ((Camera *)camera->data)->clip_end : v3d->clip_end;
 
+  if(lanpr->use_world_background){
+    copy_v3_v3(use_background_color,&scene->world->horr);
+    use_background_color[3] = 1;
+  }else{
+    copy_v3_v3(use_background_color,lanpr->background_color);
+  }
+
   GPU_point_size(1);
   /*  GPU_line_width(2); */
   GPU_framebuffer_bind(fbl->dpix_transform);
@@ -527,11 +535,11 @@ void lanpr_dpix_draw_scene(LANPR_TextureList *txl,
   DRW_draw_pass(psl->dpix_preview_pass);
 
   if (is_render) {
-    mul_v3_v3fl(clear_col, lanpr->background_color, lanpr->background_color[3]);
-    clear_col[3] = lanpr->background_color[3];
+    mul_v3_v3fl(clear_col, use_background_color, use_background_color[3]);
+    clear_col[3] = use_background_color[3];
   }
   else {
-    copy_v4_v4(clear_col, lanpr->background_color);
+    copy_v4_v4(clear_col, use_background_color);
   }
 
   GPU_framebuffer_bind(DefaultFB);
diff --git a/source/blender/draw/engines/lanpr/lanpr_ops.c b/source/blender/draw/engines/lanpr/lanpr_ops.c
index e6ed645f142..81369d26e78 100644
--- a/source/blender/draw/engines/lanpr/lanpr_ops.c
+++ b/source/blender/draw/engines/lanpr/lanpr_ops.c
@@ -4000,6 +4000,7 @@ void lanpr_viewport_draw_offline_result(LANPR_TextureList *txl,
   float clear_col[4] = {0.0f, 0.0f, 0.0f, 0.0f};
   float clear_depth = 1.0f;
   uint clear_stencil = 0xFF;
+  float use_background_color[4] = {0.0f ,0.0f,0.0f,1.0f};
 
   DefaultTextureList *dtxl = DRW_viewport_texture_list_get();
   DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
@@ -4019,18 +4020,25 @@ void lanpr_viewport_draw_offline_result(LANPR_TextureList *txl,
     camera = scene->camera;
   }
 
+  if(lanpr->use_world_background){
+    copy_v3_v3(use_background_color,&scene->world->horr);
+    use_background_color[3] = 1;
+  }else{
+    copy_v3_v3(use_background_color,lanpr->background_color);
+  }
+
   GPU_framebuffer_bind(fbl->dpix_transform);
   DRW_draw_pass(psl->dpix_transform_pass);
 
   GPU_framebuffer_bind(fbl->dpix_preview);
   eGPUFrameBufferBits clear_bits = GPU_COLOR_BIT;
   GPU_framebuffer_clear(
-      fbl->dpix_preview, clear_bits, lanpr->background_color, clear_depth, clear_stencil);
+      fbl->dpix_preview, clear_bits, use_background_color, clear_depth, clear_stencil);
   DRW_draw_pass(psl->dpix_preview_pass);
 
   GPU_framebuffer_bind(dfbl->default_fb);
   GPU_framebuffer_clear(
-      dfbl->default_fb, clear_bits, lanpr->background_color, clear_depth, clear_stencil);
+      dfbl->default_fb, clear_bits, use_background_color, clear_depth, clear_stencil);
   DRW_multisamples_resolve(txl->depth, txl->color, 1);
 }
 
@@ -4090,6 +4098,7 @@ void lanpr_software_draw_scene(void *vedata, GPUFrameBuffer *dfb, int is_render)
   View3D *v3d = draw_ctx->v3d;
   float indentity_mat[4][4];
   static float normal_object_direction[3] = {0, 0, 1};
+  float use_background_color[4]={0.0f ,0.0f,0.0f,1.0f};
 
   if (is_render) {
     lanpr_rebuild_all_command(lanpr);
@@ -4108,18 +4117,16 @@ void lanpr_software_draw_scene(void *vedata, GPUFrameBuffer *dfb, int is_render)
   uint clear_stencil = 0xFF;
   eGPUFrameBufferBits clear_bits = GPU_DEPTH_BIT | GPU_COLOR_BIT;
 
-  /*  Object *camera; */
-  /*  if (v3d) { */
-  /* 	RegionView3D *rv3d = draw_ctx->rv3d; */
-  /* 	camera = (rv3d->persp == RV3D_CAMOB) ? v3d->camera : NULL; */
-  /* } */
-  /*  else { */
-  /* 	camera = scene->camera; */
-  /* } */
+  if(lanpr->use_world_background){
+    copy_v3_v3(use_background_color,&scene->world->horr);
+    use_background_color[3] = 1;
+  }else{
+    copy_v3_v3(use_background_color,lanpr->background_color);
+  }
 
   GPU_framebuffer_bind(fbl->software_ms);
   GPU_framebuffer_clear(
-      fbl->software_ms, clear_bits, lanpr->background_color, clear_depth, clear_stencil);
+      fbl->software_ms, clear_bits, use_background_color, clear_depth, clear_stencil);
 
   if (lanpr_share.render_buffer_shared) {



More information about the Bf-blender-cvs mailing list