Volumetric light generation method applied to virtual environment

By drawing scenes in a virtual environment, generating mask maps and diffusion parameters, and performing multiple iterative calculations and value evaluation analysis, the problem of low volume light generation efficiency is solved, the generation accuracy and efficiency of volume light is improved, and the visual effect is enhanced .

CN119027569APending Publication Date: 2024-11-26WUHU WUTONGZHI NETWORK TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411094424.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-09
Publication Date
2024-11-26

Smart Images

  • Figure CN119027569A_ABST
    Figure CN119027569A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of light and shadow special effect processing, in particular to a volumetric light generation method applied to a virtual environment, which comprises the following steps: drawing a virtual scene, marking a light source in the scene meeting the requirement as an object light source based on the priority when the loading is completed, and acquiring the position, the irradiation direction and the illumination intensity of the object light source; acquiring a picture frame screenshot of the current scene, and caching the picture frame screenshot to the diffusion temporary map; generating a mask map based on the diffusion temporary map; calculating a volume light diffusion parameter, and caching a calculation result to the diffusion temporary map; carrying out superposition processing on the diffusion temporary chartlet and the picture frame screenshot, and transmitting the superposed data to a frame buffer for final display; the diffusion evaluation value is calculated, whether the generation of the volume light is qualified or not is analyzed, the disqualification reason is analyzed when the generation of the volume light is judged to be unqualified, and the generation efficiency of the volume light in the simulation scene is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of light and shadow special effects processing, and in particular to a volume light generation method applied to a virtual environment. Background Art

[0002] In current mobile games with relatively high quality, it is often necessary to display the Tyndall phenomenon caused by light sources in the scene. Conventionally, real-time simulation of ray tracing is used. The existing technology builds a delayed rendering framework and performs volumetric light smoothing through a preset algorithm. However, the calculation process is complicated, resulting in low efficiency in volumetric light generation.

[0003] Chinese patent application number: CN202011105083.2 discloses a volumetric light generation method, device, equipment and storage based on OpenSceneGraph, the method comprising: building a deferred rendering framework, generating a scene graph / depth map; generating a light source mask map based on the scene graph and the depth map; eliminating scenes when the light source is not on the screen; based on the mask map, calculating the light superposition processing effect to obtain volumetric light; wherein the calculation of the volumetric light and the generation of the light source mask map are performed in one pass; performing volumetric light smoothing through a preset algorithm; fusing the volumetric light and the scene graph and outputting the final scene.

[0004] It can be seen that the volume light generation method, device, equipment and storage based on OpenSceneGraph have the following problems: the calculation process is complicated, resulting in low efficiency of volume light generation. Summary of the invention

[0005] To this end, the present invention provides a volume light generation method applied to a virtual environment, so as to overcome the problem in the prior art that the calculation process is complex and the volume light generation efficiency is low.

[0006] To achieve the above-mentioned purpose, the present invention provides a volume light generation method for a virtual environment, comprising:

[0007] Step S1, draw a virtual scene, and when loading is completed, record the light sources in the scene that meet the requirements as object light sources based on priority, and obtain the position, illumination direction and light intensity of the object light sources;

[0008] Step S2, obtaining a screenshot of the current scene frame, and caching the screenshot of the current scene frame into a diffusion temporary map;

[0009] Step S3, generating a mask map based on the diffusion temporary map;

[0010] Step S4, calculating volume light diffusion parameters, and caching the calculation results into a temporary diffusion map;

[0011] Step S5, superimposing the temporary diffusion map and the screen frame screenshot, and transmitting the superimposed data to a frame buffer for final display;

[0012] Step S6, calculating the diffusion evaluation value based on the parameters in the superimposed screen image, and analyzing whether the generation of volume light is qualified based on the diffusion evaluation value, and analyzing the reason for the failure when it is determined that the generation of volume light is unqualified.

[0013] Furthermore, the calculation process of the volume light diffusion parameter includes:

[0014] Step S41, obtaining information data of scene information and generating an initial light source map based on the obtained information data, the information data including the light source position, direction and camera orientation;

