4

When I define the cBuffer in hlsl, some examples shows

cbuffer cbPerObject
{
  matrix worldMatrix;
  matrix viewMatrix;
  matrix projectionMatrix;
};

And the other shows

cbuffer cbPerObject
{
  float4x4 worldMatrix;
  float4x4 viewMatrix;
  float4x4 projectionMatrix;
};

Does it means that type of matrix can have unlimited elements but float4x4 can just hold the first 16 elements?

which one do you prefer in HLSL?

Divyang Desai
  • 7,483
  • 13
  • 50
  • 76
HUAQ
  • 41
  • 5

1 Answers1

4

To support older DirectX 8 era HLSL programs, matrix by itself is a typedef for matrix<float,4,4>. BTW, float4x4 is also a typedef for matrix<float,4,4>.

See HLSL, User-Defined Type

Chuck Walbourn
  • 38,259
  • 2
  • 58
  • 81