Open sketchpunk opened 5 years ago
Ahh this is very interesting thanks for sharing!
Are there any cases that you know of where this isn't strictly better than converting to matrices first?
i.e. - is there any reason that you know of that one wouldn't just use straight DQs (vs. how I currently convert to matrices)
Cheers!
I can't think of a reason why you would not use DQ directly over a Matrix. Think the benefit of sticking to DQ only is less operations done per vertex. The DQ does perform 3 cross vector cross products which should equal out to about 6 mul and 3sub each. So if you take into consideration that first your doing many operations to do the conversion, then you use have to do a Mat4 * vec4 operation after that to get the final transformed vertex.
Three Cross : 18 mul, 9 add/sub Conversion : 36 mul 12 add/sub
So just the conversion uses more operations then the 3 cross products used in transforming a vector with DQ. There is a bit more to the DQ transform, but it should be more efficient in terms of operation counts then Convert then Matrix*Vec4.
I haven't tried yet, but I wonder with the final quaternion that you get to transform the vertex can be reused to transform a normal vector without needing to pass in a normal mat3x3 to the shader.
If you have questions about Q and DQ along with transforms with it, a good person to know is @gszauer
on twitter. He's also experimenting with DQ Skinning like me but unlike me, he understands quaternion mathmatics :)
Awesome - thanks for that comparison!
I'm actually in the middle of cleaning up the mesh-visualizer
and adding a GitHub Pages for it ...
Not sure if I'll make this change in this cleanup session ... but I'll leave this issue open until that eventually happens.
but unlike me, he understands quaternion mathmatics :)
Somewhat off topic on my part...but one issue I ran into back when I was figuring out how to write my first skinning shader was that it's so hard to find simple breakdowns of the math. You really have to dig and claw and piece together resources.
I'll have to check out gszauer's stuff. Thank you for the reference!
I see that you're converting your DQ to matrices. I have some working GLSL code that uses DQ straight through for skinning. I have it working with my armature system pretty well now. Here's a link to the source. Might be something fun for you to experiment with.
https://github.com/sketchpunk/Fungi/blob/master/fungi.armature/shaders/ArmatureSkinPhong.txt