[Bf-blender-cvs] [ef8ee6b2fd2] lanpr-under-gp: LineArt: Precise and fast cutting point back-transform.

YimingWu noreply at git.blender.org
Wed Jul 15 09:03:49 CEST 2020


Commit: ef8ee6b2fd2da98abfc352a3b930ab68cc63c505
Author: YimingWu
Date:   Wed Jul 15 15:03:45 2020 +0800
Branches: lanpr-under-gp
https://developer.blender.org/rBef8ee6b2fd2da98abfc352a3b930ab68cc63c505

LineArt: Precise and fast cutting point back-transform.

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

M	source/blender/editors/lineart/lineart_chain.c
M	source/blender/editors/lineart/lineart_cpu.c

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

diff --git a/source/blender/editors/lineart/lineart_chain.c b/source/blender/editors/lineart/lineart_chain.c
index daecf562784..bdee02eb2b2 100644
--- a/source/blender/editors/lineart/lineart_chain.c
+++ b/source/blender/editors/lineart/lineart_chain.c
@@ -267,8 +267,10 @@ void ED_lineart_NO_THREAD_chain_feature_lines(LineartRenderBuffer *rb)
       if (new_rv == new_rl->l) {
         for (rls = new_rl->segments.last; rls; rls = rls->prev) {
           double gpos[3], lpos[3];
+          double *lfb = new_rl->l->fbcoord, *rfb = new_rl->r->fbcoord;
+          double global_at = lfb[2] * rls->at / (rls->at * lfb[2] + (1 - rls->at) * rfb[2]);
           interp_v3_v3v3_db(lpos, new_rl->l->fbcoord, new_rl->r->fbcoord, rls->at);
-          interp_v3_v3v3_db(gpos, new_rl->l->gloc, new_rl->r->gloc, rls->at);
+          interp_v3_v3v3_db(gpos, new_rl->l->gloc, new_rl->r->gloc, global_at);
           lineart_push_render_line_chain_point(rb,
                                                rlc,
                                                lpos[0],
@@ -288,8 +290,10 @@ void ED_lineart_NO_THREAD_chain_feature_lines(LineartRenderBuffer *rb)
         rls = rls->next;
         for (; rls; rls = rls->next) {
           double gpos[3], lpos[3];
+          double *lfb = new_rl->l->fbcoord, *rfb = new_rl->r->fbcoord;
+          double global_at = lfb[2] * rls->at / (rls->at * lfb[2] + (1 - rls->at) * rfb[2]);
           interp_v3_v3v3_db(lpos, new_rl->l->fbcoord, new_rl->r->fbcoord, rls->at);
-          interp_v3_v3v3_db(gpos, new_rl->l->gloc, new_rl->r->gloc, rls->at);
+          interp_v3_v3v3_db(gpos, new_rl->l->gloc, new_rl->r->gloc, global_at);
           lineart_push_render_line_chain_point(rb,
                                                rlc,
                                                lpos[0],
@@ -336,8 +340,10 @@ void ED_lineart_NO_THREAD_chain_feature_lines(LineartRenderBuffer *rb)
     last_occlusion = ((LineartRenderLineSegment *)rls)->occlusion;
     for (rls = rls->next; rls; rls = rls->next) {
       double gpos[3], lpos[3];
+      double *lfb = rl->l->fbcoord, *rfb = rl->r->fbcoord;
+      double global_at = lfb[2] * rls->at / (rls->at * lfb[2] + (1 - rls->at) * rfb[2]);
       interp_v3_v3v3_db(lpos, rl->l->fbcoord, rl->r->fbcoord, rls->at);
-      interp_v3_v3v3_db(gpos, rl->l->gloc, rl->r->gloc, rls->at);
+      interp_v3_v3v3_db(gpos, rl->l->gloc, rl->r->gloc, global_at);
       lineart_append_render_line_chain_point(
           rb, rlc, lpos[0], lpos[1], gpos[0], gpos[1], gpos[2], N, rl->flags, rls->occlusion);
       last_occlusion = rls->occlusion;
@@ -387,8 +393,10 @@ void ED_lineart_NO_THREAD_chain_feature_lines(LineartRenderBuffer *rb)
         rlci->occlusion = last_occlusion; /*  fix leading vertex occlusion */
         for (rls = new_rl->segments.last; rls; rls = rls->prev) {
           double gpos[3], lpos[3];
+          double *lfb = new_rl->l->fbcoord, *rfb = new_rl->r->fbcoord;
+          double global_at = lfb[2] * rls->at / (rls->at * lfb[2] + (1 - rls->at) * rfb[2]);
           interp_v3_v3v3_db(lpos, new_rl->l->fbcoord, new_rl->r->fbcoord, rls->at);
-          interp_v3_v3v3_db(gpos, new_rl->l->gloc, new_rl->r->gloc, rls->at);
+          interp_v3_v3v3_db(gpos, new_rl->l->gloc, new_rl->r->gloc, global_at);
           last_occlusion = rls->prev ? rls->prev->occlusion : last_occlusion;
           lineart_append_render_line_chain_point(rb,
                                                  rlc,
@@ -409,8 +417,10 @@ void ED_lineart_NO_THREAD_chain_feature_lines(LineartRenderBuffer *rb)
         rls = rls->next;
         for (; rls; rls = rls->next) {
           double gpos[3], lpos[3];
+          double *lfb = new_rl->l->fbcoord, *rfb = new_rl->r->fbcoord;
+          double global_at = lfb[2] * rls->at / (rls->at * lfb[2] + (1 - rls->at) * rfb[2]);
           interp_v3_v3v3_db(lpos, new_rl->l->fbcoord, new_rl->r->fbcoord, rls->at);
-          interp_v3_v3v3_db(gpos, new_rl->l->gloc, new_rl->r->gloc, rls->at);
+          interp_v3_v3v3_db(gpos, new_rl->l->gloc, new_rl->r->gloc, global_at);
           lineart_append_render_line_chain_point(rb,
                                                  rlc,
                                                  lpos[0],
diff --git a/source/blender/editors/lineart/lineart_cpu.c b/source/blender/editors/lineart/lineart_cpu.c
index 6a4bbbc8fb8..173918473a4 100644
--- a/source/blender/editors/lineart/lineart_cpu.c
+++ b/source/blender/editors/lineart/lineart_cpu.c
@@ -1314,7 +1314,9 @@ static void lineart_perspective_division(LineartRenderBuffer *rb)
   LISTBASE_FOREACH (LineartRenderElementLinkNode *, reln, &rb->vertex_buffer_pointers) {
     rv = reln->pointer;
     for (i = 0; i < reln->element_count; i++) {
-      mul_v3db_db(rv[i].fbcoord, 1 / rv[i].fbcoord[3]);
+      /* Do not divide Z, we use Z to back transform cut points in later chaining process. */
+      rv[i].fbcoord[0] /= rv[i].fbcoord[3];
+      rv[i].fbcoord[1] /= rv[i].fbcoord[3];
       rv[i].fbcoord[0] -= rb->shift_x * 2;
       rv[i].fbcoord[1] -= rb->shift_y * 2;
     }



More information about the Bf-blender-cvs mailing list