SDF rendering bug for low scale values
In the SDF actor, when the scale of the actor is set below 0.01 some deformation is observed. As the value is further decreased, the deformation gets worse


diff --git a/fury/actor.py b/fury/actor.py
index 88f7ccaf..dfc8974a 100644
--- a/fury/actor.py
+++ b/fury/actor.py
@@ -1960,6 +1960,7 @@ def billboard(centers, colors=(0, 1, 0), scales=1, vs_dec=None, vs_impl=None,
     big_verts, big_faces, big_colors, big_centers = res
 
     sq_actor = get_actor_from_primitive(big_verts, big_faces, big_colors)
+    sq_actor.GetMapper().SetVBOShiftScaleMethod(False)
     sq_actor.GetProperty().BackfaceCullingOff()
     attribute_to_actor(sq_actor, big_centers, 'center')
 
@@ -2563,6 +2564,7 @@ def sdf(centers, directions=(1, 0, 0), colors=(1, 0, 0), primitives='torus',
 
     rep_verts, rep_faces, rep_colors, rep_centers = repeated
     box_actor = get_actor_from_primitive(rep_verts, rep_faces, rep_colors)
+    box_actor.GetMapper().SetVBOShiftScaleMethod(False)
 
     if isinstance(primitives,  (list, tuple, np.ndarray)):
         primlist = [prims[prim] for prim in primitives]
diff --git a/fury/shaders/billboard_dec.frag b/fury/shaders/billboard_dec.frag
index 1da90165..05620545 100644
--- a/fury/shaders/billboard_dec.frag
+++ b/fury/shaders/billboard_dec.frag
@@ -1,3 +1,2 @@
 /* Billboard  fragment shader declaration */
-in vec3 centeredVertexMC;
-in float scalingFactor;
+in vec3 normalizedVertexMCVSOutput;
diff --git a/fury/shaders/billboard_dec.vert b/fury/shaders/billboard_dec.vert
index 97593a6c..08e1dd19 100644
--- a/fury/shaders/billboard_dec.vert
+++ b/fury/shaders/billboard_dec.vert
@@ -1,4 +1,4 @@
 /* Billboard  vertex shader declaration */
 in vec3 center;
-out vec3 centeredVertexMC;
-out float scalingFactor;
+
+out vec3 normalizedVertexMCVSOutput;
diff --git a/fury/shaders/billboard_impl.frag b/fury/shaders/billboard_impl.frag
index fea5f1ff..6721a7ee 100644
--- a/fury/shaders/billboard_impl.frag
+++ b/fury/shaders/billboard_impl.frag
@@ -1,7 +1,5 @@
 /* Billboard  Fragment shader implementation */
-
-
 // Renaming variables passed from the Vertex Shader
 vec3 color = vertexColorVSOutput.rgb;
-vec3 point = centeredVertexMC;
+vec3 point = normalizedVertexMCVSOutput;
 fragOutput0 = vec4(color, 1.);
diff --git a/fury/shaders/billboard_impl.vert b/fury/shaders/billboard_impl.vert
index 8a6d9446..c779990e 100644
--- a/fury/shaders/billboard_impl.vert
+++ b/fury/shaders/billboard_impl.vert
@@ -1,11 +1,12 @@
 /* Billboard  vertex shader implementation */
-centeredVertexMC = vertexMC.xyz - center;
-scalingFactor = 1. / abs(centeredVertexMC.x);
-centeredVertexMC *= scalingFactor;
-
-vec2 billboardSize = vec2(scalingFactor, scalingFactor);
-
-vec3 cameraRightWorldSpace = vec3(MCVCMatrix[0][0], MCVCMatrix[1][0], MCVCMatrix[2][0]);
-vec3 cameraUpWorldSpace = vec3(MCVCMatrix[0][1], MCVCMatrix[1][1], MCVCMatrix[2][1]);
-vec3 vertexPositionWorldSpace = center + cameraRightWorldSpace * billboardSize.x * centeredVertexMC.x + cameraUpWorldSpace * billboardSize.y * centeredVertexMC.y;
-gl_Position = MCDCMatrix * vec4(vertexPositionWorldSpace, 1.);
+normalizedVertexMCVSOutput = vertexMC.xyz - center; // 1st Norm. [-scale, scale]
+float scalingFactor = 1. / abs(normalizedVertexMCVSOutput.x);
+float size = abs(normalizedVertexMCVSOutput.x) * 2;
+normalizedVertexMCVSOutput *= scalingFactor; // 2nd Norm. [-1, 1]
+vec2 billboardSize = vec2(size, size); // Fixes the scaling issue
+vec3 cameraRightMC = vec3(MCVCMatrix[0][0], MCVCMatrix[1][0], MCVCMatrix[2][0]);
+vec3 cameraUpMC = vec3(MCVCMatrix[0][1], MCVCMatrix[1][1], MCVCMatrix[2][1]);
+vec3 vertexPositionMC = center +
+    cameraRightMC * billboardSize.x * normalizedVertexMCVSOutput.x +
+    cameraUpMC * billboardSize.y * normalizedVertexMCVSOutput.y;
+gl_Position = MCDCMatrix * vec4(vertexPositionMC, 1.);
diff --git a/fury/tests/test_actors.py b/fury/tests/test_actors.py
index 5cb2a934..a2d64cbd 100644
--- a/fury/tests/test_actors.py
+++ b/fury/tests/test_actors.py
@@ -1294,9 +1294,12 @@ def test_superquadric_actor(interactive=False):
 def test_billboard_actor(interactive=False):
     scene = window.Scene()
     scene.background((1, 1, 1))
-    centers = np.array([[2, 0, 0], [0, 2, 0], [0, 0, 0]])
-    colors = np.array([[1, 0, 0], [0, 1, 0], [0, 0, 1]])
-    scales = [1, 2, 1]
+    centers = np.array([[0, 0, 0], [5, -5, 5], [-7, 7, -7], [10, 10, 10],
+                        [10.5, 11.5, 11.5], [12, -12, -12], [-17, 17, 17],
+                        [-22, -22, 22]])
+    colors = np.array([[1, 1, 0], [0, 0, 0], [1, 0, 1], [0, 0, 1], [1, 1, 1],
+                       [1, 0, 0], [0, 1, 0], [0, 1, 1]])
+    scales = [6, .4, 1.2, 1, .2, .7, 3, 2]
 
     fake_sphere = \
         """
@@ -1312,15 +1315,17 @@ def test_billboard_actor(interactive=False):
         fragOutput0 = vec4(max(df_1 * color, sf_1 * vec3(1)), 1);
         """
 
-    billboard_actor = actor.billboard(centers,
-                                      colors=colors.astype(np.uint8),
-                                      scales=scales,
+    billboard_actor = actor.billboard(centers, colors=colors, scales=scales,
                                       fs_impl=fake_sphere)
     scene.add(billboard_actor)
     scene.add(actor.axes())
     if interactive:
         window.show(scene)
 
+    arr = window.snapshot(scene)
+    report = window.analyze_snapshot(arr, colors=colors)
+    npt.assert_equal(report.objects, 8)
+
 
 @pytest.mark.skipif(skip_win, reason="This test does not work on Windows"
                                      " due to snapshot (memory access"
@@ -1329,7 +1334,7 @@ def test_billboard_actor(interactive=False):
 def test_sdf_actor(interactive=False):
     scene = window.Scene()
     scene.background((1, 1, 1))
-    centers = np.array([[2, 0, 0], [0, 2, 0], [0, 0, 0]])
+    centers = np.array([[2, 0, 0], [0, 2, 0], [0, 0, 0]]) * 11
     colors = np.array([[1, 0, 0], [0, 1, 0], [0, 0, 1]])
     directions = np.array([[0, 1, 0], [1, 0, 0], [0, 0, 1]])
     scales = [1, 2, 3]
['fury/tests/test_actors.py', 'fury/actor.py', 'fury/shaders/billboard_impl.vert', 'fury/shaders/billboard_dec.frag', 'fury/shaders/billboard_impl.frag', 'fury/shaders/billboard_dec.vert']