Flash effect rendering method and device in game, storage medium and electronic device

By calculating the slope of pixels and determining the LOD level, the slope probability distribution map is used to render the flash effect in the game, which solves the problems of high rendering cost and difficulty in the existing technology, achieves high-quality flash effect rendering, and adapts to different situations. Shot changes.

CN115063517BActive Publication Date: 2024-09-20NETEASE (HANGZHOU) NETWORK CO LTD
View PDF 8 Cites 0 Cited by

Patent Information

Application Number
CN202210637233.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-06-07
Publication Date
2024-09-20
Estimated Expiration
2042-06-07

AI Technical Summary

Technical Problem

When rendering flash effects in games, the existing technology is costly and difficult, cannot be effectively reduced, and cannot achieve rendering results of real physical phenomena.

Method used

The slope is calculated by calculating the macro normal vector, observation vector and lighting vector of the pixel, and the LOD level is determined based on the texture coordinates and target particle size. The slope probability distribution map is used to sample to obtain the target distribution probability, and is combined with lighting calculation for rendering.

Benefits of technology

It reduces the cost and difficulty of flash effect rendering, improves rendering quality, can be more consistent with real physical phenomena, and adapts to different lens changes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115063517B
    Figure CN115063517B
Patent Text Reader

Abstract

The present disclosure relates to the field of computer technology, and to a method and device for rendering a flash effect in a game, a storage medium, and an electronic device. The method comprises: calculating the slope of the pixel point according to the macro normal vector, observation vector, and illumination vector of the pixel point in the model to be rendered, wherein the slope is the projection of the micro surface normal in the world space on the two-dimensional tangent space; determining the target LOD level to which the pixel point belongs based on the texture coordinates of the pixel point and the target particle size required for the flash effect, wherein the target LOD level is configured with a slope probability distribution map; sampling the slope probability distribution map using the target slope, and determining the target distribution probability of the pixel point according to the sampling result; performing illumination calculation on the model to be rendered in combination with the target distribution probability, observation vector, illumination vector, and half-angle vector, and rendering the model to be rendered with a flash effect according to the obtained illumination result. The present disclosure improves the rendering efficiency and quality of the flash effect.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and more specifically, to a method for rendering a flash effect in a game, a device for rendering a flash effect in a game, a computer storage medium, and an electronic device. Background Art

[0002] With the development of computer and Internet technology, online games are becoming more and more popular among the public. Since online games have scenes similar to real life, users can experience the visual impact brought by the game in an immersive way, and the game has strong initiative and realism. There are abundant glitter materials in real life, such as frosted metal surface, car paint surface, fine glitter of cosmetics, shiny decorations on fabrics, microcrystalline glitter on snow and sand, and sparkling water surface, etc. How to render these glitter effects in the game has become one of the tasks that cannot be underestimated in game production.

[0003] In the related art, the flash effect is rendered by artists making high-precision normal maps, but the production cost of high-precision normal maps is high and they cannot be reused. In another related art, the flash effect is generated by using a programmed noise map, but different noise maps need to be provided for different rendering requirements, which not only increases the rendering production cost, but also makes the map writing difficult and requires experienced artists to complete, and it is also impossible to obtain a rendering result that conforms to the real physical phenomenon.

[0004] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present disclosure, and therefore may include information that does not constitute the prior art known to ordinary technicians in the field. Summary of the invention

[0005] The purpose of the present disclosure is to provide a method and device for rendering a flash effect in a game, a computer storage medium and an electronic device, thereby reducing the rendering cost and difficulty of the flash effect in the game at least to a certain extent and improving the rendering quality of the flash effect.

[0006] Other features and advantages of the present disclosure will become apparent from the following detailed description, or may be learned in part by the practice of the present disclosure.

[0007] According to one aspect of the present disclosure, a method for rendering a flash effect in a game is provided, comprising: calculating the slope of the pixel point according to the macro normal vector, observation vector and illumination vector of the pixel point in the model to be rendered, the slope being the projection of the micro surface normal in the world space on the two-dimensional tangent space, the macro normal vector, observation vector and illumination vector being vectors in the world space; determining the target LOD level to which the pixel point belongs based on the texture coordinates of the pixel point and the target particle size required for the flash effect, the target LOD level being configured with a slope probability distribution map, the slope probability distribution map The figure includes the distribution probability of different slope values ​​in different coordinate directions; the slope probability distribution map is sampled using the target slope, and the target distribution probability of the pixel point is determined according to the sampling result, the target distribution probability is used to characterize the probability that the direction of the projection is the first target direction, the target slope is the slope of the texel corresponding to the pixel point, and the target slope is obtained based on the slope of the pixel point; the illumination calculation is performed on the model to be rendered in combination with the target distribution probability, the observation vector, the illumination vector and the half-angle vector, and the model to be rendered is rendered with a flash effect according to the obtained illumination result.

[0008] In an exemplary embodiment of the present disclosure, the slope of the pixel point is calculated based on the macro normal vector, observation vector and illumination vector of the pixel point in the model to be rendered, including: constructing a tangent space based on the macro normal vector, and converting the observation vector and illumination vector to the tangent space; obtaining the vector sum of the observation vector and the illumination vector in the tangent space, and normalizing the vector sum to obtain a half-angle vector; and obtaining the slope based on the half-angle vector.

[0009] In an exemplary embodiment of the present disclosure, obtaining the slope based on the half-angle vector includes: using the first component and the second component of the half-angle vector, respectively dividing them by the third component of the half-angle vector, so as to convert the half-angle vector from a three-dimensional vector to a two-dimensional plane vector; and using the two-dimensional plane vector as the slope.

[0010] In an exemplary embodiment of the present disclosure, the target LOD level to which the pixel point belongs is determined based on the texture coordinates of the pixel point and the target particle size required for the flash effect, including: taking the differential of the texture coordinate uv with respect to the screen space coordinate xy to obtain a differential result, and scaling the differential result according to the numerical value of the target particle size to obtain the texture coordinate differential; calculating the length of the vector corresponding to the texture coordinate differential to obtain a first length value and a second length value, wherein the first length value is greater than the second length value; and determining the target LOD level in combination with the second length value and a preset LOD level threshold.

[0011] In an exemplary embodiment of the present disclosure, the target LOD level is determined by combining the second length value and a preset LOD level threshold using the following formula:

[0012] L=max(0,NLEVELS-1+log2(minorLength))

[0013] Among them, the L is the target LOD level, NLEVELS is the LOD level threshold, and the minorLength is the second length value.

[0014] In an exemplary embodiment of the present disclosure, before sampling the slope probability distribution map using the slope value of the target slope and determining the target distribution probability of the pixel point based on the sampling result, the method also includes: constructing an elliptical area of ​​the pixel point in the texture space based on the texture coordinates of the pixel point and the differential of the texture coordinates; traversing the texels in the elliptical area, and for each texel, rotating and scaling the slope of the pixel point to obtain the target slope of each texel.

[0015] In an exemplary embodiment of the present disclosure, the traversal of the texels in the elliptical area and, for each texel, rotating and scaling the slope of the pixel point to obtain a target slope of each texel includes: for each texel, obtaining a random rotation angle corresponding to the texel, and rotating the slope of the pixel point according to the random rotation angle to obtain a rotated slope; calculating a slope scaling factor in combination with a preset roughness and a roughness scaling factor, and scaling the rotated slope according to the slope scaling factor to generate a target slope for each texel.

[0016] In an exemplary embodiment of the present disclosure, the obtaining of the random rotation angle corresponding to the texel and rotating the slope of the pixel point according to the random rotation angle to obtain the rotated slope includes: converting the texel index of the texel into a consistency index according to the target LOD level, the consistency index being used to indicate the consistency of the random rotation angle corresponding to the texel at different LOD levels; generating a random value based on the consistency index, and using the random value as the random rotation angle; rotating the slope of the pixel point according to the random rotation angle to obtain the rotated slope.

[0017] In an exemplary embodiment of the present disclosure, the slope scaling factor is calculated according to the following formula in combination with the preset roughness and roughness scaling factor:

[0018]

[0019] Among them, the S α is the slope scaling factor, the α dict is the preset roughness used when generating the slope probability distribution map, wherein the α is obtained from the roughness map corresponding to the model to be rendered, and the α x and the α y are the roughness scaling factors required for the rotation slope in different decomposition directions respectively.

[0020] In an exemplary embodiment of the present disclosure, the slope probability distribution map is sampled using the slope value of the target slope, and the target distribution probability of the pixel point is determined based on the sampling result, including: sampling the slope probability distribution map using the slope value of the target slope, and calculating the joint distribution probability of the texels corresponding to the pixel point based on the sampling result; determining the Gaussian weight corresponding to the texel based on the distance between the texel and the texture coordinates of the pixel point; and calculating the target distribution probability based on the joint distribution probability and the Gaussian weight corresponding to the texel.

