Functional texture generation

I want to create a functional texture of marble and wood!!How can i do this?
I would appreciate if there is any sample code

What do you mean by functional? You could do a search on google and find a marble or wood image and then with an image manipulation program (the gimp is free) you can twist it around to what you want.
If you want to create a texture with mathematical functions then you should look for fractal generation.
Ela re Elladara!

The term is “procedural”. Fractals are one of many approaches.


thanks for the advices,but i want to create a 3D texture T(s,t,r) that is set in 3D space so that the object i want to create in this space(area) will look as if it was sculptured from a real material.I know that there is a function f_marble§=sin(2πx + 2πa*f_turb§) but i dont know how to illustrate it.

P.S.:Geia sou Ellada

Mmyep. Did you follow the links?

For example

Seriously google can find this in like three seconds, it really can.

well i have searched the links and in google,but i cannot found any particular code,they all describe algorithms in general.I search noise function and turbulence illustrated in opengl code. :frowning:

it’s in there. the links that arekkusu provided are excellent, the perlin one in particlar. there’s even an example of the marble function there, only it’s in 3d, which will require you to use your imagination a little :slight_smile: .

for 3d noise, you can think of the z as a stack of 2d pancakes. use the z to lookup the right pancake in the stack. it might fall between two pancakes, in that case, you interpolate, just like in 2d.

I have finally create a function for marble but i don’t know how can i use it in opengl!!
The function takes a point(x,y,z) and returns a float value for that point!In order to create an image from this function should i do something like:

GLubyte check[512][512][3];
int i,j;
for (i = 0; i < 512 i++) {
      for (j = 0; j < 512; j++) {
         c = function_marble;
         check[i][j][0] = (GLubyte) c;
         check[i][j][1] = (GLubyte) c;
         check[i][j][2] = (GLubyte) c;
         check[i][j][3] = (GLubyte) 255;

Thanx for any help!