Re: [Algorithms] Scaling Models
Brought to you by:
vexxed72
From: <Lea...@en...> - 2000-07-30 23:01:01
|
> The transpose(inverse) for normals slipped my mind. Oops. OpenGL does do > the transpose(inverse) of course. As your probably aware, OpenGL only takes the transpose of the 3x3 rotation matrix contained within the 4x4 transformation matrix if the transformation calls were only rotations, translations... scales, shears and the like cause the matrix inverse to be calculated and then transposed. > The transpose(inverse) operation only needs to be performed once when the > matrix is loaded, and only if the API has state currently enabled that uses > normals (directional lighting or spherical environment mapping). If these > states are enabled after the fact, the matrix can be created when the state > changes. In the case where it needs to do the computation, whether or not > it checks for linearity depends on the expense of the check I guess. The > driver writers are usually pretty good at doing minimal amounts of work to > speed things up as best they can. This is where I am going to advocate using the OpenGL API to do the transformation work... there are a lot of coders who do the glLoadMatrix() thing -- in which case it is hard for an API to know whether the transformations are affine or not... The way I am pretty positive the driver writers do things (not 100% sure as they won't tell me... :) is something like: flag_t affineMatrix; flag_t isInverted; glLoadIdentity() affineMatrix = true; set values() glRotate() set values glScale() affineMatrix = false set values When it comes to transformation, it's a matter of if (!affineMatrix) if (!isInverted) invert matrix isInverted = true transform pipeline The actual pipeline could optimise that a lot, and bypass any routines to ensure maximum performance... but that's just my trying to demonstrate things clearly... :) Has anybody actually noticed performance increases from the use of glLoadMatrix()? The benefits of having your own matrices are numerous, such as for grabbing view frustum parameters, being able to transform BBoxes easily, etc... but I am thinking that a _lot_ of objects would be faster to get across to the HW if you could just send the the info with normal OpenGL calls. Leathal. |