[0021] In an exemplary embodiment of the present disclosure, the slope probability distribution map is sampled using the slope value of the target slope, and the joint distribution probability of the texels corresponding to the pixel points is calculated based on the sampling results, including: orthogonally decomposing the target slope to obtain a first slope value and a second slope value; sampling the slope distribution map using the first slope value to obtain a first distribution probability; sampling the slope distribution map using the second slope value to obtain a second distribution probability; and fusing the first distribution probability with the second distribution probability to generate the joint distribution probability.

[0022] In an exemplary embodiment of the present disclosure, the first distribution probability and the second distribution probability are fused and calculated using the following formula to generate the joint distribution probability:

[0023]

[0024] Among them, P 3 is the joint distribution probability, the P 1 is the first distribution probability, the P 2 is the second distribution probability, the α dict is the preset roughness used when generating the slope probability distribution map, the α is obtained from the roughness map corresponding to the model to be rendered, and the α x and the α y are the roughness scaling multiples required for the target slope in different decomposition directions.

[0025] In an exemplary embodiment of the present disclosure, the target distribution probability is calculated based on the joint distribution probability and the Gaussian weight corresponding to the texel, including: based on the Gaussian weight, weighted averaging the joint probability distribution corresponding to the texel in the elliptical area to obtain the target distribution probability.

[0026] In an exemplary embodiment of the present disclosure, the method further includes: calculating the target distribution probability of the pixel point at the adjacent LOD level of the target LOD level; interpolating the target distribution probability at the target LOD level using the following interpolation formula according to the target distribution probability at the adjacent LOD level and the target distribution probability at the target LOD level to obtain the interpolated target distribution probability:

[0027] P=P L (1-(L-[L]))+P L+1 (L-[L])

[0028] Wherein, P is the target distribution probability after interpolation, L is the target LOD level, L+1 is the adjacent LOD level, and P L is the target distribution probability at the target LOD level, P L+1 is the target distribution probability on the adjacent LOD levels;

[0029] The target distribution probability after interpolation is used to update the target distribution probability of the pixel point at the target LOD level.

[0030] In an exemplary embodiment of the present disclosure, before calculating the slope of the pixel point according to the macro normal vector, the observation vector and the illumination vector of the pixel point in the model to be rendered, the method further includes: generating a slope probability distribution map corresponding to different LOD levels; wherein the process of generating the slope probability distribution map of the LOD level of the Nth layer includes: generating a first Gaussian distribution function with a preset roughness as a parameter; obtaining 2 using the first Gaussian distribution function N Based on the preset target standard deviation, the value is used as the mean to generate 2 N A second Gaussian distribution function; N A second Gaussian distribution function is fitted and superimposed to generate a target Gaussian distribution function as a target slope probability density; the variable value of the target slope probability density is the slope value, the target slope probability density is used to obtain the distribution probability corresponding to each slope value, and the slope value and the distribution probability are stored in correspondence; wherein N is an integer ≥ 0.

[0031] In an exemplary embodiment of the present disclosure, the target distribution probability, the observation vector, the illumination vector and the half-angle vector are combined to perform illumination calculation on the model to be rendered, and flash effect data is rendered on the model to be rendered according to the obtained illumination result, including: calculating the normal distribution probability of the pixel point based on the projection value of the microsurface normal on the macro normal vector and the target distribution probability, and the normal distribution probability is used to characterize the probability that the orientation of the microsurface is the second target direction; combining the half-angle vector, the observation vector and the preset surface basic reflectivity, using the Neffield equation to calculate the first illumination data, the first illumination data characterizing the ratio of reflected light to total light; according to the observation vector, the illumination vector and the half-angle vector, using a geometric shielding function to calculate the second illumination data, the second illumination data characterizing the amount of light blocked by the surface; combining the normal distribution probability, the first illumination data and the second illumination data, using a bidirectional reflection distribution function to calculate the fused illumination data; obtaining the product of the fused illumination data and the preset incident light intensity to obtain the illumination result.

[0032] According to one aspect of the present disclosure, a device for rendering a flash effect in a game is provided, comprising: a slope calculation module, for calculating the slope of a pixel point in a model to be rendered according to a macro normal vector, an observation vector and an illumination vector of the pixel point, wherein the slope is a projection of a micro surface normal in a world space on a two-dimensional tangent space, and the macro normal vector, the observation vector and the illumination vector are vectors in the world space; and a level determination module, for determining a target LOD level to which the pixel point belongs based on the texture coordinates of the pixel point and a target particle size required for the flash effect, wherein the target LOD level is configured with a slope probability distribution map, and the slope probability distribution map is a projection of a micro surface normal in a world space on a two-dimensional tangent space. The figure includes the distribution probability of different slope values ​​in different coordinate directions; a sampling module, used to sample the slope probability distribution map using the target slope, and determine the target distribution probability of the pixel point according to the sampling result, the target distribution probability is used to characterize the probability that the direction of the projection is the first target direction, the target slope is the slope of the texel corresponding to the pixel point, and the target slope is obtained based on the slope of the pixel point; a rendering module, used to perform lighting calculation on the model to be rendered in combination with the target distribution probability, the observation vector, the illumination vector and the half-angle vector, and render the model to be rendered with a flash effect according to the obtained illumination result.

[0033] According to one aspect of the present disclosure, a computer storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, any one of the above methods is implemented.

[0034] According to one aspect of the present disclosure, an electronic device is provided, comprising: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to execute any one of the above-mentioned methods by executing the executable instructions.

[0035] The method for rendering a flash effect in a game in an exemplary embodiment of the present invention calculates the slope of a pixel according to its macro normal vector, observation vector and illumination vector, and determines the target LOD level to which the pixel belongs based on its texture coordinates and the target particle size required for the flash. The target LOD level is sampled using the slope value of the target slope of the texel corresponding to the pixel, and the target distribution probability of the pixel is determined according to the sampling result. Finally, illumination calculation is performed based on the target distribution probability, observation direction, illumination direction and half-angle vector, so as to render a flash effect on the model to be rendered according to the illumination result. On the one hand, there is no need for artists to create normal maps that carry detailed information about the flash effect. They only need to provide conventional macro normals and convert them into the slope of pixel points, so as to sample the slope probability distribution map through the slope value of the target slope, thereby reducing production costs and difficulties. On the other hand, corresponding slope probability distribution maps are configured for different LOD levels, and the degree of particle clarity between different LOD levels is different. Sampling is performed on different target LOD layers, and the target distribution probabilities of the pixels obtained are different. The final flash effect has distinct layers and is more in line with real physical phenomena. On the other hand, the corresponding LOD level is sampled according to the slope values ​​of different pixel points to avoid obtaining the same target distribution probability, thereby avoiding duplication of the final lighting results, adapting to different lens changes, producing different flash effects, and obtaining higher-quality flash rendering effects.

[0036] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] The above and other objects, features and advantages of the exemplary embodiments of the present disclosure will become readily understood by reading the detailed description below with reference to the accompanying drawings. In the accompanying drawings, several embodiments of the present disclosure are shown in an exemplary and non-limiting manner, in which:

[0038] Figure 1 A flowchart showing a method for rendering a flash effect in a game according to an exemplary embodiment of the present disclosure is shown;

[0039] Figure 2 A schematic diagram of comparing target particle sizes according to an exemplary embodiment of the present disclosure is shown;

[0040] Figure 3A flowchart of determining a target LOD level to which a pixel point belongs according to an exemplary embodiment of the present disclosure is shown;

[0041] Figure 4 A model rendering effect diagram after using the ellipse weight averaging method and the trilinear filtering method according to an exemplary embodiment of the present disclosure is shown;

[0042] Figure 5 A rendering effect diagram with and without filtering according to an exemplary embodiment of the present disclosure is shown;

[0043] Figure 6 A flowchart of performing illumination calculation on a model to be rendered by combining target distribution probability, observation vector, illumination vector and half-angle vector according to an exemplary embodiment of the present disclosure is shown;

[0044] Figure 7 A flowchart of calculating the slope of a pixel point according to a macro normal vector, an observation vector and an illumination vector of the pixel point in a model to be rendered according to an exemplary embodiment of the present disclosure is shown;

[0045] Figure 8 A flowchart showing a method for implementing filtering pixels according to an exemplary embodiment of the present disclosure is shown;

[0046] Fig. 9 A flow chart of obtaining a target slope according to an exemplary embodiment of the present disclosure is shown;

[0047] Fig.10 A flow chart of determining a target distribution probability of a pixel point according to an exemplary embodiment of the present disclosure is shown;

[0048] Fig.11 A flowchart of generating a slope probability distribution map of an LOD level of an Nth layer according to an exemplary embodiment of the present disclosure is shown;

[0049] Fig.12 A second Gaussian distribution function diagram corresponding to levels 0 to 15 according to an exemplary embodiment of the present disclosure is shown;

[0050] Fig.13 A comparison diagram of rendering results before and after filtering the slope according to an exemplary embodiment of the present disclosure is shown;

