Jan 18

LINUX: Fixing screen position running NVidia drivers

LINUX: Fixing screen position running NVidia drivers


Hello folks!

So lately I have been playing a lot with CentOS, and looks like I finally am on a stable setup, where I can compile all my stuff, opengl, cuda and TBB etc.

The problem that bothered me for a while was the setup of the screens, I had swapped monitor, meaning I had to go to the right  side in order to go in the left monitor, and swapping the monitors was not a solution due to a comples setup running with a shared monitor with two computers etc.

I was able to fix that with the nvidia-settings panel, unluckily the fix was not permanent, I tried a shitload of guides in order to fix the  problem, everyone suggested to use this command at runtime:

nvidia-settings --load-confing-only

But that was completely ignored for some weird reason I don;t know, so I had to do that with a script, I tried to mess around with the nvidia-settings command but no luck there, luckily I remebered a command I used ages ago on Ubuntu 10 to fix this very same problem, the command is xrandr, after a little googling on how to use the command I come out with few lines of code to fix my problem:

#!/bin/sh
xrandr --auto --output DVI-D-0 --right-of HDMI-0
xrandr --auto --output HDMI-0 --left-of DVI-D-0
xrandr --auto --output HDMI-0 --primary
echo ">>>> screens setupped properly ... I hope!"

The code first sets my second monitor on the right of my main and then the opposite, at the end I also set the HDMI monitor as primary.
Now you might wonder where I came out whit those names HDMI-0, DVI-D-0 etc. To get the names of your monitors is quite simple you just need to
run xrandr without arguments in the terminal and it will spit out the current plugged monitors.

</pre>
<pre>$ xrandr
Screen 0: minimum 8 x 8, current 3840 x 1080, maximum 16384 x 16384
VGA-0 disconnected (normal left inverted right x axis y axis)
DVI-D-0 connected 1920x1080+1920+0 (normal left inverted right x axis y axis) 531mm x 298mm
 1920x1080 60.0*+
 1680x1050 60.0 
 1600x900 60.0 
 1280x1024 75.0 60.0 
 1280x800 59.8 
 1280x720 60.0 
 1024x768 75.0 60.0 
 800x600 75.0 60.3 
 640x480 75.0 59.9 
HDMI-0 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 477mm x 268mm
 1920x1080 60.0*+ 59.9 50.0 
 1680x1050 60.0 
 1600x900 60.0 
 1440x900 59.9 
 1280x1024 75.0 60.0 
 1280x800 59.8 
 1280x720 60.0 59.9 50.0 
 1152x864 75.0 
 1024x768 75.0 70.1 60.0 
 800x600 75.0 72.2 60.3 56.2 
 720x576 50.0 
 720x480 59.9 
 640x480 75.0 72.8 59.9</pre>

Once you know that you are golden and can make your script run.
Last two step where to run the script at start-up, and create and alias for the script since I have a complex setup with HDMI swithces etc which sometimes still
freaks out the monitors, so I run the script manually from terminal and all goes in the right place.

That’s it guys , happy Linux!

Jan 06

Having fun with cuda…. again

Having fun with cuda…. again

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Hello there, today we are talking about cuda again, some time ago you saw me talking about pycuda in THIS post, here today I did something similar but with a more serious approach,

I decided to get better at c++,  parallel computation and Linux, this led me to start this learning project about image processing.

The first step was able of course to read an image and convert the data in something that can be easily processed both from cpu and gpu, also it gave me an excuse to learn how to read a binary file.

I decided to go with a BMP image format, because is one of the simplest there is around, with no compression and just simple header.

Now don’t get me wrong I am not trying to re-invent the wheel at all, I just made a simple bmp class to learn the process, the class itself is quite limited as well features wise, it just let me load and save the image or if needed generate an empty buffer then save it, as a reference I used THIS awesome article, be sure to have a look at it.

