Graphics Reference
In-Depth Information
Appendix A
GL_HALF_FLOAT
GL_HALF_FLOAT is a vertex and texture data type supported by OpenGL
ES 3.0. The GL_HALF_FLOAT data type is used to specify 16-bit floating-point
values. This can be useful, for example, in specifying vertex attributes such
as texture coordinates, normals, binormals, and tangent vectors. Using
GL_HALF_FLOAT rather than GL_FLOAT provides a two times reduction in
memory bandwidth required to read vertex or texture data by the GPU.
One might argue that we can use GL_SHORT or GL_UNSIGNED_SHORT
instead of a 16-bit floating-point data type and get the same memory
footprint and bandwidth savings. However, with that approach, you will
need to scale the data or matrices appropriately and apply a transform
in the vertex shader. For example, consider the case where a texture
pattern is to be repeated four times horizontally and vertically over
a quad. GL_SHORT can be used to store the texture coordinates. The
texture coordinates could be stored as a value of 4.12 or 8.8. The texture
coordinate values stored as GL_SHORT are scaled by (1 << 12) or (1 << 8)
to give us a fixed-point representation that uses 4 bits or 8 bits of integer
and 12 bits or 8 bits of fraction. Because OpenGL ES does not understand
such a format, the vertex shader will then need to apply a matrix to
unscale these values, which affects the vertex shading performance. These
additional transforms are not required if a 16-bit floating-point format is
used. Further, values represented as floating-point numbers have a larger
dynamic range than fixed-point values because of the use of an exponent
in the representation.
Note: Fixed-point values have a different error metric than floating-point
values. The absolute error in a floating-point number is proportional
to the magnitude of the value, whereas the absolute error in a
 
 
Search WWH ::




Custom Search