[0051] Fig.14 A comparison diagram of rendering results before and after adjusting the attenuation degree of the flash effect according to an exemplary embodiment of the present disclosure is shown;

[0052] Fig.15 A comparison diagram of rendering results using different brightness indices according to an exemplary embodiment of the present disclosure is shown;

[0053] Fig.16A schematic diagram of a rendering structure of various flash effects according to an exemplary embodiment of the present disclosure is shown;

[0054] Fig.17 A schematic structural diagram of a flash effect rendering device in a game according to an exemplary embodiment of the present disclosure is shown;

[0055] Fig.18 A schematic diagram showing a storage medium according to an exemplary embodiment of the present disclosure; and

[0056] Fig.19 A block diagram of an electronic device according to an exemplary embodiment of the present disclosure is shown.

[0057] In the drawings, the same or corresponding reference numerals represent the same or corresponding parts. DETAILED DESCRIPTION

[0058] The exemplary embodiments will now be described more fully with reference to the accompanying drawings. However, the exemplary embodiments can be implemented in a variety of forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that the present disclosure will be more comprehensive and complete and the concepts of the exemplary embodiments will be fully conveyed to those skilled in the art. The same reference numerals in the figures represent the same or similar structures, and thus their detailed description will be omitted.

[0059] In addition, the described features, structures or characteristics may be combined in one or more embodiments in any suitable manner. In the following description, many specific details are provided to provide a full understanding of the embodiments of the present disclosure. However, those skilled in the art will appreciate that the technical solutions of the present disclosure may be practiced without one or more of the specific details, or other methods, components, devices, steps, etc. may be adopted. In other cases, known structures, methods, devices, implementations or operations are not shown or described in detail to avoid blurring the various aspects of the present disclosure.

[0060] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities may be implemented in software form, or these functional entities or parts of functional entities may be implemented in one or more software hardened modules, or these functional entities may be implemented in different networks and / or processor devices and / or microcontroller devices.

[0061] In the related art of this field, in order to obtain a game scene like real life, the material with flash effect in the game scene is also rendered with flash effect. Flash effect refers to the micro-plane granular highlight reflection of the model surface. In one related art, the flash effect is rendered by making a high-precision normal map, but the map resolution is too large to occupy memory and cannot be reused. If high-precision normal maps are made according to different LOD (Levels of Detail, multiple levels of detail) levels, that is, normal maps containing rich flash effect information, the production cost is high. In another related art, the flash effect is generated by writing sampling noise, but different noise maps are required for different rendering requirements, which increases the production cost, and the writing is difficult, and requires high business capabilities of artists. In addition, the size of the noise map is limited, physical duplication is prone to occur, and it is difficult to adapt to lens changes, which affects the quality of the flash effect.

[0062] Based on this, in an exemplary embodiment of the present disclosure, a method for rendering a flash effect in a game is first provided. Figure 1 As shown, the flash effect rendering method in the game of the embodiment of the present disclosure may include the following steps S110 to S140:

[0063] Step S110, calculating the slope of the pixel point according to the macro normal vector, observation vector and illumination vector of the pixel point in the model to be rendered.

[0064] In an exemplary embodiment of the present disclosure, according to the microsurface theory, a smooth or rough macro surface is composed of many micro surfaces, and the orientation of each micro surface is determined by its micro surface normal. The slope of the pixel is calculated according to the macro normal vector, observation vector and illumination vector of the pixel, and the slope is the projection of the micro surface normal in the world space on the two-dimensional tangent space. Therefore, after obtaining the slope of the pixel, the micro surface normal can be solved. The macro normal vector of the pixel is not a high-precision macro normal vector containing flash effect information provided by the artist, but a general smooth surface macro normal vector. The observation vector refers to the vector between the world coordinates of the pixel and the position coordinates of the virtual camera, and the illumination direction indicates the direction of the sunlight in the scene.

[0065] In the embodiment of the present disclosure, based on the material file of the model to be rendered, the CPU (Central Processing Unit) reads the geometry corresponding to the material file, and organizes the reading results into vertices and submits them to the GPU (Graphic Processing Unit). The GPU converts the vertices from the model space to the world space, observation space, clipping space and screen space in sequence through the vertex shader. The result output by the vertex shader is rasterized by the pixel shader, and the vertices are discretized into pixel points on the screen space, that is, the pixel points of the model to be rendered as described in the embodiment of the present disclosure, wherein each pixel point carries shading information, and the shading information includes but is not limited to macro normal vector, illumination vector, observation vector, light color, light intensity, texture coordinates, preset roughness, metallicity and basic color information, etc.

[0066] Among them, the material files of the model to be rendered include but are not limited to the geometry files of the model, basic color maps, roughness maps, metalness maps and other files pre-made in the three-dimensional modeling software. Model space is also called object space or local space. Each model has a corresponding model space, and the model space rotates with the corresponding model; world space is a macroscopic special coordinate system. In the Unity engine, if the model has no parent node, the model is located in the world space; observation space is camera space. Unlike other spaces, the observation space uses a right-handed coordinate system; clipping space, after a vertex is multiplied by the projection matrix, it is converted from observation space to clipping space. The essence of the projection matrix is ​​to scale and translate each component of the vertex (x, y, z); screen space is to project the viewing cone in the clipping space to the screen space to determine the two-dimensional position coordinates of the pixel point. Among them, the space conversion method in the related art is applicable to the embodiment of the present disclosure to convert the vertex from model space to world space, observation space, clipping space and screen space in sequence, which is not described in detail in the present disclosure.

[0067] It should be noted that the macro normal vector, observation vector and illumination vector in the embodiment of the present disclosure are vectors in the world space.

[0068] Through the exemplary embodiments of the present disclosure, there is no need to produce a high-precision normal map containing a flashing effect. Instead, the macro-normal vector of the smooth surface is converted into a slope in combination with the observation vector and the illumination vector to characterize the projection of the micro-surface normal in the world space on the two-dimensional tangent space, so as to subsequently obtain the micro-surface normal vector and reduce the production cost.

[0069] Step S120, determining the target LOD level to which the pixel point belongs based on the texture coordinates of the pixel point and the target particle size required for the flash effect.

[0070] In an exemplary embodiment of the present disclosure, LOD technology (Levels of Detail) refers to determining the resource allocation for rendering an object model based on the position and importance of the object model's nodes in the display environment, reducing the number of faces and detail of unimportant object models, etc. The lower the LOD level, the clearer the details, and the more distinct the particles of the flash effect.

[0071] The target LOD level is configured with a slope probability distribution map, which includes the distribution probabilities of different slope values ​​in different coordinate directions, where the slope value is obtained by orthogonal decomposition of the slope. For example, the slope is decomposed into slope values ​​in the x-direction and the y-direction. The target particle size is determined based on the actual rendering scene, and the numerical value of the target particle size can be adjusted according to the actual rendering requirements. The higher the LOD level, the larger the numerical value of the target particle size, and the lower the LOD level, the smaller the numerical value of the target particle size. For example, the shimmering water surface requires a larger target particle size, and the metal surface requires a smaller target particle size, such as Figure 2 A schematic diagram showing the comparison of target particle size is shown.

[0072] In an exemplary embodiment of the present disclosure, a method for determining a target LOD level to which a pixel point belongs is provided. Based on the texture coordinates of the pixel point and the target particle size required for the flash effect, determining the target LOD level to which the pixel point belongs may include steps S310 to S330:

[0073] Step S310, obtain the differential of the texture coordinate uv with respect to the screen space coordinate xy, and scale the differential result according to the value of the target particle size to obtain the texture coordinate differential, that is, Where A is the value of the target particle size.

[0074] In the exemplary embodiment of the present disclosure, the texture coordinate is the uv used by the sampling map in the vertex written in the material file, and the differential of the texture coordinate uv to the screen space coordinate xy is obtained, and the differential result is the number of units corresponding to the texture coordinate on the screen, which can be obtained by the built-in functions ddx, ddy of HLSL (high-level shader language) or dFdx, dFdy of GLSL (rendering language). Among them, the differential of the texture coordinate uv to the screen space coordinate xy is obtained, that is,

[0075] Furthermore, the differential result is scaled according to the numerical value of the target particle size. The numerical value of the target particle size can be used as a coefficient of the differential result to enlarge or reduce the differential result. The larger the differential result, the larger the span of the corresponding texture coordinate movement for each pixel moved in the screen space, and it is necessary to sample an image with a higher mipmap (texture mapping) level.

[0076] Based on the value of the target particle size, after scaling the differential result, the texture coordinate differential is changed to change the subsequent LOD level determined based on the texture coordinate differential, thereby adjusting the displayed particle size of the flash effect.

[0077] Step S320, calculating the length of the vector corresponding to the texture coordinate differential to obtain a first length value and a second length value, wherein the first length value is greater than the second length value.

