Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

Thread: Is it possible to precompute the projection-view matrix?

  1. #1
    Junior Member Newbie
    Join Date
    Jan 2009
    Posts
    20

    Is it possible to precompute the projection-view matrix?

    The standard way to calculate mvp matrix is:

    P*V*M * v1 = v2


    In rendering my entity list, I would like to do something like the following:
    (for those not involved in games, an "entity" is a "unit" in the game world, such as an enemy or ally, the mapping typically being one entity to one (animated) mesh)

    Code :
    update()
     
        create camera matrix
        create view matrix as inverse of camera matrix
        precalculate combined pv matrix
     
        for each entity
            m * pv //as opposed to m * p * v if no precalc of pv
            make draw call

    ...Since this would result in one less matrix mul() per-entity, per-update -- leading to a fair saving when there are hundreds of entities active. Just not sure this is possible (mathematically) since then the matrix multiplication order p * v * m is duffed. Is there a way to do this, mathematically?
    Last edited by Nick Wiggill; 07-08-2012 at 06:04 AM.

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Apr 2010
    Location
    Germany
    Posts
    1,129
    If you mean (p * v) * m then you can of course precompute p * v = PV and calculate PV * m. m * PV is just plain wrong as matrix multiplication isn't commutative.

  3. #3
    Junior Member Regular Contributor Kopelrativ's Avatar
    Join Date
    Apr 2011
    Posts
    214
    To add to what thokra said, matrix multiplication is associative. That means (A*B)*C = A*(B*C). As long as you preserve the left/right relationship, you can do it in any order.

  4. #4
    Junior Member Newbie
    Join Date
    Jan 2009
    Posts
    20
    Thank you both. This

    (A*B)*C = A*(B*C)


    is what I needed to clarify.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •