12 May 2013

Procedural displacement mapping

Game players may not care about details. But I always wanted to come close to surfaces and see fine displacement mapping instead of large and flat polygons.
It’s not hard to believe that the Pixar’s micropolygons technique is about to get feasible at real-time in a near future.
But I could not wait. And I’ve tried out my rough near-micropolygons technique, working in real-time, at present.

The following video shows how, with this technique, every single stone textured gets extruded and lit properly, with its own geometry and proper vertex normals. Every crack gets carved automagically, by means of a fine increase of geometry detail, so that not a polygon is any more visible at close distances:



This technique works on current gaming video cards, such as GeForce GTX 560, OpenGL 4.0 profile. The tessellation shaders tessellate and also displace vertices procedurally, accordingly to an analitically interpreted shape of the texture. And this texture can be either a procedurally generated or a regular human-made.

Unlike the Pixar’s micropolygons, this “near-micropolygons” technique doesn’t split triangles so that their projected areas to screen are about 1 pixel, and thus can’t conveniently approximate vertex normals to facet normals (which would be a big saving of maths headaches and GPU power). Yet it works. And it is, in my opinion, a great improvement of rendering. I wish some technique like this will be exposed soon on modern games.

This feature currently is in gdevice and comes with a 30% of FPS loss. There is a bunch of data yet computed in-shader that can be wisely precomputed, therefore some margin for optimization. This will be food for my mind in the next days.