• Create Account

## Sony Vectormath problem

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

3 replies to this topic

### #1Ripiz  Members

538
Like
0Likes
Like

Posted 09 January 2012 - 06:05 PM

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 =)

### #2jjd  Members

2140
Like
0Likes
Like

Posted 09 January 2012 - 07:06 PM

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

--www.physicaluncertainty.com
--irc.freenode.net#gdnet

### #3NumberXaero  Prime Members

2496
Like
0Likes
Like

Posted 09 January 2012 - 07:47 PM

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)

### #4Ripiz  Members

538
Like
0Likes
Like

Posted 10 January 2012 - 03:38 AM

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.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.