[0015] Step S42, perform volume light diffusion calculation, iterate the calculation multiple times and record the calculated temporary effect in the diffusion map.

[0016] Furthermore, the diffusion evaluation value is calculated based on formula (1), wherein:

[0017]

[0018] In formula (1), S is the diffusion evaluation value, Fi is the actual roughness of the i-th surface obtained after simulation, Fi0 is the expected roughness for the i-th surface, Li is the actual volume brightness for the i-th surface, Li0 is the expected volume brightness for the i-th surface, Ri is the actual volume light diffusion radius for the i-th surface, Ri0 is the expected volume light diffusion radius for the i-th surface, α is the first weight coefficient, and β is the second weight coefficient.

[0019] Furthermore, whether the generation of volumetric light is qualified is determined based on the diffusion evaluation value. When the generation of volumetric light is determined to be unqualified, a processing method is determined based on the diffusion evaluation value, or it is determined to add a virtual light source and reconfigure.

[0020] Further, based on the difference between the diffusion evaluation value and the first preset diffusion evaluation value, it is determined that the reason why the volume light generation is unqualified is that the volume light generation is deviated due to the movement of the viewing angle, and the calculation is recalculated.

[0021] or, adjusting the contrast to a corresponding value based on the evaluation value difference,

[0022] Or, it is determined that the reason why the generation of volumetric light is unqualified is that volumetric light cannot be simulated by the light source, and it is determined to add a virtual light source and reconfigure.

[0023] Furthermore, the contrast is adjusted based on a ratio of the evaluation value difference to a second preset evaluation value difference.

[0024] Furthermore, when it is determined to add a virtual light source and reconfigure, the distance between the virtual light source and the light source in the scene is corrected based on the evaluation value ratio of the diffusion evaluation value to the second preset diffusion evaluation value.

[0025] Furthermore, the calculation of the diffusion parameter includes:

[0026] color = tex2D(mainTex, uv);

[0027] mask=color.r*0.299+color.g*0.587+color.b*0.114;

[0028] Among them, tex2D is the graphics library sampling function, mainTex is the screenshot, uv is the current pixel coordinate, color is the sampled pixel color, mask is the mask value, color is converted to obtain the mask value mask, and stored in the diffusion mask map.

[0029] Compared with the prior art, the beneficial effect of the present invention is that the mask sticker in the present invention Figure 1 Generally, it refers to the use of this map in conjunction with the normal map to block the reflected light on the surface of the normal map, thereby achieving diffuse reflection of light on the rough surface. The normal map is a map set on the model plane, and the fineness of the model is indirectly improved by the expression of details in the map. The present invention calculates the volumetric light diffusion through multiple iterations, thereby improving the control accuracy of the volumetric light diffusion in the scene, calculates the diffusion evaluation value of the volumetric light based on the roughness of the picture and the volumetric light brightness, and further analyzes whether the generation of the volumetric light is qualified according to the diffusion evaluation value, thereby improving the generation efficiency of the volumetric light.

[0030] Furthermore, in the present invention, the movement of viewing angle may cause deviation in the generation of volumetric light. The present invention recalculates when the evaluation value difference is less than or equal to the first preset evaluation value difference, thereby improving the control accuracy of the volumetric light generation process.

[0031] Furthermore, in the present invention, increasing the contrast of the picture can enhance the visual sense of hierarchy and hierarchical relationship, and adjusting the contrast of the picture based on the difference in evaluation values ​​improves the efficiency of generating volumetric light. BRIEF DESCRIPTION OF THE DRAWINGS

[0032] Figure 1 A flow chart of a volume light generation method for a virtual environment;

[0033] Figure 2 It is a schematic diagram of volume light effect 1 of a virtual scene;

[0034] Figure 3 It is a schematic diagram of volume light effect 2 of a virtual scene;

[0035] Figure 4 Schematic diagram of the mask map for the dynamically created volumetric light effect;

[0036] Figure 4A Inverse image of a schematic diagram of a dynamically created volumetric light effect mask map;

[0037] Figure 5 This is a schematic diagram of the first stage of the volumetric light diffusion calculation process;