Once the BMP was out of the way I could finally start working on the image processing itself, first step is the most basic and simple black and withe filter, I first implemented the serial version then the TBB version and finally the cuda version, I am not sharing the code yet just because I don’t believe it is decent enough to be shown, but I will do that soon and you will see it popping up on timings

 

Let s start with the black and white, the first thing to notice is that we don’t have such big difference between cuda and TBB, such small computation was not so worth based on all the managing of the data that cuda needs ( allocating/copying memory etc ), we start get some more speed up when we start going up on heavier images. Another interesting thing was that if I was trying to run 8 thread with TBB (aka hyper-threading), I was actually getting lower performances that just running 4 threads, unluckily I don’t know much about hyperthreading to know why but I plan on looking a little into it.

Here is a carth of the running times:

bw_line

bw_bars

bw_cuda_bars

 

Everything looks fairly standard, the increase in time is also quite linear, even though the gap between 4k and 5k is not that much, but we will see later that, that particular spot will hold some surprises for the blur aswelas well

Speaking of blur, we can see that since we have abit more computation in the blur we start getting some way better performances out of cuda, lets see the charts for the timings.

blur_linesjpg

blur_bars

blur_cuda_bars

 

As you can see here we start to get some nice performance out of the GTX 780M, we get an ~76x speedup compared to the serial code and a ~21x speed up compared TBB on a 9k Image.

It is all good and nice, except the serial execution between 4k – 5k, you can see that the 5k is actually running faster then the 4k, don’t ask me because I have no clue about it, at the beginning I thought it

was an error, but I run the program other two times for both the 4k and 5k image the result were the same, the only guess might be some combination in memory that made the 4k particularly  slower for some reason.

Other then that I was quite pleased to see the GPU starting to crunch as it is supposed to, but I am not stopping here, the plan for the future are the following, first I want to implement a gaussian blur, with a radius parameter which will force me to implement a dynamic size stancil and implement a generic convolution kernel with that stancil, also I came across THIS page where they show the different effects of different stencils, like sharpening or edge detection etc. Once the generic kernel will be implemented it will be fairly easy to play with those.

In the road map there is also the implementation of some more complex filters, or better I hope to find some filters more computationally expensive but not necessarily   super complex math wise, I don’t want to dive too much yet into image processing , last step will be add a nice UI where the user will be able to load an image and display that using opengl and then stack on each other different filters and see the result (hopefully) realtime.

Once that is done I will be ready to jump back on my opengl sandbox and make it way more robust and start implementing some more cool stuff.

That is it guys , here below a small video demo of me running the program.

Parallel Image: simple image processing program from Marco Giordano on Vimeo.

 

Cheers

 

Dec 07

My current OSs setup and why is painful

My current OSs setup and why is painful

Hello folks how is it going?

Today I would like to share with you the painful mess I put myself in order to be able to work under Linux.

First of all I am not here to make a flame about Linux vs Windows, just stating some observation based on my experience, so if you are here to flame please kindly get the fuck of this post, thanks :D.

Now I am going to list my 3 partition setup and what each partition allow me to do, my final goal would be to have a Linux distro able to let me use Maya, do python and C++ , C++ opengl and possibly cuda.

My current setup:

Ubuntu 14:  First Linux distro I ever used

  • Maya : not able to make the license to work, I got a genuine student license but since I have to convert from rpm to deb I cannot use maya installer and had to go into the mess of manually make the license to work, after several painful hours no luck
    I tried to contact Autodesk for help and they laughed at me saying: “We dont support Linux have a good day”.
  • Python: works no problem , but most of my python is done for Maya so I cannot do maya-python on here
  • C++ : I can compile nicely with g++ no problem here
  • Opengl: Thanks to Nvidia finally supporting nvidia optimus technology I was able to make opengl stuff working on my GTX (and not integrated intel) card quite easily, problem second monitor refresh is uber laggy
  • Misc: my gaming mouse works ( basic functionality but that’s all I need)

