A rendering method and device for a game scene
The cloud and water surface images are processed through the parietal Brownian motion algorithm, which solves the problem of unnatural cloud fluttering and discontinuous water surface flow, and realizes dynamic clouds and delicate water flow in natural effects, improving the visual experience of the game scene.
Patent Information
- Application Number
- CN202210176738.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-02-24
- Publication Date
- 2025-07-04
- Estimated Expiration
- 2042-02-24
AI Technical Summary
In existing game scenes, cloud rendering uses fixed map scrolling to play, resulting in unnatural clouds floating, and the water surface flow effect is discontinuous and not delicate, which cannot truly simulate the natural clouds floating and water flow.
The shaped Brownian motion algorithm is used to layer and superimpose cloud images and control the morphology, process the water surface images for fluctuation effects, and combine the water bottom image superposition to realize dynamic cloud shape and delicate water flow.
It makes the clouds flutter more natural, the water flow effect is continuous and delicate, which is more in line with the effect of nature, and improves the visual authenticity of the game scene.
Smart Images

Figure CN114529650B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image rendering, and more specifically, to a method and device for rendering a game scene. Background Art
[0002] With the progress of game technology, the production scale of game scenes is getting larger and the number of objects is increasing. In order to bring a good visual experience to users, currently, in the game image rendering solution, there is a pursuit of highly restoring natural landscapes. Therefore, in water body rendering, it is required that the water flow effect has a more realistic look and feel, and in cloud rendering, it is required to reflect that the cloud shape can achieve a random change in the floating effect.
[0003] However, in the existing game scenes, the water surface flow waveform is relatively patterned, and it is easy to see that the water surface fluctuates regularly in a certain direction. And cloud rendering generally adopts the form of fixed texture scrolling playback. Therefore, the clouds present the effect of one or several pictures translating regularly, and do not have the effect of natural cloud floating. Summary of the Invention
[0004] In view of this, the present invention discloses a method and device for rendering a game scene, so that the floating of clouds is more natural, the water flow effect is continuous and delicate, and it is more in line with the water flow effect in nature.
[0005] A method for rendering a game scene includes:
[0006] Obtaining an original game scene to be rendered;
[0007] Obtaining a sky model in the original game scene;
[0008] Rendering the sky model using sky material parameters and adopting a preset sky rendering scheme to obtain a sky scene rendering image, wherein the preset sky rendering scheme is: using the fractional Brownian motion algorithm to perform hierarchical superposition on the cloud image and using the morphology control algorithm to process it to obtain a dynamic cloud shape effect;
[0009] Obtaining a water body model in the original game scene;
[0010] Rendering a water body image on the basis of the sky scene rendering image by using water body material parameters and adopting a preset water body rendering scheme for the water body model to obtain a game scene rendering image, wherein the preset water body rendering scheme is: using the fractional Brownian motion algorithm to process the water surface image and superimposing the processed water surface image with the bottom water image after the fluctuation effect is processed.
[0011] Optionally, rendering the sky model using sky material parameters and a preset sky rendering scheme to obtain a sky scene rendering image includes:
[0012] Sampling the sky main texture map in the sky material parameters to obtain sky color image data;
[0013] Performing perspective calculation on the spatial information parameters in the sky material parameters and converting the original cloud-related texture coordinates to obtain cloud-related texture coordinates with a perspective effect;
[0014] Applying the cloud-related texture coordinates to sample the normal map and height map, and performing a fractional Brownian motion algorithm calculation on the normal sequence and height sequence sampled using the texture coordinates to obtain target cloud normal value data with a fluttering effect and corresponding target height value data;
[0015] Interpolating the cloud color between the top color and bottom color of the cloud for the target height value data, and using a cloud shape control algorithm to obtain cloud image data after shape control;
[0016] Performing scattering illumination calculation and Lambert illumination calculation on the overall sky image for the target cloud normal value data to obtain sky illumination image data;
[0017] Overlaying the sky color image data, the cloud image data, and the sky illumination image data to obtain the sky scene rendering image after rendering both the sky and the clouds.
[0018] Optionally, the original cloud-related texture coordinates include: texture coordinates of the cloud height map and texture coordinates of the cloud normal map.
[0019] Optionally, the rendering of the cloud mainly includes: cloud perspective correction, cloud height color, cloud movement, and cloud illumination.
[0020] Optionally, the processing process of the cloud perspective correction includes:
[0021] Calculating the direction of the rendering line of sight through the pose of the virtual camera;
[0022] Corresponding and correcting the normalized texture map coordinates of the cloud texture map by the geometric similarity relationship using the coordinate value in the vertical direction of the world coordinate position of the point on the sky plane and the sky overall height parameter and the line of sight direction data, thereby completing the processing of the cloud perspective correction, where the sky plane is a vertically placed plane.
[0023] Optionally, the processing process of the cloud movement includes:
[0024] After applying the perspective-corrected texture coordinates, the sampling results of the cloud normal map and the sampling results of the cloud height map are superimposed fractally according to the geometric ratio parameter by using the fractional Brownian motion algorithm to obtain a normal sampling sequence and a height sequence;
[0025] Accumulate the normal sampling sequence, and divide the accumulated value by the sum of the geometric sequence to obtain the mean value to determine the normal sampling result value;
[0026] Accumulate the height sequence, and divide the accumulated value by the sum of the geometric sequence to obtain the mean value, which is determined as the height value of the cloud. Then, continue to calculate the sparsity and softness of the cloud through the cloud shape control algorithm for the height value of the cloud, and obtain the height value after shape calculation to complete the processing of the cloud movement.
[0027] Optionally, the processing process of the cloud lighting includes:
[0028] Divide the effect of the cloud lighting into scattered light and partial specular highlights;
[0029] The calculation formula of the scattered light is as follows:
[0030] col = LightColor * pow(1 - disUV2LightPos, LightAttentionPow) * Height;
[0031] In the formula, col is the result value of the scattered light, LightColor is the light color parameter, pow is the power function, disUV2LightPos is the Euclidean distance from the normalized texture map coordinates to the light position parameter, LightAttentionPow is the scattered light power exponent parameter, and Height is the height value obtained by using the fractional Brownian motion algorithm;
[0032] Use the standard Lambert lighting model to determine the partial specular highlights.
[0033] Optionally, the processing process of the cloud height color includes:
[0034] Perform linear interpolation on the top color and the bottom color in the cloud height color by using the target height value, and multiply the interpolation result by the height value to complete the processing of the cloud height color.
[0035] Optionally, for the water body material parameters of the water body model, use a preset water body rendering scheme to continue rendering the water body image on the basis of the sky scene rendered image to obtain the game scene rendered image, including:
[0036] Obtain the relevant data of the water bottom, and perform sampling rendering on the relevant data of the water bottom to obtain a rendered image of the water bottom with fluctuations;
[0037] Obtain data related to the foreground and background objects, and sample and render the data related to the foreground and background objects to obtain a foreground and background object rendered image;
[0038] Obtain data related to the reflection, and perform coordinate transformation and texture sampling on the data related to the reflection to obtain a reflection rendered image;
[0039] Overlay the underwater rendered image, the foreground and background object rendered image, and the reflection rendered image to obtain a first water body rendered image;
[0040] Obtain data related to the water surface, and use the fractional Brownian motion algorithm on the data related to the water surface to obtain water surface related texture coordinate data with fluctuation information, where the data related to the water surface includes: normal map texture coordinates;
[0041] Based on the water surface foreground and background color changes and the water surface related texture coordinate data, obtain a second water body rendered image including foreground and background colors and fluctuations;
[0042] Obtain the spatial information of the virtual camera, and based on the spatial information and the water surface related texture coordinate data, perform lighting processing on the basis of the second water body rendered image to obtain a third water body rendered image including fluctuations, lighting, and foreground and background color changes;
[0043] Perform spatial occlusion relationship processing on the first water body rendered image and the third water body rendered image, and perform transparent blending calculation to obtain the game scene rendered image.
[0044] Optionally, the process of sampling and rendering the underwater related data includes:
[0045] The calculation formula of the underwater texture map is as follows:
[0046] UvWarp = UV0 * scale + Time * TimeParam;
[0047] In the formula, UvWarp is the underwater texture map value, UV0 is the original water body texture map value, scale is the scaling coefficient, Time is the current time, and TimeParam is the time coefficient.
[0048] Optionally, the process of reflection rendering includes:
[0049] Mirror the original material picture vertically, and perform stretching processing, transparent gradient, and Gaussian blur processing on the lower half of the material picture.
[0050] A rendering device for a game scene, including:
[0051] A game scene acquisition unit for acquiring an original game scene to be rendered;
[0052] A sky model acquisition unit for acquiring the sky model in the original game scene;
[0053] A sky rendering unit for rendering the sky model with sky material parameters and using a preset sky rendering scheme to obtain a sky scene rendering image, wherein the preset sky rendering scheme is: using the fractional Brownian motion algorithm to perform hierarchical superposition on the cloud image and using the morphology control algorithm for processing to obtain a dynamic cloud morphology effect;
[0054] A water body model acquisition unit for acquiring the water body model in the original game scene;
[0055] A water body rendering unit for using water body material parameters for the water body model and adopting a preset water body rendering scheme to continue rendering the water body image on the basis of the sky scene rendering image to obtain a game scene rendering image, wherein the preset water body rendering scheme is: using the fractional Brownian motion algorithm to process the water surface image and superimposing the processed water surface image with the water bottom image after wave effect processing.
[0056] As can be seen from the above technical solutions, the present invention discloses a method and device for rendering a game scene, acquiring an original game scene to be rendered, using sky material parameters for the sky model in the original game scene and adopting a preset sky rendering scheme to render, obtaining a sky scene rendering image, the preset sky rendering scheme being using the fractional Brownian motion algorithm to perform hierarchical superposition on the cloud image and using the morphology control algorithm for processing to obtain a dynamic cloud morphology effect, using water body material parameters for the water body model in the original game scene and adopting a preset water body rendering scheme to continue rendering the water body image on the basis of the sky scene rendering image to obtain a game scene rendering image, the preset water body rendering scheme being using the fractional Brownian motion algorithm to process the water surface image and superimposing the processed water surface image with the water bottom image after wave effect processing. The present invention uses the fractional Brownian motion algorithm to perform hierarchical superposition on the cloud image to obtain a dynamic cloud morphology effect, making the floating of the clouds more natural; using the fractional Brownian motion algorithm to process the water surface image and superimposing the processed water surface image with the water bottom image after wave effect processing, making the water body flow effect continuous and delicate, more in line with the water body flow effect in nature. Description of the Drawings
[0057] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the accompanying drawings required in the description of the embodiments or the prior art. Obviously, the accompanying drawings in the following description are only the embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other accompanying drawings can also be obtained based on the disclosed accompanying drawings.
[0058] Figure 1 Flowchart of a method for rendering a game scene disclosed in an embodiment of the present invention;
[0059] Figure 2 Flowchart of a method for rendering a sky model in a game scene disclosed in an embodiment of the present invention;
[0060] Figure 3 Flowchart of a method for rendering a water body model in a game scene disclosed in an embodiment of the present invention;
[0061] Figure 4 Structural schematic diagram of a rendering device for a game scene disclosed in an embodiment of the present invention. Detailed implementation manners
[0062] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a 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 those of ordinary skill in the art without creative efforts belong to the scope of protection of the present invention.
[0063] An embodiment of the present invention discloses a method and device for rendering a game scene. The original game scene to be rendered is obtained, and the sky model in the original game scene is rendered using sky material parameters and a preset sky rendering scheme to obtain a sky scene rendering image. The preset sky rendering scheme is to use the fractional Brownian motion algorithm to perform layered superposition on the cloud image and use the morphological control algorithm for processing to obtain a dynamic cloud morphological effect. The water body model in the original game scene is rendered using water body material parameters and a preset water body rendering scheme, and on the basis of the sky scene rendering image, the water body image is continuously rendered to obtain a game scene rendering image. The preset water body rendering scheme is to use the fractional Brownian motion algorithm to process the water surface image and superimpose the processed water surface image with the bottom water image after wave effect processing. The present invention uses the fractional Brownian motion algorithm to perform layered superposition on the cloud image to obtain a dynamic cloud morphological effect, making the floating of the clouds more natural; using the fractional Brownian motion algorithm to process the water surface image and superimposing the processed water surface image with the bottom water image after wave effect processing, making the water body flow effect continuous and delicate, and more in line with the water body flow effect in nature.
[0064] See Figure 1 , the flowchart of a rendering method for a game scene disclosed in an embodiment of the present invention, the method includes:
[0065] Step S101, obtain the original game scene to be rendered;
[0066] In practical applications, the original game scene to be rendered can be obtained from the built game scene.
[0067] Among them, the process of building the game scene is as follows:
[0068] Create an empty three-dimensional original game scene;
[0069] In the three-dimensional game scene, place the underwater model, foreground and background item models, sky model, water surface model, etc. correctly according to the spatial relationship, and assign correct material parameters (i.e., rendering code, various texture maps) to each model to create the game scene.
[0070] In practical applications, according to the correct position and orientation of the virtual camera, determine the rendering view range, that is, the original game scene to be rendered.
[0071] Step S102, obtain the sky model in the original game scene;
[0072] Step S103, use the sky material parameters for the sky model and perform rendering using a preset sky rendering scheme to obtain a sky scene rendering image;
[0073] The preset sky rendering scheme is: use the fractional Brownian motion algorithm to perform layered superposition on the cloud image and process it using the shape control algorithm to obtain a dynamic cloud shape effect.
[0074] Among them, the cloud image includes: cloud normal map and cloud height map.
[0075] The sky material parameters include but are not limited to: texture maps, lighting-related parameters, colors, FBM (Fractal Brownian Motion) algorithm parameters, and perspective-related parameters.
[0076] Texture maps: cloud height map, cloud normal map.
[0077] Lighting-related parameters: light color, light position coordinates, light attenuation parameters, and light direction.
[0078] Colors: sky color, cloud top color, and cloud bottom color.
[0079] FBM algorithm parameters: FBM scaling parameter, FBM time (i.e., speed) parameter, and FBM frequency parameter.
[0080] Perspective-related parameters: sky height and horizon position parameters.
[0081] The basic idea of the Fractal Brownian Motion (FBM) algorithm is to mix multiple noises with different frequencies according to different amplitudes.
[0082] In this embodiment, the FBM algorithm is used to layer and stack the normal map and height map of the cloud. It is equivalent to using the cloud-related maps to programmatically stack the fractal noise to obtain a dynamic cloud floating effect, thus well solving the problem that the cloud map in the traditional solution drifts in a fixed direction over time to achieve the floating effect.
[0083] Step S104: Obtain the water body model in the original game scene;
[0084] Step S105: Use the water body material parameters for the water body model and adopt a preset water body rendering scheme to continue rendering the water body image on the basis of the sky scene rendering image to obtain the game scene rendering image.
[0085] In practical applications, the rendered game scene rendering image is output to the screen for users to use.
[0086] Among them, the preset water body rendering scheme is: using the FBM algorithm to process the water surface image and superimposing the processed water surface image with the water bottom image after the wave effect processing.
[0087] The water surface image in this embodiment includes: the water surface normal image.
[0088] In practical applications, when rendering the water body, the water bottom image, the foreground and background object images, the reflection image, and the water surface image can be rendered in sequence.
[0089] Among them, the water body material parameters include but are not limited to: texture maps, lighting-related parameters, colors, and FBM algorithm parameters.
[0090] Texture maps: the main water bottom texture map, the water bottom normal texture map, and the water surface normal texture map, etc.
[0091] Lighting-related parameters: light color, light position coordinates, specular range parameters, specular intensity parameters, and lighting direction.
[0092] Colors: the water far view color, the water near view color, and the cloud bottom color.
[0093] FBM algorithm parameters: FBM scaling parameter, FBM time (i.e., speed) parameter, and FBM frequency parameter.
[0094] In summary, the present invention discloses a method for rendering a game scene. The original game scene to be rendered is obtained, and the sky model in the original game scene is rendered using sky material parameters and a preset sky rendering scheme to obtain a sky scene rendering image. The preset sky rendering scheme is to use the fractional Brownian motion algorithm to layer and stack cloud images and use a shape control algorithm to process them to obtain a dynamic cloud shape effect. The water body model in the original game scene is rendered using water body material parameters and a preset water body rendering scheme. Based on the sky scene rendering image, the water body image is continuously rendered to obtain a game scene rendering image. The preset water body rendering scheme is to use the fractional Brownian motion algorithm to process the water surface image and stack the processed water surface image with the bottom image after wave effect processing. The present invention uses the fractional Brownian motion algorithm to layer and stack cloud images to obtain a dynamic cloud shape effect, making the floating of clouds more natural; uses the fractional Brownian motion algorithm to process the water surface image and stack the processed water surface image with the bottom image after wave effect processing, making the water body flow effect continuous and delicate, and more in line with the water body flow effect in nature.
[0095] To further optimize the above embodiment, refer to Figure 2 , the flowchart of a method for rendering the sky model in a game scene disclosed in an embodiment of the present invention, that is, step S103 may specifically include:
[0096] Step S201: Sample the sky main texture map in the sky material parameters to obtain sky color image data;
[0097] Step S202: Perform perspective calculation on the spatial information parameters in the sky material parameters and convert the original cloud-related texture coordinates to obtain cloud-related texture coordinates with a perspective effect;
[0098] Among them, the original cloud-related texture coordinates include: the texture coordinates of the cloud height map and the texture coordinates of the cloud normal map.
[0099] Step S203: Apply the cloud-related texture coordinates to sample the normal map and height map, and perform fractional Brownian motion algorithm calculation on the normal sequence and height sequence sampled using the texture coordinates to obtain target cloud normal value data with a floating effect and corresponding target height value data;
[0100] Step S204: Interpolate the target height value data between the cloud top color and the cloud bottom color to obtain the cloud color, and use the cloud shape control algorithm to obtain the cloud image data after shape control;
[0101] Step S205: Perform diffuse lighting calculation and Lambert lighting calculation on the overall sky image for the target cloud normal value data to obtain sky lighting image data;
[0102] Specifically, based on data such as normal maps, height information, and lighting parameters, perform diffuse lighting calculation and Lambert lighting calculation on the overall sky image to obtain sky lighting image data.
[0103] Step S206: Overlay the sky color image data, the cloud image data, and the sky lighting image data to obtain the sky scene rendering image after rendering both the sky and the clouds.
[0104] The rendering of clouds in the present invention mainly includes: cloud perspective correction, cloud height color, cloud movement, and cloud lighting.
[0105] To facilitate understanding of the cloud rendering process, the following details the four processing parts of cloud perspective correction, cloud movement, cloud lighting, and cloud height color as follows:
[0106] (1) The processing process of cloud perspective correction includes:
[0107] Calculate the direction of the rendering line of sight through the pose of the virtual camera;
[0108] Correspondingly correct the texture map coordinates of the cloud texture map after normalization by using the overall sky height parameter and the line of sight direction data for the coordinate value in the vertical direction of the world coordinate position of the point on the sky plane, and complete the processing of the cloud perspective correction.
[0109] In practical applications, the sky is designed as a vertically placed plane, and the clouds are rendered within this plane. Therefore, the coordinate value of the world coordinate position of the point on the sky plane in the height direction represents its height value, and this height value is then obtained as the target height value H0 within the viewport through the pose of the virtual camera and the camera rotation matrix. Since points located higher in height should be rendered closer to the observation position, based on the target height value, through geometric similarity, the UV (normalized texture map coordinates) coordinates during cloud map sampling can be corrected with corresponding coefficients.
[0110] The present invention fully restores the 3D effect through perspective correction, and on this basis, performs lighting calculation to enable a more reasonable three-dimensional sense for the planar cloud texture map.
[0111] (2) The processing process of cloud movement includes:
[0112] Apply the texture coordinates after perspective correction, and use the fractional Brownian motion algorithm to perform fractional superposition on the sampling results of the cloud normal map and the sampling results of the cloud height map according to the geometric ratio parameter to obtain the normal sampling sequence and the height sequence;
[0113] Accumulate the normal sampling sequence, and divide the accumulated value by the sum of the geometric sequence to obtain the mean value to determine the normal sampling result value;
[0114] Accumulate the height sequence, and divide the accumulated value by the mean value obtained from the sum of the geometric sequence to determine the height value of the cloud. Then, continue to calculate the sparsity and softness of the cloud through the cloud shape control algorithm for the height value of the cloud, and obtain the height value after shape calculation to complete the processing of the cloud movement.
[0115] Assume that the amplitude parameter is ScaleFbm, then the amplitude sequence is s[i] = ScaleFbm^i, and the calculation formula for the sum S of the geometric sequence is as follows:
[0116] S = ScaleFbm * (1 - ScaleFbm^n) / (1 - ScaleFbm);
[0117] In the formula, n is the number of superpositions.
[0118] Assume that the frequency parameter is FreqFbm, then the amplitude sequence is f[i] = FreqFbm^i.
[0119] Under the above parameters, the calculation formula for the UV coordinate sequence UvWarp[i] of the normal map is as follows:
[0120] UvWarp[i] = UV0 * f[i] + Time * TimeParam;
[0121] Among them, UvWarp is the sequence of UV values after calculation, UV0 is the original UV coordinate, Time is the current time, TimeParam is the time coefficient, i is the index value from 1 to n, and n is the number of superpositions.
[0122] The sampling sequence is: Sample(Tex_Normal, UvWarp[i]) * s[i], where Sample represents sampling and Tex_Normal represents the normal map.
[0123] In practical applications, the movement of the cloud also uses the FBM algorithm. However, different from water body rendering, in addition to performing fractional superposition on the sampling results of cloud normals, the FBM algorithm is also applied to the target height value.
[0124] The expression of the height sequence is as follows:
[0125] Height[i] = Sample(Tex_Height, UvWarp[i]) * s[i];
[0126] In the formula, Height[i] represents the height sequence, Sample represents sampling, Tex_Height represents the height texture map, and s[i] represents the amplitude sequence.
[0127] Accumulate the height sequence and divide it by the sum S of the geometric sequence, and the obtained mean value is determined as the height value Height of the cloud.
[0128] Finally, perform the calculation of the morphological control algorithm:
[0129] Height = (Height – Emptiness) / Smoothness;
[0130] Among them, Emptiness is the sparsity, and Smoothness is the softness.
[0131] (3) The processing process of cloud lighting includes:
[0132] Divide the effect of the cloud lighting into scattered light and partial specular highlights;
[0133] The calculation formula of the scattered light is as follows:
[0134] col = LightColor * pow(1 - disUV2LightPos, LightAttentionPow) * Height;
[0135] In the formula, col is the result value of the scattered light, LightColor is the light color parameter, pow is the power function, disUV2LightPos is the Euclidean distance from the normalized texture map coordinates to the light position parameter, LightAttentionPow is the scattered light power exponent parameter, and Height is the height value obtained by using the fractional Brownian motion algorithm;
[0136] Use the standard Lambert lighting model to determine the partial specular highlights.
[0137] (4) The processing process of cloud height color includes:
[0138] Perform linear interpolation on the top color and bottom color in the cloud height color using the target height value to complete the processing of the cloud height color.
[0139] To further optimize the above embodiments, see Figure 3, the flowchart of a method for rendering a water body model in a game scene disclosed in an embodiment of the present invention, that is, step S105 may specifically include:
[0140] Step S301, obtain underwater related data, and perform sampling rendering on the underwater related data to obtain a fluctuating underwater rendering image;
[0141] Among them, the underwater related data includes data such as an underwater model, an underwater main texture map, an underwater normal map, and rendering parameters.
[0142] Specifically, obtain underwater related data such as an underwater model, an underwater main texture map, an underwater normal map, and rendering parameters, transform the texture coordinates of the underwater normal map according to a time parameter, and perform sampling rendering according to the texture coordinates of the underwater main texture map and the underwater normal map to obtain a fluctuating underwater rendering image.
[0143] Step S302, obtain foreground and background object related data, and perform sampling rendering on the foreground and background object related data to obtain a foreground and background object rendering image;
[0144] Among them, the foreground and background object related data includes: a foreground and background object model, a foreground and background object main texture map, a foreground and background normal map, and rendering parameters, etc.
[0145] Step S303, obtain reflection related data, and perform coordinate transformation and texture sampling on the reflection related data to obtain a reflection rendering image;
[0146] Among them, the reflection related data includes: models and texture maps corresponding to foreground and background items, sky, clouds, etc. that require reflections, rendering parameters, and other data.
[0147] Step S304, superimpose the underwater rendering image, the foreground and background object rendering image, and the reflection rendering image to obtain a first water body rendering image;
[0148] By superimposing the underwater rendering image, the foreground and background object rendering image, and the reflection rendering image, a water body rendering image with an underwater part, foreground and background objects, and a reflection can be obtained, that is, a first water body rendering image.
[0149] Step S305, obtain water surface related data, and use a fractional Brownian motion algorithm for the water surface related data to obtain water surface related texture coordinate data with fluctuation information;
[0150] Among them, the water surface related data includes: normal map texture coordinates.
[0151] The water surface related data includes: data such as a water surface model, a water surface normal map, and water surface rendering parameters.
[0152] Step S306: Based on the color changes of the water surface at different distances and the water surface-related texture coordinate data, obtain a second water body rendering image that includes colors at different distances and fluctuations.
[0153] Specifically, obtain the model position and rotation information of the water surface, the position and rotation information of the virtual camera, the far and near color parameters of the water surface, calculate the perspective relationship of the vertices on the water surface from the camera, interpolate the far and near colors according to the distance relationship to obtain the water surface color data as the texture map data of the water surface, and then sample and render the water surface according to the water surface-related texture coordinate data obtained in step S305 to obtain a second water body rendering image with colors at different distances and fluctuations.
[0154] Step S307: Obtain the spatial information of the virtual camera, and based on the spatial information and the water surface-related texture coordinate data, perform lighting processing on the basis of the second water body rendering image to obtain a third water body rendering image that includes fluctuations, lighting, and color changes at different distances.
[0155] Specifically, obtain the spatial information of the virtual camera. According to the water surface-related texture coordinate data, water surface normal information, virtual camera spatial information, etc. obtained in step S305, on the basis of the second water body rendering image, use the Fresnel lighting model to process the refracted light and reflected light on the water surface, and then perform BlinnPhong lighting model calculation to process the specular highlight part to obtain a water surface rendering image with lighting, that is, the third water body rendering image.
[0156] Step S308: Process the spatial occlusion relationship between the first water body rendering image and the third water body rendering image, and perform alpha blending calculation to obtain a game scene rendering image.
[0157] In practical applications, the process of water body rendering includes: underwater rendering, reflection rendering, and water surface rendering (including water surface fluctuations, water surface lighting, and water surface far and near scenes, etc.).
[0158] (1) Underwater rendering
[0159] The main materials required for underwater rendering are a high-definition texture map with a relatively large size and the corresponding normal map. According to the shooting angle of the virtual camera, the underwater picture is placed obliquely to create a perspective effect.
[0160] In order to achieve a more natural water surface fluctuation effect, when sampling the normal map of the underwater texture map, parameters of scaling and time are added to the calculation of UV (normalized texture map coordinates), realizing the effect that the normal of the underwater bottom flows with time.
[0161] The specific formula is as follows:
[0162] UvWarp = UV0 * scale + Time * TimeParam;
[0163] Wherein, UvWarp is the underwater texture map value, UV0 is the original water body texture map value, scale is the scaling coefficient, Time is the current time, and TimeParam is the time coefficient.
[0164] (2) Reflection rendering
[0165] Since the computational cost of screen space reflection is very high for the computing performance of mobile devices, the present invention adopts a non-real-time specular reflection scheme. The mountains, buildings, and trees in the foreground and background are all pictures or models placed in 3D space. To achieve the reflection, when making the materials, the original material pictures are mirrored vertically, and the lower half of the material pictures is processed according to the laws of reality.
[0166] Optionally, the original material pictures are mirrored vertically, and the lower half of the material pictures is subjected to stretching processing, transparent gradient, and Gaussian blur processing. Therefore, if there are dynamic effects in these parts, only the animations of the upper and lower parts need to be mirrored.
[0167] Since the water surface is transparent, therefore, by placing the materials in the correct position, the lower half of the pictures can pass through the water surface, and a realistic reflection effect can be displayed.
[0168] (3) Water surface rendering
[0169] The water surface rendering mainly includes three parts: fluctuation, lighting, and color change with distance.
[0170] 1) Fluctuation
[0171] The water surface fluctuation is based on the FBM (Fractal Brownian Motion) algorithm. The basic idea of the Fractal Brownian Motion algorithm is: mixing multiple noises with different frequencies according to different amplitudes.
[0172] In water body rendering, the UV (normalized texture map coordinates) calculation of the normal map adopts the frequency parameter, and the calculation of the normal map sampling value adopts the amplitude parameter. Both the frequency parameter and the amplitude parameter take geometric sequences, and a finite number of fractal superposition times are taken (such as 3 times).
[0173] Assume that the amplitude parameter is ScaleFbm, then the amplitude sequence is s[i] = ScaleFbm^i, and the calculation formula for the sum S of the geometric sequence is as follows:
[0174] S = ScaleFbm * (1 - ScaleFbm^n) / (1 - ScaleFbm);
[0175] In the formula, n is the number of stacking times.
[0176] Assume that the frequency parameter is FreqFbm, then the amplitude sequence is f[i] = FreqFbm^i.
[0177] Under the above parameters, the calculation formula of the UV coordinate sequence UvWarp[i] of the normal map is as follows:
[0178] UvWarp[i] = UV0 * f[i] + Time * TimeParam;
[0179] Where, UvWarp is the sequence of UV values after calculation, UV0 is the original UV coordinate, Time is the current time, TimeParam is the time coefficient, i is the index value from 1 to n, and n is the number of stacking times.
[0180] The sampling sequence is: Sample(Tex_Normal, UvWarp[i]) * s[i], where Sample represents sampling and Tex_Normal represents the normal map.
[0181] The normal value at the final pixel is the average value obtained by summing the sampling sequence and dividing by S.
[0182] Therefore, the present invention realizes the wave effect of the water surface.
[0183] 2) Lighting
[0184] Based on the normal direction calculated by the fractional Brownian motion for the water surface lighting, the standard Fresnel model is used to process the reflection and refraction effects of the water surface, and the BlinnPhong model is used to process lighting effects such as highlights.
[0185] 3) Far and near color change
[0186] The far and near color change uses two parameters, the far view color and the near view color. By calculating the distance of the water surface corresponding to the pixel point from the position of the virtual camera, linear interpolation is performed on the two color parameters of the far view color and the near view color.
[0187] In summary, the present invention uses the fractional Brownian motion algorithm to perform hierarchical stacking on the cloud image to obtain a dynamic cloud shape effect, making the floating of the clouds more natural; uses the fractional Brownian motion algorithm to process the water surface image, and superimposes the processed water surface image with the bottom water image after the wave effect processing, making the water flow effect continuous and delicate, more in line with the water flow effect in nature. The mirror surface scheme does not adopt real-time screen space rendering, thereby improving the rendering performance on mobile devices. The design of the far and near scenery makes the rendering scheme compatible with the scene design of any theme, and adjusts the tone of the water body based on the lighting.
[0188] Corresponding to the above method embodiments, the present invention also discloses a rendering device for a game scene.
[0189] See Figure 4 , a schematic structural diagram of a rendering device for a game scene disclosed in an embodiment of the present invention. The device includes:
[0190] A game scene acquisition unit 401, configured to acquire an original game scene to be rendered;
[0191] In practical applications, the original game scene to be rendered can be acquired from the built game scene.
[0192] Among them, the process of building the game scene is as follows:
[0193] Create an empty three-dimensional original game scene;
[0194] In the three-dimensional game scene, correctly place the underwater model, foreground and background item models, sky model, water surface model, etc. according to the spatial relationship, and assign correct material parameters (i.e., rendering code, various texture maps) to each model to create the game scene.
[0195] In practical applications, according to the correct position and orientation of the virtual camera, determine the rendering view range, that is, the original game scene to be rendered.
[0196] A sky model acquisition unit 402, configured to acquire the sky model in the original game scene;
[0197] A sky rendering unit 403, configured to render the sky model using sky material parameters and a preset sky rendering scheme to obtain a sky scene rendering image, where the preset sky rendering scheme is: using the fractional Brownian motion algorithm to perform layered superposition on the cloud image and using the morphology control algorithm for processing to obtain a dynamic cloud morphology effect;
[0198] In this embodiment, the fractional Brownian motion algorithm is used to perform layered superposition on the cloud image, which is equivalent to using the cloud image to programmatically superimpose fractional noise to obtain a dynamic cloud morphology effect, thereby well solving the problem that the cloud image in the traditional scheme drifts in a fixed direction over time to achieve a floating effect.
[0199] A water body model acquisition unit 404, configured to acquire the water body model in the original game scene;
[0200] A water body rendering unit 405 is configured to use water body material parameters for the water body model and adopt a preset water body rendering scheme to continue rendering a water body image on the basis of the sky scene rendering image to obtain a game scene rendering image, where the preset water body rendering scheme is: processing a water surface image by using the fractional Brownian motion algorithm and superimposing the processed water surface image on a water bottom image after a fluctuation effect is processed.
[0201] In practical applications, when rendering a water body, a water bottom image, a foreground and background object image, a reflection image, and a water surface image may be rendered in sequence.
[0202] In summary, the present invention discloses a rendering device for a game scene, which obtains an original game scene to be rendered, uses sky material parameters for a sky model in the original game scene and adopts a preset sky rendering scheme to perform rendering to obtain a sky scene rendering image. The preset sky rendering scheme is to perform hierarchical superposition on a cloud image by using the fractional Brownian motion algorithm and use a morphology control algorithm for processing to obtain a dynamic cloud morphology effect. Water body material parameters are used for a water body model in the original game scene and a preset water body rendering scheme is adopted to continue rendering a water body image on the basis of the sky scene rendering image to obtain a game scene rendering image. The preset water body rendering scheme is to process a water surface image by using the fractional Brownian motion algorithm and superimpose the processed water surface image on a water bottom image after a fluctuation effect is processed. The present invention performs hierarchical superposition on a cloud image by using the fractional Brownian motion algorithm to obtain a dynamic cloud morphology effect, making the floating of clouds more natural; processes a water surface image by using the fractional Brownian motion algorithm and superimposes the processed water surface image on a water bottom image after a fluctuation effect is processed, making the water body flow effect continuous and delicate, and more in line with the water body flow effect in nature.
[0203] It should be specifically noted that for the specific working principles of the components in the device embodiment, please refer to the corresponding parts of the method embodiment, which will not be elaborated here.
[0204] Finally, it should also be noted that in this article, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the term "comprising", "including" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements not only includes those elements, but also includes other elements not expressly listed, or also includes elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "including a..." does not exclude the existence of another identical element in the process, method, article or device including the element.
[0205] In the present specification, the various embodiments are described in a progressive manner. Each embodiment focuses on the differences from other embodiments. For the same or similar parts among the various embodiments, reference may be made to each other.
[0206] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present invention. Various modifications to these embodiments will be obvious to those skilled in the art. The general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the broadest scope consistent with the principles and novel features disclosed herein.
Claims
1. A rendering method for a game scene, characterized in that, Including: Obtain the original game scene to be rendered; Obtain the sky model in the original game scene; Sample the sky main texture map in the sky material parameters for the sky model to obtain sky color image data; Perform perspective calculation on the spatial information parameters in the sky material parameters and convert the original cloud-related texture coordinates to obtain cloud-related texture coordinates with a perspective effect; Apply the cloud-related texture coordinates to sample the normal map and height map, and perform a fractional Brownian motion algorithm calculation on the normal sequence and height sequence sampled using the texture coordinates to obtain target cloud normal value data with a floating effect and corresponding target height value data; Interpolate the cloud color between the top color and the bottom color of the cloud for the target height value data, and use the cloud shape control algorithm to obtain the cloud image data after shape control; Perform scattering illumination calculation and Lambert illumination calculation on the overall sky image for the target cloud normal value data to obtain sky illumination image data; Overlay the sky color image data, the cloud image data, and the sky illumination image data to obtain a sky scene rendering image after rendering both the sky and the clouds; Obtain the water body model in the original game scene; Use the water body material parameters for the water body model and adopt a preset water body rendering scheme to continue rendering the water body image on the basis of the sky scene rendering image to obtain a game scene rendering image, where the preset water body rendering scheme is: process the water surface image using the fractional Brownian motion algorithm and overlay the processed water surface image with the water bottom image after wave effect processing.
2. The rendering method according to claim 1, wherein The original cloud-related texture coordinates include: the texture coordinates of the cloud height map and the texture coordinates of the cloud normal map.
3. The rendering method according to claim 1, wherein The rendering of the cloud mainly includes: cloud perspective correction, cloud height color, cloud movement, and cloud illumination.
4. The rendering method according to claim 3, wherein The processing process of the cloud perspective correction includes: Calculate the direction of the rendering line of sight through the pose of the virtual camera; Correspondingly correct the normalized texture map coordinates of the cloud texture map by using the geometric similarity relationship based on the coordinate value in the vertical direction of the world coordinate position of the point on the sky plane, the sky overall height parameter, and the line of sight direction data to complete the processing of the cloud perspective correction, where the sky plane is a vertically placed plane.
5. The rendering method according to claim 4, wherein The processing process of the cloud movement includes: Apply the texture coordinates after perspective correction, and perform fractional superposition on the sampling results of the cloud normal map and the sampling results of the cloud height map using the fractional Brownian motion algorithm according to the ratio parameter to obtain a normal sampling sequence and a height sequence; Accumulate the normal sampling sequence, and divide the accumulated value by the sum of the ratio sequences to obtain the mean value to determine the normal sampling result value; Accumulate the height sequence, and determine the mean value obtained by dividing the accumulated value by the sum of the ratio sequences as the height value of the cloud, and continue to calculate the density and softness of the cloud through the cloud shape control algorithm for the height value of the cloud to obtain the height value after shape calculation, and complete the processing of the cloud movement.
6. The rendering method according to claim 4, wherein The processing process of the cloud illumination includes: Divide the effect of the cloud lighting into scattered lighting and partial specular highlights; The calculation formula for the scattered lighting is as follows: col = LightColor * pow(1 - disUV2LightPos, LightAttentionPow) * Height; In the formula, col is the result value of the scattered lighting, LightColor is the light color parameter, pow is the power function, disUV2LightPos is the Euclidean distance from the normalized texture map coordinates to the light position parameter, LightAttentionPow is the scattered light power exponent parameter, and Height is the height value obtained by using the fractional Brownian motion algorithm; Use the standard Lambert lighting model to determine the partial specular highlights.
7. The rendering method according to claim 4, wherein The processing process of the cloud height color includes: Perform linear interpolation on the top color and the bottom color in the cloud height color using the target height value, and multiply the interpolation result by the height value to complete the processing of the cloud height color.
8. The rendering method according to claim 1, wherein For the water body material parameters of the water body model, use a preset water body rendering scheme to continue rendering the water body image on the basis of the sky scene rendering image to obtain the game scene rendering image, including: Obtain the relevant data of the water bottom, and perform sampling rendering on the relevant data of the water bottom to obtain a fluctuating water bottom rendering image; Obtain the relevant data of the foreground and background objects, and perform sampling rendering on the relevant data of the foreground and background objects to obtain the foreground and background object rendering images; Obtain the relevant data of the reflection, and perform coordinate transformation and texture sampling on the relevant data of the reflection to obtain the reflection rendering image; Overlay and process the water bottom rendering image, the foreground and background object rendering images, and the reflection rendering image to obtain the first water body rendering image; Obtain the relevant data of the water surface, and use the fractional Brownian motion algorithm on the relevant data of the water surface to obtain the water surface related texture coordinate data with fluctuation information, where the relevant data of the water surface includes: normal map texture coordinates; Based on the water surface far and near color changes and the water surface related texture coordinate data, obtain the second water body rendering image including far and near colors and fluctuations; Obtain the spatial information of the virtual camera, and based on the spatial information and the water surface related texture coordinate data, perform lighting processing on the basis of the second water body rendering image to obtain the third water body rendering image including fluctuations, lighting, and far and near color changes; Perform spatial occlusion relationship processing on the first water body rendering image and the third water body rendering image, and perform transparent blending calculation to obtain the game scene rendering image.
9. The rendering method according to claim 8, wherein The process of sampling rendering the relevant data of the water bottom includes: The calculation formula for the water bottom texture map is as follows: UvWarp = UV0 * scale + Time * TimeParam; In the formula, UvWarp is the water bottom texture map value, UV0 is the original water body texture map value, scale is the scaling coefficient, Time is the current time, and TimeParam is the time coefficient.
10. The rendering method according to claim 8, characterized in that The process of reflection rendering includes: Mirror the original material image vertically and stretch, apply transparency fade, and Gaussian blur to the lower part of the material image.
11. A rendering device for a game scene, characterized in that, Including: A game scene acquisition unit for acquiring the original game scene to be rendered; A sky model acquisition unit for acquiring the sky model in the original game scene; A sky rendering unit for sampling the sky main texture map in the sky material parameters for the sky model to obtain sky color image data; Perform perspective calculation on the spatial information parameters in the sky material parameters and convert the original cloud-related texture coordinates to obtain cloud-related texture coordinates with a perspective effect; Apply the cloud-related texture coordinates to sample the normal map and height map, and perform the fractional Brownian motion algorithm calculation on the normal sequence and height sequence sampled using the texture coordinates to obtain the target cloud normal value data with a floating effect and the corresponding target height value data; For the target height value data, interpolate between the cloud top color and the cloud bottom color to obtain the cloud color, and use the cloud shape control algorithm to obtain the cloud image data after shape control; For the target cloud normal value data, perform diffuse lighting calculation and Lambert lighting calculation on the overall sky image to obtain sky lighting image data; Overlay the sky color image data, the cloud image data, and the sky lighting image data to obtain a sky scene rendering image with both the sky and clouds rendered; A water body model acquisition unit for acquiring the water body model in the original game scene; A water body rendering unit for using the water body material parameters for the water body model and adopting a preset water body rendering scheme to continue rendering the water body image on the basis of the sky scene rendering image to obtain a game scene rendering image, where the preset water body rendering scheme is: process the water surface image using the fractional Brownian motion algorithm and overlay the processed water surface image with the water bottom image after wave effect processing.
Citation Information
Patent Citations
Virtual reality superspeed real-time rendering method
CN106228591A
Dynamic volume cloud construction and drawing method
CN106570929A