Skip to main content

GeoTerrain

The GeoTerrain plugin extends Terrain to provide a geodetically-aware terrain system capable of integrating and rendering large-scale geographic data. It supports geographic positioning based on longitude, latitude, and ellipsoidal height, and allows dynamic geometry and texture updates within specified geographic regions. This class is particularly useful for applications requiring real-time rendering of planetary surfaces or terrain tiles based on geospatial data sources.

info

Like the Terrain plugin, GeoTerrain uses compute shaders for elevation and color data processing.

#include <geospatial/geoterrain/include/TellusimGeoTerrain.h>

Example

// Create GeoTerrain with 18 LOD levels
GeoTerrain terrain(GeoTerrain::TypeEarth);
terrain.setTileWrap(2);
terrain.setNumTiles(10);
terrain.setNumLevels(18);
terrain.setTileSize(48);

// Terrain Geometry kernel
terrain.setGeometryKernel(geometry_kernel, [&](Compute compute, Terrain::GeometryParameters *parameters, uint32_t size) {
compute.setUniform(0, target_parameters);
compute.setSampler(0, point_sampler);
compute.setTexture(0, height_texture.getTexture());
compute.setStorageBuffer(2, height_texture.getBuffer());
return size;
});

// Terrain Normal kernel
terrain.addTexture(FormatRGBAu8n, 256, normal_kernel, [&](Compute compute, Terrain::TextureParameters *parameters, uint32_t size) {
compute.setUniform(0, target_parameters);
compute.setSampler(0, point_sampler);
compute.setTexture(0, height_texture.getTexture());
compute.setStorageBuffer(2, height_texture.getBuffer());
return size;
});

// Terrain Diffuse kernel
terrain.addTexture(FormatRGBAu8n, 256, diffuse_kernel, [&](Compute compute, Terrain::TextureParameters *parameters, uint32_t size) {
compute.setUniform(0, target_parameters);
compute.setSampler(0, linear_sampler);
compute.setTexture(0, color_texture.getTexture());
compute.setStorageBuffer(2, color_texture.getBuffer());
return size;
});

// Initialize terrain resources using the rendering device, scene graph, and shading material
if(!terrain.create(device, graph, shading_material)) return false;

// update terrain
if(!terrain.update(device, camera_node)) return false;

// dispatch terrain
if(!terrain.dispatch(device, compute)) return false;