
Cellular
Texture Components
This page presents some of Steve Worley's Cellular Texture Basis
Functions (CTBF) implemented as additional components for DarkSim's DarkTree 2.5 procedural
shader creation software. Although DarkTree already contains DarkSim's
own implementation of many of these texturing functions, I created
these as a way to learn and experiment with the new DarkTree 2.5
Component API. I tried to throw in a few new features that aren't found
in DarkSim's original implementations (and the parameters are not
necessarily the same). I am also making the source code available so
other programmers might benefit in some way from my experimentation. I
am hoping that those 2 things will make these new components useful to
at least a few people.
The cellular.dll file included in this zip file was created with the DarkTree 2.5 Component API, and should work with DarkTree 2.5, all of the 2.5 Simbionts, and any application that uses the DarkTree 2.5 Engine. The 64-bit version of the component, cellular_64.dll, is now also included in this zip file.
Just place the cellular.dll file into your DarkSim\Components directory along with all the other existing .dll files. When you invoke the DarkTree Editor, you should now see a new Component group titled Cellular which contains 6 components: Cells, ChebyChev, Dented Cells, Fractal Cells, Fractal F2-F1, and Manhattan.
You will need the DarkTree 2.5 Component API to compile these source files into the cellular.dll shared library. The ctbf.cpp file contains Steve Worley's code from Texturing & Modeling, A Procedural Approach, 3rd edition (see the comments at the beginning of that file for copyright and usage information). The cellular.cpp file is the main file that defines what components will exist in the .dll file. The other files contain the code for each individual component. The only Windows compiler I am familiar with is Microsoft Visual C++, and the Makefile should allow any user of that software to compile and link all the files into the final shared library. Other compilers might be able to take advantage of that Makefile as well.
There are plenty of opportunities to add features to enhance these components, or add new components. I may also have implemented things in a little different way than it really should be, so there are many reasons you might want to modify this code. Unfortunately, I will have to apologize in advance about the fact that I didn't do a very good job of commenting my code. Hopefully it will still prove useful and educational.
To use these trees, you will definitely need the cellular.dll file to be located in your DarkSim\Components directory as described above.
There are many tweaks available in these trees (I always seem to go overboard adding tweaks). Here a few images and a short description about how the cellular components are used in these shader trees. If you develop a tree with one or more of the cellular components, send me some e-mail. I would love to see it and (with your permission) would be happy to add it to the examples on this page.
![]() |
Birds Eye Maple - A noisy sine wave is used as the blend function of a warped Cells component to form the birds eye patterns in this wood texture. |
![]() |
Circuit Board - A simple circuit board pattern based on techniques found in Skyler Swanson's circuit texture. This is mainly intended as just a test of the Dented Cells component and the ChebyChev distance metric. |
![]() |
Cobblestone - Two layers of the Fractal F2-F1 component is used to define the bumps for the stepping stones, and a randomizer region component is used with a Fractal F2-F1 for the color. A Cells component is used to color the dirt between the stones. |
![]() |
Cork - A simple texture that uses the Cells and Fractal Cells for colors, and Fractal Cells and Fractal F2-F1 components for bumps. |
![]() |
Old Cobblestone - A few variations on the CobbleStone texture to provide a more weathered, well-trodden version of the stone path. |
![]() |
Pine Bark - Several instances and layers of the Fractal F2-F1 component for color, diffuse and bump channels. |
![]() |
Stream Bed - The bump channel uses Fractals Cells and Dented Cells as the foreground and background bumps for the Fractal F2-F1 component. Fractal F2-F1 is used for color, diffuse and specular channels. |
And here are a few more shader trees that have been created since the original release of this web page. You can download the individual .dsts files by clicking on the appropriate link preceding the description of each tree.
![]() |
RockyField.dsts Rocky Field - Several Fractal Cells and Fractal F2-F1 components in this shader. The grass is DarkTree's Scratches component. |
![]() |
Asteroid.dsts Asteroid - Cells components for the craters. Dented Cells and Fractal Cells for the surface crust. The image shown here was created in Lightwave, demonstrating that these cellular components work just fine with the DarkTree 2.5 simbionts. |
![]() |
CellularTest.dsts Cellular Test - This shader was created by Skyler Swanson. It is an example of the cellular Manhattan component combined with DarkTree's Tech component. |
In 1985, Ken Perlin's fractal noise basis function became the primary tool for procedural texturing. In 1996, Steve Worley presented a paper at SIGGRAPH that proposed a new set of procedural texture basis functions. In summary, Steve's cellular functions calculate the distance between the point being shaded and random "Feature Points" scattered throughout 3D space. If we consider the current point being shaded, there is some Feature Point that is closer to it than all the other Feature Points in space. F1 is defined to be the distance from the current point to that closest Feature Point. At certain critical locations, the current point will be equidistant from two Feature Points. These cusp locations are the most interesting, and provide the basis for the visual effects that these textures can produce.
Extending this another step, F2 is defined to be the distance between the current point and the second closest Feature Point. These nth closest Feature Point calculations can be made for any value of n, but Steve notes that the patterns are not as varied and interesting beyond F5, so these DarkTree components only support F1 through F5 calculations. The Cells component in this distribution is the simple implementation of these Feature Point calculations.
Fractal variations of these Feature Point calculations also provide interesting ways to enhance the visual effects produced by these textures. the Fractal Cells and Dented Cells components in this distribution provide some fractal variations of these textures. You will also find fractal calculations (the Octave parameter) in some of the other components described below.
Other metrics besides the standard Euclidean distance can be used to calculate the numeric "distance" between points (actually by default, the Euclidean distance squared is used so that a little calculation time can be saved by not having to calculate a square root). The Manhattan and ChebyChev components use those distance metrics during the Feature Point calculation. Another distance metric I wanted to experiment with called "Quasi-Euclidean" can be found as a parameter in the Dented Cells component (it would be very easy to create a standalone QuasiEuclidean component similar to the Manhattan and Chebychev components, but I left that task as an exercise for the interested programmers in the audience :-). The Cells component also has a Conical profile check box parameter which uses the actual Euclidean distance rather than the distance squared calculation.
And finally, mathematical combinations of the Feature Point calculations are also possible, and the Fractal F2-F1 component is an implementation of probably the most interesting of these combinations.
A detailed description and application examples can be found in Worley's 1996 SIGGRAPH paper "A Cellular Texture Basis Function" and especially in the 2003 book Texturing & Modeling, A Procedural Approach, 3rd edition. And just to provide some information that can be found online, here is a link to Michael Monks' presentation about the texture functions.