OpenSpace / OpenSpace

This is the official GitHub repository for OpenSpace: an open source astrovisualization project. For instructions on how to build and run OpenSpace, see the Getting Started Guides on the wiki page at http://docs.openspaceproject.com.
http://openspaceproject.com
Other
798 stars 123 forks source link

Ability to apply a transfer function to Globe Browsing Tiles #292

Open alexanderbock opened 7 years ago

alexanderbock commented 7 years ago

NASA Worldview uses a processing step where a transfer function is applied to each tile to support changing color maps on the fly. From Ben King:

We first create an object that maps our default colormap to our new colormap. We loop through a canvas-imageData object and if our colormap-key-object has a value at any position, we update the canvas with the new pixel-value at that location. It's pretty slow but works and can be preloaded and cached for animations.

The actual code is here: https://github.com/nasa-gibs/worldview/blob/master/web/js/ol.wv/ol.wv.lookupimagetile.js#L56-L70

kbladin commented 7 years ago

The basic infrastructure of having transfer functions for layers is there. The functionality would be possible using LayerAdjustment. Adding properties can be done the same way as is done for the chroma key layer adjustment.

When it comes to the color lookup I am not entirely sure how that will be done since there are no lookup tables in GLSL (which are not textures). Alternatives would be to either use a 256256256 texture or to loop through an array to check if the sampled color match any of the values in the lookup table which could be a one dimensional texture of size 256. Neither alternative seems reasonable to be done in shader code though..

This kind of multi dimensional lookup I feel should be done out of core as tiles are loaded like worldview does. What I think makes most sense if we would like to support the same feature using their datasets with their lookup tables would be to transform the tiles to single channel grayscale tiles using the loop-lookup as tiles are created and then having our own dynamic transfer function as the tiles are rendered.

Standard transfer functions with one dimensional lookups however makes much more sense and could be implemented using a LayerAdjustment mode.

We could have a new layer type with a different tile provider that takes in a lookup table used to transform the values to single channel which we then can use for standard rendering and layer adjustments if desired.

But why doesn't GIBS provide the untransformed, normalized, single channel datasets I ask myself...