A performance testing method for game engine
By employing detailed testing procedures and environments, and combining image pyramid decomposition and conditional random field models, fake game scene data is generated, overcoming the limitations of traditional testing methods and enabling a comprehensive and in-depth evaluation and optimization of game engine performance.
Patent Information
- Application Number
- CN202410224722.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-02-29
- Publication Date
- 2024-11-15
- Estimated Expiration
- 2044-02-29
AI Technical Summary
Traditional game engine performance testing methods cannot fully consider performance under different scenarios and conditions, lack a deep understanding of the internal mechanisms of game engines, and require a lot of manpower and time, resulting in inaccurate and incomplete test results.
By initializing the game engine test environment, recording the initialization time, starting the rendering loop and randomly changing the lighting conditions and the number of objects, rendering time and collision detection are performed. Combined with image pyramid decomposition and conditional random field model, detailed test steps and environment are constructed, fake game scene data is generated for training, and the generator is optimized to improve test accuracy and efficiency.
It enables a comprehensive evaluation of game engine performance, provides more accurate and comprehensive performance data, reduces testing costs, improves the accuracy and reliability of testing, and supports the continuous optimization and improvement of game engines.
Smart Images

Figure CN117982897B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a performance testing method for a game engine. Background Art
[0002] In today's digital game industry, game engine performance testing is one of the important links to ensure the quality of game products. The stability and efficiency of game engine performance directly affect the user experience and market competitiveness of game products. Therefore, it is crucial for game developers and game platform providers to develop an effective game engine performance testing method. At present, game engine performance testing usually adopts some traditional benchmarking methods, such as frame rate-based testing, CPU and GPU utilization-based testing, etc. These methods mainly evaluate the performance of game engines by measuring the running effect of games under specific hardware configurations. However, traditional benchmarking methods have some limitations:
[0003] First, these methods cannot fully consider the performance of game engines under different scenarios and conditions. The performance of games is affected by many factors, including scene complexity, lighting effects, physical simulation, etc. Traditional benchmarking methods can only provide local performance data, making it difficult to fully evaluate the performance of game engines. Second, traditional benchmarking methods often lack an in-depth understanding of the internal mechanisms of game engines. As a complex software system, the performance of game engines is affected by many internal factors, including rendering pipelines, physics engines, collision detection, etc. Traditional benchmarking methods often fail to deeply analyze the internal operating mechanisms of game engines, resulting in the inability to optimize performance in a targeted manner. In addition, traditional benchmarking methods often require a lot of manpower and time costs. Due to the complexity and diversity of game engines, traditional benchmarking methods often require the design of a large number of test cases and scenarios, and a lot of testing and analysis work. This not only increases the time cost of testing, but may also lead to inaccurate and incomplete test results. Therefore, there is currently a demand for game engine performance testing methods, and a more comprehensive, in-depth and efficient testing method needs to be developed to meet the needs of game developers and game platform providers for game engine performance evaluation. Summary of the invention
[0004] In view of this, the present invention provides a performance testing method for a game engine, which achieves more accurate and efficient game engine performance testing.
[0005] The technical solution adopted by the present invention is as follows:
[0006] A performance testing method for a game engine, the method comprising:
[0007] Step 1: Initialize the game engine test environment, including: loading resources and generating test scenes; when the test environment is initialized, record the initialization time;
[0008] Step 2: Start the rendering loop, render the test scene under different rendering pipelines, record the rendering time of each frame, randomly change the lighting conditions in the test scene in each frame, and increase or decrease the number of objects rendered in the test scene to obtain the rendering time distribution function under different rendering pipelines;
[0009] Step 3: During the rendering cycle, the game engine performs physical simulation on the objects under test, and then drives the objects in the test scene to move randomly in the test scene; at the same time, the game engine performs collision event detection on the objects moving randomly in the test scene in parallel, and records the accuracy of the collision detection;
[0010] Step 4: Calculate the game engine performance value based on the initialization time, rendering time distribution function and collision detection accuracy; the game engine performance value is obtained by multiplying the initialization time, rendering time distribution function and collision detection accuracy by their respective weight values, and then calculating the average value of the sum of the three.
[0011] Furthermore, the types of rendering pipelines in step 3 include at least: forward rendering, deferred rendering, cluster rendering and tile rendering; the resources loaded in step 1 include at least: textures, sounds, physical materials, collision bodies, script files and special effect particles; and the generated test scene is a three-dimensional test scene.
[0012] Furthermore, step 2 specifically includes: defining a test scene S, including N rendering objects, each of which has a refractive index of n i and surface roughness s i ; Test scenario Representation; generate multiple light sources in the test scene; calculate the surface reflectivity of each object under the illumination of multiple light sources; perform image pyramid decomposition on the test scene to generate image pyramids of different resolutions; build a conditional random field model based on the generated image pyramid, and regard each pixel in the scene as a random variable; in each frame, randomly change the lighting conditions and the number of objects, including changing the direction and intensity of the light source and increasing or decreasing the number of objects; define the energy function of the conditional random field; use the conditional random field model to infer the optimal state to minimize the energy function, and perform rendering under the current rendering pipeline; record the time it takes to render a frame, and obtain the rendering time distribution function under different rendering pipelines.
[0013] Furthermore, the surface reflectivity of each object is calculated using the following formula:
[0014]
[0015] Among them, R i represents the reflectivity of the surface of the i-th object, which indicates the proportion of light reflected after it hits the surface of the object; ω is the frequency parameter of the light source, which is used to describe the oscillation frequency of the light; s i is the surface area of the i-th object; M is the number of light sources; x k and k are the X-axis and Y-axis coordinates of the kth light source, indicating the position of the light source in the test scene; σ is the standard deviation of the Gaussian distribution, which is used to describe the range of light source distribution; k is the subscript index; θ i,k is the incident angle of the kth light source onto the i-th object; θ i,k,t The transmission angle of the kth light source to the i-th object.
[0016] Furthermore, each pixel node in the image pyramid is regarded as a random variable, denoted as X j , j = 1, 2, ..., V, where V is the number of pixels in the image pyramid; for each pixel node X j , consider its adjacent pixel nodes and establish edges; define it through the spatial position of the pixel node, consider the 8 adjacent pixel nodes around each pixel node, and use the Gaussian kernel function to define the adjacency relationship so that the relationship between spatially adjacent pixel nodes can be modeled as a probabilistic relationship; define the potential function of the probabilistic relationship, and construct the energy function of the conditional random field based on the defined potential function.
[0017] Furthermore, the potential function Ψ(X j ,X z ) is expressed using the following formula:
[0018]
[0019] Among them, λ is the Poisson distribution parameter, is the standard deviation of the Gaussian kernel function; P(X j ,X z ) is the jth pixel node and X z The probability that pixel nodes are spatially adjacent pixel nodes to each other; the energy function E of the conditional random field is expressed using the following formula:
[0020]
[0021] Among them, φ j (X j ) is its own potential function, which is expressed using the following formula:
[0022]
[0023] Among them, P j is pixel node X j ; μ is the mean pixel value of all pixel nodes in the image pyramid; the conditional random field model is used to infer the optimal state to minimize the energy function and perform rendering under the current rendering pipeline.
[0024] Furthermore, in step 3, the method for detecting collision events of objects randomly moving in the test scene by the game engine includes: collecting real game scene data, designing a generator, and generating false game scene data based on the real game scene data; both the false game scene data and the real game scene data include at least: an object motion parameter vector and a collision label; the object motion parameter vector includes at least the speed, position, direction, acceleration, volume and shape of the object; the distance between the object motion parameter vector in the false game scene data and the real game scene data is less than a set threshold, and all collision label values in the false game scene data are 0, indicating that no collision occurs, while the collision label value in the real game scene data may be 0 or 1, and when it is 1, it indicates that a collision occurs; the real game scene data and the false game scene data are randomly mixed to obtain mixed data as training data; a discriminator is designed, and the discriminator is trained using the training data. During the training process, the discriminator aims to discriminate the corresponding label as accurately as possible according to the object motion parameter vector in the training data; and then the discriminator is used to detect collision events of objects randomly moving in the test scene.
[0025] Furthermore, when using the training data to train the discriminator, the loss function of the discriminator is Use the following formula to express it:
[0026]
[0027] Among them, λ is the first adjustment parameter, which is used to control the degree of Laplace smoothing. The larger its value, the smoother it is; h is the Dirac weight parameter, which ranges from 0.5 to 0.8; is the Laplace operator of the discriminator D(x); δ is the Dirac function; γ is the Dirac threshold; p data (x) represents the distribution of real game scene data; p(f) is the distribution of fake game scene data.
[0028] Furthermore, after the generator generates fake game scene data based on real game scene data each time, the generator will be reversely trained by adjusting the parameters of the generator so that the distance between the object motion parameter vectors in the fake game scene data and the real game scene data is as small as possible when the distance between the object motion parameter vectors in the fake game scene data and the real game scene data is less than a set threshold.
[0029] Furthermore, when the generator is trained in reverse, the loss function of the generator is Use the following formula to express it:
[0030]
[0031] Among them, U is the regularization coefficient, and its value range is 0.3 to 0.6.
[0032] By adopting the above technical scheme, the present invention produces the following beneficial effects: First, the present invention provides a comprehensive and in-depth game engine performance testing method, which can comprehensively evaluate the performance of the game engine under different scenarios and conditions. Traditional benchmarking methods can often only provide local performance data, and it is difficult to comprehensively evaluate the performance of the game engine. The present invention realizes a comprehensive test of the game engine performance by defining detailed test steps and environments, including loading resources, generating test scenes, starting rendering cycles, etc. By recording indicators such as initialization time, rendering time distribution function, and collision detection accuracy, the performance of the game engine under different conditions can be fully understood, providing developers with more accurate and comprehensive performance evaluation data. Secondly, the present invention adopts advanced technical means, such as image pyramid decomposition, conditional random field model, etc., to model and analyze the game scene in detail, and deeply understand the internal operation mechanism of the game engine. By constructing a conditional random field model, the present invention can comprehensively consider the influence of each pixel node in the game scene and more accurately evaluate the performance of the game engine. This deep analysis method based on advanced technology makes the evaluation results more scientific and reliable, and provides developers with more convincing performance test data. In addition, the present invention also proposes an innovative data generation and training method, which realizes continuous optimization and improvement of game engine performance by generating false game scene data and reverse training the generator. This method can not only reduce the test cost, but also improve the accuracy and reliability of the test. By continuously optimizing the generator, the generated false data is closer to the distribution of real data, thereby improving the efficiency and credibility of the game engine performance test. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] Figure 1 The present invention is a method flow chart of a performance testing method for a game engine according to an embodiment of the present invention. DETAILED DESCRIPTION
[0034] All features disclosed in this specification, or steps in all methods or processes disclosed, except mutually exclusive features and / or steps, can be combined in any manner.
[0035] Any feature disclosed in this specification (including any additional claims and abstract), unless otherwise stated, may be replaced by other equivalent or alternative features having similar purposes. That is, unless otherwise stated, each feature is only an example of a series of equivalent or similar features.
[0036] Example 1: Reference Figure 1 , a performance testing method for a game engine, the method comprising:
[0037] Step 1: Initialize the game engine test environment, including: loading resources and generating test scenes; when the test environment is initialized, record the initialization time;
[0038] This step involves loading the resources required for the game into memory, including but not limited to models, textures, audio, etc. Resources can come from the local file system, network or other external storage media. The process of loading resources may include file reading, parsing, memory allocation and other operations. After loading resources, a virtual game scene for performance testing needs to be generated. This scene may include various game elements such as terrain, buildings, props, characters, and set appropriate environmental parameters such as lighting and weather. The generation of the scene may require programming or configuration according to the characteristics of the game engine and test requirements. Initializing the test environment of the game engine is to perform performance testing based on the simulation of the real game running environment. The process of loading resources is to ensure that the various data required by the game can be correctly read and processed by the engine, and generating the test scene is to provide a specific scene to evaluate the performance of the engine. In the process of loading resources and generating scenes, file I / O operations, memory management, graphics rendering and other technologies may be involved, and their principles are similar to resource loading and scene construction in actual game development.
[0039] By recording the initialization time, you can evaluate the time required for the game engine to start up, thereby understanding possible performance bottlenecks or optimization space during the engine startup process.
[0040] Step 2: Start the rendering loop, render the test scene under different rendering pipelines, record the rendering time of each frame, randomly change the lighting conditions in the test scene in each frame, and increase or decrease the number of objects rendered in the test scene to obtain the rendering time distribution function under different rendering pipelines;
[0041] In a game engine, a rendering loop refers to the process of continuously updating and rendering the game screen. Usually, a game engine will update the state of the game world, perform physical simulations, process user input, and finally render the updated scene to the screen in a loop. Starting a rendering loop means starting to execute this loop, continuously updating and rendering the game screen. In a rendering loop, rendering the test scene is a key step. This includes drawing various objects, textures, lighting and other elements in the scene to the screen to form the final game screen. In this process, various graphics rendering technologies may be involved, such as rasterization, shading, texture mapping, etc. After each frame is rendered, the rendering time of the current frame is recorded. Rendering time refers to the time interval from the start of rendering to the completion of rendering. By recording the rendering time of each frame, a rendering time series can be obtained for subsequent performance evaluation and analysis.
[0042] Recording the rendering time of each frame can evaluate the rendering performance of the game engine under different conditions. The length of the rendering time reflects the calculation and resource consumption required by the engine to process and draw the scene, and is an important indicator for evaluating rendering efficiency. Rendering under different rendering pipelines and recording the rendering time can compare the performance of different rendering technologies or algorithms, which helps engine developers choose the appropriate rendering solution. By recording the rendering time distribution function, the stability of the engine's rendering performance during long-term operation can be evaluated, and fluctuations or abnormalities in rendering performance can be discovered in a timely manner.
[0043] Step 3: During the rendering cycle, the game engine performs physical simulation on the objects under test, and then drives the objects in the test scene to move randomly in the test scene; at the same time, the game engine performs collision event detection on the objects moving randomly in the test scene in parallel, and records the accuracy of the collision detection;
[0044] The game engine performs physical simulation on the object under test, which includes calculating the force on the object based on its mass, shape, speed and other parameters, and then simulating the object's motion trajectory according to physical laws such as Newton's laws of motion. Physical simulation can involve the calculation of physical effects such as rigid body motion, collision response, gravity, friction, etc. Based on the physical simulation, the game engine drives the objects in the test scene to move randomly. This random motion may include translation, rotation, jumping, etc. to simulate the behavior of objects in real game scenes. At the same time as the objects move randomly, the game engine performs collision event detection on the objects in the test scene that are moving randomly in parallel. Collision event detection refers to detecting whether a collision occurs between objects and how to handle the collision response when a collision occurs. While performing collision event detection, the accuracy of collision detection is recorded. This can be calculated by counting the number of collision events detected and comparing them with the objects that actually collided. The accuracy or error rate.
[0045] Record the calculation time and accuracy during the physical simulation process, and evaluate the performance of the game engine in physical simulation, including its processing capabilities for rigid body motion, collision detection, etc. Record and analyze the accuracy of collision detection, and evaluate the accuracy and stability of the game engine when handling collision events to ensure that the interaction between objects in the game can be handled correctly. By comprehensively considering the physical simulation performance and collision detection accuracy, a comprehensive evaluation of the physical simulation capabilities of the game engine is conducted to provide a reference for developers to help them optimize the physical engine and collision detection algorithm.
[0046] Step 4: Calculate the game engine performance value based on the initialization time, rendering time distribution function and collision detection accuracy; the game engine performance value is obtained by multiplying the initialization time, rendering time distribution function and collision detection accuracy by their respective weight values, and then calculating the average value of the sum of the three.
[0047] First, the initialization time is multiplied by the corresponding weight value to reflect the impact of the initialization process on the overall performance. This weight value can be set according to actual needs and experience, and usually takes into account the proportion of the initialization time in the entire game process. Weight each rendering time distribution function. This may involve statistical analysis of the rendering time series, such as calculating the mean, standard deviation, etc., to better reflect the stability and fluctuation of the rendering performance. Then, these statistical indicators are multiplied by the corresponding weight value to reflect the contribution of the performance under different rendering pipelines to the overall performance. Weight the accuracy of collision detection. Usually, the accuracy is multiplied by a weight value to reflect the importance of collision detection in the entire game process. This weight value can be adjusted according to the game type and needs. For example, for action games, the accuracy of collision detection may be more critical. The weighted initialization time, rendering time distribution function, and collision detection accuracy are added together, and then their average is calculated. The average value obtained in this way is the performance value of the game engine, which reflects the comprehensive performance of the game engine in initialization, rendering, and physical simulation.
[0048] By weighting multiple performance indicators, a comprehensive performance value is obtained to more comprehensively evaluate the overall performance of the game engine, rather than just being limited to a single performance indicator. By setting the weight values of different indicators, the influence of different indicators in the comprehensive evaluation can be adjusted according to actual needs and priorities, so as to better meet the actual application scenarios and developer needs.
[0049] Embodiment 2: The types of rendering pipelines in step 3 include at least: forward rendering, deferred rendering, cluster rendering and tile rendering; the resources loaded in step 1 include at least: textures, sounds, physical materials, collision bodies, script files and special effect particles; the generated test scene is a three-dimensional test scene.
[0050] Specifically, forward rendering is a traditional rendering technology, which is a method that directly calculates each pixel in the scene in screen space. The specific steps are as follows: Geometry processing: First, the geometry in the scene is rendered, including vertex transformation, clipping, projection and other operations to obtain the pixel position information in the screen space. Lighting calculation: For each pixel, the color value of the pixel is calculated based on the material properties of its surface and the light source information. This includes the calculation of lighting effects such as diffuse reflection, specular reflection, and ambient light. Rendering: The calculated pixel color value is written to the frame buffer to complete the rendering of the pixel. When there are a large number of light sources in the scene, the performance of forward rendering will be affected because each pixel needs to calculate all light sources, resulting in a large rendering overhead. Deferred rendering is a rendering technology that first stores the geometric information and surface properties in the scene in the geometry buffer, and then calculates the lighting in the post-processing stage. The specific steps are as follows: Geometry processing and G-buffer filling: First, the geometric information and surface properties (such as color, normal, roughness, etc.) in the scene are stored in the geometry buffer (G-buffer). Lighting calculation: In the post-processing stage, the lighting effect of each pixel is calculated based on the information in the G buffer and the properties of the light source. This can include diffuse reflection, specular reflection, global illumination, etc. Rendering: Finally, the calculated pixel color value is written to the frame buffer to complete the rendering of the pixel. Deferred rendering does not support transparent objects enough and requires additional memory overhead. Cluster rendering is a rendering technology based on the spatial distribution of objects in the scene. The specific steps are as follows: Space segmentation: Divide the scene space into multiple clusters or regions, each cluster contains multiple objects. Visibility calculation: For each cluster, determine which objects are visible, that is, objects that can be seen from the current perspective. Rendering: Render each visible object, only render the visible objects in the field of view, thereby reducing unnecessary rendering calculations. Cluster rendering also requires additional space segmentation and visibility calculations, which adds a certain degree of complexity. Tile rendering is a technology that divides the screen into multiple small blocks (tiles) and performs independent rendering calculations on each tile. The specific steps are as follows: Tile partitioning: Divide the screen space into multiple tiles, usually in fixed-size pixel blocks. Tile rendering: Perform independent rendering processing on each tile, including geometry processing, lighting calculation, etc. Merge rendering results: Merge the rendering results of each tile into the final screen image. Tile rendering requires additional rendering result merging operations, which may increase certain overhead.
[0051] Embodiment 3: Step 2 specifically includes: defining a test scene S, including N rendering objects, each of which has a refractive index of n i and surface roughness s i ; Test scenario Representation; generate multiple light sources in the test scene; calculate the surface reflectivity of each object under the illumination of multiple light sources; perform image pyramid decomposition on the test scene to generate image pyramids of different resolutions; build a conditional random field model based on the generated image pyramid, and regard each pixel in the scene as a random variable; in each frame, randomly change the lighting conditions and the number of objects, including changing the direction and intensity of the light source and increasing or decreasing the number of objects; define the energy function of the conditional random field; use the conditional random field model to infer the optimal state to minimize the energy function, and perform rendering under the current rendering pipeline; record the time it takes to render a frame, and obtain the rendering time distribution function under different rendering pipelines.
[0052] Specifically, in the game engine, a test scene is first constructed, including multiple rendering objects and light sources. Each object has specific optical properties, such as refractive index and surface roughness. The layout and properties of these objects and light sources affect the computational complexity and performance of the rendering process. Image pyramids of different resolutions are generated by image pyramid decomposition. Then, based on these image pyramids, a conditional random field model is constructed. The conditional random field can describe the spatial relationship and mutual constraints between pixels, which helps to optimize the pixel state in the rendering process. Define the energy function, treat each pixel in the scene as a random variable, and consider factors such as image pyramids, object properties, and lighting conditions to construct an energy function to describe the constraints and optimization goals in the rendering process. The minimization of the energy function represents the optimization goal of the rendering process. Using the conditional random field model, the optimal state that minimizes the energy function is inferred by optimizing the energy function. This process is similar to image segmentation and image restoration problems, and the pixel state is inferred to obtain the best rendering result.
[0053] The energy function of the conditional random field is usually defined as a function of random variables, which measures the "irrationality" of the configuration under a given state. In Example 3, the energy function can be defined as a function that takes into account factors such as the image pyramid, object attributes, and lighting conditions. The energy function usually consists of two parts: Data Term: The data term represents the degree of match between the observed data and the model. In Example 3, the data term can describe the degree of match between the observed image pyramid and the rendering result predicted by the model. Smoothness Term: The smoothness term is used to represent the spatial relationship and constraints between adjacent pixels. It promotes the similarity of the states of adjacent pixels, thereby maintaining the continuity and consistency of the rendering results. Taking into account the data term and the smoothness term, a global energy function can be constructed to describe the constraints and optimization objectives of the entire rendering process. Using the conditional random field model, the optimal state that minimizes the energy function can be inferred by optimizing the energy function. The commonly used method is to find the local minimum of the energy function through iterative optimization algorithms, such as gradient descent, coordinate descent, etc., or to find the global minimum through heuristic search methods. In the rendering process, the optimal state corresponds to a set of pixel state configurations that minimize the energy function. This means that in this state, the rendering result matches the observed data of the image pyramid to the highest degree, and at the same time satisfies the constraints of the smoothing term. In the conditional random field model, by optimizing the energy function, we are actually trying to find a set of pixel states so that the rendering result not only matches the observed data, but also satisfies the spatial constraints and model prior knowledge. Therefore, when the energy function is minimized, the corresponding pixel state is the state configuration that best meets the model assumptions and constraints under the given observed data, that is, the optimal state. In Example 3, the optimal state corresponds to the pixel state configuration that can produce the best rendering effect under the current rendering pipeline. By minimizing the energy function, such an optimal state can be obtained, thereby optimizing and controlling the rendering process. In the inferred optimal state, the rendering operation is performed. This includes calculating the color value of each pixel according to the lighting conditions and object properties, and writing the result to the frame buffer. In Example 4, the formula gives an energy function that describes the relationship between the reflectivity of the object surface and multiple factors. In the rendering process, by minimizing this energy function, the object surface reflectivity configuration that makes the rendering result optimal can be obtained. Minimizing the energy function means finding the state configuration that makes the reflectivity match the observed data most closely, which is also considered the optimal state. Therefore, when the energy function is minimized, the corresponding state is the optimal state.
[0054] Example 4: Use the following formula to calculate the surface reflectivity of each object:
[0055]
[0056] Among them, R i represents the reflectivity of the surface of the i-th object, which indicates the proportion of light reflected after it hits the surface of the object; ω is the frequency parameter of the light source, which is used to describe the oscillation frequency of the light; s i is the surface area of the i-th object; M is the number of light sources; x k and k are the X-axis and Y-axis coordinates of the kth light source, indicating the position of the light source in the test scene; σ is the standard deviation of the Gaussian distribution, which is used to describe the range of light source distribution; k is the subscript index; θ i,k is the incident angle of the kth light source onto the i-th object; θ i,k,t The transmission angle of the kth light source to the i-th object.
[0057] Specifically, the formula is divided into two items. For the first item: This section describes the self-reflectivity of a surface, which is the reflection that occurs when light is directed from one medium to another. This section uses the Fresnel formula for the self-reflectivity expression. is the refractive index n of the surface material of the object i The relative refractive index of air represents the change in refractive index when light is emitted from a medium to air. Substituting the relative refractive index into the Fresnel formula, we can get the self-reflection rate when light is emitted from air to the same medium, and then take the square and divide it by 2 to take into account the two possibilities of light when it is incident and emitted (horizontally and vertically), so it is divided by 2 to average. This part describes the sum of the reflectance contributions from all light sources, taking into account the impact of the angle of incidence and transmission of each light source on the object surface. i,k is the incident angle of the kth light source onto the i-th object, θ i,k,t is the transmission angle of the kth light source irradiating the i-th object. This part uses the reflectivity expression of the Fresnel formula, taking into account the change in refractive index when the light is emitted from a medium to the same medium. The summation part represents the accumulation of the contributions of all light sources. The incident angle and transmission angle of each light source are calculated separately, and then substituted into the Fresnel formula to calculate the reflectivity when the light is emitted from each medium to the same medium, and then squared and summed to take into account the two possibilities of the light when it is incident and emitted (horizontally and vertically).
[0058] For the second item: the molecular part Describes the effect of the surface area of an object on the reflectivity, taking into account the frequency domain characteristics of the surface area of the object. ω is the frequency parameter of the light source, which is used to describe the oscillation frequency of the light. iis the surface area of the ith object. This part uses the idea of frequency domain analysis, treating the surface area of the object as a signal in the frequency domain. By Fourier transforming the surface area of the object, we can get an expression in the frequency domain. In this process, the frequency parameter ω of the light source adjusts the oscillation frequency of the signal. The denominator part Describes the effect of the light source position on the reflectivity, taking into account the spatial characteristics of the light source position. σ is the standard deviation of the Gaussian distribution, describing the range of the light source distribution. (x k ,y k ) is the position of the kth light source in the test scene. This part uses the idea of spatial domain analysis and regards the light source position as a distribution in space. By calculating the second-order partial derivative of the Gaussian function of the light source position, the influence of the light source position in the spatial domain can be obtained. In this process, the standard deviation σ of the Gaussian distribution adjusts the range of the light source distribution. The numerator in the formula describes the influence of the surface area of the object on the reflectivity. Through the Fourier transform of the surface area of the object, an expression in the frequency domain can be obtained, which reflects the influence of the frequency domain characteristics of the surface area of the object on the reflectivity. In other words, this part considers the contribution of the frequency domain distribution of the surface area of the object to the reflectivity. The denominator in the formula describes the influence of the light source position on the reflectivity. By calculating the Gaussian distribution function and the second-order partial derivative of the light source position, the influence of the light source position in the spatial domain can be obtained. This reflects the influence of the spatial characteristics of the light source position on the reflectivity. In other words, this part considers the contribution of the spatial distribution of the light source position to the reflectivity.
[0059] The performance test of the game engine involves calculating the reflectivity of the surface of objects in different scenes. The formula in Example 4 provides a complex method to calculate the reflectivity of the surface of an object. By calculating the reflectivity of each object surface, the engine's ability to process light during the rendering process and its simulation accuracy of object materials and lighting conditions can be evaluated. The formula in Example 4 involves optical properties such as reflection, refraction and transmission of light on the surface of an object, as well as parameters such as the refractive index and roughness of the surface of an object. These parameters can be used to simulate the surface properties of objects of different materials in the game scene, such as metal, wood, glass, etc., and the reflection effect under different lighting conditions. By simulating these properties, the rendering effect and realism of the game engine under different scenes and lighting conditions can be evaluated. The formula in Example 4 provides a complex calculation method for light reflection and object surface properties during the rendering process of the game engine. By analyzing the calculation results, the performance of the game engine in processing light and object surface properties can be evaluated. Specifically, the rendering effect of the engine under different scenes, lighting conditions and object materials, as well as its utilization efficiency of hardware resources can be analyzed. These analysis results can help developers optimize the rendering algorithms and performance of the game engine, improving the visual quality and user experience of the game.
[0060] Example 5: Consider each pixel node in the image pyramid as a random variable, denoted as X j , j = 1, 2, ..., V, where V is the number of pixels in the image pyramid; for each pixel node X j , consider its adjacent pixel nodes and establish edges; define it through the spatial position of the pixel node, consider the 8 adjacent pixel nodes around each pixel node, and use the Gaussian kernel function to define the adjacency relationship so that the relationship between spatially adjacent pixel nodes can be modeled as a probabilistic relationship; define the potential function of the probabilistic relationship, and construct the energy function of the conditional random field based on the defined potential function.
[0061] Specifically, the game engine performance test not only involves rendering speed, but also needs to evaluate rendering quality. The conditional random field model established in Example 5 can help evaluate the image quality rendered by the game engine. By modeling the random variables of each pixel node in the image pyramid and considering the adjacent relationship and probability relationship between the pixel nodes, the image structure and features in the game scene can be more fully understood. This helps to detect rendering errors, artifacts and other visual defects in the image, thereby evaluating the performance of the game engine in rendering images. The conditional random field model established in Example 5 can help understand the spatial relationship between pixel nodes in the image, and describe the state of the entire image by potential function and energy function. By analyzing the energy function and minimizing its value, the optimal state configuration can be inferred, that is, the image interpretation that best meets the conditional random field model. This helps to discover local features and global structures in the image, and provides a reference for the rendering optimization of the game engine. By optimizing aspects such as rendering algorithms and image processing processes, the rendering efficiency of the game engine can be improved, thereby improving game performance.
[0062] In the image pyramid, each pixel node can be regarded as a random variable X j , where j represents the index of the pixel node and V is the number of pixels in the image pyramid. These random variables represent the pixel values or pixel attributes at different locations in the image. j, considering the 8 neighboring pixel nodes around it, the adjacency relationship between them can be defined by the spatial position of the pixel nodes. Gaussian kernel function is usually used to establish this adjacency relationship so that the relationship between spatially adjacent pixel nodes can be modeled as a probabilistic relationship. In conditional random fields, the potential function defines the relationship between random variables. Here, the potential function can be defined based on the probabilistic relationship between adjacent pixel nodes. This potential function can take into account factors such as the similarity and spatial continuity between pixel nodes. Based on the defined potential function, the energy function of the conditional random field can be constructed. The energy function describes the state of the entire system, which is the sum of the interactions between random variables. By minimizing the energy function, the optimal state configuration can be inferred, that is, the state that best conforms to the conditional random field model.
[0063] Example 6: Potential function Ψ(X j ,X z ) is expressed using the following formula:
[0064]
[0065] The spatial similarity between pixel nodes is mainly considered. In this part, |X j -X z | represents pixel node X j and X z Generally, pixel nodes with similar pixel values in space have greater correlation, so the potential value between pixel nodes with closer distance is larger, and the potential value between pixel nodes with farther distance is smaller. is the standard deviation of the Gaussian kernel function, which controls the effect of spatial distance on the potential function. The smaller the standard deviation, the greater the difference in potential values between pixel nodes with smaller spatial distances, and thus the stronger the relationship between the corresponding pixel nodes. The pixel value differences between pixel nodes are taken into account. In this part, |X j -X z | represents pixel node X j and X z λ is the parameter of Poisson distribution, which is used to adjust the effect of pixel value difference on potential function. The smaller the parameter λ is, the smaller the effect of pixel value difference on potential function is; the larger the parameter λ is, the greater the effect of pixel value difference on potential function is. The introduction of Poisson distribution parameters makes the contribution of pixel value difference to potential function not linear, but exponential growth. This setting can better capture the effect of pixel value difference on potential function, thereby improving the accuracy of the model.
[0066] Among them, λ is the Poisson distribution parameter, is the standard deviation of the Gaussian kernel function; P(X j ,Xz ) is the jth pixel node and X z The probability that pixel nodes are spatially adjacent pixel nodes to each other; the energy function E of the conditional random field is expressed using the following formula:
[0067]
[0068] The energy function comprehensively considers the contributions of its own potential function and the potential function of adjacent pixel nodes, and describes the state of the entire conditional random field system. By minimizing the energy function, the optimal state configuration can be inferred, that is, the state configuration with the smallest energy function. In the game engine performance test, this means finding the state configuration that best suits the current rendering pipeline, thereby improving rendering efficiency and rendering quality.
[0069] Among them, φ j (X j ) is its own potential function, which is expressed using the following formula:
[0070]
[0071] Among them, P j is pixel node X j ; μ is the mean pixel value of all pixel nodes in the image pyramid; the conditional random field model is used to infer the optimal state to minimize the energy function and perform rendering under the current rendering pipeline.
[0072] Embodiment 7: The method for detecting collision events of objects performing random motion in a test scene by a game engine in step 3 includes: collecting real game scene data, designing a generator, and generating false game scene data based on the real game scene data; both the false game scene data and the real game scene data include at least: an object motion parameter vector and a collision label; the object motion parameter vector includes at least the speed, position, direction, acceleration, volume and shape of the object; the distance between the object motion parameter vector in the false game scene data and the real game scene data is less than a set threshold, and all collision label values in the false game scene data are 0, indicating that no collision occurs, while the collision label value in the real game scene data may be 0 or 1, and when it is 1, it indicates that a collision occurs; the real game scene data and the false game scene data are randomly mixed to obtain mixed data as training data; a discriminator is designed, and the discriminator is trained using the training data. During the training process, the discriminator aims to discriminate the corresponding label as accurately as possible according to the object motion parameter vector in the training data; and then the discriminator is used to detect collision events of objects performing random motion in the test scene.
[0073] Specifically, in the performance test of the game engine, collision detection is an important indicator. Example 7 By training a discriminator model, the detection accuracy of the game engine for collision events can be improved. The discriminator model can accurately predict whether a collision occurs based on the motion parameter vector of the object, thereby more effectively evaluating the collision detection performance of the game engine. The mixture of false game scene data and real game scene data generated by the generator can increase the diversity of training data. In this way, various situations in real game scenes can be better simulated, thereby improving the reliability of performance testing. By training the discriminator model, the performance of the game engine can be tested in a wider range of scenarios to ensure that it can accurately detect collision events in various situations. Example 7 By designing a discriminator model and training it with training data, the collision detection algorithm of the game engine can be deeply analyzed. By observing the training process and detection results of the discriminator, problems and room for improvement in the algorithm can be found, thereby optimizing the collision detection algorithm of the game engine and improving its performance and stability. Using the discriminator model for collision detection can realize an automated collision detection process, reduce the workload of manual detection, and improve test efficiency. At the same time, by training the discriminator model, the test data set can be synthesized into a unified training data, which makes testing and analysis more convenient and accelerates the performance testing process.
[0074] Example 8: When using training data to train the discriminator, the loss function of the discriminator Use the following formula to express it:
[0075]
[0076] Among them, λ is the first adjustment parameter, which is used to control the degree of Laplace smoothing. The larger its value, the smoother it is; h is the Dirac weight parameter, which ranges from 0.5 to 0.8; is the Laplace operator of the discriminator D(x); δ is the Dirac function; γ is the Dirac threshold; p data (x) represents the distribution of real game scene data; p(f) is the distribution of fake game scene data.
[0077] Specifically, Represents the loss of the discriminator on the real game scene data. This term consists of two parts: cross entropy loss and Laplace smoothing term. logD(x) represents the logarithm of the discriminator's predicted probability for the real data. By minimizing this term, the discriminator can classify the real data as real data as accurately as possible. is a Laplace smoothing term used to penalize the gradient change of the discriminator. Denotes the Laplace operator of the discriminator D(x), which measures the second-order spatial variation of the discriminator output probability. By minimizing this term, the discriminator output probability can be smoothed in space, thereby improving the stability and generalization ability of the model.
[0078] Represents the loss of the discriminator on fake game scene data. This item also includes two parts: cross entropy loss and Dirac loss. log(1-
[0079] D(G(f))) represents the logarithm of the discriminator’s predicted probability of false data. By minimizing this term, the discriminator can classify false data as false data as accurately as possible. is the Dirac loss term, which is used to increase vigilance against false data. δ(D(G(f))) represents the Dirac function. When the output probability of the discriminator is close to the Dirac threshold γ, the Dirac function takes a non-zero value, otherwise it is zero. By minimizing this term, the discriminator can be more cautious in predicting false data and improve the robustness of the model.
[0080] Example 9: After the generator generates fake game scene data based on real game scene data each time, the generator will also be reversely trained by adjusting the parameters of the generator so that the distance between the object motion parameter vectors in the fake game scene data and the real game scene data is as small as possible when the distance between the object motion parameter vectors in the fake game scene data and the real game scene data is less than a set threshold.
[0081] Specifically, during the reverse training process, the parameters of the generator will be adjusted so that the fake game scene data generated by the generator is as close to the real game scene data as possible. By adjusting the parameters of the generator, the output of the generator can be changed so that the data it generates is closer to the distribution of the real data, thereby improving the generator's generation ability. The goal of reverse training is to reduce the distance between the fake game scene data and the real game scene data. By making the distance between the object motion parameter vector of the fake data generated by the generator and the object motion parameter vector in the real data as small as possible, the fidelity and accuracy of the fake data generated by the generator can be improved to make it more consistent with the characteristics of the real scene. Through reverse training, the generator is forced to generate more realistic fake game scene data, which helps to improve the generator's generation ability. The generator learns how to generate more realistic false data based on the characteristics of the real data, thereby improving its effect in generating game scene data.
[0082] Example 10: When the generator is trained in reverse, the loss function of the generator is Use the following formula to express it:
[0083]
[0084] Among them, U is the regularization coefficient, and its value range is 0.3 to 0.6.
[0085] Specifically, is the adversarial loss of the generator, which is used to measure the negative logarithm of the probability that the fake data generated by the generator is judged as real data by the discriminator. By minimizing this term, the generator tries to generate more realistic fake data to deceive the discriminator. This helps to improve the realism of the fake game scene data generated by the generator. is the gradient penalty term, which is used to penalize the second-order derivative of the discriminator output probability with respect to the real data. This term helps stabilize the training process and avoid gradient explosion or gradient vanishing problems. By minimizing this term, the output probability of the discriminator can be made relatively smooth, improving the stability of the model. The regularization coefficient U is an important parameter used to adjust the gradient penalty term. Its value range is 0.3 to 0.6. By adjusting the size of the regularization coefficient U, the influence of the gradient penalty term in the loss function can be controlled. A larger regularization coefficient U can increase the weight of the gradient penalty term, thereby more strictly penalizing changes in the discriminator output probability, making the false data generated by the generator closer to the distribution of real data.
[0086] The present invention is not limited to the above-mentioned specific embodiments, but extends to any new features or any new combination disclosed in this specification, as well as any new method or process steps or any new combination disclosed.
Claims
1. A performance testing method for a game engine, characterized in that: The method comprises: Step 1: Initialize the game engine test environment, including: loading resources and generating test scenes; when the test environment is initialized, record the initialization time; Step 2: Start the rendering loop, render the test scene under different rendering pipelines, record the rendering time of each frame, randomly change the lighting conditions in the test scene in each frame, and increase or decrease the number of objects rendered in the test scene to obtain the rendering time distribution function under different rendering pipelines; Step 3: During the rendering cycle, the game engine performs physical simulation on the objects under test, and then drives the objects in the test scene to move randomly in the test scene; at the same time, the game engine performs collision event detection on the objects moving randomly in the test scene in parallel, and records the accuracy of the collision detection; Step 4: Calculate the game engine performance value based on the initialization time, the rendering time distribution function and the accuracy of collision detection; the game engine performance value is the arithmetic mean of the initialization time, the rendering time distribution function and the accuracy of collision detection multiplied by their respective weight values; Step 2 specifically includes: defining a test scenario ,include render objects, each with a refractive index of and the surface roughness is ; Test scenario Representation; generate multiple light sources in the test scene; calculate the surface reflectance of each object under the illumination of multiple light sources; perform image pyramid decomposition on the test scene to generate image pyramids of different resolutions; build a conditional random field model based on the generated image pyramid, and regard each pixel in the scene as a random variable; randomly change the lighting conditions and the number of objects in each frame, including changing the direction and intensity of the light source and increasing or decreasing the number of objects; define the energy function of the conditional random field; use the conditional random field model to infer the optimal state to minimize the energy function, and perform rendering under the current rendering pipeline; record the time it takes to render a frame, and obtain the rendering time distribution function under different rendering pipelines; In step 3, the method for the game engine to detect collision events of objects performing random motion in the test scene includes: collecting real game scene data, designing a generator, and generating false game scene data based on the real game scene data; both the false game scene data and the real game scene data at least include: an object motion parameter vector and a collision label; the object motion parameter vector at least includes the speed, position, direction, acceleration, volume and shape of the object; the distance between the object motion parameter vector in the false game scene data and the real game scene data is less than a set threshold, and all collision label values in the false game scene data are 0, indicating that no collision occurs, while the collision label value in the real game scene data may be 0 or 1, and when it is 1, it indicates that a collision occurs; the real game scene data and the false game scene data are randomly mixed to obtain mixed data as training data; a discriminator is designed, and the discriminator is trained using the training data. During the training process, the discriminator aims to discriminate the corresponding label as accurately as possible according to the object motion parameter vector in the training data; and then the discriminator is used to detect collision events of objects performing random motion in the test scene.
2. The performance testing method of the game engine according to claim 1, characterized in that: The types of rendering pipelines in step 3 include at least: forward rendering, deferred rendering, cluster rendering and tile rendering; the resources loaded in step 1 include at least: textures, sounds, physical materials, collision bodies, script files and special effect particles; the generated test scene is a three-dimensional test scene.
3. The performance testing method of the game engine according to claim 2, characterized in that: Calculate the surface reflectivity of each object using the following formula: ; in, Indicates The reflectivity of an object's surface indicates the proportion of light that is reflected after it hits the object's surface. It is the frequency parameter of the light source, which is used to describe the oscillation frequency of the light; It is The surface area of an object; is the number of light sources; and They are The X-axis and Y-axis coordinates of a light source, indicating the position of the light source in the test scene; is the standard deviation of the Gaussian distribution, which is used to describe the range of light source distribution; is the subscript index; For the The light source shines on the The angle of incidence of an object; No. The light source shines on the The transmission angle of an object.
4. The performance testing method of the game engine as claimed in claim 3, characterized in that: Each pixel node in the image pyramid is regarded as a random variable, denoted as , ,in is the number of pixels in the image pyramid; for each pixel node , consider its adjacent pixel nodes and establish edges; define by the spatial position of the pixel node, consider the 8 adjacent pixel nodes around each pixel node, and use the Gaussian kernel function to define the adjacency relationship so as to model the relationship between spatially adjacent pixel nodes as a probabilistic relationship; A probability relationship is defined to define a potential function, and based on the defined potential function, an energy function of a conditional random field is constructed.
5. The performance testing method of the game engine according to claim 4, characterized in that: Potential Function Use the following formula to express it: ; in, Poisson distribution parameters, is the standard deviation of the Gaussian kernel function; For the Pixel nodes and The probability that pixel nodes are spatially adjacent to each other; the energy function of the conditional random field Use the following formula to express it: ; in, is its own potential function, which is expressed using the following formula: ; in, For pixel nodes The pixel value of It is the mean of the pixel values of all pixel nodes in the image pyramid. The conditional random field model is used to infer the optimal state, minimize the energy function, and perform rendering under the current rendering pipeline.
6. The performance testing method of the game engine according to claim 5, characterized in that: When using training data to train the discriminator, the loss function of the discriminator is Use the following formula to express it: ; in, It is the first adjustment parameter, which is used to control the degree of Laplace smoothing. The larger its value, the smoother it is. is the Dirac weight parameter, ranging from 0.5 to 0.8; It is a discriminator The Laplace operator of is the Dirac function; is the Dirac threshold; Represents the distribution of real game scene data; The distribution of fake game scene data.
7. The performance testing method of the game engine according to claim 6, characterized in that: After the generator generates fake game scene data based on real game scene data each time, it will also be reversely trained by adjusting the parameters of the generator so that the distance between the object motion parameter vectors in the fake game scene data and the real game scene data is as small as possible when the distance between the object motion parameter vectors in the fake game scene data and the real game scene data is less than a set threshold.
8. The performance testing method of the game engine according to claim 7, characterized in that: When the generator is trained in reverse, the loss function of the generator is Use the following formula to express it: ; in, is the regularization coefficient, ranging from 0.3 to 0.6.
Citation Information
Patent Citations
Collision detection method and device in game scene
CN112245923A
Rendering time consumption acquisition method, rendering time display method, performance monitoring method and device, and equipment
CN112346935A
Information processing method and device in game, storage medium and electronic device
CN115999148A
Rendering method, device and equipment
CN117197320A
Emulation apparatus and method for interaction test of war game simulation model
KR101724519B1
