Archive
Colorblindness simulation in the Source engine
While making a Portal 2 map last month, Robert Yang asked:
Was choosing “red” a bad idea / horribly insensitive to colorblind people? Like, will they be able to distinguish the non-portalable metal plating from the stone walls? I don’t want a BioShock 2 debacle on my hands.
This gave me an idea. I knew there was research into simulating the effects of colourblindness, and had come across applications that implemented the method from that paper: Color Oracle for one. I also knew that the Source engine supported colour mapping. So why not combine the two, to simulate colourblindness in game?
Putting the bits together
Colour mapping in the Source engine is done with the color_correction entity. You can start the game—Team Fortress 2 for example—in “tools” mode to create and save a colour map file. You then create a color_correction entity in your map within Hammer, and configure it to use your colour map file. But the tools for creating colour maps are fairly basic, and I needed more.
So I wrote a short Python script to convert a colour map to a .tga image file, and vice-versa. I also set it up so it could generate an identity colour map file or image; that is, one in which every colour remains the same.
There are three common forms of colourblindness:
- Deuteranomaly/deuteranopia (red/green), which affects about 5% of men.
- Protanamoaly/protanopia (red/green), which affects about 2.5% of men.
- Tritanomaly/tritanopia (blue/yellow), which affects less than 1% of men and women.
The simulation that is done here is of the “anopia” forms, where one of the types of cones in the eye is missing or completely non-functional. The “anomaly” forms are less severe, but as I understand it, if your visual design is accessible to people with deuteranopia, it will be at least as good for people with deuteranomaly.
To create the colour maps for these, instead of doing the maths described in the paper, I converted the identity colour map to an image and opened it in Photoshop. I then used Color Oracle to view the image with each simulation, took a screenshot of each, and saved them back to .tga files. Finally, I converted each of the .tga files back into colour maps to use in the game.
Results
The last step was to put the necessary entities into my map to turn on colour correction with each colour map in turn, and test it out in the game. Here is each colour map image, with a screenshot of how it appears in-game:
Identity (normal appearance)
![]()

Protanopia
![]()

Deuteranopia
![]()

Tritanopia
![]()

Try it for yourself
I have posted the colour maps and the python script on GitHub. I have also included a prefab of the colour correction entities, so you can easily drop them into any map you’re working on.
One more thing
Because the script will convert any suitably-sized .tga to a colour map or vice versa, you are no longer limited to the tools Valve provides to create colour maps, but can use all the tools that Photoshop or any other image editor provides to adjust the colours in the image, then convert the result back to a color map for use in the game.
Blog comments powered by Disqus