Parallax mapping for the masses

I have spent the last ten days studying hard, reading the first half of the Orange Book (it’s the last book in the list, of course πŸ˜€ ), a plethora of papers, many demos code, tons of tutorials and guides, but at last I achieved what I would have never imagined just two weeks ago. πŸ˜‰

Fixed Pipeline

Per-pixel Lighting

Normal Mapping Parallax Mapping

The GLSL_parallax demo shows per pixel Blinn-Phong shading, specular mapping and tangent space parallax mapping with offset limiting! πŸ˜€

Actually I’m not really sure about the correctness of my implementation (especially regarding tangent space lighting) but screenshots demonstrate that I’m close to it.
In the first one the usual and boring OpenGL fixed functionality per-vertex lighting (ambient, diffuse and specular components of a point light with attenuation), in the second one shaders are enabled, but only to calculate lighting on a per-pixel basis. At last, the third and the fourth image show normal and parallax mapping.

Talking in more detail, the code is written for OpenGL 2 only, it makes use of Vertex Buffer Objects and GLSL shaders using core functions.

Here is the magic:

if (withParallax == true) { // alpha channel encodes the height map
  height = scale * texture2D(Tex1, gl_TexCoord[1].st).a - bias;
  TexCoord = gl_TexCoord[0].st + height * ecPos.xy;
if (withNormal == true)
  nor = 2.0 * normalMap.rgb - 1.0; // decoding normal map

Some statistics:

  • 6 varying variables
  • 7 uniform variables (texture samples and enable/disable booleans)
  • 3 texture fetches every fragment processed
  • (24×3)x3 + 24×2 = 432 floats (1728 bytes) stored in VBOs

Enjoy the shaders! πŸ™‚

The quest is over!

The quest for the lost fragment is over, at last!
Today I have returned from Athens and installed in Electron the additional ram module and the long awaited shader capable MSI FX5900XT-VTD128 card!

The first thing I’ve done was to update the Nvidia driver packages from ‘nvidia-96xx’ to ‘nvidia’, this currently means going from 96.31 to 97.55.

This is what’s new from GeForce4 Ti 4200 (NV25) to GeForce FX5900 XT (NV35):

  • The OpenGL version string is now 2.1.0
  • The CineFX 2.0 engine allows for two new anti-aliasing modes: 4x Bilinear Multisampling by 4x Supersampling and 4x Bilinear Multisampling by 2x Supersampling
  • There are eighteen new extensions available: GL_ARB_fragment_program, GL_ARB_fragment_program_shadow, GL_ARB_fragment_shader, GL_ARB_half_float_pixel, GL_EXT_blend_func_separate, GL_EXT_framebuffer_blit, GL_EXT_framebuffer_multisample, GL_EXT_framebuffer_object, GL_EXT_stencil_two_side, GL_EXT_texture_sRGB, GL_NV_float_buffer, GL_NV_fragment_program, GL_NV_fragment_program_option, GL_NV_framebuffer_multisample_coverage, GL_NV_half_float, GL_NV_primitive_restart, GL_NV_vertex_program2, GL_NV_vertex_program2_option

What follows is a series of test, actually they are exactly the same, and with the same settings, as the ones shown in the Easter gifts post:

Test NoAA, NoAF 2xAA, 4xAF
glxgears 4852.8 2678.0
Blender 9978 7927
GL_shadow 1189.4 793.0
GL_pointz 544.8 552.0
GL_blit 2006.0 1391.4
GL_smoke 449.4 402.8

Some tests perform better on Electron than on Thunder (which has a much faster graphic card and DDR RAM), this is very strange, maybe I’ve got to run these tests on Thunder again. πŸ˜‰

Accepted for Summer of Code

Dear Applicant,
Congratulations! This email is being sent to inform you that your
application was accepted to take part in the Summer of Code.

Yeah, one of my two proposals has been accepted!

My first proposal was about working on GL O.B.S. under the Python Software Foundation, unfortunately it was very likely going to be discarded.
I learned this from a mentor who contacted me, he wrote that my application was based on a personal program and that it would have been hard to find someone to mentor me, moreover I wouldn’t have contributed to the Python community. He also added that I could have been a good candidate for his project, he is, indeed, Arc Riley, Project Manager of PySoy.
And so I did, I wrote another application and, this time, it has been accepted. πŸ™‚

My work will be to integrate multi-texturing in the PySoy rendering loop and API, document API additions, test the whole under many different free software drivers and then implement some related techniques, like bump or normal mapping.

I’m really glad of this opportunity, I will learn many interesting OpenGL and Python topics and I will improve my design, teamwork and communication skills.
Thank you Google! πŸ˜‰

Easter gifts

While in Greece to spend holidays with my family I was able to get my hands on some interesting piece of hardware to bring back in Italy for Electron: a 128MB module of SDR RAM to fill up the last motherboard slot and *two* different graphic cards (my old 5900XT and a 6200)! πŸ™‚
Actually all this was possible thanks to Easter gifts! πŸ˜‰
My uncle installed a 512MB module of DDR RAM inside his old PC, while both me and a friend of mine changed our old cards with the good and cheap Gigabyte GV-N76G256D-RH, a GeForce 7600GS equipped card with 256MB of DDR2 memory.

It is a completely silent card which delivers sufficient performance at a great price, it is capable of running Shader Model 3.0 vertex and fragment programs, supports OpenGL 2.1 and all the G70 Extensions, moreover it features a lm_sensors compatible thermal sensor on the GPU core. πŸ™‚

A reduced series of tests follows, all performed at 640×480 excepts Blender 2.43 draw benchmark, which was run at 1024×768, my desktop resolution.

Test NoAA, NoAF 2xAA, 4xAF
glxgears 4966.6 3123.3
Blender 10855 10764
GL_shadow 1428.8 996.2
GL_pointz 631.0 617.6
GL_blit 2052.8 1223.8
GL_smoke 358.2 316.8

The low resolution at which most of the test were run could have made the results a bit too cpu limited, some other games I’ve tested seem to confirm this theory, however that the card shows its strength and I’m satisfied with it.
I hope you also get nice Easter gifts and I wish you a merry Easter! πŸ˜‰

Back to globs too, committed r45

Three months and three weeks after rev. 43 (ignoring rev. 44 which was related to the site only) I committed a new revision of globs.
I would like to show some of the tiny refinements cited in the ChangeLog which I made to the interface.

In the new Information tab all the info are displayed inside a single TextView widget with gtk.WRAP_WORD which makes use of a bold TextTag to highlight the relevant text.
The policy of the surrounding ScrolledWindow widget is set to gtk.POLICY_AUTOMATIC for both scrollbars, which really makes it less cluttered.

Inside the updated Options tab you can see a new resolution ComboBox and a Frame surrounding benchmark options, this permits to perform a simpler and cleaner self.options_frame.set_sensitive(False) to gray out everything in case the “Lock current” ToggleButton is checked.

This is all very cute but the hard work, the adaptation of the submit code to the new database, is still postponed… πŸ™‚

Back to work, Mars r622

Yesterday my exams session finally ended, I’m really satisfied about the results achieved, but during the studying period I was eager to get back to coding…

Today I fixed bug #0000008, a fastidious one which caused program termination if the user tried to take a screenshot after having deleted the hidden directory inside his home where settings and images are saved by default. πŸ™‚

Mars 0.1.1 2nd

The first thing I thought was that I was missing a fopen() return code check, but, fortunately for my reputation, it wasn’t the case. πŸ˜‰

// Opening output file
if((fp = fopen(filename, "wb")) == NULL)
  throw Exception("Screen", "fopen error");
  return -1;

The problem, as the shell output was suggesting, was related to the exception system: the fopen() exception was never caught.

Just changing this:

case SDLK_F4:

into this:

case SDLK_F4:
  catch(Exception e)

fixed everything.

Have a look at r622 log and at mars.cpp changes and remember to catch all the exception you may throw. πŸ˜‰

Blender 2.43

Today is a memorable day for Blender!
First of all got a massive redesign and it’s now really cool and professional. For instance, have a look at the new features page, I think it’s a perfect showcase for our beloved program.

Moreover Blender 2.43 was released!

Blender 2.43 Splash

As usual the release log is full of appealing new functionalities that I’m eager to try.
Some of them can be previewed in feature videos or tested using the blend files which come inside the archive.

I would like to express my congratulations to the whole Blender community.

The quest for the lost fragment

Yesterday I was donated a new graphic card from a generous guy at the university, including cables, manual and bundled software, it is a nice MSI G4Ti4200-DT64 with red PCB.

MSI G4Ti4200-DT64

It’s a good card but unfortunately it has only a primitive version of pixel shaders, they are neither floating point (supporting at most the proprietary “HILO” format) nor GLSL compliant, and they cannot be used via GL_ARB_fragment_program (as a matter of fact it is not present in the extensions array πŸ™ ), but only through the family of GL_NV_register_combiners and GL_NV_texture_shader functions, which make use of the OpenGL state machine.
Nvidia Cg actually supports the fp20 profile, but its output is just a nvparse program, which has to be passed to a function that will setup GL texture states.

Anyway, let’s analyze what’s new going from a GeForce4 MX440-8X (NV18) to a GeForce4 Ti 4200 (NV25):

  • The OpenGL version string hasn’t changed (mainly because of the lack of Shader Model 2.0), it is still 1.5.8.
  • Thanks to the Accuview AA Engine there are three new anti-aliasing modes: 4x Bilinear Multisampling, 4x Gaussian Multisampling and 2x Bilinear Multisampling by 4x Supersampling.
  • There are twenty new extensions available, most of them are related to multisample, depth textures, occlusion queries, shadows and texture shaders:
    GL_ARB_depth_texture, GL_ARB_multisample, GL_ARB_occlusion_query, GL_ARB_shadow, GL_ARB_texture_border_clamp, GL_EXT_shadow_funcs, GL_EXT_texture3D, GL_EXT_timer_query, GL_HP_occlusion_test, GL_NV_copy_depth_to_color, GL_NV_depth_clamp, GL_NV_multisample_filter_hint, GL_NV_occlusion_query, GL_NV_register_combiners2, GL_NV_texture_compression_vtc, GL_NV_texture_shader, GL_NV_texture_shader2, GL_NV_texture_shader3, GL_SGIX_depth_texture, GL_SGIX_shadow.

Of course I performed some benchmarks too (have a look at Electron specs), all at 1024×768, except from glxgears and globs tests, they were run at the default 640×480 resolution.
Quake 3 was tested on the four.dm_68 demo with sound, Blender 2.42 was tested with the draw benchmark, while the GLSLvp_pointz test uses only vertex shader to move and color points.
Note that this last test is emulated in software on NV18 while is performed in hardware on the NV25, but shaders plus full scene anti-aliasing seem to be impossible to achieve on the latter.

Test NV18 NV25
NoAA, NoAF 2xAA, 4xAF NoAA, NoAF 2xAA, 4xAf
glxgears 1568.5 833.5 2976.7 1571.7
Blender 2580 1580 7000 4484
Quake 3 93.0 51.7 113.6 92.3
gl_shadow 296 148.4 674.6 360
gl_pointz 421.8 272.6 526.2 398.4
gl_blit 600.6 285.8 1197.4 612.4
gl_smoke 299 177.2 404.2 302
GLSLvp_point 118.6 103.8 317.6 X

The card is nice and fast, but the search for the fragment (extension) has not ended. πŸ˜‰

A panoramic of Vista

Wow, Vista retail is out today!
This means I can go in a computer shop, pay 360€ and get a shiny box containing Windows Vista Home Premium Edition (the right one for a “power user” like me πŸ˜‰ ).

Windows Vista

Let’s have a brief look at some of its “innovative” features:

  • The new Windows Update is a stand-alone application, not a web site anymore.
    This sounds great, but pacman (as well as the other package managers) does already a great job keeping my box up to date, and it can run from a terminal, a script or wrapped in a graphical front end.
    Another point is that it updates all the applications, not just the core modules of my OS, and, of course, what it downloads is just free (as in speech) software.
  • Windows Desktop Search is a brand new technology (who said Spotlight? πŸ™‚ ) for desktop search that searches instantly for files and their content too.
    It’s quite similar to what Beagle, Strigi or Tracker do on our Linux desktops since some time…
  • Aero Glass is the fantastic new 3D GUI that everyone already knows, “inspired” by Aqua and already available on our beloved Linux boxes via Compiz or Beryl.
  • The Reliability and Performance Monitor, for what I can see from screenshots, doesn’t make much more than the Gnome System Monitor, KSysGuard or GKrellM.
  • Windows Sidebar adds to your desktop all these tiny and colorful Gadgets, they are nice to look at, but I can’t see any innovation in them, have a look at adesklets, gDesklets, SuperKaramba, GKrellM again or at the Dashboard of Mac OS X.
  • Windows Defender is a nice addition, I have to admit that we don’t have something similar for our *nix like boxes. πŸ˜€
  • Network Map is a graphical network monitor, like Nomad.
  • The Windows Firewall got an update, it now supports IPv6 and IPsec and performs outbound packet filtering. Linux has netfilter/iptables that is capable of much more, but a home user without running servers (and without Windows πŸ˜‰ ) shouldn’t need a firewall in the first place.
  • A new version of Movie Maker is included, but we have plenty of alternatives like Cinelerra, LiVES, Kino, PiTiVi
  • There’s Media Player 11, but, again, there are so many free alternatives that I won’t even list them here.
  • Windows Photo Gallery is a photo management application with basic editing, no more or less than what F-Spot, gPhoto, Mirage, KPhotoAlbum or digiKam can do.
  • Internet Explorer 7 and Windows Mail are the brand new applications for the basic network tasks of browsing the Internet and working with e-mails. Suffice it to say that one of the most important new features of IE7 is tabbed browsing while for Windows Mail it’s a Bayesian junk-mail filter. What does the words Firefox and Thunderbird mean to you?
    Don’t ignore the possibility to use other alternatives too, like Epiphany, Galeon, Konqueror or Sylpheed, Balsa, KMail.
  • The User Account Control is an attempt to mimic *nix users and permissions system, but, I think, it will be soon deactivated by everyone. A Windows user is not accustomed to entering her/his password every time the system needs more privileges. πŸ™‚
  • DirectX 10 is maybe the only thing that could make you install Vista. If you are a gamer you absolutely need Vista to play the newest games, but if you are a graphic programmer you won’t need Direct3D 10 to actually take advantage of, say, geometry shaders, you can use GL_EXT_geometry_shader4 or GL_NV_geometry_program4. For detailed specifications about all the nVidia’s G80 OpenGL extensions you can have a look at g80specs.pdf (it is needless to say that we are all waiting for OpenGL 3.0 πŸ™‚ ).
  • Microsoft admits that a shell is useful sometimes, so in Vista we have the Windows PowerShell. πŸ™‚

Unfortunately WinFS has not made its debut in Vista, it would have been a really innovative file system, like the BFS was when first appeared ten years ago. πŸ˜‰

We have demonstrated that Vista is beautiful and innovative, so let’s go to the shop and buy… plenty of RAM! One to two GB will suffice to run the monster, and don’t forget a DirectX 9 video card.
Yes, you need Pixel Shader 2.0 to handle Aero, there’s no fall back no-shaders mode like in some Beryl plugins (the blur one, for instance, works even on older cards).

To summarize the whole post, I will definitely not go to a computer shop and spend three hundred sixty Euros for something that doesn’t offer anything new, that is not free (both because it is proprietary and because it supports strong TC-like protections), and that is not a *nix!. πŸ˜‰

Don’t steal from the Scene!

I’m really angry after having read this and watch this
To make a long story short, a big producer had the brilliant idea to dig in this enormous artistic resource which is the Scene, to take an “inspiration” from it.


No one has the right to do this to the Scene, it’s made by great artists which work for fun and not for money, they should be respected, not robbed!

Janne, you’ve all the comprehension and support from a long time Amiga user and Scene lover.