• Advertisement


  • Content count

  • Joined

  • Last visited

Community Reputation

125 Neutral

About wtherapy

  • Rank
  1. Sorry, but the matrix presented was column-ordered, however, this would make no difference. Good point, JoeJ. I just made the following test:   float vMat[] =  { -0.99064791 ,     0.13169301  ,   0.035664752 ,     0, 2.6822096e-007  ,   -0.26139921 ,     0.96523124 ,  0, -0.13643673 ,    -0.95620453 ,    -0.25895494, 0, 0.00000000 ,     0.00000000 ,     0.00000000,       1.0000000   };   Matrix4F mat; mat.LoadLineOrdered(vMat);   Vector3F sx = mat*Vector3F::UNIT_X; Vector3F sy = mat*Vector3F::UNIT_Y; Vector3F sz = mat*Vector3F::UNIT_Z;   Vector3F tsz = sx^sy; //cross product float fAngle = tsz*sz;   based on the assumption that, on a right-handed coordinate sys, Z = X x Y ( cross product ), it should verify that fAngle = 1. However, after checking, turned out that fAngle is -1. Indeed, the matrix includes a mirroring. Strange that the matrix comes from a POD file exported by PowerVR in 3DMax. Any idea on what to do in this kind of situations? My best guess at the moment is to alter the scaling component of the TRS ( since scaling is computed as a length of a vector, taking the positive value ), to reflect the mirroring component. Anyone have a better idea ( which component of the scaling should have the sign inverted )?
  2. I am having a nightmare question these days with my Matrix -> TRS ( translation / rotation / scaling ) conversion and back ( working on a skeletal animation sys ). Given a SO(3) matrix, which should equivalently produce a unit quaternion ( with the real part positive ), I cannot successfully convert the matrix to a quaternion and then, converting back the quaternion, to obtain the original matrix back. Code for conversion is straighforward, copy-pasted from Internet and also determined by me on the paper.   The matrix is:   -0.99064791 , 2.6822096e-007, -0.13643673, 0.13169301, -0.26139921, -0.95620453, 0.035664752, 0.96523124, -0.25895494   row major.   I assume there are people around that have competent code for this kind of conversion. Can someone convert this matrix to a unit quaternion, then convert it back to a matrix and confirm they get back the same matrix?   Cristian.
  3. hello, I don't need 'nice slopes', since my grid of 256x256 is much smaller than my 3d world. I am using interpolation functions to create the smooth surface. I just want every texel to contain 3 floats and I want o access them as memory data. Here is a snippet from my shader: [CODE] #define OPENTG_HEIGHTMAPRES 256 float xn = X / OPENTG_SUBCELLSIZE; float yn = Y / OPENTG_SUBCELLSIZE; unsigned int i = (uint)floor( yn ); unsigned int j = (uint)floor( xn ); float u = fract(xn); float v = fract(yn); if( OPENTG_HEIGHTMAPRES == i ) { i --; v = 1; } if( OPENTG_HEIGHTMAPRES == j ) { j --; u = 1; } vec4 vH00 = GetVertCellParameters( i, j ); vec4 vH10 = GetVertCellParameters( i + 1u, j ); vec4 vH01 = GetVertCellParameters( i, j + 1u ); vec4 vH11 = GetVertCellParameters( i + 1u, j + 1u ); /*do something with the vec4's they contain infos of height values in i, j cell and gradient information */ } [/CODE] it seems there are problems if some of those values are negative - the rendering looks somehow like it renders part of the scene and then stops rendering anything else in a certain point.
  4. Hello, I am importing various animations from PowerVR POD files. I need conversions from matrices to quaternions & stuff, as I want to implement animation blending and inter-frame interpolation. My problem is that, when reading data exported from powervr as quaternions, translations and rotations, matrices converted from those TRS does not equal ( even by far ) the matrices read if I export the models with matrices. Also, if I try to decompose the matrix into TRS, after extracting the scaling component, the resulting matrix is not a rotation matrix: columns are unit length, but rows aren't ( I have removed the translation component ). For example, when I export as matrices ( model has about 100 bones, with about 250 frames ), the 11174 matrix is, COLUMN ORDERED: -0.209940, -0.409073, -0.000002, 0.000000, 0.960153, -0.089445, -0.000002, 0.000000, 0.000003, -0.000001, 0.725079, 0.000000, -0.116999, -0.340356, -0.732254, 1.000000 but, when I export as TRS, the 11174 set of parameters are: Trans = (-0.116999, -0.340356, -0.732254) Scale = (0.418738, 0.982837, 0.725079) Quat = (0.000000, -0.000002, 0.778976, 0.627054) I have checked and by no means the TRS could be converted to a matrix that comes even close to the one read from powervr. Objects are read from the POD file as follow: translation: Vector3(&(node->pfAnimPosition[j * 3])); rotation: Quaternion( node->pfAnimRotation[j * 4 + 0], node->pfAnimRotation[j * 4 + 1], node->pfAnimRotation[j * 4 + 2], node->pfAnimRotation[j * 4 + 3] ); scale: Vector3(&(node->pfAnimScale[j * 7])) Perhaps there is some bug in my conversion code although I have checked 1000 times, also I have created random translation, rotations and scaling and converted to matrices and then converted back to TRS and got the same values. That's why I have put here the parameters read from POD file. From imgtec site I received no answer. Or perhaps the frame matrices does not come from a simple T*R*S transform and there is something more. Animations are done in 3dmax. Any solution or explanation for this is welcome. Useless to say, the model, when used with matrices that come from TRS read from the POD file, deforms horribly. The first frame looks good, but the following not.
  5. Hello, I am developing a fractal terrain generation based on an original 256x256 heightmap. I need to use a texture to represent this heightmap, together with other gradients in each point, that is, 3 floats per 'texel'. //////////////////////////////////////////////////////////////////////////////in the vertex shader, I am doing: uniform sampler2D TexHeightMap; vec4 GetVertCellParameters( uint i, uint j ) { return texture( TexHeightMap, vec2( i, j ) ) * 2500.0f; } the * 2500.0f multiplication was used just to make sure the values are not somewhere between 0-1; in the final code, the function will just return texture( TexHeightMap, vec2( i, j ) ); //////////////////////////////////////////////////////////////////////////////in the CPU, I am using: void GLTexture::CreateHTExture( const void* pvBytes, unsigned int unW, unsigned int unH ) { glEnable( GL_TEXTURE_2D ); glGenTextures( 1, &m_uglID ); glBindTexture( GL_TEXTURE_2D , m_uglID ); glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB32F, unW + 1, unH + 1, 0, GL_RGB, GL_FLOAT, pvBytes ); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_LINEAR); } glEnable(GL_TEXTURE_2D ); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D , pTexture->GetID()); glUniform1i(m_ugl_HeightMapTexture, 0); pTexture is of type GLTexture; m_ugl_HeightMapTexture = glGetUniformLocation(m_uglProgram, "TexHeightMap"); for some reason, I am only getting zeros in the vertex shader ( when calling GetVertCellParameters ). I checked the parameters pvBytes with memory view and they look fine. I just need to get the float values, unmodified, just as I send them, in the vertex shader, and access them via texture as vec4. Thank you.
  6. I guess I will try uniform buffer objects, move to OpenGL 3.*. Keep you informed about this if any relevant increase in speed is noticed. Thanks for the answers.
  7. Hi, thanks for the answer, to make everything more clear, I was using uniforms for this and invoking a vertex shader for each terrain quad that project, in the XY plane, into an original grid location. That was very slow and wasn't taking advantage of the fact that the grid never gets modified.
  8. Hello, I am working on a simple terrain demo and I have a 256x256 height-map that stores not only height but also other information, each grid point having 8 floats. I need this grid available in the video card memory ( so I can create a VBO or smth ). The most important, in the vertex shader, when drawing the terrain, when getting the x and y ( Z is vertical ) of a vertex in the terrain, I will compute the cell grid in which the x-y point lies and then I need to be able to access in the vertex shader those 8 floats that are stored in the closest grid point of the 256x256 points "height map". If someone has a suggestion on how to do it, any help is appreciated.
  • Advertisement