[0078] In an exemplary embodiment of the present disclosure, the length function can be used to calculate the length of the vector corresponding to the texture coordinate differential, and the differential result obtained in step S310 is The length function is used to calculate the first length value and the second length value. The ratio of the first length value to the second length value can be controlled not to be greater than a set threshold value, so as to avoid increasing the number of subsequent sampling times in the direction with the first length value as the major axis due to a large ratio, thereby reducing the running efficiency of the program.

[0079] Step S330 , determining a target LOD level by combining the second function length value and a preset LOD level threshold.

[0080] In an exemplary embodiment of the present disclosure, the target LOD level is determined by combining the second length value and a preset LOD level threshold using the following formula:

[0081] L=max(0,NLEVELS-1+log2(minorLength)) (1)

[0082] Wherein, L is the target LOD level, NLEVELS is the LOD level threshold, and minor Length is the second length value. The LOD level threshold can be set according to actual rendering requirements, for example, it can be 14, 16 or 18, etc., and the embodiments of the present disclosure do not make special limitations on this.

[0083] Through the exemplary embodiments of the present disclosure, the target LOD level required for the pixel point is determined based on the texture coordinates of the pixel point and the target particle size required for the flash effect, so that map sampling can be performed in the target LOD level later, and then map sampling is performed in different LOD levels according to different pixels, so as to avoid duplication of pixel map points and improve the rendering diversity of the flash effect to adapt to changes in the lens.

[0084] Step S130, sampling the slope probability distribution map using the target slope, and determining the target distribution probability of the pixel point according to the sampling result.

[0085] In an exemplary embodiment of the present disclosure, the target distribution probability (also referred to as the target slope distribution probability) is used to characterize the direction of the projection of the microsurface normal in the world space on the two-dimensional tangent space, which is the probability of the first target direction. The target slope is the slope of the texel corresponding to the pixel point, which is obtained based on the slope. Among them, the target slope is the result of slope rotation and scaling. In the embodiment of the present disclosure, the elliptical weighted averaging method is used to filter the slope probability of the texel point to obtain the slope probability of the pixel point. Of course, other filtering methods, such as the trilinear filtering method, can also be selected according to actual needs. Since the trilinear filtering method is an isotropic filtering method that does not consider the difference between different axes, when the line of sight direction is switched to perpendicular to the normal, blurring is likely to occur. Therefore, in order to increase the anisotropy, the embodiment of the present disclosure preferably uses the elliptical weighted averaging method to filter the slope probability of the texel point, such as Figure 4 The figure shows the rendering effect of the model after using the ellipse weighted averaging method and the trilinear filtering method according to the embodiment of the present disclosure. The rendering effect corresponding to the ellipse weighted averaging method in the right figure is relatively clear. Figure 5 The rendering effect diagram with and without filtering shows that, compared with the rendering effect without filtering, the rendering result corresponding to the filtering using the elliptical weighted averaging method in the right figure has less noise.

[0086] Based on the target LOD level determined in step S130, the slope probability distribution map configured at the target LOD level is sampled using the slope value of the target slope, and the target distribution probability of the pixel point is determined according to the sampling result.

[0087] According to an exemplary embodiment of the present disclosure, a pre-configured slope probability distribution map is sampled by utilizing the slope value of the target slope, thereby avoiding the production of high-precision normal maps or noise maps containing flash effects, reducing development costs and difficulties, and the pre-configured slope probability distribution maps corresponding to different LOD levels are reusable, thereby improving rendering efficiency.

[0088] Step S140, performing illumination calculation on the model to be rendered in combination with the target distribution probability, the observation vector, the illumination vector and the half-angle vector, and performing flash effect rendering on the model to be rendered according to the obtained illumination result.

[0089] In an exemplary embodiment of the present disclosure, illumination calculation includes but is not limited to calculating normal distribution probability, the ratio of reflected light to total light, geometric shielding, etc. It may include steps S610 to S650:

[0090] Step S610, based on the projection value of the microsurface normal on the macro normal vector and the target distribution probability, calculate the normal distribution probability of the pixel point. Among them, the normal distribution probability is used to characterize the probability that the orientation of the microsurface is the second target direction. The ratio of the target distribution probability to the fourth power of the projection value of the microsurface normal on the macro normal can be obtained, and the ratio is used as the normal distribution probability of the pixel point. The normal distribution probability characterizes the probability that the microsurface normal is consistent with the half-angle vector in the same direction. It is worth noting that obtaining the normal distribution probability is to obtain the probability that the microsurface normal is consistent with the half-angle vector in the same direction. Therefore, the ratio of the target distribution probability to the fourth power of the projection value of the half-angle vector on the macro normal can also be obtained here, and the ratio is used as the normal distribution probability of the pixel point.

[0091] Step S620, combining the half-angle vector, the observation vector and the preset surface basic reflectivity, and using the Neffield equation to calculate the first illumination data.

[0092] The first illumination data represents the ratio of reflected light to total light. Combining the half-angle vector, the observation vector and the preset surface basic reflectivity, the first illumination data is calculated using the following formula:

[0093] F schlick (h,v,F 0 )=F 0 +(1-F 0 )(1-(h·v)) 5 (2)

[0094] Among them, F schlick is the first illumination data, F 0 is the preset surface base reflectivity, h is the half-angle vector, ν is the observation vector, F 0 It can be obtained by calculation based on the surface color and metalness of the model to be rendered, or by referring to relevant material information, and the embodiments of the present disclosure do not make special limitations on this.

[0095] Step S630, calculating the second illumination data using a geometric shading function according to the observation vector, the illumination vector and the half-angle vector.

[0096] The second illumination data represents the amount of light blocked by the surface. The second illumination data is calculated using the following geometric occlusion function v-cavity according to the observation vector, illumination vector, and half-angle vector:

[0097]

[0098] Among them, G is the second illumination data, n is the macro normal vector, h is the half-angle vector, ν is the observation vector, and l is the illumination vector.

[0099] Step S640, combining the normal distribution probability, the first illumination data, and the second illumination data, and using a bidirectional reflectance distribution function to calculate fused illumination data.

[0100] Among them, the normal distribution probability, the first illumination data, and the second illumination data are combined, and the bidirectional reflection distribution function is used to calculate the fused illumination data. The values ​​of the normal distribution probability, the first illumination data, and the second illumination data can be substituted into the BRDF formula (Bidirectional Reflectance Distribution Function, bidirectional reflection distribution function):

[0101]

[0102] Among them, f is the fused illumination data, D is the value of the target distribution probability, F is the value of the first illumination data, G is the value of the second illumination data, n is the macro normal vector, ν is the observation vector and l' is the incident direction.

[0103] It should be noted that if there is only one light source in the scene, such as sunlight, the incident direction of the sunlight is substituted into the above formula (4) to obtain the illumination data; if there are at least two light sources in the scene, such as sunlight and a lamp (point light source), the at least two light sources are substituted into the above formula (4) respectively to obtain the corresponding at least two illumination data.

[0104] Step S650, multiplying the fused illumination data by the preset incident light intensity to obtain an illumination result.

[0105] The preset incident light intensity can be obtained by multiplying the intensity of sunlight with the base color of the model to be rendered. The base color is obtained according to the material file of the model to be rendered, and is the color obtained by sampling the base color map provided in advance by the artist. The lighting result is obtained by multiplying the fused lighting data with the preset incident light intensity. The obtained fused lighting data is used to indicate how the radiant illumination in a given incident direction affects the radiance in a given outgoing direction. The fused lighting data is multiplied by the incident light intensity to obtain the reflected light intensity, which can reflect the rendering requirements of the flash effect.

[0106] In an exemplary embodiment of the present disclosure, a method for calculating the slope of a pixel point is provided. According to the macro normal vector, observation vector and illumination vector of the pixel point in the model to be rendered, the slope of the pixel point can be calculated by steps S710 to S730:

[0107] Step S710, constructing a tangent space according to the macro normal vector, and converting the observation vector and the illumination vector into the tangent space.

[0108] In an exemplary embodiment of the present disclosure, the tangent space refers to a space composed of normals, tangents, and bitangents, and the LookAt algorithm can be used to calculate the three axes of the tangent space according to the macro normal vector, wherein the macro normal vector is used as the z-axis, and the observation vector and the illumination vector are converted to the tangent space.

[0109] Specifically, the LookAt algorithm is used to calculate the three axes of the tangent space based on the macro normal vector, including: determining a vertical upward vector (0,0,1), taking the cross product of the vertical upward vector and the macro normal vector as the tangent, calculating the cross product of the tangent and the macro normal vector as the secondary tangent, and composing the z-axis, x-axis and y-axis of the tangent space based on the macro normal vector, the secondary tangent and the tangent.

[0110] The process of converting the observation vector to the tangent space may include: respectively calculating the projections of the observation vector on the three axes of the tangent space to form a three-dimensional vector of the tangent space.

[0111] Correspondingly, the process of converting the illumination vector to the tangential space is similar and will not be described in detail in this disclosure.

