Surface topography
The surface topography actor renders a 2-D pressure field as terrain. Because the vertical coordinate of the scene is pressure, a surface pressure field is the orography: where the surface pressure is low, the ground is high.
Source code: src/actors/nwpsurfacetopographyactor.cpp,
src/glsl/surface_topography.fx.glsl.
Displacement mapping
The technique is classical vertex-shader displacement mapping:
The 2-D field is uploaded as a texture and interpreted as a height map.
A triangle mesh with one vertex per grid point of the 2-D field is drawn. Vertex positions are not stored in a buffer; the shader derives the grid indices (i, j) of each vertex from
gl_VertexIDandgl_InstanceID.In the vertex shader, the field value at (i, j) is fetched and converted to the world space vertical coordinate, and the vertex is displaced accordingly.
Any 2-D field carrying pressure can be used, not only the surface pressure. For example, pressure at boundary layer height can be used.
Normals are computed in the vertex shader from the four neighbouring grid points: the cross products of the vectors to the neighbours give four candidate normals, and their mean is used.
Colouring is independent of the displacement: a second 2-D field can be mapped through a transfer function onto the terrain, for example 2 m temperature on top of the surface pressure relief.
A flat variant of the vertex shader (VSflat) renders the same field as a plain
textured quad within a bounding box, without displacement.