title: Converting 8 bit color into RGB value
body: <p>I'm implementing global illumination in my game engine with "reflective shadow maps". RSM has i.a. color texture. To save memory. I'm packing 24 bit value into 8 bit value. Ok. I know how to pack it. But how do I unpack it? I had idea to create a 1D texture with 8 bit palette, with 255 different colors. My 8 bit color would be index of pixel in that texture.
  I'm not sure how to generate this kind of texture.
  Are there any mathematical ways to convert 8 bit value into rgb?</p>
  
  <p>@edit
  The color is in this format:<br>
  <kbd>RRR GGG BB</kbd></p>
  
  <p>@edit2:
  And I'm packing my colour like this:    </p>
  
  <pre><code>int packed = (red / 32 &lt;&lt; 5) + (green / 32 &lt;&lt; 2) + (blue / 64);
  //the int is actually a byte, c# compiler is bitching if it's byte.
  </code></pre>
  
  <p>@edit3:<br>
  Alright, I found a way to do this I think. Tell me if it's wrong.</p>
  
  <p>@edit4 It's wrong...   </p>
  
  <pre><code>int r = (packed &gt;&gt; 5) * 32;    
  int g = ((packed &gt;&gt; 2) &lt;&lt; 3) * 32;    
  int b = (packed &lt;&lt; 6) * 64;
  </code></pre>