Matrices passed to the shader (via the ShaderParameterCollection) are transposed #748
Labels
Core
Area: Duality runtime or launcher
Discussion
Nothing to be done until decided otherwise
Rendering
Related to rendering / graphics
Milestone
Summary
When passing a matrix to the shader via the Camera or DrawDevice's
shaderParameters
the resulting matrix in the shader is a transposed version of the passed in matrix.How to reproduce
Since debugging a shader is quite difficult, I am not sure how to demonstrate this. I ran into this when passing a matrix to the shader code but you can also see this behavior with the default duality view Matrix and shader code. Let me describe the flow,
IsSphereInView
Vector4.Transform
method treats the vector as a 1x4 row based matrix when multiplying it against the passed in 4x4 matrix. From a math perspective this is like putting the vector on the left (rowVector * matrix), vs putting it on the right (matrix * columnVector).Workaround
In the shader code to multiply against the original matrix put the vector on the right (instead of the left) when performing the multiplication.
This is pretty straight forward but still extremely confusing when trying to debug why your shader is broken.
Analysis
When the
ShaderParameterCollection
serializes the matrix it does it row by row, but when glsl creates a matrix it reads the data column by column.The text was updated successfully, but these errors were encountered: