Ogre rendering optimization experience (5)-replacing software skin with hardware skin and replacing CPU with GPU

Source: Internet
Author: User

The calculation of bone animation is time-consuming because of the large amount of data.

This part of data is computed using the CPU, that is, the software skin. If GPU is used for computing, the hardware skin is used.

 

1. Software skin

 

Ogre itself has implemented the software skin, which is the software skin by default. The calculated code is in void entity: updateanimation (void)

 

2. Hardware skin

 

The shader needs to be used to put the computing into the GPU for processing, and the shader Code does not need to be written by itself. The Ogre itself contains a vertex program that supports two weights,

Because a vertex can be bound with a maximum of four bones and a maximum of four weights, it is a little effort to implement the vertex in four cases. Therefore, the configuration of the vertex program should be dynamically added in the code, not written in. in material.

It is better to use the hardware skin of the torch light and have a complete set of implementations,

 

Do we need hardware skin? The answer is that every 3D game should have one.

Tianlong and torch light use hardware skins because they can greatly increase the running speed,

The only shader program used by torch light is hardware skin, and no other shader program can be found.

Therefore, hardware skin should be the most important shader program, which is efficient.

 

We use the Ogre example to test the speed.

 

 

 

 

6 people, 132 and 198 FPS, the gap is not small,

 

 

//////////////////////////////////////// //////////////////////////////////////// //////

In addition, if the shader program is used, the Xray implementation method I mentioned earlier will be changed.

 

Because the previous method is for a fixed rendering pipeline, I want to disable the rendering state change method. If there is a shader program, it will not work if it is disabled.

 

However, another method can be used, that is, after the pass attribute is set to the rendering state, I will change the rendering State. Where can I change it? In subentity, rewrite the following function,

You can change it before rendering.

Virtual bool prerender (scenemanager * SM, rendersystem * rsys)
{(Void) Sm; (void) rsys; return true ;}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.