Average Color of TIles

Started by
4 comments, last by The Only 20 years, 4 months ago
hi! I''m trying to programe a mini map, which shows a big map on a small texture, as you know in AoE eg. For that, I try to get the average Color of every TIle which is used in the big map. I lock the texture for that an try to get out all color components. I sum all components for every texture pixel. Then i divide them with the number of texture Pixels. It works, but the results are not very good... sometimes the colors dont seem to be like the original texture. For example a green Texture-Tile is on the minimap somethin glike darkpurple Is there another way to calculate the color?
Advertisement
Lock the last level of the texture, assuming you used full mipmaps, it will be the final 1x1 representation of the texture.
But i dont use MIPs, because i dont need to resize the textures, i use 2D
I was afraid you''d say that.

Are you sure you''re summing the values for each channel correctly? As unsigned, and into a type large enough (32 bit should be fine, 16 bit isn''t enough, and 8 bit certainly isn''t enough)?

Green grass going to dark purple would imply your green wrapped around back to near 0, or was though of as a negative value.

The average value should be fine in most tiles.
For every tile in the map
--Scale tile to 1 pixel square
--Render tile

Depends on your tiles.. If they are square, this should work.
If you're doing 3D, ignore this post.

--
You're Welcome,
Rick Wong
- sitting in his chair doing the most time-consuming thing..

[edited by - Pipo DeClown on December 16, 2003 2:21:31 PM]
The red, green, and blue values are packed into a single 32-byte value (with 8 bits extra padding/alpha). I suspect that you are adding these values. Rather you need to split up the 32-byte value (an unsigned long, right) into three different 8-bit components, and then add and average each of the components seperately . Then repack them.

This topic is closed to new replies.

Advertisement