Difference between revisions of "Shader Attribute Descriptors"
From GiderosMobile
(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...") |
|||
Line 1: | Line 1: | ||
Each attribute descriptor entry is a Lua table with the following fields: | 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 | + | * 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 | + | * 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 | + | * mult: number of components of the input vector |
− | * slot: index of the input slot (HLSL only) | + | * slot: index of the input slot (HLSL only) |
− | * offset: offset within the input slot (HLSL only, should be 0) | + | * offset: offset within the input slot (HLSL only, should be 0) |
The first three attributes have fixed meaning. Those are, in order: | 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.''' | + | '''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.''' |
Revision as of 06:37, 4 November 2023
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.