Sign in to follow this  
4fingers

Procedural textures and fractals

Recommended Posts

I wanted to do Procedural textures as my project at Uni and emailed one of my lecturers if he knew anything about them. He replied by saying that Procedural textures sounds like fractals, or mathematical functions (the latter are used for 3D textures where you can’t just store an image). What is the difference between fractals and Procedural textures? Are they ever used in games for example?

Share this post


Link to post
Share on other sites
Fractals can be used to generate procedural textures, but not all procedural textures are fractal in nature. 'Mathematical function' matches more closely with the notion of a procedural texture, but it's difficult to draw a genuine parallel, as the two terms arise in very different fields and are studied differently.

A fractal is any geometric form that is self-similar with regards to scaling. The mathematical concept of a fractal pivots on an object being indistinguishable when viewed from two different scales. By induction, this means that the object is infinite in magnitude and will appear the same under arbitrary magnification or minification. The idiomatic definition is much looser. For example, a tree could be described as a (finite) fractal, as its twigs resemble its branches which resemble its trunk. Other examples in nature include snowflakes, coastlines and lung infrastructure.

A procedural texture is any digital image (usually two-dimensional, but not necessarily) that is defined by a generating-algorithm, rather than an array of pixels. As very simple example in pseudo-C would be:

Colour ProceduralPeriodicGradient(int x, int y) {
Colour pixel;
pixel.red = 0.0;
pixel.green = 1.0;
pixel.blue = (float) x / 100.0;
return pixel;
}
Here, we describe the colour of any pixel in terms of its coordinates by means of an algorithm/procedure (hence we have defined it procedurally). Using this function, we can create the texture as a bitmap without ever having to store hard pixel values.

It would be very difficult to write a procedure to generate an image of, say, a telephone, but much easier to create a lunar terrain. Many patterns in nature are generated by physical processes and so they can often be neatly described in an algorithm. Notably, many such images are fractal in appearance, and can thus be approximated very well using a recursive function.

For these reasons, we tend to see procedural textures used far more often in scenarios requiring a fractal-like image, which is why the two are linked and sometimes confused. However, their two definitions don't overlap at all.

Many games employ procedural texturing. Commonly, one will procedurally generate textures for their cloud-scape, terrain height-maps, fog and other organic patterns. The reason they are considered superior to traditional textures is that the function describing the texture may only be a few bytes in size, whereas the texture itself may be several megabytes. Furthermore, the algorithm will often allow the texture to be generated at any scale required. In this way, we can trade storage and memory-consumption off against processing/loading time.

Admiral

Share this post


Link to post
Share on other sites
Probably the best source of info on procedural textures is this book:

http://www.texturingandmodeling.com/


You should also download Terragen:

http://www.planetside.co.uk/terragen/

and play with it for a couple of minutes. That should give you the idea what procedural content really is.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this