Skip main navigation

Colours in Virtual Worlds

How would you describe a colour to a computing device?
17.7
In this session, we’re going to learn about colours. This is one of the core concepts for working with virtual worlds, so let’s begin. All objects in a virtual world have a colour associated with them. For example, take a look at this scene. Colour can be used to communicate an intent, an affordance, or an aesthetic for a given object, so Colour becomes very important. The difficulty is representing Colour in a numerical way, which a computer can store and display in a way that humans expect it to look like. For example, what do you think is the Colour of this object? While there are many ways to describe colours, the most common format is the RGB format.
56.8
This is based on the additive Colour theory, which assumes that all perceptible colours can be made by combining the wavelengths of the primary colours, red, green, and blue. The contribution of each primary Colour determines how the Colour looks to a human. For computers, this simplifies storage, too. By assigning a byte to each Colour, a computer system can represent a total of 16 million colours using just 3 bytes. Given 1 byte can encode 256 values, we get 256 red values times 256 green values times 256 blue values. This leaves us with a total of 16 million possible colours. The hexadecimal numbering system is a base 16 system which uses 0 to 9 and the letters A to F to represent numbers.
104.5
For graphics, the three bytes of Colour are usually represented in hex. AFrame uses a system similar to HTML for specifying colours. HTML supports the definition of RGB triplets that are prefixed by a hashtag. So for example, the Colour white would be hashtag followed by six F’s. It also supports named colours, such as papayawhip, peachpuff and tomato. You can use named colours or hex codes interchangeably. For example, the result of the first block, which uses named colours, is the same as the result of the second block, which uses hex codes. Objects in the real world can be transparent. Similarly, virtual worlds support varying levels of transparency and opacity. In summary, colours communicate and intent, an affordance, or an aesthetic.
157.4
Colours can be defined by using hex triplets or named Colours, and transparency and opacity are named attributes that also need to be set.
Concept of Colours

This video introduces the concept of codifying colour into numerical values. Using these numerical representations, any virtual object can be given a colour.

Source-code of example used in video is available in “See Also” section below.

This article is from the free online

Construct a Virtual Reality Experience

Created by
FutureLearn - Learning For Life

Our purpose is to transform access to education.

We offer a diverse selection of courses from leading universities and cultural institutions from around the world. These are delivered one step at a time, and are accessible on mobile, tablet and desktop, so you can fit learning around your life.

We believe learning should be an enjoyable, social experience, so our courses offer the opportunity to discuss what you’re learning with others as you go, helping you make fresh discoveries and form new ideas.
You can unlock new opportunities with unlimited access to hundreds of online short courses for a year by subscribing to our Unlimited package. Build your knowledge with top universities and organisations.

Learn more about how FutureLearn is transforming access to education