Game Development Reference
In-Depth Information
Figure 76 - The offset calculated for the radian gradient.
We start by sampling the pixel at the heatmap image, we do this because we will want to
blend the colors additively to achieve the heat effect.
auto& sourcePixel = m_data[indexY * m_size + indexX ];
We get a reference to the pixel in the heatmap, it is important to make it a reference as we
will write into it later. The sourcePixel is 32-bit type that holds color information, we will
use it to construct a color entity in order to be able to perform some color arithmetic on it.
We also sample the gradient color data, and create a color entity for it.
const render::color destination = (grad * grad.A()) + source;
The final step is to do an additive blend between the color in the heatmap and the color in
the gradient, if you recall from the Blend Modes section, the additive blend is:
Whichispreciselywhatwearedoing,where a isthegradient'scolorgradand b istheheat-
map's color. Finally, we write this color back into the heatmap's source pixel reference.
Once we have added as many points as we need we will have built an intensity map, recall
that the radian gradient we used had colors ranging from black to white, the next operation
we want to perform is to colorize this intensity map. For this we will create a small helper
Search WWH ::




Custom Search