A display control method and device in a game
By calculating the Fresnel coefficient and adjusting the highlight color of the environment, the problem of difficulty in simulating the real glass texture effect in the game is solved, and the glass texture that presents a double-layer reflection effect is achieved on the mobile platform with low consumption calculation, supporting realistic game projects Art needs.
Patent Information
- Application Number
- CN202111585307.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-22
- Publication Date
- 2025-02-18
- Estimated Expiration
- 2041-12-22
AI Technical Summary
In games, especially on mobile platforms, it is difficult to simulate the real glass texture effect. The existing technology usually ignores the special physical properties of glass, resulting in the glass effect being not perfect and realistic enough.
By obtaining the dot product results of the basic surface properties and normal direction and line of sight direction of the glass model, calculate the Fresnel coefficient, determine the mixing factors of diffuse reflection, inner reflection and outer reflection, and adjust the environmental highlight color according to these factors. Achieve glass rendering with double-layer reflective effect.
It realizes the glass texture with double-layer reflective effect with low consumption calculations on the mobile platform, supports the art needs of realistic game projects for glass, and facilitates the iteration of later art effects and program maintenance.
Smart Images

Figure CN114307133B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of computer graphics processing, and in particular to a display control method and a display control device in a game. Background Art
[0002] With the continuous improvement of game rendering technology, most of the game rendering effects are now implemented based on the PBR (Physically Based Rendering) rendering process, which is a physically based rendering process that aims to restore the behavior of light and object interaction in the real world based on the principles of physics and microplanes.
[0003] Although under the PBR process, game makers can easily restore the material properties of most real-world substances in the game. However, even with the now very mature PBR process, it is still a difficult problem to render a real glass effect in the game, because real glass has many special physical properties, such as reflection, refraction, total internal reflection and thickness, etc., and these physical properties require a lot of calculations when rendering, such as using ray tracing. At present, most games classify real glass as common translucent objects in the game, only process the translucent properties of glass, and ignore some other physical properties of real glass, that is, abandon the special properties of glass materials. The glass effect achieved in this way is not perfect and realistic. Even on the host platform that can fully utilize the game performance, the glass effect achieved is not ideal, not to mention that considering the hardware and computing limitations of the mobile platform, it is basically impossible to achieve a perfect glass texture on mobile games. Therefore, it is urgent to provide a relatively friendly performance solution that can simulate the physical texture of real glass for realistic mobile platform games. Summary of the invention
[0004] In view of the above-mentioned problem that it is difficult to simulate the effect of real glass texture in mobile games, an embodiment of the present invention is proposed to provide a display control method and a corresponding device in a game that overcomes the above-mentioned problem or at least partially solves the above-mentioned problem.
[0005] The embodiment of the present invention discloses a display control method in a game, comprising:
[0006] Obtaining basic surface properties of a glass model in the game, and determining a first ambient highlight color of the glass model according to the basic surface properties;
[0007] Acquire the normal direction of the glass model and the sight direction of the virtual camera in the game photographing the glass model, and determine the Fresnel coefficient according to the normal direction and the sight direction;
[0008] Determine a first mixing factor corresponding to diffuse reflection and a second mixing factor corresponding to inner reflection according to the basic surface properties and the Fresnel coefficient, and determine a third mixing factor corresponding to outer reflection according to the first ambient highlight color;
[0009] Adjusting the first ambient highlight color according to the first mixing factor, the second mixing factor, and the third mixing factor to obtain a target ambient color;
[0010] The glass model is rendered according to the target environment color to present a glass texture with a double-layer reflection effect.
[0011] Optionally, the basic surface attributes include basic color, metalness, smoothness and first transparency;
[0012] The determining, according to the basic surface properties and the Fresnel coefficient, a first mixing factor corresponding to diffuse reflection and a second mixing factor corresponding to inner reflection comprises:
[0013] determining a second transparency according to the first transparency, a base color and a metallicity;
[0014] Determine a first mixing factor of diffuse reflection according to the Fresnel coefficient and the second transparency;
[0015] A second mixing factor of the inner layer reflection is determined according to the Fresnel coefficient and the smoothness.
[0016] Optionally, determining the second transparency according to the first transparency, the base color and the metallicity includes:
[0017] adjusting the first transparency according to the basic color;
[0018] The second transparency is obtained by interpolating the adjusted first transparency and a preset reflection coefficient according to the metalness, wherein the second transparency is used to retain a highlight portion when the glass model is completely transparent.
[0019] Optionally, determining a third mixing factor corresponding to the outer layer reflection according to the first ambient highlight color includes:
[0020] The first ambient highlight color is grayed to obtain a third mixing factor corresponding to the outer layer reflection.
[0021] Optionally, the adjusting the first ambient highlight color according to the first mixing factor, the second mixing factor, and the third mixing factor to obtain a target ambient color includes:
[0022] Determine a maximum value from the second mixing factor and the third mixing factor as a target mixing factor;
[0023] Correcting the first ambient highlight color according to the target mixing factor to obtain a second ambient highlight color;
[0024] The first ambient highlight color and the second ambient highlight color are interpolated according to the first mixing factor to obtain the target ambient color.
[0025] Optionally, determining the Fresnel coefficient according to the normal direction and the sight direction includes:
[0026] Performing dot product processing on the normal direction and the sight line direction to obtain a dot product result;
[0027] The Fresnel coefficient is obtained by calculating the square of the dot product result.
[0028] Optionally, after the step of obtaining the basic surface properties of the glass model in the game, the method further includes:
[0029] Get the dirty surface properties corresponding to the dirty effect;
[0030] The base surface properties are adjusted using the dirty surface properties.
[0031] The embodiment of the present invention further discloses a display control device in a game, comprising:
[0032] A first ambient highlight determination module, used to obtain basic surface properties of a glass model in the game, and determine a first ambient highlight color of the glass model according to the basic surface properties;
[0033] A Fresnel coefficient determination module, used to obtain the normal direction of the glass model and the sight direction of the virtual camera in the game shooting the glass model, and determine the Fresnel coefficient according to the normal direction and the sight direction;
[0034] A mixing factor determination module, used to determine a first mixing factor corresponding to diffuse reflection and a second mixing factor corresponding to inner reflection according to the basic surface properties and the Fresnel coefficient, and to determine a third mixing factor corresponding to outer reflection according to the first ambient highlight color;
[0035] An ambient color determination module, configured to adjust the first ambient highlight color according to the first mixing factor, the second mixing factor, and the third mixing factor to obtain a target ambient color;
[0036] A rendering module is used to render the glass model according to the target environment color to present a glass texture with a double-layer reflection effect.
[0037] The embodiment of the present invention further discloses an electronic device, including:
[0038] A processor and a storage medium, wherein the storage medium stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor executes the machine-readable instructions to perform the method as described in any one of the embodiments of the present invention.
[0039] An embodiment of the present invention further discloses a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the method described in any one of the embodiments of the present invention is executed.
[0040] The embodiments of the present invention include the following advantages:
[0041] In the embodiment of the present invention, the first ambient highlight color of the glass model is first determined according to the basic surface properties, and then the mixing factor is determined by using the Fresnel coefficient to mix the diffuse reflection, inner reflection and outer reflection, thereby restoring the double-layer reflection property existing in the real glass; and no complicated lighting calculation process is required during processing, so that it can support the artistic requirements of realistic game projects for glass, and can also run perfectly on the mobile terminal with low-consumption computing, which is convenient for the later art effect iteration and program maintenance, such as increasing the diversity of glass, making dirty glass or adding other properties. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] In order to more clearly illustrate the technical solution of the present invention, the accompanying drawings required for use in the description of the present invention will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative labor.
[0043] Figure 1 is a flowchart of a display control method in a game provided by an embodiment of the present invention;
[0044] Figure 2 This is a schematic diagram of the effect of a glass model provided by an embodiment of the present invention;
[0045] Figure 3 is a schematic diagram of adding dirt control provided by an embodiment of the present invention;
[0046] Figure 4 is a structural block diagram of a display control device in a game provided by an embodiment of the present invention;
[0047] Figure 5 is a structural block diagram of an electronic device of the present invention;
[0048] Figure 6It is a structural block diagram of a computer-readable storage medium of the present invention. DETAILED DESCRIPTION
[0049] In order to make the above-mentioned purposes, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0050] In the prior art, for games that need to achieve glass effects, except for the offline rendering part, the glass effects rendered in real time in the game are not realistic enough, including in some mainstream 3A games and console games known for their performance. The glass effects achieved are not ideal. Basically, they only achieve the rendering of traditional PBR transparent mixed materials, and then add the refraction part according to performance requirements on this basis, and then calculate in the rendering queue for rendering transparent objects, and obtain the color texture of a screen and distort it to get the refraction result.
[0051] The above solution mainly classifies real glass as a common translucent object in the game, and only processes the translucent properties of the glass, while ignoring some other physical properties of real glass, that is, abandoning the special properties of the glass material. This processing method is more friendly to mobile platforms with limited performance, and can also add refraction effects to the glass according to the performance adaptation of the target mobile platform. However, this will make the performance of the game texture appear too simple. In realistic games, if the game user group is very pursuing the details of the game or there are scenes in the game that need to display multiple glass objects at the same time, it may make it difficult for some players to distinguish or judge the difference between other translucent objects and glass objects in the scene, causing players to feel visual fatigue.
[0052] In order to solve the above technical problems in the prior art, in an embodiment of the present invention, based on Unity's URP (Universal Render Pipeline), and modified based on the existing BRDF rendering technology, the role of BRDF is to scale or weight the incident radiance based on the surface material properties. In current games, the most difficult part of the lighting calculation related to glass is the light entering the glass. This part of the light will undergo internal reflection and refraction in the glass, forming a double-layer reflection phenomenon in real glass, which is often referred to as the thickness of the glass. It can generally only be reflected in offline rendering. In an embodiment of the present invention, when rendering, for the part of calculating global illumination, the traditional ambient highlight part is calculated twice, once according to the traditional PBR process to calculate the traditional ambient highlight effect; the other time is to simulate the double-layer reflection effect generated by the refraction of light in the glass. When calculating the second layer of reflection, the dot product result of the sight direction and the normal direction is first calculated to create a Fresnel function formula to distinguish the range of the double-layer reflection and the outer reflection of the glass. The grayscale value is calculated using the color of the outer layer of the ambient highlight, and the inner and outer reflections are mixed by the max function to output the final alpha transparency value, and the colors of the two reflections are retained by transparency mixing. The color output is obtained by adding the two internal and external reflections and the ambient diffuse reflection through the Fresnel function interpolation. In this way, the double-layer reflection and edge diffuse reflection properties of real glass in reality can be simulated based on the translucent properties of traditional glass rendered in real time.
[0053] Reference Figure 1 , shows a flowchart of a display control method in a game provided by an embodiment of the present invention, which may specifically include the following steps:
[0054] Step 101, obtaining basic surface properties of a glass model in the game, and determining a first ambient highlight color of the glass model according to the basic surface properties;
[0055] Among them, the basic surface attributes refer to the data used to describe the material characteristics of the glass model, such as basic color, metalness, smoothness and first transparency. Among them, the basic color refers to the color value of the glass model before the influence of ambient light is added; the metalness refers to the maximum ability of the glass model to resist the destructive effect of external forces, for example, the metalness is set to 0.2; the smoothness refers to the smoothness of the surface of the glass model; the first transparency refers to the initial transparency of the glass model.
[0056] The basic surface properties of the glass model will affect the effect of the glass model reflecting and refracting light. In the embodiment of the present invention, when rendering the glass model, in order to simulate the physical texture of real glass, the basic surface properties of the glass model are obtained to perform global lighting calculations using the basic surface properties. Specifically, the first environment highlight color environmentSpecular of the glass model can be determined according to the basic surface properties using PBR (Physically Based Rendering) rendering technology, where the first environment highlight color is used to represent the highlight color value of the outer layer reflection of the glass model.
[0057] Step 102, obtaining the normal direction of the glass model and the sight direction of the virtual camera in the game photographing the glass model, and determining the Fresnel coefficient according to the normal direction and the sight direction;
[0058] In the real world, except for metals, other substances have different degrees of "Fresnel effect". The glass model also follows the "Fresnel effect". According to the Fresnel effect, when observing the surface of an object, when the line of sight is perpendicular to the surface, the reflection is weaker, and when the line of sight is not perpendicular to the surface, the smaller the grazing angle, the more obvious the reflection. For example, looking at a sphere, the reflection in the center of the sphere is weaker and stronger near the edge.
[0059] In the embodiment of the present invention, in order to simulate the effect of real glass texture, the normal direction of the glass model and the sight direction of the glass model shot by the virtual camera in the game are obtained, and the Fresnel coefficient is determined according to the normal direction and the sight direction. The Fresnel coefficient is used to describe the reflection intensity of light when the glass model is observed from different angles, so that the phenomenon of different reflection degrees of the glass model observed at different angles in reality can be simulated by the Fresnel coefficient.
[0060] In a preferred embodiment of the present invention, step 102 may specifically include the following sub-steps:
[0061] Performing dot product processing on the normal direction and the sight line direction to obtain a dot product result; and calculating the square of the dot product result to obtain the Fresnel coefficient.
[0062] In the specific implementation, the normal direction of the glass model in the world space is recorded as normalWS, and the line of sight direction of the virtual camera shooting the glass model is recorded as viewDirWS. The dot product result NdotV=normalWS·viewDirWS. Furthermore, the dot product result can be normalized to standardize the dot product result to between 0 and 1. The expression for calculating the dot product result is as follows: NdotV=saturate(dot(normalWS,viewDirWS)), where the dot() function is used to perform dot product operation on the data, and the saturate() function is used to normalize the data.
[0063] Step 103, determining a first mixing factor corresponding to diffuse reflection and a second mixing factor corresponding to inner reflection according to the basic surface properties and the Fresnel coefficient, and determining a third mixing factor corresponding to outer reflection according to the first ambient highlight color;
[0064] When light shines on the glass model, part of the light will be reflected, and the other part will pass through the glass and be refracted. In the embodiment of the present invention, in order to simulate the double-layer reflection effect caused by the refraction of light in the glass, the mixing factors corresponding to the diffuse reflection, inner reflection and outer reflection are calculated to correct the first ambient highlight color according to these mixing factors. Specifically, according to the basic surface properties and the Fresnel coefficients, the first mixing factor corresponding to the diffuse reflection and the second mixing factor corresponding to the inner reflection can be determined; according to the first ambient highlight color, the third mixing factor corresponding to the outer reflection can be determined.
[0065] Step 104, adjusting the first ambient highlight color according to the first mixing factor, the second mixing factor and the third mixing factor to obtain a target ambient color;
[0066] In the embodiment of the present invention, the target environment color is obtained by adjusting the first environment highlight color according to the first mixing factor, the second mixing factor and the third mixing factor.
[0067] Step 105 , rendering the glass model according to the target environment color to present a glass effect with a double-layer reflection effect.
[0068] In the embodiment of the present invention, by rendering the glass model according to the target environment color, a glass texture with a double-layer reflection effect can be presented in the graphical user interface of the game, such as Figure 2 The following is a schematic diagram of the effect of rendering a glass model.
[0069] In a preferred embodiment of the present invention, the basic surface attributes include basic color, metalness, smoothness and a first transparency.
[0070] In a preferred embodiment of the present invention, after the step of obtaining the basic surface properties of the glass model in the game, the method further includes:
[0071] Obtain dirty surface properties corresponding to the dirty effect; and use the dirty surface properties to adjust the basic surface properties.
[0072] In the embodiment of the present invention, dirt control can be added to the glass model according to project requirements, and after adding the dirt control, the original glass properties and dirt are interpolated and calculated to distinguish them. The dirt surface properties corresponding to the dirt effect are obtained, and then the basic surface properties are adjusted using the dirt surface properties.
[0073] In the specific implementation, the dirty part requires the art designer to pre-make the base color map (_BaseColor) and normal map (_BumpMap) corresponding to the required dirty effect. The RGB channel of the base color map stores the color of the dirty, and the Alpha channel is used to distinguish the range of dirt and glass (the black part of the map is pure glass, and the white part is dirty). The base color map, that is, the normal map, records the dirty surface properties corresponding to the dirty effect, such as Figure 3 , the function of adding dirt control is provided in 3D modeling software (such as Unity). In the user interface of the 3D modeling software, the base color map and normal map of the required dirt effect are inserted by calling the interface. After obtaining the dirt surface properties corresponding to the dirt effect, in the lighting data preparation stage, the Alpha channel of the glass model can be used for interpolation calculation to control the base color and transparency of the glass and dirt respectively.
[0074] As an example, the base color of the glass model is recorded as surfaceData.albedo, the metalness is recorded as surfaceData.metallic, the smoothness is recorded as surfaceData.smoothness, and the first transparency is recorded as surfaceData.alpha. The color of the dirt effect is recorded as dirtColor, and the transparency is recorded as dirtAlpha. According to dirtAlpha, the properties of the glass model and the dirt effect are interpolated. Specifically, the lerp() function can be used to perform linear interpolation calculation to add a dirt effect to the glass model. When adding dirt control to the glass model, the metalness of the glass model surfaceData.metallic can be kept unchanged, such as fixing surfaceData.metallic to 0.2.
[0075] In a preferred embodiment of the present invention, step 103 may specifically include the following sub-steps:
[0076] The second transparency is determined according to the first transparency, the basic color and the metalness; the first mixing factor of diffuse reflection is determined according to the Fresnel coefficient and the second transparency; and the second mixing factor of inner layer reflection is determined according to the Fresnel coefficient and the smoothness.
[0077] In an embodiment of the present invention, the second transparency can be determined according to the first transparency, basic color and metalness, the first mixing factor of diffuse reflection can be determined according to the Fresnel coefficient and the second transparency, and the second mixing factor of inner reflection can be determined according to the Fresnel coefficient and smoothness.
[0078] As an example, the Fresnel coefficient is recorded as OneMinusNodtV2, and the second transparency obtained after correction in the above steps is recorded as alpha. Then, when calculating the first mixing factor of the environment diffuse reflection environmentDiffuseAlpha, first adjust OneMinusNodtV2 according to the preset coefficient _EdgRefer to obtain fresnelTerm=OneMinusNodtV2*_EdgRefer, and interpolate fresnelTerm with the transparency alpha to obtain the first mixing factor of the diffuse reflection. Specifically, the lerp() function can be used for linear interpolation calculation, which is expressed as environmentDiffuseAlpha=lerp(fresnelTerm, 1.0, alpha). When calculating the second mixing factor of the inner reflection environmentSpecularInsideAlpha, the distance is fitted by the power function of the Fresnel term, and then the fitting result and smoothness are normalized to obtain the required environmentSpecularInsideAlpha.
[0079] In a preferred embodiment of the present invention, determining the second transparency according to the first transparency, the base color and the metallicity comprises:
[0080] The first transparency is adjusted according to the basic color; the adjusted first transparency and a preset reflection coefficient are interpolated according to the metallicity to obtain the second transparency, wherein the second transparency is used to retain the highlight phenomenon when the glass model is completely transparent.
[0081] The preset reflection coefficient is a parameter pre-set according to the metalness, which is used to represent the reflectivity of real glass. In a specific implementation, the base color surfaceData.albedo and the first transparency surfaceData.alpha can be pre-multiplied, expressed as surfaceData.albedo*=surfaceData.alpha. Then, referring to the reflectivity of the real glass, the first transparency after the final adjustment is interpolated to obtain the second transparency. Specifically, the lerp() function can be used for linear interpolation calculation.
[0082] In a preferred embodiment of the present invention, determining a third mixing factor corresponding to the outer layer reflection according to the first ambient highlight color includes:
[0083] The first ambient highlight color is grayed to obtain a third mixing factor corresponding to the outer layer reflection.
[0084] As an example, the first environment highlight color is recorded as environmentSpecular, and the third mixing factor corresponding to the outer reflection is recorded as environmentSpecularAlpha. Then, the color values of the three channels of RGB of environmentSpecular are mixed according to the preset ratio to obtain environmentSpecularAlpha. For example, the mixing ratio of the R channel is 0.2125, the mixing ratio of the G channel is 0.7154, and the mixing ratio of the B channel is 0.0721, then environmentSpecularAlpha = 0.2125*environmentSpecular.r+0.7154*environmentSpecular.g+0.0721*environmentSpecular.b.
[0085] In a preferred embodiment of the present invention, the adjusting the first ambient highlight color according to the first mixing factor, the second mixing factor and the third mixing factor to obtain the target ambient color includes:
[0086] Determine the maximum value from the second mixing factor and the third mixing factor as the target mixing factor; correct the first ambient highlight color according to the target mixing factor to obtain the second ambient highlight color; interpolate the first ambient highlight color and the second ambient highlight color according to the first mixing factor to obtain the target ambient color.
[0087] Specifically, the max() function can be used to determine the maximum value from the second mixing factor and the third mixing factor as the target mixing factor specularAlpha, so as to combine the inner and outer reflections through transparency to ensure that the color details of the outer and inner reflections are retained at the same time. After determining specularAlpha, the first environment highlight color environmentSpecular is offset by using the reflection map (used to represent the ambient light data) to obtain the second environment highlight color, wherein the second environment highlight color is used to represent the color of the inner reflection of the glass model. In a specific implementation, the reflection map is obtained by sampling the skybox and reflection probe of the game scene, and the reflection direction is calculated (the viewing direction is reversed, and then the normal direction is added twice to obtain it). The reflection direction is used as the sampling coordinate, and the skybox and reflection probe data stored in the cube space are sampled to obtain the color of the environment reflection, and then the first environment highlight color environmentSpecular is offset by the color of the environment reflection, and at the same time, it is multiplied by the basic color of the glass model itself, because the inner reflection of the glass will reflect the basic color of the glass model itself after refraction.
[0088] Furthermore, the first environment highlight color and the second environment highlight color are interpolated according to the first mixing factor to obtain the target environment color environmentSpecularOut. Specifically, the lerp() function can be used to perform linear interpolation calculation to mix the environment highlight color and the result of outer reflection plus diffuse reflection, so that the diffuse reflection of the environment can be retained at the edge of the glass model.
[0089] In an embodiment of the present invention, the basic surface properties of a glass model in a game are obtained, and the first ambient highlight color of the glass model is determined according to the basic surface properties; the normal direction of the glass model and the line of sight direction of a virtual camera in the game photographing the glass model are obtained, and the Fresnel coefficient is determined according to the normal direction and the line of sight direction; according to the basic surface properties and the Fresnel coefficient, a first mixing factor corresponding to diffuse reflection and a second mixing factor corresponding to inner reflection are determined, and a third mixing factor corresponding to outer reflection is determined according to the first ambient highlight color; the first ambient highlight color is adjusted according to the first mixing factor, the second mixing factor and the third mixing factor to obtain a target ambient color; the glass model is rendered according to the target ambient color to present a glass texture with a double-layer reflection effect. The Fresnel coefficient is used to determine the mixing factor and use it to mix diffuse reflection, inner reflection and outer reflection, restoring the double-layer reflection property existing in real glass. There is no need to perform complex lighting calculations during processing. The global highlight part of BRDF (Bidirectional Reflectance Distribution Function) is used as the basic framework. At the same time, it supports the artistic requirements of realistic game projects for glass, and can also run perfectly on mobile terminals with low-consumption calculations. The entire solution is developed based on the BRDF framework, which can facilitate the iteration of later art effects and program maintenance. For example, it is very convenient to increase the diversity of glass, make dirty glass or add other attributes.
[0090] It should be noted that, for the sake of simplicity, the method embodiments are described as a series of action combinations, but those skilled in the art should be aware that the embodiments of the present invention are not limited by the order of the actions described, because according to the embodiments of the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.
[0091] Reference Figure 4 , shows a structural block diagram of a display control device in a game provided by an embodiment of the present invention, which may specifically include the following modules:
[0092] A first ambient highlight determination module 401 is used to obtain basic surface properties of a glass model in the game, and determine a first ambient highlight color of the glass model according to the basic surface properties;
[0093] A Fresnel coefficient determination module 402 is used to obtain the normal direction of the glass model and the sight direction of the virtual camera in the game shooting the glass model, and determine the Fresnel coefficient according to the normal direction and the sight direction;
[0094] A mixing factor determination module 403 is used to determine a first mixing factor corresponding to diffuse reflection and a second mixing factor corresponding to inner reflection according to the basic surface properties and the Fresnel coefficient, and to determine a third mixing factor corresponding to outer reflection according to the first ambient highlight color;
[0095] An ambient color determination module 404 is used to adjust the first ambient highlight color according to the first mixing factor, the second mixing factor and the third mixing factor to obtain a target ambient color;
[0096] The rendering module 405 is used to render the glass model according to the target environment color to present a glass texture with a double-layer reflection effect.
[0097] In a preferred embodiment of the present invention, the basic surface attributes include basic color, metalness, smoothness and first transparency;
[0098] The mixing factor determination module 403 includes:
[0099] A second transparency determination submodule, configured to determine a second transparency according to the first transparency, a basic color and a metallic degree;
[0100] A first mixing factor determination submodule is configured to determine a first mixing factor for diffuse reflection according to the Fresnel coefficient and the second transparency;
[0101] The second mixing factor determination submodule is used to determine the second mixing factor of the inner layer reflection according to the Fresnel coefficient and the smoothness.
[0102] In a preferred embodiment of the present invention, the second transparency determination submodule includes:
[0103] a transparency adjustment unit, configured to adjust the first transparency according to the basic color;
[0104] A transparency interpolation unit is used to interpolate the adjusted first transparency and a preset reflection coefficient according to the metalness to obtain the second transparency, wherein the second transparency is used to retain the highlight part when the glass model is completely transparent.
[0105] In a preferred embodiment of the present invention, the mixing factor determination module 403 includes:
[0106] The third mixing factor determination submodule is used to perform grayscale processing on the first ambient highlight color to obtain a third mixing factor corresponding to the outer layer reflection.
[0107] In a preferred embodiment of the present invention, the environment color determination module 404 includes:
[0108] a target mixing factor determination submodule, configured to determine a maximum value from the second mixing factor and the third mixing factor as a target mixing factor;
[0109] A second ambient highlight color determination submodule, configured to correct the first ambient highlight color according to the target mixing factor to obtain a second ambient highlight color;
[0110] The ambient highlight color interpolation submodule is used to interpolate the first ambient highlight color and the second ambient highlight color according to the first mixing factor to obtain the target ambient color.
[0111] In a preferred embodiment of the present invention, the Fresnel coefficient determination module 402 includes:
[0112] A dot product processing submodule, used for performing dot product processing on the normal direction and the sight line direction to obtain a dot product result;
[0113] The Fresnel coefficient determination submodule is used to calculate the square of the dot product result to obtain the Fresnel coefficient.
[0114] In a preferred embodiment of the present invention, it also includes:
[0115] A dirty surface property acquisition module, used to acquire dirty surface properties corresponding to the dirty effect;
[0116] The basic surface property adjustment module is used to adjust the basic surface property by using the dirty surface property.
[0117] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0118] The embodiment of the present invention further provides an electronic device, such as Figure 5 As shown, including:
[0119] A processor 501 and a storage medium 502, wherein the storage medium 502 stores machine-readable instructions executable by the processor 501, and when the electronic device is running, the processor 501 executes the machine-readable instructions to execute the method as described in any one of the embodiments of the present invention. The specific implementation method and technical effect are similar and will not be repeated here.
[0120] The embodiment of the present invention also provides a computer readable storage medium, such as Figure 6As shown, the storage medium stores a computer program 601, and the computer program 601 is executed by a processor to execute a method as described in any one of the embodiments of the present invention. The specific implementation method and technical effect are similar and will not be described here.
[0121] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0122] It will be appreciated by those skilled in the art that the embodiments of the present invention may be provided as methods, devices, or computer program products. Therefore, the embodiments of the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the embodiments of the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.
[0123] The embodiments of the present invention are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0124] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0125] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1A step that specifies a function in one or more boxes.
[0126] Although the preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present invention.
[0127] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the elements.
[0128] The above is a detailed introduction to a display control method in a game and a display control device in a game provided by the present invention. Specific examples are used herein to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of the present invention, there will be changes in the specific implementation methods and application scopes. In summary, the content of this specification should not be understood as a limitation on the present invention.
Claims
1. A display control method in a game, characterized in that: include: Obtaining basic surface properties of a glass model in the game, and determining a first ambient highlight color of the glass model according to the basic surface properties; The basic surface properties include basic color, metalness, smoothness and first transparency; Acquire the normal direction of the glass model and the sight direction of the virtual camera in the game photographing the glass model, and determine the Fresnel coefficient according to the normal direction and the sight direction; determining a second transparency according to the first transparency, the base color, and the metalness; Determine a first mixing factor of diffuse reflection according to the Fresnel coefficient and the second transparency; Determine a second mixing factor of inner layer reflection according to the Fresnel coefficient and the smoothness; Determine a third mixing factor corresponding to the outer layer reflection according to the first ambient highlight color; Adjusting the first ambient highlight color according to the first mixing factor, the second mixing factor, and the third mixing factor to obtain a target ambient color; The glass model is rendered according to the target environment color to present a glass texture with a double-layer reflection effect.
2. The method according to claim 1, characterized in that The determining the second transparency according to the first transparency, the basic color and the metalness includes: adjusting the first transparency according to the basic color; The second transparency is obtained by interpolating the adjusted first transparency and a preset reflection coefficient according to the metalness, wherein the second transparency is used to retain a highlight portion when the glass model is completely transparent.
3. The method according to claim 1, characterized in that The determining of a third mixing factor corresponding to the outer layer reflection according to the first ambient highlight color includes: The first ambient highlight color is grayed to obtain a third mixing factor corresponding to the outer layer reflection.
4. The method according to claim 1, characterized in that The adjusting the first ambient highlight color according to the first mixing factor, the second mixing factor and the third mixing factor to obtain a target ambient color includes: Determine a maximum value from the second mixing factor and the third mixing factor as a target mixing factor; Correcting the first ambient highlight color according to the target mixing factor to obtain a second ambient highlight color; The first ambient highlight color and the second ambient highlight color are interpolated according to the first mixing factor to obtain the target ambient color.
5. The method according to claim 1, characterized in that The determining of the Fresnel coefficient according to the normal direction and the sight direction comprises: Performing a dot product process on the normal direction and the sight line direction to obtain a dot product result; The Fresnel coefficient is obtained by calculating the square of the dot product result.
6. The method according to claim 1, characterized in that After the step of obtaining the basic surface properties of the glass model in the game, the method further includes: Get the dirty surface properties corresponding to the dirty effect; The base surface properties are adjusted using the dirty surface properties.
7. A display control device in a game, characterized in that: include: A first ambient highlight determination module, used to obtain basic surface properties of a glass model in the game, and determine a first ambient highlight color of the glass model according to the basic surface properties; the basic surface properties include basic color, metalness, smoothness and first transparency; A Fresnel coefficient determination module, used to obtain the normal direction of the glass model and the sight direction of the virtual camera in the game shooting the glass model, and determine the Fresnel coefficient according to the normal direction and the sight direction; A second transparency determination submodule, configured to determine a second transparency according to the first transparency, the basic color and the metallicity; A first mixing factor determination submodule, used to determine a first mixing factor of diffuse reflection according to the Fresnel coefficient and the second transparency; A second mixing factor determination submodule, used to determine a second mixing factor of inner layer reflection according to the Fresnel coefficient and the smoothness; A third mixing factor determination submodule, used to determine a third mixing factor corresponding to the outer layer reflection according to the first ambient highlight color; an ambient color determination module, configured to adjust the first ambient highlight color according to the first mixing factor, the second mixing factor, and the third mixing factor to obtain a target ambient color; A rendering module is used to render the glass model according to the target environment color to present a glass texture with a double-layer reflection effect.
8. An electronic device, characterized in that: include: A processor and a storage medium, wherein the storage medium stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor executes the machine-readable instructions to perform the method according to any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 6 is executed.
Citation Information
Patent Citations
Highlight calculation method based on physics
CN104463944A
Real 3D real-time mixed rendering method
CN107256574A