Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


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.

  • You cannot reply to this topic
3 replies to this topic

#1 Ripiz   Members   -  Reputation: 529

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

Thank you in advance.

Sponsor:

#2 jjd   Crossbones+   -  Reputation: 2122

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
--linkedin
--irc.freenode.net#gdnet


#3 NumberXaero   Prime Members   -  Reputation: 1505

Like
0Likes
Like

Posted 09 January 2012 - 07:47 PM

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.

#4 Ripiz   Members   -  Reputation: 529

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.



PARTNERS