Brief analysis on the resource management mechanism of game engine--the resource management hidden behind in the unity3d of a grilled piece

Source: Internet
Author: User
Tags svn

Games often have a lot of resources, such as grids, materials, textures, animations, shader programs and music, game engine as a tool to do the game, naturally to provide good resource management, so that the game developers in the simplest way to use resources. Game Engine resource management consists of two major parts: offline resource management and runtime resource management. In this paper, the former is briefly introduced and combined with Unity3d and ogre for analysis.
Resource Authoring and exportthe resources in the game are created by a variety of digital content authoring tools (DCC, digital contents creation), such as:
    • Three-dimensional model: 3DS Max,maya and so on;
    • Texture: Photoshop, etc.;
    • Music: Sound forge, etc.;
    • ..................
DCC often supports multiple export formats, such as:
    • 3DS max:3ds, AI, DDF, DEM, DWG, DXF, HTR, FBX, IAM, IGES, IPT, LP, LS, MTL, obj, etc.;
    • PHOTOSHOP:PSD, TIFF, EPS, PCX, GIF, JPEG, PNG, PICT, TGA, etc.
    • ..................
the game engine typically supports partial export formats for the specified DDC, such as Unity3d supports the FBX format exported by 3ds Max, or an export plug-in for a specific resource authoring tool, such as an export plug -in that Ogre has a variety of three-dimensional modeling software. While basically all DCC supports multiple export formats, in many cases these formats are not suitable for the game engine because
    • The content of the export is too complex, the game only uses some of its data, and the game is often more demanding performance requirements, so need to remove redundant data;
    • Many DCC export formats are slow to read, and some are closed formats that cause the engine to fail to read.
therefore, after DCC exports the resources, the engine needs to be further processed to convert the resources into the engine's internal format, which is called asset conditioning pipeling. Children's shoes using unity3d should be found, every time you import resources to read the bar, is in the asset conditioning pipeling;ogre in this aspect of support is not perfect, this part of the work is done by the custom export plug-in. compiling and linking of resourcesbecause there are some problems with the exported resources, a certain conversion is required, which is called asset conditioning pipeling, which consists of 2 steps:
    • Resource "Compile"
read the data from a single resource and convert it to a format that can be used directly in the game (using the most efficient or high format), such as re-ordering mesh vertices, or compressing textures using compression algorithms such as BC5. This process is somewhat similar to the compilation of the C language and is therefore called "compiling". Of course, if the exported resource can be used directly, you can skip this step.
    • Resources "Links"
in the game, many resources are not used alone, such as a three-dimensional model, which refers to materials and textures that are separate resources. In the previous step, the engine "compiles" a single resource into a format that can be used directly in the game, and this step links all resources so that the game can find all the resources that each resource relies on at run time, such as a three-dimensional model that correctly finds the materials and textures it needs. This process is somewhat similar to the C language link and is therefore named "link". Of course, if the exported resources can be used directly, you can also skip this step.   Unity3d This section to provide a more comprehensive support, so only need to export the standard resources supported by the engine, and put into the assets folder, the engine will be "compile" and "link", the result is in the Library folder (inside the mess, although we do not understand, But Unity3d liked it); Ogre does not provide a dedicated asset conditioning pipeling tool, so all operations are done in the resource's export plug-in without a separate "compile" and "link". Resource Management databasebefore a resource passes asset conditioning pipeline, the engine needs to store the way it handles the resource, typically using metadata (metadata), such as specifying how a texture should be compressed. The engine manages the metadata through the resource database, which can be described either simply using an XML file or using a database such as MySQL. Game developers use the interface provided by the engine to reconfigure the resources, for example, in the Unity3d editor, you can modify the mesh compression mode, choose whether to optimize the mesh, and so on. the game engine's resource database typically provides the following features:
    • supports mutual references to resources, and ensures references are valid after the referenced resource moves the path;

the use of Unity3d children's shoes can be found, Unity3d provides a more complete resource management functions, use more easily. resource Read (runtime)During the development process, all the original resources are saved as a single file for easy modification, but when the game runs the read resource, the resource is typically packaged into one or more files for faster reading. The reason for packaging is very simple, the time to read files from the hard disk, mainly consists of three parts:
    • Hard drive seek time;
    • The time the file was opened;
    • The time the file was read.
The last item is impossible to change unless you are using a faster storage medium, but packaging multiple files into one file can shorten the time of the previous two items. Unity3d when the game is released, the resource is packaged, and Ogre does not have a way to customize the packaging of resources, typically packaged as one or more zip files, or without packaging resources. Example AnalysisUnity3dWhen copying Unity3d works, be sure to copy the "Assets", "Library" and "Projectsettings" folders. Resources are in the "Assets", the settings are in the "Projectsettings", "Library" is to soy sauce? Not too! If you do not copy the "Library", you will be surprised to open the project, the previous settings are all gone?! And the things in the scene file are mess! Combining the above, it is easy to understand this strange phenomenon, understand why the "soy sauce" of the "Library." put the resource in the "Assets" folder and cut back to Unity3d, then go to importing Assets State (asset conditioning pipelining), asImporting Resourcesin this step, Unity3d generates metadata for all resources and compiles, links, and transforms the resources that the game can use directly. The resource before conversion is saved in "Assets", the converted resource is saved in "Library", all resources can modify metadata data in the Inspector panel, as"Library" folderInspectorIf you are using a version controller such as SVN, you need to synchronize all resources and their metadata. Open Edit->roject Settings->editor and change mode to "Meta Files" (Default "Disabled"), asSelect "Meta Files"when mode is changed to "Meta files", back to the Resources folder, you will find that each resource has more ***.meta files, such as, and these. Meta files save how these resources will be handled by asset conditioning pipeline. resource file with metadatanow Assets folder not only have all the resources, but also the corresponding metadata, "library" completely soy sauce, at this time in the Copy project or use SVN synchronization project can ignore the "library" folder. in the published game, the resource file is as shown in. As you can see, Unity3d resources are packaged to reduce resource loading time.

232336094438755.png (51.08 KB, download number: 0)

Download attachments to albums

Uploaded 2 minutes ago

Post -Release game ResourcesIn General, from the import of resources, generate metadata, "compile", "link" resources, and then release the game packaging resources, Unity3d are packaged, in the simplest way to provide us with, greatly improving the productivity of game developers. Although it may be the first time in use just feel unity3d used relatively simple, but it does a lot of work behind the back, but we did not pay attention to it. OGREOgre in this respect compared with Unity3d, the gap is relatively large, only the export of resources to provide plug-ins; In a published game, you can use zip to package your game resources without providing custom resource packaging. Of course, overall, it's a pretty good graphics engine, and the most important thing is that it's open source.
Disclaimer: This document is from the "Dog Planing Learning Network" community, is the Netizen self-published Unity3d study articles, if there is any content violated your relevant interests, please communicate with the official, we will deal with the real-time. More Highlights:Www.gopedu.com

Brief analysis on the resource management mechanism of game engine--the resource management hidden behind in the unity3d of a grilled piece of water

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.