[0038] Figure 5A This is an inverted diagram of the first stage of the volumetric light diffusion calculation process;

[0039] Figure 6 This is a schematic diagram of the second stage of the volumetric light diffusion calculation process;

[0040] Fig. 6A This is an inverted diagram of the second stage of the volumetric light diffusion calculation process;

[0041] Figure 7 This is a schematic diagram of the halo calculation process;

[0042] Fig. 7A This is an inverted diagram of the halo calculation process. DETAILED DESCRIPTION

[0043] In order to make the objects and advantages of the present invention more clearly understood, the present invention is further described below in conjunction with embodiments; it should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.

[0044] It should be pointed out that the data in this embodiment are obtained by comprehensive analysis and evaluation of the historical data of the system of the present invention in the six months before this determination and the corresponding historical determination results. Before this detection, the system of the present invention comprehensively determines the values ​​of the preset parameter standards for this determination based on the evaluation values ​​of the 37,383 retrieval results detected cumulatively in the first three months. It can be understood by those skilled in the art that the system of the present invention can determine the single parameter mentioned above by selecting the value with the highest proportion as the preset standard parameter according to the data distribution, using weighted summation to use the obtained value as the preset standard parameter, substituting each historical data into a specific formula and using the value obtained by the formula as the preset standard parameter or other selection methods, as long as the system of the present invention can clearly define the different specific situations in the single determination process through the obtained values.

[0045] The preferred embodiments of the present invention are described below with reference to the accompanying drawings. It should be understood by those skilled in the art that these embodiments are only used to explain the technical principles of the present invention and are not intended to limit the protection scope of the present invention.

[0046] It should be noted that, in the description of the present invention, terms such as "up", "down", "left", "right", "inside" and "outside" indicating directions or positional relationships are based on the directions or positional relationships shown in the drawings. This is merely for the convenience of description and does not indicate or imply that the device or element must have a specific orientation, be constructed and operated in a specific orientation. Therefore, it cannot be understood as a limitation on the present invention.

[0047] In addition, it should be noted that in the description of the present invention, unless otherwise clearly specified and limited, the terms "installed", "connected", and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be indirectly connected through an intermediate medium, or it can be the internal communication of two components. For those skilled in the art, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.

[0048] See also Figure 1-Figure 7 As shown, Figure 1 A flow chart of a volumetric light generation method for a virtual environment. Figure 2 This is a schematic diagram of the volume light effect 1 of the virtual scene. Figure 3 This is a schematic diagram of the volumetric light effect 2 of the virtual scene. Figure 4 A schematic diagram of a dynamically created volumetric light effect mask map. Figure 5 This is a schematic diagram of the first stage of the volume light diffusion calculation process. Figure 6 This is a schematic diagram of the second stage of the volume light diffusion calculation process. Figure 7 Schematic diagram of the halo calculation process. Figure 2-7 All of them reflect the real effect of volumetric light in virtual scenes. For a clearer expression, Figure 4A Inverse image of a schematic diagram of a dynamically created volumetric light effect mask map;

[0049] Figure 5A This is an inverted diagram of the first stage of the volumetric light diffusion calculation process; Fig. 6A This is an inverted diagram of the second stage of the volumetric light diffusion calculation process; Fig. 7A This is an inverted diagram of the halo calculation process.

[0050] The present invention provides a volume light generation method applied to a virtual environment, comprising:

[0051] Step S1, draw a virtual scene, and when loading is completed, record the light sources in the scene that meet the requirements as object light sources based on priority, and obtain the position, illumination direction and light intensity of the object light sources;

[0052] Step S2, obtaining a screenshot of the current scene frame, and caching the screenshot of the current scene frame into a diffusion temporary map;

[0053] Step S3, generating a mask map based on the diffusion temporary map;

[0054] Step S4, calculating volume light diffusion parameters, and caching the calculation results into a temporary diffusion map;

[0055] Step S5, superimposing the temporary diffusion map and the screen frame screenshot, and transmitting the superimposed data to a frame buffer for final display;

[0056] Step S6, calculating the diffusion evaluation value based on the parameters in the superimposed screen image, and analyzing whether the generation of volume light is qualified based on the diffusion evaluation value, and analyzing the reason for the failure when it is determined that the generation of volume light is unqualified.

