Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is the difference between matrix and float4x4 in HLSL

Tags:

directx

hlsl

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?

like image 849
HUAQ Avatar asked Oct 17 '25 05:10

HUAQ


1 Answers

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

like image 200
Chuck Walbourn Avatar answered Oct 19 '25 14:10

Chuck Walbourn



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!