// // procedual.cc // // Procedural texture testbed // // Copyright (C) J. Belson 2000.03.06 // #include #include #include "texture.h" #include "perlin.h" #include "procedural.h" #include "types.h" /** * Initialisation routine for textures which use * perlin noise */ void proc::init_perlin(void) { p.set_seed(clock()); p.set_freq_scale(10.0); p.set_persistence(0.5); } /** * Attempt at grass covered ground */ fcolour proc::grass(float s, float t) { float ss = s; //floor(s); float tt = t; //floor(t); float val = p.perlin_noise_2d(ss, tt); float mixer = texture::smooth_step(val, -0.4, 0.4); //mixer += 0.2; if (mixer < -1.0 || mixer > 1.0) { std::cout << "PANIC!!" << std::endl; } //cout << "mixer = " << mixer << endl; //return texture::mix(fcolour(0.1, 0.7, 0.1), fcolour(0.25, 0.25, 0.25), mixer); //return texture::mix(fcolour(0.47, 0.52, 0.25), fcolour(0.25, 0.25, 0.25), mixer); // Use mixer as alphablend #if 0 float blend_r = 0.32; //0.47; float blend_g = 0.38; //0.52; float blend_b = 0.20; //0.25; float r = 0.45; float g = 0.45; float b = 0.45; #endif float blend_r = /*0.70;*/ 0.47; float blend_g = /*0.70;*/ 0.52; float blend_b = /*0.70;*/ 0.25; float r = 0.30; float g = 0.30; float b = 0.30; r = (1.0 - mixer)*r + (mixer)*blend_r; g = (1.0 - mixer)*g + (mixer)*blend_g; b = (1.0 - mixer)*b + (mixer)*blend_b; return fcolour(r, g, b); }