[0057] Specifically, the calculation process of the volume light diffusion parameters includes:

[0058] Step S41, obtaining information data of scene information and generating an initial light source map based on the obtained information data, the information data including the light source position, direction and camera orientation;

[0059] Step S42, perform volume light diffusion calculation, iterate the calculation multiple times and record the calculated temporary effect in the diffusion map.

[0060] The specific implementation steps of the volumetric light effect in the embodiment of the present invention are described as follows:

[0061] In the game, when the player character enters a virtual scene, it first determines whether the scene needs to display volumetric light effects. The basis for judgment is whether the current scene has a main physical light source unit, such as the sun, the moon, a bright light, etc. If so, one of them is selected as the volumetric light object unit according to the priority, and its corresponding attributes are used as the diffusion parameters of the volumetric light, such as position, direction, and light intensity.

[0062] When the player character moves in the scene, adjusts the perspective, etc., the selected volumetric light object unit will also be dynamically adjusted according to a certain priority algorithm. After the volumetric light object unit is selected, the disclosed technical solution will further determine whether it is necessary to perform subsequent volumetric light diffusion calculations. This judgment is related not only to the parameters of the lighting unit, but also to the camera perspective, etc. The specific calculation expressions are listed below:

[0063] screenPoint=curCamera.WorldToScreenPoint(lightPos);

[0064] screenPos=(screenPoint.x / curCamera.pixelWidth, screenPoint.y / curCamera.pixelHeight);

[0065] distanceX=1-(Math.Abs(screenPos.x)-0.2) / 0.2;

[0066] LDotV=Dot(curCamera.forward,lightDir);

[0067] The calculation result screenPos is the screen position of the light source in the screen space. When screenPos.y>1.5, the light source is judged to be too high and no volumetric light calculation is performed. distanceX is a calculation parameter to measure the light source in the horizontal direction. When distanceX<0 or distanceY>1, the light source is judged to be too deviated in the horizontal direction and no subsequent volumetric light calculation is performed. LDotV is the dot product result of the viewing angle direction and the light source unit direction. When LDotV<0, the player's line of sight is judged to be opposite to the lighting direction, that is, backlight, and no subsequent volumetric light calculation is performed.

[0068] After passing the test of whether to perform subsequent calculations, the preparation work for diffusion calculation is first carried out. The preparation work includes but is not limited to: first, creating maps used subsequently, including volumetric light mask maps, volumetric light diffusion temporary maps, volumetric light diffusion result maps, etc.; secondly, registering the volumetric light calculation module to the post-processing flow of the rendering pipeline; then, sampling the current scene drawing results into a temporary screenshot of the screen; finally, pre-calculating the parameters used in the diffusion calculation.

[0069] After the above preparations are completed, the volume light diffusion calculation stage begins. This stage uses the graphics chip's drawing API to generate an output target image based on the input parameters, images, and registered algorithm calculation process.

[0070] The first step of the diffusion calculation is to generate a diffusion mask map from the screenshot. The core conversion process is as follows:

[0071] color = tex2D(mainTex, uv);

[0072] mask=color.r*0.299+color.g*0.587+color.b*0.114;

[0073] Among them, tex2D is the graphics library sampling function, mainTex is the screenshot, uv is the current pixel coordinate, and color is the sampled pixel color. The above conversion is performed on color to obtain the mask value mask, which is stored in the diffusion mask map. After the diffusion mask map is obtained, the initial illumination map for diffusion is further generated and stored in the diffusion temporary map. The HLSL expression of its shader core calculation is as follows:

[0074] mixColor=color*(1-saturate(length(uv-lightScreenPos) / MathPI));

[0075] height=smoothstep(0.35,1,lightScreenPos.y);

[0076] height=height*min(lerp(-2,2,uv.y),height);

[0077] finalColor=lerp(0,Luminance(saturate(mixColor-colorThreshold)),(1+height)*0.5)*mask;

