   Procedural textures - Perlin noise
  Hello!I would like to map "marble" texture on cube.I found this function:double PerlinNoise ( double xyz[3], double freq, double pers, double octaves);function returns values from interval [0..1].I don't know how to map this to the cube.My First idea was:Create 128x128 bitmap and call "PerlinNoise" for each pixel.Then map image the usual way.I am not sure that I am on the right way to achieve my goal.Any help appreciated.Thanks   
  Your idea of making a texture map is fine. This way you only need to sample along the surface of the cube, saving tons of time by not sampling the interior space. If you created a 128x128 texture for each side, that would work perfectly.The xyz parameter denotes a point in space which is essentially used as the noise function seed.The easiest example would be to use the corner vertex locations of the cube. So, you pass all 8 of them one-by-one into the noise function, and you get a colour value back for each. This essentially gives you a texture of 2x2x2 dimensions, one colour per vertex (there's 2^3 vertices in a cube).That doesn't give you much texture detail, but you can sample as many points as you want. If you were to logically divide each face into a 32x32 grid by sampling at points between the vertices, your texture would be much finer.I'm not sure if you're familiar with the concept of a scalar (or vector) field in mathematics. If you aren't, take a quick peek on wikipedia for them. It's the best way to explain this concept of subdividing space.For instance, here is the method for generating the sample points along a single face (assume that Z is -0.5 or 0.5):;  Thanks for quick reply...Quote:Original post by tabyYour idea of making a texture map is fine. This way you only need to sample along the surface of the cube, saving tons of time by not sampling the interior space. If you created a 128x128 texture for each side, that would work perfectly.The xyz parameter denotes a point in space which is essentially used as the noise function seed.Do I really have to create texture for each side of the cube?What if I have a cylinder with 12-sides or even more complex object like:http://www.noisemachine.com/talk1/Quote:Original post by tabyThe easiest example would be to use the corner vertex locations of the cube. So, you pass all 8 of them one-by-one into the noise function, and you get a colour value back for each. This essentially gives you a texture of 2x2x2 dimensions, one colour per vertex (there's 2^3 vertices in a cube).I understand this, but as you said I only get color value for those 8 vertices.Quote:Original post by tabyThat doesn't give you much texture detail, but you can sample as many points as you want. If you were to logically divide each face into a 32x32 grid by sampling at points between the vertices, your texture would be much finer.If I understand this correctly, then I should subdivide each poly (now I have 6 polys - Top, Bottom, Front, Back, Left, Right)Is this the only way?I am loading a lot of objects into the scene and this would slow down framerate for my "game".Quote:Original post by tabyI'm not sure if you're familiar with the concept of a scalar (or vector) field in mathematics. If you aren't, take a quick peek on wikipedia for them. It's the best way to explain this concept of subdividing space.I am familiar with term vector (I was listening mathematics at the university).Any examples (I am using OpenGL/C++).I found this: http://www.gamedev.net/reference/articles/article2085.aspIs this what I need to study?Thanks;  You only have to make the textures once, before the gameplay begins. Or if you want to cut that time out too, then make the textures at build time and distribute them with the game.   