I have implemented some commonly used textures. You can combine the textures to produce more complicated textures for example you can mask part of a texture and then have a gradient, bitmap or any other texture applied to those parts.

At the moment I have all textures return a <Colour> value. I wonder if there is a way to be able to include nodes that modify the texture like a gamma curve, apply some sort of filter etc., which can be added as a input to a texture.

Other things such as rotation, tiling in U and V directions can be added later to the base class <Texture>, currently rotation has only be implemented for the striped texture.

Below is an example of combining different textures to produce a more complex texture.

The mix texture works like an add between the first two textures and then a multiply of the mix texture with the first two. An example is shown in Photoshop of mixing red, and green, and gray. Note that the final colour is not (0.5, 0.5, 0) since gamma correction is applied to textures.

virtual Colour GetValue(float U, float V, Intersection&amp; HitPoint) const override
Colour colour1 = Colour1-&gt;GetValue(U, V, HitPoint);
Colour colour2 = Colour2-&gt;GetValue(U, V, HitPoint);
Colour mix_amount = MixAmount-&amp;gt;GetValue(U, V, HitPoint);
float value = (mix_amount.GetR() + mix_amount.GetG() + mix_amount.GetB())/ 3.0f;

return mix(colour1, colour2, value);



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s