2
$\begingroup$

I wrote a program that displays points expressed in 3D in a 2D canvas, using perspective projection. The aim is to display a cube. Each face of the cube is drawn by linearly interpolating the points that define it. My cube can be translated, scaled and rotated thanks to transformation matrices.

For the moment, my program is not paralelized at all and uses CPU to make the various computations (e.g. : projection of 3D points into the 2D canvas using perspective projection, matrices computations, product of a point by a matrix, drawing cube's faces with linear interpolation).

There is a speed problem. I described it below :

  1. Linear interpolation as I wrote it, which never calculates duplicates, costs a lot of accesses to RAM. Applied to each face, it requires also a lot of computations.

  2. My cube's faces should be drawn thanks to a linear interpolation with a very very small step (e.g. : 0.001) to be beautiful. However, it's simply a utopia. It would require too many computations and accesses to RAM. My program would freeze.

  3. A given transformation matrice is multiplied by point N°1, then by N°2, then by N°k, then by N°8. Obviously, the matrices are not multiplied by the interpolated points ! (it implies a gain in computation speed).

Questions

Without using any API :

  1. Are GPU util to paralelize linear interpolations ? If I remember well my courses, yes. So : how could I send my points and my linear interpolation function to GPU ? Note that I would be disapointed if I must use linear interpolation program of the GPU (if it exists) instead of mine.

  2. How could I draw beautiful cube's faces without using a linear interpolation's step of 0.001 ?

  3. Less important : is it possible to increase computation speed in making the product of a sequence of points with a matrice ?

$\endgroup$
2
  • $\begingroup$ What you are doing is what a GPU as a graphics processor is designed to do. Is it a requirement to do it in Scala or can you use a graphics API such as openGL or DirectX? $\endgroup$
    – Nadir
    Commented Jun 3, 2018 at 12:41
  • $\begingroup$ Yes, I wanted to know about the geometric mechanisms involved in perspective projection and in filling a face with interpolation. The best solution would consist in executing parts of my code (e.g. : interpolation between the 4 points of my face) by the GPU and not the CPU. Perhaps GPGPU could be useful for me ? $\endgroup$ Commented Jun 3, 2018 at 19:19

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.