Sign in to follow this  
Pseudo

HLSL float3x3 constructor?

Recommended Posts

If you pass the float3x3 constructor 3 float3 vectors, does it treat them like colomn vectors or row vectors? for example: float3x3 mat = float3x3(A,B,C); is that: mat = {A.x,A.y,A.z, //row 1 B.x,B.y,B.z, //row 2 C.x,C.y,C.z} //row 3 or: mat = {A.x,B.x,C.x, //row 1 A.y,B.y,C.y, //row 2 A.z,B.z,C.z} //row 3 thanks in advance.

Share this post


Link to post
Share on other sites
Quote:
Original post by Pseudo
If you pass the float3x3 constructor 3 float3 vectors, does it treat them like colomn vectors or row vectors?

for example:
float3x3 mat = float3x3(A,B,C);

is that:
mat = {A.x,A.y,A.z, //row 1
B.x,B.y,B.z, //row 2
C.x,C.y,C.z} //row 3

or:
mat = {A.x,B.x,C.x, //row 1
A.y,B.y,C.y, //row 2
A.z,B.z,C.z} //row 3


thanks in advance.


The constructer takes rows.

Note, however that for uniform parameters HLSL default packing order is COLUMN, though this can be changed by using the row_major usage modifier.

Share this post


Link to post
Share on other sites
Get documentation from
http://www.opengl.org/documentation/oglsl.html
On page 35 you can see
Quote:

And
u = m * v;
is equivalent to
u.x = m[0].x * v.x + m[1].x * v.y + m[2].x * v.z;
u.y = m[0].y * v.x + m[1].y * v.y + m[2].y * v.z;
u.z = m[0].z * v.x + m[1].z * v.y + m[2].z * v.z;

Looks like matrix are composed of column vectors,so it's why i would be very surprised.
Better quote:
Quote:

...
5.4.2 Vector and Matrix Constructors
Constructors can be used to create vectors or matrices from a set of scalars, vectors, or matrices. This
includes the ability to shorten vectors.
If there is a single scalar parameter to a vector constructor, it is used to initialize all components of the
constructed vector to that scalar’s value. If there is a single scalar parameter to a matrix constructor, it is
used to initialize all the components on the matrix’s diagonal, with the remaining components initialized
to 0.0. If there are non-scalar parameters, and/or multiple scalar parameters, they will be assigned in
order, from left to right, to the components of the constructed value.
In this case, there must be enough
components provided in the parameters to provide an initializer for every component in the constructed
value. If more components are provided in the last used argument to a constructor than are needed to
initialize the constructed value, the left most components of that argument are used, and the remaining
ones are ignored. It is an error to provide extra arguments beyond this last used argument. Matrices will
be constructed in column major order.
It is an error to construct matrices from other matrices. This is
reserved for future use ]
...

Share this post


Link to post
Share on other sites
He was talking about HLSL, or the Direct3D High Level Shading Language, not glsl. I would be very surprised if that takes column vectors, since Direct3D treats vertices as row vectors (unlike OpenGL, which uses column vectors).

Share this post


Link to post
Share on other sites
Quote:
Original post by Pseudo
If you pass the float3x3 constructor 3 float3 vectors, does it treat them like colomn vectors or row vectors?

for example:
float3x3 mat = float3x3(A,B,C);

is that:
mat = {A.x,A.y,A.z, //row 1
B.x,B.y,B.z, //row 2
C.x,C.y,C.z} //row 3

or:
mat = {A.x,B.x,C.x, //row 1
A.y,B.y,C.y, //row 2
A.z,B.z,C.z} //row 3


thanks in advance.


Its row, or more precisely,

if float3x3 mat = float3x3(A,B,C),

then mat._11_12_13 = A.xyz

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this