[0112] Step S720, obtain the vector sum of the observation vector and the illumination vector in the tangent space, and normalize the vector sum to obtain a half-angle vector.

[0113] The vector sum of the observation vector and the illumination vector in the tangent space is first obtained, and then the vector sum is normalized, and the normalized vector is used as the half-angle vector.

[0114] Step S730, obtaining the slope based on the half-angle vector.

[0115] In an exemplary embodiment of the present disclosure, the half-angle vector may be converted into a slope. Obtaining the slope based on the half-angle vector may be: converting the half-angle vector from a three-dimensional vector into a two-dimensional plane vector, and using the obtained two-dimensional plane vector as the slope.

[0116] For example, if the half-angle vector is (x, y, z), we can divide the x value and y value by the z value to get The slope as a pixel.

[0117] Through the exemplary embodiments of the present disclosure, the macro normal vector of the model to be rendered is converted into the slope of the pixel point, avoiding the production of a high-precision normal map containing a flashing effect. Only a general smooth surface map is needed, thereby reducing the difficulty of production. The slope probability distribution map is sampled by the slope value of the obtained slope, and the slope probability distribution map can be reused to improve rendering efficiency.

[0118] In an exemplary embodiment of the present disclosure, a method for implementing filtering pixel points is also provided. Before sampling the slope probability distribution map using the slope value of the target slope and determining the target distribution probability of the pixel point according to the sampling result, steps S810 and S820 may also be performed:

[0119] Step S810: construct an elliptical area of ​​the pixel point in the texture space according to the texture coordinates of the pixel point and the texture coordinate differential.

[0120] In an exemplary embodiment of the present disclosure, the first length value and the second length value can be obtained by calculating the length of the vector corresponding to the differential of the texture coordinates, which can be used as the major axis and minor axis of the ellipse, respectively, and the rotation angle of the ellipse can be calculated. Then, the elliptical area of ​​the ellipse in the texture space can be constructed according to the major axis, minor axis and rotation angle.

[0121] If the texture coordinates of the current pixel are (u, v), the left boundary of the bounding box corresponding to the elliptical area is The right boundary is The upper boundary is The lower boundary is And filter the pixels outside the ellipse area. Where A is the major axis, B is the minor axis, and C is the rotation angle.

[0122] Step S820, traverse the texels in the elliptical area, and for each texel, rotate and scale the slope of the pixel point to obtain the target slope of each texel.

[0123] In an exemplary embodiment of the present disclosure, obtaining the target slope of each texel may include steps S910 and S920:

[0124] Step S910: for each texel, obtain a random rotation angle corresponding to the texel, and rotate the slope of the pixel point according to the random rotation angle to obtain a rotation slope.

[0125] In an exemplary embodiment of the present disclosure, the texel index of the texel can be first converted into a consistency index according to the target LOD level. The texel index is a search directory for the texel area. The higher the LOD level, the fewer the number of texels. For example, when the LOD level is 0, there are n texels in the u or v direction, and the corresponding texel index is 0, 1, 2, 3, ..., n-1. When the LOD level is L, there are n texels in the u or v direction. The corresponding texel index is The consistency index is used to indicate the consistency of the random rotation angle corresponding to the texel at different LOD levels, that is, to ensure that when the LOD level changes, the slope corresponding to the texel in the same area remains consistent in the random rotation angle.

[0126] The calculation method to obtain the consistency index based on the texel index is to multiply the texel index by 2 L For example, when the LOD level is L, the consistency index is 0, 2 L , 2*2 L , 3*2 L , 4*2 L , ..., n-2 L .

[0127] Further, after obtaining the consistency index of the texel in the horizontal and vertical directions (x direction and y direction), a preset polynomial is used to merge the two consistency indexes to obtain a value, and the value is used as a random seed. The preset polynomial can be a linear polynomial, such as Y=c1Y1+c2Y2, where Y is the obtained value, Y1 and Y2 are consistency indexes, c1 and c2 are coefficients of the corresponding consistency indexes, and the embodiment of the present disclosure does not specifically limit the form of the polynomial, which can be set according to the actual rendering scene.

[0128] After obtaining the random seed, a hash function can be used to map the random seed to a numerical value as a random rotation angle, so as to rotate the slope of the pixel point according to the random rotation angle to obtain the rotation slope. Among them, the hash function can be selected according to actual needs, such as IQ (Inigo Quilez) hash, etc., and the present disclosure does not make special restrictions on this. It is worth noting that the initial slope of the texel corresponding to the pixel point is the slope of the pixel point, so the slope of the pixel point is rotated according to the random rotation angle.

[0129] The slope is rotated based on a random rotation angle so that each texel samples the slope probability distribution map according to the target slope, which enriches the subsequent lighting results based on the target distribution probability, thereby enriching the rendering diversity.

[0130] Step S920, calculating the slope scaling factor in combination with the preset roughness and the roughness scaling factor, and scaling the rotation slope according to the slope scaling factor to generate a target slope for each texel.

[0131] The slope scaling factor can be calculated according to the preset roughness and roughness scaling factor according to the following formula:

[0132]

[0133] Among them, S α is the slope scaling factor, α dict The preset roughness used when generating the slope probability distribution map is obtained from the roughness map corresponding to the model to be rendered. x and α yare the roughness scaling factors required for the rotation slope in different decomposition directions.

[0134] Furthermore, the rotation slope is scaled according to the scaling factor. Based on formula (5), the roughness map α provided by the artist can be reused, avoiding the artist from making roughness maps in different directions. The efficiency of the rendering operation can be improved by simply adjusting the roughness scaling factor.

[0135] In an exemplary embodiment of the present disclosure, a method for determining the joint distribution probability of pixel points is provided. Sampling a slope probability distribution map using the slope value of the target slope, and determining the target distribution probability of the pixel points according to the sampling result may include steps S1010 to S1040:

[0136] Step S1010, performing orthogonal decomposition on the target slope to obtain a first slope value and a second slope value.

[0137] The target slope is orthogonally decomposed, for example, the slope is decomposed into orthogonal x-direction and y-direction.

[0138] Step S1020, sampling the slope distribution map using the first slope value to obtain a first distribution probability.

[0139] The first slope value is used to sample the slope distribution map to obtain a first distribution probability corresponding to the first slope value.

[0140] Step S1030, sampling the slope distribution map using the second slope value to obtain a second distribution probability.

[0141] The second slope value is used to sample the slope distribution map to obtain a second distribution probability corresponding to the second slope value.

[0142] Step S1040: fusion calculation is performed on the first distribution probability and the second distribution probability to generate a joint distribution probability of the pixel corresponding to the texel.

[0143] In an exemplary embodiment of the present disclosure, the first distribution probability and the second distribution probability are fused and calculated using the following formula to generate a joint distribution probability of the pixel corresponding to the texel:

[0144]

[0145] Among them, P 3 is the joint distribution probability, P 1 is the first distribution probability, P 2 is the second distribution probability, α dict is the preset roughness used when generating the slope probability distribution map, α is obtained from the roughness map corresponding to the model to be rendered, and α x and αy They are the roughness scaling factors required for the target slope in different decomposition directions.

[0146] Furthermore, the target distribution probability may be calculated based on the joint distribution probability of the texels corresponding to the pixels and the Gaussian weights corresponding to the texels.

[0147] In an exemplary embodiment of the present disclosure, obtaining the Gaussian weight corresponding to the texel may be: determining the Gaussian weight corresponding to the texel according to the distance between the texel and the texture coordinates of the pixel point.

[0148] Specifically, based on the determined elliptical area, if the texture coordinates of the current pixel are (u, v), then the left boundary of the bounding box corresponding to the elliptical area is The right boundary is The upper boundary is The lower boundary is From the left border of the bounding box to the right border of the bounding box, and from the upper border of the bounding box to the lower border of the bounding box, traverse in sequence, calculate the distance from the texture coordinate to the center of the ellipse area, and determine whether the texel point is in the ellipse area based on the ellipse formula and the distance. If the texel point is in the ellipse area, use the standard Gaussian function to calculate the weight based on the distance from the texel to the center of the ellipse, and record the sum of the weights (to ensure that the sum of the weights is 1) for weighted averaging.

[0149] The joint probability distribution corresponding to the texels in the elliptical area may be weighted averaged based on the Gaussian weight to obtain the target distribution probability of the pixel point.

[0150] In the exemplary embodiment of the present disclosure, the slope is a two-dimensional vector. If the slope probability distribution map corresponding to the slope is pre-stored, the time and space complexity are both O(n 2 ), if the slope distribution map is sampled by the two slope values ​​after slope decomposition, and the sampling results are fused, then the time and space complexity are both O(n) by sampling twice and fusion, which reduces the amount of calculation. For example, if there are n slope values, then it takes n times to calculate the slope probability density (slope probability distribution map) corresponding to the slope value, and there are n slopes obtained by combining two slope values. 2 If we only calculate the slope probability density (slope probability distribution map) of the two-dimensional slope at the beginning, we need n 2 Operations.