[0078] In the above expressions, color and mask have the same meanings as above, lightScreenPos is the uv position coordinate of the light source in the screen space, colorThreshold is the color threshold of the diffusion, and only when it is greater than colorThreshold, the finalColor value is greater than 0. From the above calculations, it can be found that the technical solution disclosed in the present invention limits the range of the initial diffusion source to a certain distance from the light source from a logical calculation point of view, and the height is also limited to a certain range after adjustment. Compared with not adjusting, the final effect is more in line with people's intuitive feelings.

[0079] The Luminance function in the above expression is the luminance adjustment of the color space. The specific calculation is as follows, where _ColorSpaceLuminance is the luminance of the current environment color space:

[0080]

[0081] After the initial light map calculation is completed, the disclosed solution will start the diffusion calculation iteration. This diffusion process is divided into two sub-stages. The iterative calculation of each sub-stage is repeated several times. The number of repetitions is related to the quality of the game image quality level selected by the current game player. The better the image quality level selected, the more repetitions.

[0082] The iterative calculation of the first stage is as follows:

[0083] stepDirection=curUv-lightScreenPos;

[0084] stepUv=stepDirection*spreadDistance / spreadSampleCount;

[0085]

[0086] spreadColor=spreadSumColor / spreadSampleCount*spreadFactor;

[0087] In the above expression, spreadSampleCount is the number of diffusion samples, spreadDistance is the diffusion distance control parameter factor, tempSpreadTex is the cached initial light map or the result of the previous iteration, and spreadFactor is the diffusion adjustment parameter factor. The core idea of ​​iterative calculation is to first calculate the sampling step stepUv from the current pixel point toward the uv coordinate direction of the light source, and then sum the samples according to the step stepUv, superimpose the color value of the previous result on the step direction path, and make corrections to obtain the diffusion color value of the current pixel position. When the spreadFactor value is greater than 1, the total brightness value after one iterative calculation will be increased, and the result of the iteration will also make the brightness value spread from the light source position to the surrounding areas, which effectively achieves the effect of diffusion and overall enhancement. After the first stage of diffusion iteration is completed, the second stage of iterative calculation begins. The algorithm of the second stage is adjusted from the first stage. The main modification is to add correction parameters to the summation formula, as follows:

[0088]

[0089] fadeFactor=max(0.125,2-stepIndex*0.25);

[0090] The disclosed solution adds fadeFactor as a correction parameter at this stage. The fadeFactor is negatively correlated with stepIndex in calculation. The larger the stepIndex, the smaller the fadeFactor. The addition of fadeFactor changes the linear accumulation property in the final diffusion calculation of this solution, and finally achieves the target effect of smooth attenuation of the diffusion intensity, that is, the brightness of the diffused light, in the process of diffusion from the light source to the end edge.

[0091] After the final diffusion map is generated, the final synthesis stage begins. The final synthesis algorithm of the disclosed solution is implemented by targeted optimization design.

[0092] The synthesis algorithm of this solution includes a special treatment for the gradual attenuation of the illumination color. This gradual treatment makes the volumetric light effect simulate the attenuation and hue change caused by refraction, reflection and other reasons when light propagates in the medium in the real Tyndall phenomenon, and reflects the human eye's visual perception of the changes from the incandescent center of the real light source to the orange-yellow diffuse edge, which can better meet the needs of art to express the artistic conception of the evening glow. The core calculation logic formula of the gradient correction color of specific pixels in this public solution is as follows:

[0093] atten=saturate(smoothstep(minAtten,1,lightScreenPos.y));

[0094] finalAtten=saturate(lerp(smoothstep(0.35,attenFactor,lightScreenPos.y),atten,atten));

[0095] lightFixColor=lerp(lightColorBottom,lightColorTop,atten)*finalAtten;

[0096] In the above expression, lightColorTop is the lighting color parameter at the beginning of diffusion, lightColorBottom is the lighting color parameter at the end of diffusion gradient, and minAtten is the attenuation lower limit control parameter. The disclosed solution calculates two attenuation values, atten and finalAtten, according to the screen position height of the light source, and finally interpolates to obtain the corrected lightFixColor. The obtained lightFixColor value gradually changes from lightColorTop to lightColorBottom according to a certain curvature, while continuously attenuating and decreasing to achieve the target effect.

