Hello everyone.

I'm trying to make a small demo of VSM technique to learn it. I'm using OpenGL 2.0 + framebuffer extension, also using SDL and GLEW for utility. I've got some visual problems, looking like that:
(clickable image link to imgbox.com, image host)


After searching information on this forum, i've found a trick of clamping minimum value of (M2 - M1*M1) by 0.00002. It makes shadow look much better, except certain angles, which still look like that:
(clickable image link to imgbox.com, image host)


If I increase this minimum value, artifacts become less visible, at the same time shadow becomes fainter (probably that's why artifacts less visible too).

I have done blurring after second test. While it helped, some artifacts are still visible:
(clickable image link to imgbox.com, image host)


Full source code (tested on Gentoo Linux 64bit) is here: http://pastebin.com/iAkeW85V
I know it's not optimized in any way, and many textures/fbos could be reused and some textures combined, i'll do it later, for now I want to get rid of artifacts. Please help me to get rid of them.