[Bf-blender-cvs] [b3b40fca75f] soc-2019-npr: LANPR: CPU mode camera view pan/zoom aligned.

YimingWu noreply at git.blender.org
Mon Jul 8 15:33:22 CEST 2019


Commit: b3b40fca75fb4492317250e3bb56413dfadffae3
Author: YimingWu
Date:   Mon Jul 8 21:26:26 2019 +0800
Branches: soc-2019-npr
https://developer.blender.org/rBb3b40fca75fb4492317250e3bb56413dfadffae3

LANPR: CPU mode camera view pan/zoom aligned.

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

M	source/blender/draw/engines/lanpr/shaders/lanpr_software_chain_geom.glsl
M	source/blender/draw/engines/lanpr/shaders/lanpr_software_line_chain_geom.glsl

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

diff --git a/source/blender/draw/engines/lanpr/shaders/lanpr_software_chain_geom.glsl b/source/blender/draw/engines/lanpr/shaders/lanpr_software_chain_geom.glsl
index 5a401456fea..004028a94cc 100644
--- a/source/blender/draw/engines/lanpr/shaders/lanpr_software_chain_geom.glsl
+++ b/source/blender/draw/engines/lanpr/shaders/lanpr_software_chain_geom.glsl
@@ -225,11 +225,12 @@ void decide_line_style(int component_id)
   }
 }
 
-vec4 correct_camera_scale(vec4 p){
-  
-  p.x-=camdx*4;
-  p.y-=camdy*4;
-  p.xy*=camzoom;
+vec4 correct_camera_scale(vec4 p)
+{
+
+  p.x -= camdx * 4;
+  p.y -= camdy * 4;
+  p.xy *= camzoom;
   return p;
 }
 
@@ -242,15 +243,40 @@ void main()
 
   float asp1 = output_viewport.z / output_viewport.w;
   float asp2 = preview_viewport.z / preview_viewport.w;
-  float x_scale = asp1 / asp2;
+  float x_scale;
+  float y_scale;
+  if (asp1 > 1) {
+    if (asp2 < 1) {
+      x_scale = 1 / asp2;
+      y_scale = 1 / asp1;
+    }
+    else {
+      x_scale = 1;
+      y_scale = asp2 / asp1;
+    }
+  }
+  else {
+    if (asp2 < 1) {
+      x_scale = asp1 / asp2;
+      y_scale = 1;
+    }
+    else {
+      x_scale = asp1;
+      y_scale = asp2;
+    }
+  }
 
   vec4 LL = vec4(gl_in[0].gl_Position.xy, 0, 1), L = vec4(gl_in[1].gl_Position.xy, 0, 1),
        R = vec4(gl_in[2].gl_Position.xy, 0, 1), RR = vec4(gl_in[3].gl_Position.xy, 0, 1);
 
   LL.x *= x_scale;
+  LL.y *= y_scale;
   L.x *= x_scale;
+  L.y *= y_scale;
   R.x *= x_scale;
+  R.y *= y_scale;
   RR.x *= x_scale;
+  RR.y *= y_scale;
 
   LL = correct_camera_scale(LL);
   L = correct_camera_scale(L);
diff --git a/source/blender/draw/engines/lanpr/shaders/lanpr_software_line_chain_geom.glsl b/source/blender/draw/engines/lanpr/shaders/lanpr_software_line_chain_geom.glsl
index c2648ecb620..6bbf6147b03 100644
--- a/source/blender/draw/engines/lanpr/shaders/lanpr_software_line_chain_geom.glsl
+++ b/source/blender/draw/engines/lanpr/shaders/lanpr_software_line_chain_geom.glsl
@@ -132,11 +132,11 @@ void decide_color_and_thickness(float component_id)
   }
 }
 
-vec4 correct_camera_scale(vec4 p){
-  
-  p.x-=camdx*4;
-  p.y-=camdy*4;
-  p.xy*=camzoom;
+vec4 correct_camera_scale(vec4 p)
+{
+  p.x -= camdx * 4;
+  p.y -= camdy * 4;
+  p.xy *= camzoom;
   return p;
 }
 
@@ -145,13 +145,36 @@ void main()
 
   float asp1 = output_viewport.z / output_viewport.w;
   float asp2 = preview_viewport.z / preview_viewport.w;
-  float x_scale = asp1 / asp2;
-      
+  float x_scale;
+  float y_scale;
+  if (asp1 > 1) {
+    if (asp2 < 1) {
+      x_scale = 1 / asp2;
+      y_scale = 1 / asp1;
+    }
+    else {
+      x_scale = 1;
+      y_scale = asp2 / asp1;
+    }
+  }
+  else {
+    if (asp2 < 1) {
+      x_scale = asp1 / asp2;
+      y_scale = 1;
+    }
+    else {
+      x_scale = asp1;
+      y_scale = asp2;
+    }
+  }
+
   vec4 p1 = vec4(gl_in[0].gl_Position.xy, 0, 1);
   vec4 p2 = vec4(gl_in[1].gl_Position.xy, 0, 1);
 
   p1.x *= x_scale;
   p2.x *= x_scale;
+  p1.y *= y_scale;
+  p2.y *= y_scale;
 
   p1 = correct_camera_scale(p1);
   p2 = correct_camera_scale(p2);



More information about the Bf-blender-cvs mailing list