[0097] Before the final synthesis stage, the disclosed solution first generates a halo effect and stores it in a halo effect map. The halo effect algorithm is as follows: after obtaining the direction of the light source, configure the percentage position of different apertures on the direction line and the aperture style map, and finally convert the percentage position into UV coordinates in the rendering pipeline, and sample the corresponding style map to superimpose the final light source effect map. The core formula is as follows:

[0098]

[0099] circleTex is the halo style map, circleUvPos is the pre-calculated screen uv coordinate of the halo center, and the sampling and summing result is the final light source effect color. After the flareColor calculation is completed, the diffusion effect synthesis stage is entered. The synthesis stage of this solution is set after the screen post-effect Bloom and before Color Grading to ensure that this solution is not affected by the Bloom effect, and participate in the overall color adjustment to keep the final effect coordinated. The core synthesis formula is as follows:

[0100] shaftStrength=dot(spreadColor.rgb,(0.222,0.707,0.71));

[0101] finalLightColor=lightFixColor*shaftStrength*(1-mask)*attenParam;

[0102] finalColor=originColor+finalLightColor+flareColor;

[0103] spreadColor is the diffusion color value recorded in the final diffusion map, lightFixColor is the above attenuation gradient correction value, flareColor is the halo effect color, mask is the diffusion mask map sampling value, attenParam is the custom attenuation control variable, and originColor is the original color value of the screenshot. The above calculation converts the diffusion result into a diffusion grayscale value, and the grayscale value is used as the intensity and color correction value. The mask is multiplied into the final diffusion color, and added to the screen color to complete the entire synthesis process.

[0104] Specifically, the diffusion evaluation value is calculated based on formula (1), where:

[0105]

[0106] In formula (1), S is the diffusion evaluation value, Fi is the actual roughness of the i-th surface obtained after simulation, Fi0 is the expected roughness for the i-th surface, Li is the actual volume brightness for the i-th surface, Li0 is the expected volume brightness for the i-th surface, Ri is the actual volume light diffusion radius for the i-th surface, Ri0 is the expected volume light diffusion radius for the i-th surface, α is the first weight coefficient, and β is the second weight coefficient.

[0107] In the embodiment of the present invention, the expected roughness Fi0 of the i-th surface is obtained by pre-measurement, and the roughness of several surfaces is calculated, and Fi0 is the average value of the calculated roughness of the several surfaces.

[0108] In the embodiment of the present invention, the expected volume light diffusion radius Ri0 of the i-th surface is obtained by pre-measurement, and the volume light diffusion radii of several surfaces are calculated. Ri0 is the average of the calculated volume light diffusion radii of several surfaces. The first weight coefficient α is 0.35, and the second weight coefficient β is 0.65.

[0109] The masking sticker of the present invention Figure 1 Generally, it refers to the use of this map in conjunction with the normal map to block the reflected light on the surface of the normal map, thereby achieving diffuse reflection of light on the rough surface. The normal map is a map set on the model plane, and the fineness of the model is indirectly improved by the expression of details in the map. The present invention calculates the volumetric light diffusion through multiple iterations, thereby improving the control accuracy of the volumetric light diffusion in the scene, calculates the diffusion evaluation value of the volumetric light based on the roughness of the picture and the volumetric light brightness, and further analyzes whether the generation of the volumetric light is qualified according to the diffusion evaluation value, thereby improving the generation efficiency of the volumetric light.

[0110] Specifically, a preliminary determination method for whether the generation of volumetric light is qualified is determined based on the diffusion evaluation value, wherein:

[0111] The first preliminary determination method is to determine that the generation of volumetric light is unqualified, and determine a processing method based on the diffusion evaluation value; the first preliminary determination method satisfies that the diffusion evaluation value is greater than or equal to a first preset diffusion evaluation value;

[0112] The second preliminary determination method is to determine that the generation of volumetric light is qualified; the second preliminary determination method satisfies that the diffusion evaluation value is less than the first preset diffusion evaluation value and is greater than or equal to the second preset diffusion evaluation value;