CentoOS 7:   Best would be to use this distro, which is the same I use at work

  • Maya: CentOS uses rpm packages so I could use their installer and was just a matter of click click click done, installed (plus of course linking manually all the missing shared libs), license works ! wooot
  • Python : all good here, python works no problem and I can do maya stuff
  • C++ : I can compile with g++ no problem here
  • OpenGL: Bloody mess, there is no official support from Nvidia, so need to use Bumblebee project  which is quite of a pain to make it work, after I made it work my opengl viewport kinda works so for now I am stuck there.
  • Misc : gaming mouse does not work, need to have another mouse plugged

Windows 7: Works out of the box

  • Maya: always worked never had a problem
  • Python : all nice and smooth
  • C++ : well best is to use Microsoft compiler , but I need to use gcc/g++ and on windows doesn’t work so well, need to use some portings like MingGW, etc which gave me quite a bit of trouble before
  • OpengGL: I made stuff working on windows, but always on windows compiler I will try with MingGW
  • Misc : every device worked,

The final thoughts you guys might have is “Fuck Linux then, use Windows that works”. You got a point here ,  and I am not an a strict adopter of open-source, I am pro open source stuff but that s not my reason for jumping on Linux.

There are two main reasons I want to use Linux:

  • Loving the work flow: damn how much I like my work flow on Linux, where I pretty much interact only with the console, I can  get similar work flow on Win but is a pale imitation.
  • Work: for the kind of work I do and I wish to do in the future I need to be comfortable in programming and compiling on Unix systems.

Right now I am in the situation where I kinda do all I need to do but I have to switch between 2 different distros and each one has it s own pro-cons as you can see from the list above. I am by no means a Linux expert so might be just me the retarded one not being able to make it work XD,  but I hope one day I can stay on Linux all the time and just jump on Win for gaming purpose.

I might one day just buy a desktop PC and remove the Nvidia Optimus problem all at once, but we will see about that.

So that s all for now folks

M

 

Dec 01

MAYA 2015: Intstalling on CentOS tips

MAYA 2015: Intstalling on CentOS tips

Quick posts on installing Maya 2015, mostly for myself I need it I know where to find it, but for anyone else that might be interested as-well.

There are many guides on how install Maya on Linux, on centos was the easiest one since I did not have to convert the rpm packages to deb, I could also use the GUI setup for the very same reason.

The installation went nice and smooth (remember to sudo setup).

First problem was in activating the license, I got a student license, when I was trying to activating the license it would just time out, in the end I just figured out I just had to run:

“sudo maya”, that s not entirely true, because for some reason when running Maya command with sudo the command itself was unknown, (no clue here) , so what I did was running the  installer directly from installation folder, something like:

“sudo /usr/autodesk/maya2015-x64/bin/maya”.

After the licensing went nice and smooth, only problem left was maya erroring like crazy not being able to find some fonts the error was something like this:

“error: Failed trying to load font : -*-helvetica-bold-r-normal–10-*-*-*-*-*-iso8859-1″.

To fix it go in your package manager and filter for “xorg-x11-fonts-ISO8859-1″, there will be a handful of packages after the filtering, I installed them all just to stay on the safe side, but you should look for the 100 dpi ones.

After that all was nice and good.

Cheers

Jul 31

DEMO SPLICE : Bendy arm

DEMO SPLICE : Bendy arm

Hello folks! As promised here a follow up of my development in Fabric Splice !! Today we are talking about bendy arms! Ever heard of it? In the computer graphic industry when you talk about bendy arms you mean a cartoony setup that allows you  to create arcs in body limbs like it was a tail rather that just simple sharp bends in knees and elbows  for example. Now to achieve that result require to resolve of a couple of problems :

  • How to bend the arm? Means how to get an arc?
  • How to orient the bones along the arc?
  • What about distributed twisting?

The node I wrote in splice is going to adress exactly all those problems.

