   [SOLVED] Color reduction / Generating optimized palette
  Hi,does anyone know how to do this properly? I need to write some (c++) code that compresses a number of 24-bit colors to a palette representation, finding the set of colors that most accurately represents the source image (without using any dithering, this is important). I've googled but it almost seems like an lost art. Just about every hit is about how you do it using photoshop or similar. Any tips?[Edited by - simonjacoby on May 26, 2010 3:07:17 AM]
  Nevermind, I found a different way to solve my problem :)   ;  Would you mind telling us what your problem actually was and how you solved it?   ;  Sure. I was looking for ways of minimizing the size of the vertex format I'm using. Instead of storing the vertex color explicitly as a DWORD (as is common practice), I thought I might use a palettized approach, and only store the index to a color in each vertex. By doing this (and lots of other tricks), I would be able to shrink the vertex size to 16 bytes. The vertex would then include position, color, UV-coords, normal and tangent, which is everything I needed for my meshes.However, one of the problems with this approach would be to supply the palette for every mesh instance. Using shader registers is too wasteful (and costly), and using a texture would require a texture read for each vertex, which also is too costly. Also, it would add complexity and overhead to batching and instancing.Instead, I opted to simply pack the color into 10 bits, using a 3:4:3 "packed pixel" approach, storing each color channel explicitly. Thanks to the interpolation of vertex colors over each triangle, it isn't noticeable for what I'm doing.