[0113] The third preliminary determination method is to determine that the generation of volumetric light is unqualified, and to determine to add a virtual light source and reconfigure; the third preliminary determination method satisfies that the diffusion evaluation value is less than the second preset diffusion evaluation value.

[0114] In the embodiment of the present invention, the first preset diffusion evaluation value is 2.3, and the second preset diffusion evaluation value is 1.5.

[0115] Specifically, in the first preliminary determination method, a processing method for unqualified generation of volume light is determined based on the evaluation value difference between the diffusion evaluation value and the first preset diffusion evaluation value, wherein:

[0116] The first processing method is to determine that the reason why the volume light generation is unqualified is that the volume light generation is deviated due to the movement of the viewing angle, and recalculate; the first processing method satisfies that the evaluation value difference is less than or equal to the first preset evaluation value difference;

[0117] The second processing method is to determine to adjust the contrast to a corresponding value based on the evaluation value difference; the second processing method satisfies that the evaluation value difference is greater than the first preset evaluation value difference and less than or equal to the second preset evaluation value difference;

[0118] The third processing method is to determine that the reason for the unqualified generation of volumetric light is that the volumetric light cannot be simulated by the light source, and to determine to add a virtual light source and reconfigure; the third processing method satisfies that the evaluation value difference is greater than the second preset evaluation value difference.

[0119] In the embodiment of the present invention, the first preset evaluation value difference is 0.25, and the second preset evaluation value difference is 0.35.

[0120] In the present invention, the movement of viewing angle may lead to deviation in the generation of volumetric light. The present invention recalculates when the evaluation value difference is less than or equal to the first preset evaluation value difference, thereby improving the control accuracy of the volumetric light generation process.

[0121] Specifically, in the second processing mode, the adjustment mode for contrast is determined based on the ratio of the evaluation value difference to the second preset evaluation value difference, wherein:

[0122] The first adjustment method is to select the first adjustment coefficient α1 to adjust the contrast D to a corresponding value, and set the adjusted contrast D'=α1×D0, where D0 is the initial contrast; the first adjustment method satisfies that the ratio is less than or equal to the preset ratio;

[0123] The second adjustment method is to select the second adjustment coefficient α2 to adjust the contrast D to a corresponding value, and set the adjusted contrast D'=α2×D0; the second adjustment method satisfies that the ratio is greater than the preset ratio.

[0124] In the embodiment of the present invention, the first adjustment coefficient is 1.2, the second adjustment coefficient is 1.3, and the preset ratio is 0.85.

[0125] In the present invention, increasing the contrast of the picture can enhance the visual sense of hierarchy and hierarchical relationship, and adjusting the contrast of the picture based on the difference of the evaluation value improves the generation efficiency of volumetric light.

[0126] Specifically, under the first preset condition, a correction method for the distance between the virtual light source and the light source in the scene is determined based on the evaluation value ratio of the diffusion evaluation value to the second preset diffusion evaluation value, wherein:

[0127] The first correction method is to select the first correction coefficient β1 to correct the distance Z to the corresponding value, and set the corrected distance Z'=β1×Z0, where Z0 is the initial distance before correction; the first correction method satisfies that the evaluation value ratio is less than or equal to the preset evaluation value ratio;

[0128] The second correction method is to select a second correction coefficient β2 to correct the distance Z to a corresponding value, and set the corrected distance Z'=β2×Z0; the second correction method satisfies that the evaluation value ratio is greater than the preset evaluation value ratio.

[0129] The first preset condition is to determine whether to add a virtual light source and reconfigure.

[0130] In the embodiment of the present invention, the first correction coefficient is 0.95, the second correction coefficient is 0.8, and the preset evaluation value ratio is 0.75.

[0131] Specifically, the calculation of the diffusion parameter includes:

[0132] color = tex2D(mainTex, uv);

[0133] mask=color.r*0.299+color.g*0.587+color.b*0.114;

[0134] Among them, tex2D is the graphics library sampling function, mainTex is the screenshot, uv is the current pixel coordinate, col or is the sampled pixel color, mask is the mask value. The above conversion is performed on col or to obtain the mask value mask, which is stored in the diffusion mask map.