twistSplice

Before get started with explanations let s see what we got here. This is a picture of the actual node , with opengl debug on, the node get as input an array of matrices, in this case 3 , shoulder , mid , elbow and shoots out the matrix array of the computed bendy bones. The resulting dots are the position computed and the lines is the Y axis of the resulting rotation matrix

How to bend the arm? Means how to get an arc?

In order to have the bones deforming into a nice arc I used the input matrices to interpolate a nurbs curve ( Yeah now you see why I wrote a nurbs curve huh?) . Once I get a nurbs computed in the node I can then evalute points along the curve, done we got our bendy positions.

How to orient the bone along the arc? &  What about distributed twisting ?

I am actually gonna answer this two questions all at once because solving one means solving the other. In order to compute the orientation along the curve first of all I need to be able to query a tangent to the curve and an up up vector, once I takled this I can actually generate an orientation matrix , but the math I did is a bit different , since I had to re-adapt the algorithm from maya API to splice API. First thing I did was extracting the twist , this is quite tricky since you need to be able to re-alling quaternions without losing the twist , and I actualyl improved my old algorithm and found a better axis for performing the align, with a combination and the twist and a tangent vector I am able to compute the final quaternion rotation that allows me to get my object aligned to the tangnet on the curve and twisted properly. Actually splice allows you to extract a matrix from a  quaternion and a point which saved me a bit of math. Of course the whole thing is running on parallel thanks to PEX ( where possible).   Enough talk here is the demo!

That s it folks! As usual If you like it please follow my channel and share it around. You can also stay up to date with all my videos by subscribing to the newsletter at : marcogiordanotd.com/newsletter.php

Jul 30

DEMO SPLICE : Bezier and Nurbs curve in Creative Splice API

DEMO SPLICE : Bezier and Nurbs curve in Creative Splice API

 

 

    

 

Hello everyone, today we are talking about SPLICE !

If you don’t know what Splice is I command you to rush to their website and have a look , is quite awesome and I do believe it might be next leap forward in the industry.

I finally started  to play with Splice  and I decided to implement a nurbs curve, you might wonder why I wanted to do that.

The reason behind  that are mainly two, first Splice for now lacks a nurbs curve/surface implementation ( no worries will come soon) and second  I always wanted to learn the the math behind the  nurbs curves , so I took two bones  with one stone and got my hands dirty.

In order to grasp the math I started by implementing  the bezier curve  which is just a specific type of nurbs curve, then I generalized it to a nurbs curve.

I started by being able to compute berstain polinomials , that led me to compute the weights of each control point, this was not too hard, once that was implemented I was  able to do what I had in mind, computing a tangent on the curve at given u param. In order to do so you need to get the derivative at the given u , this was less easy but a lot of study  and banging my head against the wall

in the end made the math clicking in my head and I was eble to implement.

As you can see in the demo , the main problem with bezier is that  in order to add control point you need to raise up the degree of the curve , which will make you lose contol of the locality of the curve, also high degree polinomials will start to get unstable.

This is where next step of the development led me to, implement a nurbs curve , like the maya one.

Again I  followed  the same steps and got it done, also with the tangent computation. (It took also a lot of italian swearing which I am not gonna report , it is like somewhot “colorful”).

Great, I have implemented everything I wanted so time to get serious and start using the nurbs curve class for some heavy lifting.

 

The first usage I could thing of was Parallel Frame transportation ( If you wanna know more you can check  my maya plugin  demo ), basically is a nice and stable way to compute normals along the curve avoiding flipping. Once you are able to compute those normals then is a piece of cake to be able to compute a positon and orientation along the curve, and that s what the second part of the demo is talking about.

Here is the actual demo :

 

That s it folks!

As usual If you like it please follow my channel and share it around.
You can also stay up to date with all my videos by subscribing to the newsletter at :
marcogiordanotd.com/newsletter.php

 

 

Older posts «