// // texture_rough.cc // // Procedural rough ground texture. // // Copyright (C) J. Belson 2003.09.27 // // $Id: texture_rough.cc,v 1.1 2003/10/11 18:11:00 jon Exp $ // #include #include "texture_rough.h" /** * Constructor. */ texture_rough::texture_rough(const textset_noise& ts) : texture(ts) { noise = new perlin; noise->set_seed(ts.seed); noise->set_freq_scale(10.0); noise->set_persistence(ts.persistence); } /** * Deonstructor. */ texture_rough::~texture_rough() { delete noise; } /** * Calculate colour at specified point. * @param s Texture coordinate. * @param t Texture coordinate. * @param u Texture coordinate. * @return Colour at specified point. */ fcolour texture_rough::colour(float s, float t, float, vector3d* normal) { assert(normal); float val = noise->perlin_noise_2d(s, t); //float mixer = texture::smooth_step(val, -0.4, 0.4); // Use mixer to alphablend //float blend_r = 0.32; //0.47; //float blend_g = 0.38; //0.52; //float blend_b = 0.20; //0.25; float r = 150/255.0; float g = 125/255.0; float b = 100/255.0; // r = (1.0 - mixer)*r + (mixer)*blend_r; // g = (1.0 - mixer)*g + (mixer)*blend_g; // b = (1.0 - mixer)*b + (mixer)*blend_b; val /= 3.0; // Perturb normal vector according to val normal->i += val; normal->j += val; normal->k += val; normal->normalise(); return fcolour(r, g, b); }