GeoTexture
The GeoTexture plugin manages dynamic, multi-resolution geographic textures derived from XYZ-tile datasets. It uses a 2D array texture internally, where each layer corresponds to an XYZ tile, and relies on an internal BVH tree to efficiently select the appropriate texture layer based on geodetic coordinates. The plugin supports multiple XYZ-tile sources, local caching, and asynchronous data processing, making it ideal for applications requiring efficient and scalable geographic imagery visualization.
note
The GeoTexture provides an updated region that must be used to regenerate resources such as terrain.
#include <geospatial/geotexture/include/TellusimGeoTexture.h>
Example
The following example creates and configures two GeoTexture instances for terrain height and color data using XYZ tiles:
// create height texture
GeoTexture height_texture;
height_texture.setRadius(terrain.getRadius());
height_texture.setTargetRadius(1000.0);
height_texture.setMaxLevel(TILES_MAX_HEIGHT);
if(!height_texture.create(device, FormatRf32, 260, 2048)) return false;
height_texture.addSource(String(TILES_PATH "height_{Z}/{y}/{x}.tif"));
height_texture.setSourceCache(0, String("cache/height_{Z}/{y}/{x}.tif"));
// create color texture
GeoTexture color_texture;
color_texture.setRadius(terrain.getRadius());
color_texture.setTargetRadius(1000.0);
color_texture.setMaxLevel(TILES_MAX_COLOR);
if(!color_texture.create(device, FormatRGBAu8n, 256, 2048)) return false;
color_texture.addSource(String(TILES_PATH "color_{Z}/{y}/{x}.jpg"));
color_texture.setSourceCache(0, String("cache/color_{Z}/{y}/{x}.jpg"));
// background thread processing
thread = makeAutoPtr(makeThreadFunction([&](Thread *thread) {
bool ret = false;
ret |= height_texture->process(async);
ret |= color_texture->process(async);
if(!ret) Time::sleep(10000);
async.wait();
}));
// update target position
height_texture.setTargetPosition(camera_position);
color_texture.setTargetPosition(camera_position);
if(!height_texture.update(device)) return false;
if(!color_texture.update(device)) return false;