title: (How) can a scalar be cast to another scalar without conversion in GLSL?
body: <p>(How) can a scalar be cast to another scalar without conversion in GLSL?</p>
  
  <p>The definition of "cast" used in this question is changing the interpretation of the exact same data without changing the data itself, assuming the two types are of the same number of bits. i.e. (float)B00101111 == B00101111</p>
  
  <p>The definition of "conversion" used in this question is changing both the interpretation of the data as well as reformatting said data to some mathematical approximation of the original value, i.e.  (float)1 == 1.0</p>
  
  <p>5.4.3 of GLSL 4.30.6 spec implies that scalar float-to-int and int-to-float constructors perform only conversion:
  <em>"When constructors are used to convert any floating-point type to an integer type, the fractional part of the
  floating-point value is dropped."</em> - pg. 87</p>
  
  <p>Another nail in the coffin is with this line on section 5.1, pg. 85:
  <em>"There is no typecast operator; constructors are used instead."</em></p>
  
  <p>The goal is to use a Buffer-Texture/Texture-Buffer and texelFetch(...) to obtain float vec4s (128bit) and fill a struct such as:</p>
  
  <pre><code>struct MyStruct
  {
  int foo; //32bit
  float bar; //32bit
  int baz; //32bit
  short blah; //16bit
  short hmm; //16bit
  } // 128bit total
  </code></pre>
  
  <p>...but there is trouble pinning down how to break apart that vec4 into the binary sub-chunks and re-cast them to set said struct values.</p>
  
  <p>Would the following, in theory work?</p>
  
  <pre><code>MyStruct myUuberChunk = MyStruct(myVec4);
  </code></pre>
  
  <p>The rationale behind using float vec4s (or int vec4s for that matter), pending it is correct, is to get all values in one 128bit fetch for bandwidth performance purposes (most cards have four 32-bit memory buses).</p>