GSnap Improvements
While preparing to introduce GSnap
to the world, I have refined several of the features. The code has also become more modular and the source documentation is now more detailed. Here’s a brief overview of what has been done:
- Divided the source into five components:
Core
,IO
(input/output),CLI
,GUI
, andViz
(visualization). - Used the Qt Framework’s QtScript functionality to add a nice scripting interface. The base scripting language is ECMAScript (JavaScript). This is augmented with custom functions which manipulate
GSnap
’s internal objects. - Re-implemented the depth of field effect as a separate class rather than a large, complicated member function of the volume rendering class. The new depth of field effect uses a faster Gaussian blur algorithm and produces much better results because larger blur radii are now practical.
- Improved the performance and memory usage of the volume renderer for a given quality level by using a
std::priority_queue
to accelerate the neighbor search. This allows higher-quality volume rendering in a reasonable amount of time. - Finished the gas temperature computation and color mapping feature.
- Redesigned the snapshot I/O to make it easier to add other snapshot format readers.
- Added a new visualization option,
--view stars
, which is intermediate between--view particles
and--view flux
. Star particles are rendered as points, but they are rendered in the context of the volume renderer. This means that interstellar dust is able to obscure and redden the starlight. The results are somewhat similar to Sunrise output. This option is better than the--view flux
option for simulations containing hundreds of millions of billions of star particles
In addition to that, many of the code formatting rules are now automatically enforced using AStyle and the coding guide now discourages the use of exceptions and RTTI (as do Google, the LLVM project, and others). Several GCC-specific features have been exploited in order to improve the performance of the code when it is compiled with g++. Overall, the final binary file is smaller by about 30% and the volume rendering code runs about 10% faster just because of the GCC-specific pragmas and function attributes combined with the set of compiler flags that are now used. The performance of the velocity dispersion statistics functionality improved negligibly. The hot
and cold
function attributes were particularly helpful.
Here are a few sample renderings…
First, a demonstration of the improved color mapping and depth of field features. The gas in the foreground galaxy is in focus while the gas in the background galaxy is blurred. This draws attention to the foreground object without the need to remove the background object from the scene. Also, note: dark red = cold gas, white = warm gas.
Without the depth of field effect, your attention is not as focussed on the foreground object, since the background object is equally in focus.
Of course, foreground objects are also blurred. This is the same system as above, but rotated so that the background object is now in the front:
The effect works equally well with visual renderings:
and
Now, here’s a demonstration of the new --view stars
option without including any gas in the rendering:
That’s pretty basic. Including gas (and dust) in the rendering process makes this looks more like a galaxy:
But in a real galaxy, you generally can’t see the individual stars like this. In fact, the particles in the simulation don’t really represent stars; they are more like tracer particles which represent the density field in a statistical sense. For a more realistic representation, we use the full volume renderer, which smooths the particles into a continuum:
For a bit more fun, we can look at the gas distribution, and then do some post-processing. Here’s the gas by itself:
If we add the gas image to the star image using photo editing software like ImageMagick, GIMP, or Photoshop, we get:
The distribution of stars relative to the gas is interesting. Finally, if we add the dust-attenuated star image to the gas image, we get this: