+ return vis_scene;
+}
+
+float Terrain::get_height(const Vec3 &pos) const
+{
+ float x = pos.x;
+ float y = pos.z;
+
+ float half_width = params.xsz / 2.0;
+ float half_height = params.ysz / 2.0;
+
+ if(x < -half_width || x > half_width)
+ return 0;
+ if(y < -half_height || y > half_height)
+ return 0;
+
+ float u = (x + half_width) / params.xsz;
+ float v = (y + half_height) / params.ysz;
+
+ return get_height(u, v) * params.max_height;
+}
+
+float Terrain::get_height(float u, float v) const
+{
+ float sn = gph::fbm(u * params.noise_freq, v * params.noise_freq, params.num_octaves);
+ sn = sn * 0.5 + 0.5;
+
+ if(params.coarse_heightmap.pixels) {
+ Vec4 texel = params.coarse_heightmap.lookup_linear(u, v, 1.0 / params.tile_usub, 1.0 / params.tile_vsub);
+ sn *= texel.x;
+ }
+ return sn;