[0151] In an exemplary embodiment of the present disclosure, a method for interpolating the target distribution probability is also provided, so as to update the target distribution probability of the pixel point at the target LOD level by using the target distribution probability after the difference, which may include:

[0152] Calculate the target distribution probability of the pixel point on the adjacent LOD level of the target LOD level;

[0153] According to the target distribution probability at the adjacent LOD level and the target distribution probability at the target LOD level, the target distribution probability at the target LOD level is interpolated using the following interpolation formula to obtain the interpolated target distribution probability:

[0154] P=P L (1-(L-[L]))+P L+1 (L-[L])

[0155] Among them, P is the target distribution probability after interpolation, L is the target LOD level, L+1 is the adjacent LOD level, and P L is the target distribution probability at the target LOD level, P L+1 is the target distribution probability on adjacent LOD levels;

[0156] Furthermore, the target distribution probability after interpolation is used to update the target distribution probability of the pixel point on the target LOD level, so as to perform lighting calculation on the model to be rendered in combination with the updated target distribution probability, observation vector, illumination vector and half-angle vector, and render the model to be rendered with a flash effect based on the obtained lighting result.

[0157] It should be noted that the process of calculating the target distribution probability of a pixel point at an adjacent LOD level of the target LOD level is the same as the process of calculating the target distribution probability of a pixel point corresponding to the target LOD level in the above-mentioned embodiment of the present disclosure, and will not be repeated here.

[0158] Through the exemplary embodiments of the present disclosure, by interpolating the target distribution probability, the target distribution probability can be smoothly transitioned between LOD levels, thereby avoiding abrupt transitions between different LOD levels and causing obvious seams in the rendering results.

[0159] In an exemplary embodiment of the present disclosure, a method for generating a slope probability distribution map is also provided. The process of generating a slope probability distribution map of the Nth LOD level may include steps S1110 to S1150:

[0160] Step S1110, generating a first Gaussian distribution function with the preset roughness as a parameter.

[0161] Among them, The first Gaussian distribution function is generated with 0 as the mean and the standard deviation as .

[0162] Step S1120, using the first Gaussian distribution function to obtain 2 N A numerical value.

[0163] Use is the standard deviation, and the first Gaussian distribution function with 0 as the mean, obtain 2 N values, where N is the target LOD level. For example, if the target LOD level is 0, 1 value is obtained, if the target LOD level is 1, 2 values ​​are obtained, and so on, to obtain the values ​​corresponding to each LOD level.

[0164] Step S1130, based on the preset target standard deviation, using the value in step S1120 as the mean, generates 2 N The second Gaussian distribution function.

[0165] In an exemplary embodiment of the present disclosure, based on a preset target standard deviation, the numerical value obtained in step S1120 is used as the mean to generate a second Gaussian distribution function corresponding to each LOD level. For example, if the target LOD level is 0, 1 numerical value is obtained, and 1 is used as the mean and the preset target standard value is used as a parameter to generate a second Gaussian distribution function. If the target LOD level is 1, the first numerical value and the second numerical value are obtained, and the first numerical value is used as the mean and the preset target standard value is used as a parameter to generate a second Gaussian distribution function, and the second numerical value is used as the mean and the preset target standard value is used as a parameter to generate 2 second Gaussian distribution functions, and so on, to generate a second Gaussian distribution function corresponding to each LOD level. Fig.12 A second Gaussian distribution function diagram corresponding to levels 0 to 15 according to an embodiment of the present disclosure is shown.

[0166] Step S1140: N The second Gaussian distribution function is fitted and superimposed to generate the target Gaussian distribution function as the target slope probability density.

[0167] In an exemplary embodiment of the present disclosure, for each LOD level, the obtained 2 N The second Gaussian distribution functions are fitted and superimposed as the target slope probability density. For example, if the target LOD level is 1, the two second Gaussian distribution functions are fitted; if the target LOD level is 2, the four second Gaussian distribution functions are fitted, and so on, to obtain the target slope probability density corresponding to each LOD level.

[0168] Step S1150, taking the variable value of the target slope probability density as the slope value, using the target slope probability density, obtaining the distribution probability corresponding to each slope value, and storing the slope value and the distribution probability in correspondence.

[0169] In an exemplary embodiment of the present disclosure, the variable value of the target slope probability density is the slope value, the target slope probability density is used to obtain the distribution probability corresponding to each slope value, and the slope value and the distribution probability are stored in correspondence, and the distribution probability of different slope values ​​in different coordinate directions is stored, that is, the obtained target slope probability density is saved in the format of a picture. Among them, the range of the variable can be determined according to the actual rendering scene, for example where α dict The preset roughness used when generating the slope probability distribution map, the number of samples of the variable between the range interval can also be determined according to the actual rendering scene, and the number of samples determines the resolution of the slope probability distribution map. The more samples, the higher the resolution.

[0170] It should be noted that, in order to increase the diversity of rendering results in the embodiments of the present disclosure, the number of slope probability distribution maps may be increased, and the embodiments of the present disclosure do not impose any special limitation on this.

[0171] Through the embodiments of the present disclosure, a slope probability distribution map corresponding to each LOD level is generated, which is reusable. The slope probability distribution map can be sampled according to the slope value of the target slope to obtain the target distribution probability of the pixel point, which is used for the lighting calculation of the model to be rendered. This not only improves the rendering operation effect, but also eliminates the need for artists to produce normal maps including flash effects. Moreover, sampling based on the LOD level to which the pixel point belongs can increase the diversity of the sampling results, thereby increasing the diversity of the rendering results.

[0172] In an exemplary embodiment of the present disclosure, a method for adjusting the flash effect is also provided. In the embodiment of the present disclosure, at least one of the following operations may be performed to change the flash effect of the model to be rendered:

[0173] 1) The density parameter of the flash effect display particles is used as the filtering threshold, and the texels are filtered according to the comparison relationship between the random seed corresponding to the consistency index of the texel and the filtering threshold. The slope corresponding to the remaining texels is used as the target slope to adjust the display density of the flash effect and avoid abrupt boundaries in the rendering result. Fig.13 As shown, after filtering the slope, the rendering result in the right image has no harsh boundaries.

[0174] 2) Change the target LOD level corresponding to the pixel point to change the display particle size of the flash effect. The higher the target LOD level, the larger the display particle size of the flash effect. Therefore, the display particle size of the flash effect can be changed by adjusting the number of target LOD levels, such as Figure 2 .

[0175] 3) Adjust the vector distance between the world coordinates of the pixel point and the position coordinates of the virtual camera so that the flash effect changes its attenuation degree with the vector distance. In real life, the flash effect generally needs to be observed at a close distance. The farther the distance, the weaker the brightness of the flash effect. Therefore, it is necessary to adjust the distance attenuation coefficient. In the disclosed embodiment, the relationship between brightness and distance is a negative exponential function, and the attenuation coefficient is used as the coefficient of the negative exponent. For example, the rhinestones on clothes can often still be seen at a farther distance, so the attenuation coefficient is relatively small; the paint particles on the car need to be observed at a closer position, so the attenuation coefficient is relatively large. Fig.14 As shown in the figure on the right, after adjusting the attenuation of the flash effect as the vector distance between the world coordinates of the pixel point and the position coordinates of the virtual camera changes, the rendering result can be made like the flash effect in real life.

[0176] 4) Adjust the microsurface parameters of the model to be rendered, and use the microsurface parameters as the coefficient of the target LOD level obtained in step S330, thereby changing the LOD level to which the pixel belongs, and thereby changing the display intensity of the flash effect. For example, when the conditional target LOD level exceeds 17 layers, the greater the microsurface density, the weaker the flash effect, and the closer it is to the mirror reflection of a smooth surface, which is suitable for transparent plastic materials such as raincoats; on the contrary, the microsurface density is small, the particles are fine and the sense of fragmentation is strong, and the flash effect is more obvious, which is suitable for materials that produce sharp light, such as frosted metals and gemstones.

[0177] 5) Using the obtained illumination result as the base to generate an exponential function, and using the brightness parameter as the exponent of the exponential function, the brightness of the model to be rendered is adjusted. Fig.15 The following is a comparison chart using different brightness indexes. The left picture shows the rendering result when the brightness index is 0.01, and the right picture shows the rendering result when the brightness index is 1.2.

