terrain working - no culling
[demo] / src / terrain.cc
index 92dce56..ff54f46 100644 (file)
@@ -98,13 +98,14 @@ static float calc_height(float u, float v, void *ptr)
        GenData *data = (GenData*)ptr;
        const TerrainParams *tp = data->tp;
 
-       // float ufreq = tp->noise_freq / tp->xtiles;
-       // float vfreq = tp->noise_freq / tp->ytiles;
-
        u = u / tp->xtiles + data->xoffs;
        v = v / tp->ytiles + data->yoffs;
 
        float sn = gph::fbm(u * tp->noise_freq, v * tp->noise_freq, tp->num_octaves);
-       /* todo use the image later */
+
+       if(tp->coarse_heightmap) {
+               Vec4 texel = tp->coarse_heightmap->lookup_nearest(u, v);
+               sn *= texel.x;
+       }
        return sn;
 }
\ No newline at end of file