Closed slerpyyy closed 1 year ago
The reason we had avoided officially adding HLSL style matrix type aliases so far is that the dimensions are the opposite way around (WGSL is column-major like GLSL, unlike HLSL), so we weren't sure whether that would cause more confusion than it's worth? Obviously square matrices are fine, but then only having aliases for those would be odd.
We have a small system for fixing up shaders on the website whenever there's a breaking change, so that part should be fine.
What do you think of just adding a comment in the prelude that says "these types are column major" for when people check the prelude? I know one of the first things I check when working with matrices in a new environment is whether they are row or column major.
I'm glad the breaking change isn't an issue, I can amend that system later.
A comment about which way around matrices go is always welcome, though I think this should probably go into the explainer on the website rather than into the prelude itself?
Sounds good. Can you submit a PR for the fixup and explainer? Then I'll merge both at once
Adds the following type aliases to the prelude.
Since
vecN<T>
requiresT
to be a concrete scalar, andmatNxM<T>
requiresT
to be a float, this new set of type aliases covers all possible use cases (with the exception off16
).The downside is that some shaders already contain a subset of these aliases, meaning some shaders will break and need to be fixed manually. Though this should be a 5-second fix in most cases, and the impact of such a change would be a lot greater further down the line.