title: Can I put a R8G8B8A8 in a UBO, and use it as a vec4?
body: <p>I try to optimize a working compute shader. Its purpose is to create an image: find the good color (using a little palette), and call <code>imageStore(image, ivec2, vec4)</code>.</p>
  
  <ul>
  <li>The colors are indexed, in an array of uint, in an UniformBuffer.</li>
  <li>One color in this UBO is packed inside one uint, as {0-255, 0-255, 0-255, 0-255}.</li>
  </ul>
  
  <p>Here the code:</p>
  
  <pre><code>struct Entry
  {
      *some other data*
      uint rgb;
  };
  
  layout(binding = 0) uniform SConfiguration
  {
      Entry materials[MATERIAL_COUNT];
  } configuration;
  
  void main()
  {
      Entry material = configuration.materials[currentMaterialId];
  
      float r = (material.rgb &gt;&gt; 16) / 255.;
      float g = ((material.rgb &amp; G_MASK) &gt;&gt; 8) / 255.;
      float b = (material.rgb &amp; B_MASK) / 255.;
  
      imageStore(outImage, ivec2(gl_GlobalInvocationID.xy), vec4(r, g, b, 0.0));
  }
  </code></pre>
  
  <p>I would like to clean/optimize a bit, because this color conversion looks bad/useless in the shader (and should be precomputed). My question is:</p>
  
  <ul>
  <li>Is it possible to directly pack a <code>vec4(r, g, b, 0.0)</code> inside the UBO, using 4 bytes (like a R8G8B8A8) ?</li>
  </ul>