+ terrain_tex = gfx_create_texture();
+ if(!terrain_tex->load("data/grass.jpeg")) {
+ fprintf(stderr, "Failed to load ground texture.\n");
+ return false;
+ }
+
+ Image ter_hmap;
+ if(!ter_hmap.load("data/terhmap.png")) {
+ fprintf(stderr, "Failed to load terrain heightmap.\n");
+ return false;
+ }
+
+ p.xsz = 200;
+ p.ysz = 200;
+ p.max_height = 30;
+ p.xtiles = 40;
+ p.ytiles = 40;
+ p.tile_usub = 10;
+ p.tile_vsub = 10;
+ p.num_octaves = 3;
+ p.noise_freq = 5;
+ p.coarse_heightmap = ter_hmap;
+
+ terrain.init();
+ terrain.generate(p);
+
+ terrain_mat.diffuse = Vec3(1, 1, 1);
+ terrain_mat.specular = Vec3(0, 0, 0);
+ terrain_mat.shininess = 40;
+ terrain_mat.dtex = terrain_tex;
+ terrain_mat.name = "tt";
+
+ terrain.material = terrain_mat;
+
+ terrain_rend = new Renderer;
+ terrain_rend->camera = camera;
+ terrain_rend->scene = terrain.get_visible(camera);
+
+ skybox_tex = gfx_create_texture();
+ skybox_tex->load("data/cubemap/cubemap.hdr");
+ terrain_rend->set_sky_tex(skybox_tex);
+
+ irradiance_tex = gfx_create_texture();
+ irradiance_tex->load("data/cubemap/irradiance.hdr");
+ terrain_rend->set_diffuse_sky_tex(irradiance_tex);
+
+ if(!terrain_rend->create()) {
+ fprintf(stderr, "terrain fail\n");
+ return false;
+ }
+ terrain_rend->fog_density = fog_density;
+
+ cow_scene = new Scene;
+ if(!cow_scene->load("data/spot/spot.obj")) {
+ fprintf(stderr, "Failed to load scene: spot.obj.\n");