Jump to content
  • Advertisement
Sign in to follow this  
Ripiz

Sony Vectormath problem

This topic is 2532 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello,

I have decided to use Sony's Vectormath from Bullet Physics, however it seems I'm having some problems with it.
Firstly, I simply swapped out all my math with Vectormath one, but rendering got broken. Eventually I noticed it's row major, not column major like I had before, so I transposed matrix, however rendering still didn't work. Then I tried to transform single vertex on CPU to see if there's anything wrong with shaders, but I got same value as outputed by shader. Therefore I came here to ask for help and figure out if I've done something wrong, or something is wrong with library. Here's single transformed vertex:


Matrix World = Matrix::identity();
Matrix View = Matrix::lookAt(Point3(1, 500, 1), Point3(0, 0, 0), Vector3(0, 1, 0)); // looking from above
Matrix Proj = Matrix::perspective(PI * 0.5f, 1, 1, 1000);
Matrix WorldViewProj = World * View * Proj;
Vector4 Vertex(-63.5f, 0, -63.5f, 1); // first vertex in my mesh
Vector4 TransformedVertex = WorldViewProj * Vertex; // result is (-88.4768, 1.32573, -31750.1, 63.5)


Mesh consists of 128 * 128 vertices, they all are between (-63.5, 0, -63.5) and (63.5, 0, 63.5) (flat heightmap), but shader output varies a lot; x is between -88 and 91, y between -83 and 80, z between -31000 and 31000, w is just negative of untransformed z.

If anyone could help me out that'd be just nice =)

Thank you in advance.

Share this post


Link to post
Share on other sites
Advertisement
From your description, It's a little difficult to understand what you have verified and what is wrong. If you have an example where you use Vectormath versus whatever you were previously using it should be straightforward to step through and see where the problem occurs. From the code you have posted it is not clear what is wrong or what it has to do with Vectormath. Are you saying that Vectormath works on the GPU but not the CPU?

I would like to help but it's a little confusing.

-Josh

Share this post


Link to post
Share on other sites
What about
Matrix ProjViewWorld = Proj * View * World;
Vector4 Vertex(-63.5f, 0, -63.5f, 1); // first vertex in my mesh
Vector4 TransformedVertex = ProjViewWorld * Vertex; // result is (-88.4768, 1.32573, -31750.1, 63.5)
Otherwise, need more info.

Share this post


Link to post
Share on other sites
jjd, it gives same result on CPU and GPU, but it's wrong as nothing is visible.

NumberXaero, thanks. I didn't think about it. Appear matrix multiplication order here is different. Everything works now.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!