• Advertisement

WhatEver

Member
  • Content count

    561
  • Joined

  • Last visited

Everything posted by WhatEver

  1. I've been looking all over the place for an answer to this question and I'm only getting bits and pieces of the answer. I learned the hard way a long time ago that calling glBindTexture is relatively slow; I found out from a friend of mine that it was because I was binding the texture every time I drew a triangle lol! The simple fact is that calling glBindTexture comes at a price, and minimizing calls is always the best choice!   Anyway, there's a reason it's slower than most other function calls that change the opengl states, and I'm looking for the technical answer.   So far, with my limited understanding of hardware in general, the main reason I think it's slow is because every time you call glBindTexture, the hardware copies the texture from Texture RAM into the Texture Cache because the Cache is faster to read from. Although the copy is fast in it's own right, copying larger textures should take longer than smaller textures, and if done enough times no matter the size of the texture, will become a performance bottleneck.   Yes/No? Is there more to it than that?
  2. Ha, so much has changed since I last wrote an OpenGL program! Thanks for the clarification and insight into the latest generation of graphics acceleration.
  3. Never mind, it just sunk in. It doesn't seem like that would be the reasons for being so slow, but I don't really understand the hardware.   What's the bind-less function thing you're talking about?
  4. I'm a little confused. Is glBindTexture still slow, but not for the reason I thought, and it's been replaced by a different function: a bindless function?
  5. OpenGL OpenGL artifacts

    You're getting what looks like z fighting. In your case, turning on back face culling should fix it. If not, look at the model and make sure you don't have double sided polygons. If you do delete the polygons you can't see, or never will see.
  6. I'm a little confused by the difference between inverting a matrix versus transposing a matrix. I invert my camera matrix to bring objects into camera space, and transpose my texture matrix to be used for my shadow maps. The two function that I have that invert and transpose matrices are similar, and that's what is confusing me. The xyz rotation axis are being transposed in both, but the forth column, and position, are treated differetly. I guess I understand why the invert function I have works, but I don't understand what the 4x4 transpose is doing with the 4th column and position data. Invert function: b[0]=a[0]; b[1]=a[4]; b[2]=a[8]; b[3]=0.0f; b[4]=a[1]; b[5]=a[5]; b[6]=a[9]; b[7]=0.0f; b[8]=a[2]; b[9]=a[6]; b[10]=a[10]; b[11]=0.0f; b[12]=-(a[12]*a[0])-(a[13]*a[1])-(a[14]*a[2]); b[13]=-(a[12]*a[4])-(a[13]*a[5])-(a[14]*a[6]); b[14]=-(a[12]*a[8])-(a[13]*a[9])-(a[14]*a[10]); b[15]=1.0f; Transpose function: temp[0]=m[0]; temp[1]=m[4]; temp[2]=m[8]; temp[3]=m[12]; temp[4]=m[1]; temp[5]=m[5]; temp[6]=m[9]; temp[7]=m[13]; temp[8]=m[2]; temp[9]=m[6]; temp[10]=m[10]; temp[11]=m[14]; temp[12]=m[3]; temp[13]=m[7]; temp[14]=m[11]; temp[15]=m[15]; -WhatEver
  7. I guess so. I have never scaled my camera before...but I do remember having problems with lighting when my objects are scaled. My shaders perform lighting in object space, so I have to multiply the lights by the inverse of the object world matrix. I pretty much get how the invert matrix works then, but what about the transpose matrix? I get it when it has to do with rotations, but other than that, I'm clueless. Here's the source code that creates my textureMat for shadowing (it's the same as the one in the OpenGL SuperBible but with my functions) S3Dmat16f textureMat; s3dMatIdentity16f(textureMat); s3dMatTranslate16f(textureMat, 0.5f, 0.5f, 0.5f); s3dMatScale16f(textureMat, 0.5f, 0.5f, 0.5f); s3dMatMultiply16x16f(textureMat, projection, textureMat); s3dMatMultiply16x16f(textureMat, modelView, textureMat); s3dMatTranspose16f(textureMat); glTexGenfv(GL_S, GL_EYE_PLANE, &textureMat[0]); glTexGenfv(GL_T, GL_EYE_PLANE, &textureMat[4]); glTexGenfv(GL_R, GL_EYE_PLANE, &textureMat[8]); glTexGenfv(GL_Q, GL_EYE_PLANE, &textureMat[12]); I understand that S, T, R, and Q are holding the results of the textureMat. But what exactly is going on? I was under the impression that the textureMat would need to be inverted not transposed so that S, T, R, and Q would be brought into texture space.
  8. I looked around all over the place to find out how to extract euler angles from a matrix, and I found it. Yippeee right? Nope, I'm dealing with sort of a more unique problem. Apparently, and this makes sense, you can only extract angles that are limited to 0 and 89 degrees. Here is the problem I am posed with: 1. Rotate a matrix around it's axes 360 degrees 2. Extract x rotation from matrix I end up with 0 degrees. I need it to give me 360 degrees. I am writing a plugin for AfterEffects that will export animations to LightWave. If I have a AfterEffects layer rotating around it's axes 4 times, then I need to be able to convert that rotation from xyz order (AfterEffects) to yxz order (LightWave). Actually, all these numbers are in radians in my source code, but I am calling them degrees here for simplicity. Any help would be appreciated. Thank you.
  9. Euler Angles Beyond 90 degrees from Matrix

    That's a good idea SiCrane, but my boss won't let me do that because their big thing is to conserve memory along with quick load times. Thank you everyone for your help. Because of the nature of how the rotations work, I can at least keep acurate rotations around the z, simply because it is the last to rotate in both orders and therefore not scewed.
  10. Euler Angles Beyond 90 degrees from Matrix

    I forgot to mention that I don't care about perfect precision.
  11. Euler Angles Beyond 90 degrees from Matrix

    edit: Key frames can contain values beyond the range of 0-360 degrees, so I need to preserve degrees that are beyond the 0-360 degree limit. I'm trying to export key frames from AfterEffects to Lightwave, the only problem is that AfterEffects rotates in xyz order, and LightWave rotates in yxz order. The only method that I am aware of that will convert from one order of angles to another is a two part process. These are the steps I am taking to convert from xyz order to yxz order 1. rotate a matrix in x, y and z order 2. extract the angles in y, x and z order But when I do this, I lose any angle that goes outside of the 0 - 180 degree range. So is it not possible? Am I using the wrong method for converting keyframes from one rotation system to another? I'm beginning to think it is not possible. Because like you said, I lose that rotation value once the conversion has been made.
  12. Euler Angles Beyond 90 degrees from Matrix

    That makes total sense, but here is my theory. If I have the variable that rotated the matrix, I know the exact rotation of the matrix. So what I am essentially trying to do is convert from xyz rotation to yxz rotation and since I currently have the angles from the xyz rotation, shouldn't I be able to use the xyz rotations to modify the yxz rotations in conjunction with the matrix?
  13. Euler Angles Beyond 90 degrees from Matrix

    Mike, maybe that was a bad example. Let's say I rotate 385 degrees. I don't want to retrieve a value that is restricted to a number that falls between 0 and 90 degrees, I want it to return 385 degrees.
  14. Euler Angles Beyond 90 degrees from Matrix

    I just ran some more tests, and it looks like I can get a number aproximatly between -1.57 to 1.57, which ends up being 180 degrees. I still need it to give me a larger range than that, if it is even possible. The variables r0, r1, and r2 was my attempt at determining how many times a full rotation occurred, and then I was adding it to the rotations after they were converted to a different order. Here's my source code (updated to reflect what does work -- but not to the degree I need it to work, pun not intended :)): CMNvoid aeAnglesToLwAngles() { CMNKeyIterator i0, i1, i2; CMNKey *k0, *k1, *k2; CMNint r0, r1, r2; EulerAngles outAngs, inAngs; HMatrix R; k0 = Channels[3].getFirstKey( i0 ); k1 = Channels[4].getFirstKey( i1 ); k2 = Channels[5].getFirstKey( i2 ); while( k0 || k1 || k2 ) { inAngs.x = inAngs.y = inAngs.z = 0.0f; inAngs.w = EulOrdXYZr; r0 = r1 = r2 = 0; if(k0) { inAngs.x = k0->Value; r0 = k0->Value / CMN_PI; } if(k1) { inAngs.y = k1->Value; r1 = k1->Value / CMN_PI; } if(k2) { inAngs.z = k2->Value; r2 = k2->Value / CMN_PI; } Eul_ToHMatrix(inAngs, R); outAngs = Eul_FromHMatrix(R, EulOrdYXZr); //if(k0) { k0->Value = outAngs.y + (r0 * CMN_PI); } //if(k1) { k1->Value = outAngs.x + (r1 * CMN_PI); } if(k2) { k2->Value = outAngs.z + (r2 * CMN_PI); } if(k0) { k0->Value = outAngs.y; } if(k1) { k1->Value = outAngs.x; } //if(k2) { k2->Value = outAngs.z; } if(k0) { k0 = Channels[3].getNextKey( i0 ); } if(k1) { k1 = Channels[4].getNextKey( i1 ); } if(k2) { k2 = Channels[5].getNextKey( i2 ); } } } [Edited by - WhatEver on August 26, 2008 6:59:00 PM]
  15. I have looked everywhere and I can't seem to find out how to pass a pointer of an array of tangents to the GPU for use by the TANGENT semantic in my cg shader. I know you use glActiveClientTextureARB(GL_TEXTURE0...4) and so on along with glTexCoordPointer for setting up texture pointers, but how do you pass a pointer that contains a tangent array? I'm stumped!
  16. Thanks for your input deathkrush! Ok, I did some experimenting and discovered that TEXCOORD6 and TEXCOORD7 are the same as TANGENT and BINORMAL, so glClientActiveTexture works fine for now.
  17. I guess I should have posted this thread in the graphics programming forum...
  18. Since this topic doesn't really fit anywhere else, I thought I'd post it here, because I'm sure the answer has something to do with math. I've been trying to think of different ways to remove duplicated xyz values from an array of vertices. I've been testing each vertex with all the other vertices, but processing 300,000 vertices (100,000 triangles) is waaaaay to slow using that method. LightWave does it quickly somehow, but how??? Are they hashing the vertices or something?
  19. Thanks guys, sounds like hashing is the right solution then.
  20. I'm conducting a simple loop test that sets a vectors components to zero 5000x5000 times, and it looks like this: for(uint i=0; i<5000; i++) { for(uint j=0; j<5000; j++) { ZeroVector(Vector[j]); } } You'd think that this bit of code would process pretty quickly, but it doesn't. It takes 10 seconds. Why? I tried it in release mode and it's still slow. Thanks
  21. Thanks for the help guys. I retested the same code after class last night and it took less than a second. So I don't know what all the slowness was all about. Maybe the memory started swapping or something. The ZeroVector routine is inline and it's just setting Vector[0], Vector[1], and Vector[2] to zero. The 'i' is only there to itterate the outer loop 5000 times. LOL PlutoWarrior!
  22. I noticed in some games collision occurs with invisible surfaces. Does that mean that there are two BSP trees, one for determining what to draw, and the other for collision detection?
  23. Thanks RobTheBloke! I'll be using any type of data organization that is pertinent to the geometry: BSP for outdoors, octree for indoors, and portals whereever they're useful (I have to read up on that one, but I sort of understand it).
  24. World Creation System - Where to start?

    The compexity of what you're suggesting is beyond a two year project, especially if you're doing it alone. Listen to Glak, just like any language it takes years to speak any language fluently, and it will take a lot of trial and error before you even come close to what you set out for at the beginning. However, if you are as dedicated as you say, you will prevail. With that said, you need to first pick up a book that teaches C++. I would also suggest that you take college classes in math (preferably up to calculas). Without the math C++ will take even longer to learn and master since the two are interrelated, IMO. Personally I've been programming for 10 years. The first 5 years were spent learning C/C++ (I should have taken math at the beginning :)), and the second 5 have been spent writing and perfecting my game engine. Good luck on your endeaver.
  25. Games with C++

    To answer the original question, a lot of the games are written in C++. Due to the modularity of objects in C++ the process for writing games is more modular, allowing for authors to reuse code in newer projects, whereas in the Wolfenstein/DOOM/Quake/Quake2 days a lot of game were written in spegetti code, meaning hardly any modularity at all. I read a post by John Carmack a while back where he said he would start to use C++ in Q3A. C++ was still relativily new at the time Quake 2 came out, so Carmack kept to his C style productivity until the production of Q3A. I won't say that Quake 2 didn't use any C++ at all, but I will say that Q3A used it, but I don't know how much.
  • Advertisement