How do I add up Color Values of Textures with Different Resolutions?

How do I add up the black and white color values of textures with different resolutions?

Example:

alt text + alt text =
alt text

NOTE: these textures are their apparent resolutions; I have just resized them for visualization.

We will need to find the color array of the first image, and somehow “add” it to the color array of the second image, and so on until complete. Then, store the final color values array.

The resolution of the highest resolution image will always be the resolution of the final product image, of course.

Does anyone know exactly how to do this?

Thanks.

Just out of interest, why are you doing this? In any case, I’d assume that the correct method would be to scale up the smaller images and then just add the images in whatever way you choose (shader, manual addition on every element of the color array, etc.).

To resample the texture, you could create a new texture, and then use

newTexture.SetPixel(x, y, oldTexture.GetPixel(x / 2, y / 2));

for each pixel in the new texture. I’m pretty sure this would be quite slow.

Another option would be to use a shader for this. Is there any reason why you can’t just use a subtractive shader that takes several texture inputs?