Shader Attribute Descriptors

From GiderosMobile
Revision as of 16:33, 2 July 2020 by Anthony (talk | contribs) (Created page with "Each attribute descriptor entry is a Lua table with the following fields: * name: the name of the attribute/vertex data stream. Must match the name used in GLSL and HLSL code...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Each attribute descriptor entry is a Lua table with the following fields:

  • name: the name of the attribute/vertex data stream. Must match the name used in GLSL and HLSL code.
  • type: data type used from the host point of view. One of Shader.DFLOAT, Shader.DBYTE, Shader.DUBYTE, Shader.DSHORT, Shader.DUSHORT or Shader.DINT.
  • mult: number of components of the input vector.
  • slot: index of the input slot (HLSL only).
  • offset: offset within the input slot (HLSL only, should be 0).

The first three attributes have fixed meaning. Those are, in order:

  • The vertex coordinate stream. Type must be Shader.DFLOAT and mult should be 3.
  • The per-vertex color. Type must be Shader.DUBYTE and mult should be 4.
  • The texture coordinates. Type must be Shader.DFLOAT and mult should be 2.

If one of these fixed attributes is not used by the custom shader program, it should still be defined with a mult value of 0 to serve as a placeholder.