[0135] So far, the technical solutions of the present invention have been described in conjunction with the preferred embodiments shown in the accompanying drawings. However, it is easy for those skilled in the art to understand that the protection scope of the present invention is obviously not limited to these specific embodiments. Without departing from the principle of the present invention, those skilled in the art can make equivalent changes or substitutions to the relevant technical features, and the technical solutions after these changes or substitutions will fall within the protection scope of the present invention.

[0136] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A volumetric light generation method for a virtual environment, It is characterized in that include: Step S1, draw a virtual scene, and when loading is completed, record the light sources in the scene that meet the requirements as object light sources based on priority, and obtain the position, illumination direction and light intensity of the object light sources; Step S2, obtaining a screenshot of the current scene frame, and caching the screenshot of the current scene frame into a diffusion temporary map; Step S3, generating a mask map based on the diffusion temporary map; Step S4, calculating volume light diffusion parameters, and caching the calculation results into a temporary diffusion map; Step S5, superimposing the temporary diffusion map and the screen frame screenshot, and transmitting the superimposed data to a frame buffer for final display; Step S6, calculating the diffusion evaluation value based on the parameters in the superimposed screen image, and analyzing whether the generation of volume light is qualified based on the diffusion evaluation value, and analyzing the reason for the failure when it is determined that the generation of volume light is unqualified.

2. The volume light generation method for a virtual environment according to claim 1, It is characterized in that The calculation process of the volume light diffusion parameters includes: Step S41, obtaining information data of scene information and generating an initial light source map based on the obtained information data, the information data including the light source position, direction and camera orientation; Step S42, perform volume light diffusion calculation, iterate the calculation multiple times and record the calculated temporary effect in the diffusion map.

3. The volume light generation method for a virtual environment according to claim 2, It is characterized in that The diffusion evaluation value is calculated based on formula (1), where: In formula (1), S is the diffusion evaluation value, Fi is the actual roughness of the i-th surface obtained after simulation, Fi0 is the expected roughness for the i-th surface, Li is the actual volume brightness for the i-th surface, Li0 is the expected volume brightness for the i-th surface, Ri is the actual volume light diffusion radius for the i-th surface, Ri0 is the expected volume light diffusion radius for the i-th surface, α is the first weight coefficient, and β is the second weight coefficient.

4. The volume light generation method for a virtual environment according to claim 3, It is characterized in that Whether the generation of volumetric light is qualified is determined based on the diffusion evaluation value. When the generation of volumetric light is determined to be unqualified, a processing method is determined based on the diffusion evaluation value, or it is determined to add a virtual light source and reconfigure.

5. The volume light generation method for a virtual environment according to claim 4, It is characterized in that Based on the difference between the diffusion evaluation value and the first preset diffusion evaluation value, it is determined that the reason why the generation of volume light is unqualified is that the generation of volume light is deviated due to the movement of the viewing angle, and the calculation is recalculated. or, adjusting the contrast to a corresponding value based on the evaluation value difference, Or, it is determined that the reason why the generation of volumetric light is unqualified is that volumetric light cannot be simulated by the light source, and it is determined to add a virtual light source and reconfigure.

6. The volume light generation method for a virtual environment according to claim 5, It is characterized in that The contrast is adjusted based on a ratio of the evaluation value difference to a second preset evaluation value difference.

7. The volume light generation method for a virtual environment according to claim 6, It is characterized in that When it is determined that a virtual light source is added and reconfigured, the distance between the virtual light source and the light source in the scene is corrected based on the evaluation value ratio of the diffusion evaluation value to the second preset diffusion evaluation value.

8. The volume light generation method for a virtual environment according to claim 7, It is characterized in that The calculation of the diffusion parameters includes: color = tex2D(mainTex, uv); mask=color.r*0.299+color.g*0.587+color.b*0.114; Among them, tex2D is the graphics library sampling function, mainTex is the screenshot, uv is the current pixel coordinate, color is the sampled pixel color, mask is the mask value, color is converted to obtain the mask value mask, and stored in the diffusion mask map.