[0178] In summary, the flash effect rendering method in the game of the exemplary embodiment of the present disclosure does not require artists to make high-precision normal maps with flash effects. It only needs to provide general smooth surface normals and convert the normals into the slopes of pixels, so as to sample the slope probability distribution map through the slope value of the slope, thereby reducing the production cost and difficulty. The corresponding slope probability distribution map is configured for different LOD levels, and the degree of particle clarity between different LOD levels is different. Sampling is performed for different target LOD layers, and the target distribution probabilities of the obtained pixels are different. The final flash effect has clear layers and is more in line with real physical phenomena. On the other hand, the corresponding LOD level is sampled according to the slope values ​​of different pixels to avoid obtaining the same target distribution probability, thereby avoiding the repetition of the final lighting results, and can adapt to different lens changes, produce different flash effects, and obtain higher-quality flash rendering effects. In addition, through various parameter adjustments, the flash effect rendering method in the game of the embodiment of the present disclosure can render various flash effects, see. Fig.16 The frosted metal surface, shiny embellishments on the surface of clothes, etc. obtained by the flash effect rendering method in the game based on the embodiment of the present disclosure are respectively shown. For various flash effect rendering scenes, the method of the embodiment of the present disclosure is universal and will not be listed one by one here.

[0179] In an exemplary embodiment of the present disclosure, a flash effect rendering device in a game is also provided. Fig.17 As shown, the flash effect rendering device 1700 in the game may include:

[0180] A slope calculation module 1710 is used to calculate the slope of a pixel point in the model to be rendered according to a macro normal vector, an observation vector and an illumination vector of the pixel point in the model to be rendered, wherein the slope is a two-dimensional vector used to characterize the position characteristics of the pixel point in the model to be rendered, and the macro normal vector, the observation vector and the illumination vector are vectors in the world space;

[0181] A level determination module 1720 is used to determine a target LOD level to which the pixel point belongs based on the texture coordinates of the pixel point and the target particle size required for the flash effect, wherein the target LOD level is configured with a slope probability distribution map, and the slope probability distribution map includes distribution probabilities of different slope values ​​in different coordinate directions;

[0182] A sampling module 1730 is used to sample the slope probability distribution map using a target slope, and determine the target distribution probability of the pixel point according to the sampling result, wherein the target distribution probability is used to characterize the probability that the direction of the projection is a first target direction, and the target slope is the slope of the texel corresponding to the pixel point, and the target slope is obtained based on the slope of the pixel point;

[0183] The rendering module 1740 is used to perform illumination calculation on the model to be rendered in combination with the target distribution probability, the observation vector, the illumination vector and the half-angle vector, and render the model to be rendered with a flash effect according to the obtained illumination result.

[0184] Since the functional modules of the flash effect rendering device in the game of the exemplary embodiment of the present disclosure are the same as those in the inventive embodiment of the flash effect rendering method in the game described above, they will not be described in detail here.

[0185] It should be noted that although several modules or units of the flash effect rendering device in the game are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided into multiple modules or units to be embodied.

[0186] In addition, in the exemplary embodiment of the present disclosure, a computer storage medium capable of implementing the above method is also provided. A program product capable of implementing the above method of this specification is stored thereon. In some possible embodiments, various aspects of the present disclosure may also be implemented in the form of a program product, which includes a program code, and when the program product is run on a terminal device, the program code is used to enable the terminal device to perform the steps according to various exemplary embodiments of the present disclosure described in the above "Exemplary Method" section of this specification.

[0187] refer to Fig.18 As shown, a program product 1800 for implementing the above method according to an exemplary embodiment of the present disclosure is described, which can adopt a portable compact disk read-only memory (CD-ROM) and include program code, and can be run on a terminal device, such as a personal computer. However, the program product of the present disclosure is not limited thereto. In this document, a readable storage medium can be any tangible medium containing or storing a program, which can be used by or in combination with an instruction execution system, an apparatus or a device.

[0188] The program product may use any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.

[0189] Computer readable signal media may include data signals propagated in baseband or as part of a carrier wave, in which readable program code is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Readable signal media may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.

[0190] The program code embodied on the readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination of the foregoing.

[0191] Program code for performing the operations of the present disclosure may be written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Java, C++, etc., and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving a remote computing device, the remote computing device may be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (e.g., through the Internet using an Internet service provider).

[0192] In addition, in an exemplary embodiment of the present disclosure, an electronic device capable of implementing the above method is also provided. It will be appreciated by those skilled in the art that various aspects of the present disclosure may be implemented as a system, method, or program product. Therefore, various aspects of the present disclosure may be specifically implemented in the following forms, namely: a complete hardware embodiment, a complete software embodiment (including firmware, microcode, etc.), or an embodiment combining hardware and software aspects, which may be collectively referred to herein as a "circuit", "module", or "system".

[0193] Refer to the following Fig.19 1900 according to this embodiment of the present disclosure is described. Fig.19 The electronic device 1900 shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.

[0194] like Fig.19 As shown, the electronic device 1900 is in the form of a general computing device. The components of the electronic device 800 may include, but are not limited to: the at least one processing unit 1910, the at least one storage unit 1920, a bus 1930 connecting different system components (including the storage unit 1920 and the processing unit 1910), and a display unit 1940.

[0195] The storage unit stores program codes, which can be executed by the processing unit 1910, so that the processing unit 1910 executes the steps according to various exemplary embodiments of the present disclosure described in the above “Exemplary Method” section of this specification.

[0196] The storage unit 1920 may include a readable medium in the form of a volatile storage unit, such as a random access storage unit (RAM) 1921 and / or a cache storage unit 1922 , and may further include a read-only storage unit (ROM) 1923 .

[0197] The storage unit 1920 may also include a program / utility 1924 having a set (at least one) of program modules 1925, such program modules 1925 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment.

[0198] Bus 1930 may represent one or more of several types of bus structures, including a memory unit bus or memory unit controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.

[0199] The electronic device 1900 may also communicate with one or more external devices 2000 (e.g., keyboards, pointing devices, Bluetooth devices, etc.), may also communicate with one or more devices that enable a user to interact with the electronic device 1900, and / or communicate with any device that enables the electronic device 1900 to communicate with one or more other computing devices (e.g., routers, modems, etc.). Such communication may be performed via an input / output (I / O) interface 1950. Furthermore, the electronic device 1900 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) via a network adapter 1960. As shown, the network adapter 1960 communicates with other modules of the electronic device 1900 via a bus 1930. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 1900, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.

[0200] Through the description of the above embodiments, it is easy for those skilled in the art to understand that the example embodiments described here can be implemented by software, or by software combined with necessary hardware. Therefore, the technical solution according to the embodiment of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, and includes several instructions to enable a computing device (which can be a personal computer, a server, a terminal device, or a network device, etc.) to execute the method according to the embodiment of the present disclosure.

[0201] In addition, the above-mentioned figures are only schematic illustrations of the processes included in the method according to the exemplary embodiments of the present disclosure, and are not intended to be limiting. It is easy to understand that the processes shown in the above-mentioned figures do not indicate or limit the time sequence of these processes. In addition, it is also easy to understand that these processes can be performed synchronously or asynchronously, for example, in multiple modules.

[0202] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. The present disclosure is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary technical means in the art that are not disclosed in the present disclosure. The description and examples are to be considered exemplary only, and the true scope and spirit of the present disclosure are indicated by the claims.

[0203] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims

1. A method for rendering flash effects in a game, characterized in that: include: Calculate the slope of a pixel point according to a macro normal vector, an observation vector and an illumination vector of the pixel point in the model to be rendered, wherein the slope is a projection of a micro surface normal in a world space on a two-dimensional tangent space, and the macro normal vector, the observation vector and the illumination vector are vectors in the world space; Based on the texture coordinates of the pixel point and the target particle size required for the flash effect, determining the target LOD level to which the pixel point belongs, the target LOD level being configured with a slope probability distribution map, the slope probability distribution map including distribution probabilities of different slope values ​​in different coordinate directions; The slope probability distribution map is sampled using a target slope, and the target distribution probability of the pixel is determined according to the sampling result, wherein the target distribution probability is used to characterize the probability that the direction of the projection is a first target direction, and the target slope is the slope of the texel corresponding to the pixel, and the target slope is obtained based on the slope of the pixel; The target distribution probability, the observation vector, the illumination vector and the half-angle vector are combined to perform illumination calculation on the model to be rendered, and the model to be rendered is rendered with a flash effect according to the obtained illumination result.

2. The method according to claim 1, characterized in that The step of calculating the slope of a pixel point according to a macro normal vector, an observation vector and an illumination vector of the pixel point in the model to be rendered comprises: Constructing a tangent space according to the macro normal vector, and converting the observation vector and the illumination vector into the tangent space; Obtaining a vector sum of the observation vector and the illumination vector in the tangent space, and normalizing the vector sum to obtain a half-angle vector; The slope is obtained based on the half-angle vector.

3. The method according to claim 2, characterized in that The obtaining the slope based on the half-angle vector comprises: Dividing the first component and the second component of the half-angle vector by the third component of the half-angle vector respectively, so as to convert the half-angle vector from a three-dimensional vector to a two-dimensional plane vector; The two-dimensional plane vector is taken as the slope.

