Skip to content

Pigments

Pigments are the objects that describe the color of the different shapes. They are used in BRDFs to specify both the diffuse color and the emitted one.

Uniform

The simplest pigment available is the uniform one. It is used to make the shapes appear as homogeneously coloured objects.
A color is defined by three floats (better if in the range [0, 1]), that describe the three components RBG, within <>.
Some of the most common colors can be called also with its HTML name, always included within <>. The list of the available names is updated here.

material sky ( 
        diffuse ( uniform(<skyblue>) ), 
        uniform(<skyblue>)
)
...
Uniform shapes, ground and sky

Image

Not all the shapes, though, will be monochromatic. Sometimes something more complex is what you need to make you image appear realistic. For example, colouring a sphere with the map of the world will make it resemble the earth.
In this case an image pigment is what you need. You only need to have a PFM file with the image you want to apply to the shape and define your material.

material earth ( 
        diffuse ( image ( "earth.pfm" ) ), 
        uniform(<black>)
)
...
Earth is placed in the universe, both textured with image pigments

Procedural Pigments

Some kind of pigment can be generated with the help of mathematical functions, the evaluation of which returns the color of each point of the surface of the object. Sometimes, with the help of a pseudo-random noise you can generate very fancy effects!

Checkered

This is the easiest procedural pigment and is often use in debug process. It produces a texture like the one of a chess board.
Of course, you may set the 2 colors of tiles, and their number per side. Usually this pigments makes great grounds, that let you understand better if your world is set as you like.

material ground ( 
        diffuse( 
            checkered( 
                <black>,        #Color 1
                <white>,        #Color 2
                12              #n of tiles per side
            )
        ),
        uniform(<black>)
)
...
The checkered ground makes the object more visible

Marble

Thanks to the Perlin noise it is possible to use some functions to evaluate the color of surface points as if the object was made of marble. Since this is an advanced pigment, it is provided also of a default setting that you can use by simply defining the pigment as marble().
Otherwise, you can play with some parameters to custom your marble pigment:

  • c1 Background color of marble (recommended is white)
  • c2 Veining color of marble, you may change this to slightly modify the marble look toward this color
  • xPeriod Number of vertical veining lines
  • yPeriod Number of horizontal veining lines. Together with xPeriod defines the orientation of the stripes
  • turbPower Intensity of the twists to apply to the lines to make veins more realistic
  • octaves Number of octaves summed, more octaves mean blurrier texture (must be a power of 2)
material marbleMat (
    diffuse( marble() ),
    uniform(<black>)
)
material marbleMat (
    diffuse(
        marble(
            <white>,        #c1 
            <black>,        #c2 
            1.0,            #xPeriod 
            2.0,            #yPeriod
            3.0,            #turbPower 
            512             #octaves
        )
    ),
    uniform(<black>)
)

Wood

With a different repetition of the lines, this time concentric, and with different colors, Perlin noise based texture can be made into wood textures. Once again default setting is provided, but you can customize your wood as you like. Parameters are similar to those of marble, but for the period parameter xyPeriod , that this time is unique, and is the number of circles of wood's vein.

material woodMat (
    diffuse( wood() ),
    uniform(<black>)
)
material woodMat (
    diffuse(
        wood(
            <darkbrown>,    #c1 
            <black>,        #c2
            13.0,           #xyPeriod
            0.15,           #turbPower 
            512             #octaves
        )
    ),
    uniform(<black>)
)

Lava

Another available pigment is a lava-like one, with color from reddish brown to yellow. For this pigment too there's the default one. For lava pigment only two parameters are customizable:

  • scale Sets the detail of the noise. Higher value reflects in more detailed noise and therefore into more fragmented lava style.
  • octaves Number of octaves summed, more octaves mean blurrier texture (must be a power of 2)
material lavaMat (
    diffuse( lava() ),
    uniform(<black>)
)
material lavaMat (
    diffuse(
        lava(
            4.0,            #scale
            512             #octaves
        )
    ),
    uniform(<black>)
)
Wood, Marble and Lava pigments
Back to top