Batch rendering technology (batching) in ogre)

Source: Internet
Author: User

Rendering in any engine is a process that consumes system resources. To render an object to the screen, a rendering operation is required, if tens of thousands of identical trees exist in the scenario, the system will perform tens of thousands of rendering operations.ProgramEfficiency will be very slow. If you can draw these trees with the same rendering state with one rendering operation, the efficiency will be improved several times.

The ogre: staticgeometry class provided by the Ogre engine is to implement batch rendering operations. If some objects are not intended to be rotated, scaled, or moved after being loaded into the scenario, they can be loaded to the scenario as static ry.

However, batch rendering is not highly efficient in all situations. If there are tens of thousands of trees in the scenario, but the camera can only see one tree at a certain angle, ogre will also render tens of thousands of trees together, which is less efficient than scene node objects with the vision cropping function. In this case, ogre also provides a solution, that is to divide all static ry into regions for batch rendering. If some areas are invisible to the camera, ogre will not render them, so that it can be ensured at any angle of view, the system provides stable rendering efficiency.

 

The specific division method is to first set a regional division origin point in the scenario, which is the center of the surrounding area, then set the volume XYZ of each region, and then add an object, finally, the build () method is called, and the ogre will automatically divide the rendering area for all objects.

 

DetailsCode:

Ogre: staticgeometry * m_pstaticgeometry = NULL;

M_pstaticgeometry = m_pscenemgr-> createstaticgeometry ("dims/staticgeometry"); // create a static ry
M_pstaticgeometry-> setregiondimensions (vector3 (1000,); // you can specify the rendering size for each batch.
M_pstaticgeometry-> setorigin (vector3 (500,500,500); // you can specify the origin location of the batch rendering part.

// Add several objects to the static ry. Note that only the pointer of the object in the same mesh needs to be passed in.
M_pstaticgeometry-> addentity (pentobject, position, orientation, scale );

// Division of batch rendering regions for static ry
M_pstaticgeometry-> build ();

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.