4. The method according to claim 1, characterized in that: The determining the target LOD level to which the pixel point belongs based on the texture coordinates of the pixel point and the target particle size required for the flash effect includes: Calculate the differential of the texture coordinate uv with respect to the screen space coordinate xy to obtain a differential result, and scale the differential result according to the value of the target particle size to obtain the texture coordinate differential; Calculating the length of the texture coordinate differential corresponding vector to obtain a first length value and a second length value, wherein the first length value is greater than the second length value; The target LOD level is determined by combining the second length value and a preset LOD level threshold.

5. The method according to claim 4, characterized in that In combination with the second length value and the preset LOD level threshold, the target LOD level is determined using the following formula: L=max(0,NLEVELS-1+log2(minorLength)) Among them, L is the target LOD level, NLEVELS is the LOD level threshold, and the minor Length is the second length value.

6. The method according to claim 4, characterized in that Before sampling the slope probability distribution map using the slope value of the target slope and determining the target distribution probability of the pixel point according to the sampling result, the method further includes: Constructing an elliptical region of the pixel point in a texture space according to the texture coordinates of the pixel point and the differential of the texture coordinates; The texels in the elliptical area are traversed, and for each texel, the slope of the pixel point is rotated and scaled to obtain the target slope of each texel.

7. The method according to claim 6, characterized in that The traversing of the texels in the elliptical area and rotating and scaling the slope of the pixel point for each texel to obtain the target slope of each texel includes: For each of the texels, a random rotation angle corresponding to the texel is obtained, and the slope of the pixel point is rotated according to the random rotation angle to obtain a rotation slope; The slope scaling factor is calculated in combination with the preset roughness and the roughness scaling factor, and the rotation slope is scaled according to the slope scaling factor to generate a target slope for each of the texels.

8. The method according to claim 7, characterized in that The obtaining of the random rotation angle corresponding to the texel and rotating the slope of the pixel point according to the random rotation angle to obtain the rotation slope includes: According to the target LOD level, converting the texel index of the texel into a consistency index, where the consistency index is used to indicate the consistency of the random rotation angle corresponding to the texel at different LOD levels; Generate a random value based on the consistency index, and use the random value as the random rotation angle; The slope of the pixel point is rotated according to the random rotation angle to obtain a rotated slope.

9. The method according to claim 7, characterized in that: Combining the preset roughness and roughness scaling factor, the slope scaling factor is calculated according to the following formula: Among them, the S α is the slope scaling factor, the α dict is the preset roughness used when generating the slope probability distribution map, wherein the α is obtained from the roughness map corresponding to the model to be rendered, and the α x and the α y are the roughness scaling factors required for the rotation slope in different decomposition directions respectively.

10. The method according to claim 6, characterized in that The method of sampling the slope probability distribution map by using the slope value of the target slope and determining the target distribution probability of the pixel point according to the sampling result includes: The slope probability distribution map is sampled using the slope value of the target slope, and the joint distribution probability of the texels corresponding to the pixel points is calculated according to the sampling result; Determining a Gaussian weight corresponding to the texel according to a distance between the texel and the texture coordinates of the pixel point; The target distribution probability is calculated based on the joint distribution probability and the Gaussian weight corresponding to the texel.

11. The method according to claim 10, characterized in that The step of sampling the slope probability distribution map by using the slope value of the target slope, and calculating the joint distribution probability of the texels corresponding to the pixel points according to the sampling result, includes: Performing orthogonal decomposition on the target slope to obtain a first slope value and a second slope value; Using the first slope value to sample the slope distribution map, obtaining a first distribution probability; Using the second slope value to sample the slope distribution map, to obtain a second distribution probability; The first distribution probability and the second distribution probability are fused and calculated to generate the joint distribution probability.

12. The method according to claim 11, characterized in that The first distribution probability and the second distribution probability are fused and calculated using the following formula to generate the joint distribution probability: Among them, P 3 is the joint distribution probability, the P 1 is the first distribution probability, the P 2 is the second distribution probability, the α dict is the preset roughness used when generating the slope probability distribution map, the α is obtained from the roughness map corresponding to the model to be rendered, and the α x and the α y are the roughness scaling multiples required for the target slope in different decomposition directions.

13. The method according to claim 11, characterized in that The calculating the target distribution probability based on the joint distribution probability and the Gaussian weight corresponding to the texel includes: Based on the Gaussian weights, the joint probability distributions corresponding to the texels within the elliptical area are weighted averaged to obtain the target distribution probability.

14. The method according to any one of claims 10 to 13, characterized in that The method further comprises: Calculate the target distribution probability of the pixel point on the adjacent LOD levels of the target LOD level; According to the target distribution probability at the adjacent LOD level and the target distribution probability at the target LOD level, the target distribution probability at the target LOD level is interpolated using the following interpolation formula to obtain the interpolated target distribution probability: P=P L (1-(L-[L]))+P L+1 (L-[L]) Wherein, P is the target distribution probability after interpolation, L is the target LOD level, L+1 is the adjacent LOD level, and P L is the target distribution probability at the target LOD level, P L+1 is the target distribution probability on the adjacent LOD levels; The target distribution probability after interpolation is used to update the target distribution probability of the pixel point at the target LOD level.

15. The method according to any one of claims 1 to 13, characterized in that Before calculating the slope of the pixel point according to the macro normal vector, the observation vector and the illumination vector of the pixel point in the model to be rendered, the method further includes: Generate slope probability distribution maps corresponding to different LOD levels; The process of generating the slope probability distribution map of the LOD level of the Nth layer includes: Using the preset roughness as a parameter, generating a first Gaussian distribution function; Use the first Gaussian distribution function to obtain 2 N numerical values; Based on the preset target standard deviation, the value is used as the mean to generate 2 N A second Gaussian distribution function; The 2 N The second Gaussian distribution function is fitted and superimposed to generate the target Gaussian distribution function as the target slope probability density; Taking the variable value of the target slope probability density as the slope value, using the target slope probability density, obtaining the distribution probability corresponding to each slope value, and storing the slope value and the distribution probability in correspondence; Wherein, N is an integer ≥0.

16. The method according to any one of claims 1 to 13, characterized in that The step of performing illumination calculation on the model to be rendered in combination with the target distribution probability, the observation vector, the illumination vector and the half-angle vector, and performing flash effect data rendering on the model to be rendered according to the obtained illumination result, comprises: Calculating the normal distribution probability of the pixel point based on the projection value of the microsurface normal on the macro normal vector and the target distribution probability, wherein the normal distribution probability is used to characterize the probability that the orientation of the microsurface is the second target direction; In combination with the half-angle vector, the observation vector and a preset surface basic reflectivity, the Nephilim equation is used to calculate first illumination data, wherein the first illumination data represents the ratio of reflected light to total light; Calculate second illumination data using a geometric shielding function according to the observation vector, the illumination vector and the half-angle vector, wherein the second illumination data represents the amount of light blocked by the surface; Combining the normal distribution probability, the first illumination data, and the second illumination data, and using a bidirectional reflectance distribution function to calculate fused illumination data; The product of the fused illumination data and the preset incident light intensity is calculated to obtain the illumination result.

17. A flash effect rendering device in a game, characterized in that: include: A slope calculation module, used to calculate the slope of a pixel point in a model to be rendered according to a macro normal vector, an observation vector and an illumination vector of the pixel point, wherein the slope is a projection of a micro surface normal in a world space onto a two-dimensional tangent space, and the macro normal vector, the observation vector and the illumination vector are vectors in the world space; A level determination module, for determining a target LOD level to which the pixel point belongs based on the texture coordinates of the pixel point and the target particle size required for the flash effect, wherein the target LOD level is configured with a slope probability distribution map, and the slope probability distribution map includes distribution probabilities of different slope values ​​in different coordinate directions; A sampling module, used to sample the slope probability distribution map using a target slope, and determine the target distribution probability of the pixel point according to the sampling result, wherein the target distribution probability is used to characterize the probability that the direction of the projection is a first target direction, and the target slope is the slope of the texel corresponding to the pixel point, and the target slope is obtained based on the slope of the pixel point; A rendering module is used to perform illumination calculation on the model to be rendered in combination with the target distribution probability, the observation vector, the illumination vector and the half-angle vector, and render the model to be rendered with a flash effect according to the obtained illumination result.

18. A storage medium having a computer program stored thereon, wherein the computer program implements the method according to any one of claims 1 to 16 when executed by a processor.

19. An electronic device, characterized in that: include: processor; as well as A memory, configured to store executable instructions of the processor; The processor is configured to perform the method of any one of claims 1 to 16 by executing the executable instructions.

Citation Information

Patent Citations

  • Method and device for zooming image in level-of-detail model

    CN103077497A

  • Pixel point identification and illumination rendering method and device, electronic equipment and storage medium

    CN111311723A

  • Rendering method and device of game resource map and electronic equipment

    CN111583381A

  • Object surface highlight rendering method and device in game, equipment and storage medium

    CN112419466A

  • Environment shielding rendering method, environment shielding rendering device, computer readable storage medium and electronic equipment.

    CN112734896A