Adventures in engine land, part 2
Welcome back to the second installation of engine adventures! This
time I'll talk about the changes I've introduced to the model
rendering in the next version of the game. If you don't like
technical details, you may just skip to the end of this blog post
:)
The first major change is that we've switched the model format we use for skeletal animation: SKM/SKP is gone, IQM is in. The reasons are quite simple: SKM isn't used anywhere outside Warsow, it's an obscure and barely supported tools and exporters wise format. IQM aims to be the universally accepted format for all relevant Quake-based engines so the chances it's not going to become obsolete in the near future are higher than those for SKM. By the way, the SKM/SKM to IQE exporter was part of the 0.62 release..
One thing I noticed while speccing bomb matches in 0.6x is that framerates dropped considerably with several player models in sight. Clearly something had to be done about that. Two things came to mind: performing skeletal animation on GPU and avoiding multipass shaders for our player skins. Moreover, both approaches required GLSL programming, could be implemented independently and would complement each other nicely.
Non GLSL path could also be optimized using an approach called matrix palette skinning, which is done on CPU. It allows performing only one matrix multiplication per vertex, irregardless of the number of affecting bones. In case you didn't know, each vertex in a skeletal model has 1 or more influencing bones attached to it. Both SKM and IQM pose a limit of influencing bones at 4. Each influence is basically a matrix and a influencing factor (weight), ranging from 0 to 1. Skeletal animation basically boils done to transforming these matrices and then applying the result to vertices. In short, matrix palette skinning allows combining these influencing matrices beforehand and not transforming the vertex by each influence individually, saving the CPU power.
For the GPU skinning dual quaternions technique could be used. eihrul (the author and maintainer of the IQM format) helped me enormously to implement both approaches, patiently answering my questions on the IRC and providing me with clues and code. Thank you, Lee!
Perhaps the least mathematically intriguing part of my optimizations and the most torturing one was writing a specialized GLSL shader that would allow to render all of our player models in a single pass, no matter what skin. That required painstakingly analyzing, grouping and templating of all of the shaders we use for player skins and then writing and debugging the aforementioned GLSL program, which wasn't a terribly exciting experience, but I won't go into further details on that.
All the changes I described here took a couple of months of on and off work to implement and debug.
Now what's the outcome in terms of framerates a reader might ask? Here are screenshots of 0.62 and 0.7 running the same scene with 20 animated bigvic models with default skins (fps counter is in the upper right corner).
Note that both screenshots were taken with model outlines enabled, so that doubled the number of models actually rendered.
The first major change is that we've switched the model format we use for skeletal animation: SKM/SKP is gone, IQM is in. The reasons are quite simple: SKM isn't used anywhere outside Warsow, it's an obscure and barely supported tools and exporters wise format. IQM aims to be the universally accepted format for all relevant Quake-based engines so the chances it's not going to become obsolete in the near future are higher than those for SKM. By the way, the SKM/SKM to IQE exporter was part of the 0.62 release..
One thing I noticed while speccing bomb matches in 0.6x is that framerates dropped considerably with several player models in sight. Clearly something had to be done about that. Two things came to mind: performing skeletal animation on GPU and avoiding multipass shaders for our player skins. Moreover, both approaches required GLSL programming, could be implemented independently and would complement each other nicely.
Non GLSL path could also be optimized using an approach called matrix palette skinning, which is done on CPU. It allows performing only one matrix multiplication per vertex, irregardless of the number of affecting bones. In case you didn't know, each vertex in a skeletal model has 1 or more influencing bones attached to it. Both SKM and IQM pose a limit of influencing bones at 4. Each influence is basically a matrix and a influencing factor (weight), ranging from 0 to 1. Skeletal animation basically boils done to transforming these matrices and then applying the result to vertices. In short, matrix palette skinning allows combining these influencing matrices beforehand and not transforming the vertex by each influence individually, saving the CPU power.
For the GPU skinning dual quaternions technique could be used. eihrul (the author and maintainer of the IQM format) helped me enormously to implement both approaches, patiently answering my questions on the IRC and providing me with clues and code. Thank you, Lee!
Perhaps the least mathematically intriguing part of my optimizations and the most torturing one was writing a specialized GLSL shader that would allow to render all of our player models in a single pass, no matter what skin. That required painstakingly analyzing, grouping and templating of all of the shaders we use for player skins and then writing and debugging the aforementioned GLSL program, which wasn't a terribly exciting experience, but I won't go into further details on that.
All the changes I described here took a couple of months of on and off work to implement and debug.
Now what's the outcome in terms of framerates a reader might ask? Here are screenshots of 0.62 and 0.7 running the same scene with 20 animated bigvic models with default skins (fps counter is in the upper right corner).
Note that both screenshots were taken with model outlines enabled, so that doubled the number of models actually rendered.
Awesome work. Looks like the default hud AR was updated in .7 too.
:D
yeah this goes way beyond my understanding but really really awsome
job!
u mixed up the links to the screenshots or are you telling us that
0.62 has better fps?
great work. i've noticed fps drops when 6-8 players are on screen
(esp. without fullbright), hope this will be gone.
nice one vic
the switch of the model type to iqm was imo very wise, alot of players never heard or skm before ^^
the switch of the model type to iqm was imo very wise, alot of players never heard or skm before ^^
i'va heard of skm before!) i'm the winner!
thanks vic for explaining your work. really informative and interesting post.
thanks vic for explaining your work. really informative and interesting post.
The models shading seems slightly different. What's the
difference?
P.S: Yes Solidfake, because all players haver heard of IQM before.
P.S: Yes Solidfake, because all players haver heard of IQM before.

