for some reason
doesnt match up with
cbuffer cb0 : register( b1 )
in the shader… like it unaligns or something, what could cause this?
(even though this example works, but sometimes when i add a variable all
hell breaks loose)
Please log in or register to post a reply.
Yes, HLSL has specific rules for alignment of vector quantities in
constant buffers, which can result in differing alignment to what you’d
get in C/C++. This
the rules. Basically, you cannot split a vector (like a float3) across a
16-byte (4-float) boundary, so padding will be added to prevent this.
You often have to add this padding to the C/C++ version of the struct
How are your VEC, MAT and “matrix” types defined?
ahhh thanks man! i was always troubled by this for a long time… i
thought something screwy was going on.
VEC is the 3 component vector, and MAT is a 4x4… so i guess the 3
component vector was the strange one.
i get it, so you cant put two 3 component vectors in a row (sometimes),
cause it crosses a 16 byte boundary… ? you can if it doesnt. if you
look at the structure provided, youll see i havent crossed a boundary,
just with naive trial and error, i see now.
thanks reed - you the man.