For better visualization of how the cubemap is mapped to the screen using a certain lens, I wanted to employ a rubix cube color, displaying a grid over the cubeface as sort of an indicatrix of the projection. I wanted to do this using translucent colors.
Quake has a color palette, and all pixels on the rendered cubefaces are indexes to this color palette. Eventually, these color indices are used to retrieve the RGB value of the element in the color palette. When you jump in the water, a separate color palette is used to simulate the murky colors you would see underwater. This is done by precomputing a different color palette by taking a weighted RGB average between the original color and the color of the water.
I do not believe this is an option when wanting to shift the palette of only a certain portion of the screen. Rather, one can apply alpha compositing by creating a mapping from each original color to a slighly bluer color, or a slightly redder color on the same palette. This creates a palette mapping, completely onto itself. It seems to be small and fast.
The palette maps are currently created by averaging the original color and a target color in RGB space, and then selecting the nearest color on the original palette, using euclidean RGB distance.
The question we are left with is if the small errors in color in some areas are a result of the limited color palette, the weighted average in RGB space, or the nearest color algorithm in RGB space. This is hardly significant enough for a project like this, but it's interesting that the RGB space is incorrect for nearest color matching. Apparently the three dimensions of color perception for humans are Lightness, Red vs Green, and Blue vs Yellow, not RGB. These are used by the Lab color space, and is stated in the wikipedia article on color quantization as the most used nearest color matching algorithm.
There is python-colormath library for converting between color spaces, as well as computing color differences using all the common methods. I may use this library to precompute the color palette maps.
For better visualization of how the cubemap is mapped to the screen using a certain lens, I wanted to employ a rubix cube color, displaying a grid over the cubeface as sort of an indicatrix of the projection. I wanted to do this using translucent colors.
Quake has a color palette, and all pixels on the rendered cubefaces are indexes to this color palette. Eventually, these color indices are used to retrieve the RGB value of the element in the color palette. When you jump in the water, a separate color palette is used to simulate the murky colors you would see underwater. This is done by precomputing a different color palette by taking a weighted RGB average between the original color and the color of the water.
I do not believe this is an option when wanting to shift the palette of only a certain portion of the screen. Rather, one can apply alpha compositing by creating a mapping from each original color to a slighly bluer color, or a slightly redder color on the same palette. This creates a palette mapping, completely onto itself. It seems to be small and fast.
The palette maps are currently created by averaging the original color and a target color in RGB space, and then selecting the nearest color on the original palette, using euclidean RGB distance.
The question we are left with is if the small errors in color in some areas are a result of the limited color palette, the weighted average in RGB space, or the nearest color algorithm in RGB space. This is hardly significant enough for a project like this, but it's interesting that the RGB space is incorrect for nearest color matching. Apparently the three dimensions of color perception for humans are Lightness, Red vs Green, and Blue vs Yellow, not RGB. These are used by the Lab color space, and is stated in the wikipedia article on color quantization as the most used nearest color matching algorithm.
http://en.wikipedia.org/wiki/Color_difference
There is python-colormath library for converting between color spaces, as well as computing color differences using all the common methods. I may use this library to precompute the color palette maps.