A grass rendering method, system, electronic device, and storage medium

By adopting the improved BlinnPhong model and light transmission model in grass rendering and calculating the lighting effect at the vertex, the problem of low fusion between grass and scenes in the existing technology is solved, achieving more efficient rendering effects and more realistic game pictures.

CN114022608BActive Publication Date: 2025-06-03广州三七极耀网络科技有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111212568.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-10-18
Publication Date
2025-06-03
Estimated Expiration
2041-10-18

AI Technical Summary

Technical Problem

Existing grass rendering technology is difficult to improve the degree of integration between grass and scenes while ensuring equipment performance. Especially when using PBR lighting, the degree of integration between grass and surrounding environment is low.

Method used

The improved BlinnPhong model is used as the first layer highlight model and combined with the second layer of light transmission model for rendering, simplifying the calculation by fixed normal vectors, and calculating the results of the highlight and light transmission model at the vertex to reduce the pressure on the game engine.

Benefits of technology

On the premise of meeting the performance of the equipment, the fusion effect between grass and scenes is significantly improved, the calculation pressure of the game engine is reduced, the game screen is avoided, and a more realistic rendering effect is achieved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114022608B_ABST
    Figure CN114022608B_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of 3D rendering, and in particular, to a grass rendering method, system, electronic device, and storage medium. The method includes: rendering the grass cluster to be rendered using a first-layer specular model, where the first-layer specular model is an improved Blinn-Phong model, and the improved Blinn-Phong model sets the normal vector to a fixed value; rendering the grass cluster to be rendered using a second-layer light-transmitting model. The present application has the technical effect of improving the fusion degree of grass and the scene when performing grassland rendering on the premise of meeting the device performance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the technical field of 3D rendering, and in particular, to a grass rendering method, system, electronic device, and storage medium. Background Art

[0002] Currently, in some game scenes involving natural scenery, there are usually some grassland scenes. In order to bring an immersive gaming experience to users, the rendering of grass in the game scene usually adopts a lighting method that simulates PBR (Physically Based Rendering). That is, the goal is to render the game scene by combining a rendering technique based on a theory that is basically consistent with the physical principles of the real world and an empirical lighting model, and to achieve real-time rendering of grass by simulating the refraction, scattering, reflection, etc. of light directly irradiating on the grass.

[0003] The inventor found during the implementation of the present invention that in the face of a large area of grass, generally only simple models such as Lambert (pure diffuse reflection) and Blinn Phong can be selected. In use, they cannot be integrated with the PBR scene, resulting in a low degree of integration between the grass and the surrounding environment. During the implementation of the present invention, the inventor tried to bake the GGX specular (micro-surface reflection lighting model) to the vertices, but it has high requirements for device performance and is difficult to adapt to the requirements of general game scene rendering. Summary of the Invention

[0004] Therefore, the embodiments of this application provide a grass rendering method, system, electronic device, and storage medium, which solve the technical problem of how to improve the integration degree between the grass cluster and the scene while ensuring the device performance during the existing grass rendering. The specific technical solution content is as follows:

[0005] In a first aspect, the embodiments of this application provide a grass rendering method, and the method includes:

[0006] Render the grass cluster to be rendered using a first-layer specular model, where the first-layer specular model is an improved Blinn Phong model, and the improved Blinn Phong model sets the normal vector to a fixed value;

[0007] Render the grass cluster to be rendered using a second-layer light transmission model.

[0008] By adopting the above technical solution, the first-layer specular model is used for specular calculation, and the second-layer light-transmitting model is used for light-transmitting calculation. The specular calculation and the light-transmitting calculation are superimposed. On the premise of meeting the device performance, the fusion effect between the grass to be rendered and the scene is better. The first-layer specular model adopts an improved BlinnPhong model with a fixed normal vector, and uses an empirical value model to render the real-time scene, reducing the pressure on the game engine. Moreover, the BlinnPhong model has a smooth specular effect and omits two multiplication operations for calculating the reflection light direction vector, so the calculation speed is faster. The improved BlinnPhong model sets the normal vector to a fixed value. In actual rendering, the calculation is simplified, and there is no need to obtain the normal vectors of each vertex of the grass model to be rendered in real time. Secondly, the fixed normal vector makes the rendering direction of the grass unified. While simplifying the calculation, the specular rendering effect on the surface of the grass is similar.

[0009] Furthermore, the improved BlinnPhong model sets the normal vector to (0, 1, 0).

[0010] By adopting the above technical solution, the normal vector is fixed to (0, 1, 0), which simplifies the calculation amount of the improved BlinnPhong model, eliminates the need to recalculate the normal vectors of each vertex of the grass model to be rendered, and also saves the calculation amount of normal vector calculation.

[0011] Furthermore, the calculations of the first-layer specular model and the second-layer light-transmitting model of the grass to be rendered are performed in the vertex, and the calculated data is passed to the pixel, where the calculated lighting effects are superimposed.

[0012] By adopting the above technical solution, the calculations of the first-layer specular model and the second-layer light-transmitting model are simplified to vertex calculations, which can reduce the calculation amount of the lighting model and simplify the calculation. Secondly, the calculation results of the lighting model are superimposed on the vertex pixels, making the model color associated with the lighting and increasing the fusion degree between the grass to be rendered and the scene.

[0013] Furthermore, the second-layer light-transmitting model performs light-transmitting calculation through the viewing direction and the light direction to simulate the Fresnel specular of PBR.

[0014] By adopting the above technical solution, using the viewing direction and the light direction to perform light-transmitting calculation to simulate the Fresnel specular of PBR simplifies the calculation method of the Fresnel specular. While making the fusion degree between the grass to be rendered and the scene better, it also reduces the processing pressure on the game engine and makes the game scene not prone to freezing.

[0015] Furthermore, the second-layer light-transmitting model also includes adjusting the local base color through the specular color intensity of the A channel of the vertex color, and the base color attenuates as the angle between the viewing direction and the light direction increases.

[0016] By adopting the above technical solution, the local solid color is adjusted through the A channel of the vertex color, and the solid color attenuation is performed through the included angle between the viewing direction and the light direction, which is used to locally correct the problem of color non-fusion caused by the ground Fresnel, and further improve the fusion degree of the to-be-rendered grass after rendering with the scene.

[0017] Further, before rendering the to-be-rendered grass using the first layer of specular model, it further includes:

[0018] Judging the to-be-rendered grass, and adjusting the density and rendering effect intensity of the to-be-rendered grass according to the importance degree of the to-be-rendered grass.

[0019] By adopting the above technical solution,

[0020] Further, before rendering the to-be-rendered grass using the first layer of specular model, it further includes:

[0021] Judging the distance between the to-be-rendered grass and the screen, and the area of the to-be-rendered grass;

[0022] If the distance between the to-be-rendered grass and the screen is greater than the preset distance and the area is greater than the preset area, then draw the to-be-rendered grass on the ground texture map.

[0023] By adopting the above technical solution, judging the to-be-rendered grass, and thus setting the density and rendering effect intensity of the to-be-rendered grass can reduce the calculation amount of the game engine, and during the calculation of the lighting model, it can focus on rendering according to the importance degree of the to-be-rendered grass, reasonably allocate device resources, reduce the situation of game screen freezing, and also make the effect of the game scene seen by the player more realistic.

[0024] In a second aspect, an embodiment of the present application provides a grass rendering system, and the system includes:

[0025] A first specular calculation module, which is used to render the to-be-rendered grass using the first layer of specular model, and the first layer of specular model is an improved BlinnPhong model, and the improved BlinnPhong model sets the normal vector as a fixed value;

[0026] A second specular calculation module, which is used to render the to-be-rendered grass using the second layer of light transmission model.

[0027] In a third aspect, an embodiment of the present application provides an electronic device, including a memory, a processor, and a computer program stored in the memory and running on the processor, and when the processor executes the computer program, it implements the steps of the grass rendering method described in any one of the foregoing.

[0028] Fourthly, an embodiment of the present application provides a computer-readable storage medium storing a computer program, which when executed by a processor implements the steps of the grass rendering method described in any one of the foregoing.

[0029] In summary, compared with the prior art, the beneficial effects brought by the technical solution provided by the embodiment of the present application at least include:

[0030] 1. The first-layer specular model is used for specular calculation, and the second-layer light transmission model is used for light transmission calculation. The specular calculation and the light transmission calculation are superimposed. On the premise of meeting the device performance, the fusion effect between the grass to be rendered and the scene is better.

[0031] 2. The real-time scene is rendered with an empirical value model, which reduces the pressure on the game engine. The BlinnPhong model has a smooth specular effect, and two multiplication operations for calculating the reflection light direction vector are omitted, so the calculation speed is faster.

[0032] 3. The normal vector in the BlinnPhong model is set to a fixed value. In actual rendering, the calculation is simplified and there is no need to obtain the normal vectors of each vertex of the grass model to be rendered in real time. Secondly, the fixed normal vector makes the rendering direction of the grass unified. While simplifying the calculation, the specular rendering effect on the surface of the grass is similar.

[0033] 4. The perspective direction and the light direction are used for light transmission calculation to simulate the Fresnel specular of PBR, which simplifies the calculation method of the Fresnel specular. While making the fusion degree between the grass to be rendered and the scene better, it also reduces the processing pressure on the game engine and makes the game scene not easy to freeze.

[0034] 5. The local base color is adjusted by the specular color intensity of the A channel of the vertex color, and the base color decays as the angle between the viewing direction and the light direction increases, which is used to locally correct the problem of color non-fusion caused by the ground Fresnel, and further improves the fusion degree between the rendered grass and the scene. Description of the Drawings

[0035] Figure 1 is a schematic flowchart of a grass rendering method provided by one embodiment of the present application.

[0036] Figure 2 is one of the schematic flowcharts of a grass rendering method provided by another embodiment of the present application.

[0037] Figure 3 is the second of the schematic flowcharts of a grass rendering method provided by another embodiment of the present application.

[0038] Figure 4 is a schematic structural diagram of a grass rendering system provided by one embodiment of the present application.

[0039] Figure 5 It is a schematic structural diagram of an electronic device provided by one embodiment of the present application. Detailed implementation manners

[0040] This specific embodiment is only an interpretation of the present application and does not limit the present application. After reading this specification, those skilled in the art can make modifications to this embodiment without creative contributions as needed, but as long as it is within the scope of the claims of the present application, it is protected by the patent law.

[0041] To make the objectives, technical solutions, and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are some, but not all, of the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without making creative efforts fall within the scope of protection of the present application.

[0042] In addition, the term "and / or" in the present application is only a description of the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B may represent: A exists alone, A and B exist simultaneously, and B exists alone. In addition, the character " / " in the present application generally represents an "or" relationship between the associated objects before and after, unless otherwise specified.

[0043] The term "at least one" in the present application means one or more, and the meaning of "a plurality" is two or more. For example, a plurality of first positions means two or more first positions.

[0044] In real life, people see objects due to the colors reflected by light. In current 3D scene games, in order to simulate a real game scene as much as possible, it is necessary to simulate the real lighting effect on the model, perform lighting calculations, and introduce lighting models. Lighting models are also known as shading models and are used to calculate the light intensity (color value) at a certain point on an object. From the algorithmic theoretical basis of lighting models, lighting models are mainly divided into two categories: one is the lighting model based on physical theory, and the other is the lighting model based on empirical models. The lighting model based on physical theory emphasizes the use of physical measurement and statistical methods, and many of its parameters need to be measured by instruments. The advantage of using this lighting model is that the effect is very realistic, but the calculation is complex and it is also more difficult to implement. It is often used for non-real-time rendering. For real-time rendering, the amount of calculation is large, and the current device performance is difficult to achieve; the lighting model based on empirical models emphasizes the use of specific probability formulas, so most empirical models are relatively simple and the effects are relatively idealized, and are often used for real-time rendering. These two lighting models do not have to choose only one. No matter what kind of lighting model, it is essentially based on physics, but only has different emphases in calculation methods. From the perspective of the use of lighting models, lighting models are divided into local lighting models and global lighting models. The local lighting model decomposes the types of lighting and only considers one of them during calculation; while the global lighting model takes into account all types of lighting.

[0045] The following further describes the embodiments of the present application in detail with reference to the accompanying drawings of the specification.

[0046] Refer to Figure 1 , in an embodiment of the present application, a grass rendering method is provided, and the main steps of the method are described as follows:

[0047] S3: Render the grass to be rendered using the first-layer specular model. The first-layer specular model is an improved Blinn-Phong model, and the improved Blinn-Phong model sets the normal vector to a fixed value;

[0048] S4: Render the grass to be rendered using the second-layer light transmission model.

[0049] In this embodiment, when a grass rendering event is detected, the grass to be rendered corresponding to the grass rendering event is obtained, and specular calculation is performed on the grass to be rendered. In this embodiment, the grass rendering event is an event triggered when rendering the grass in a game or virtual scene. For example, when performing real-time rendering of a game, it is triggered when loading a loading page containing the grass to be rendered, that is, in a pre-loaded data frame, when it is recognized that there is grass to be loaded, the grass rendering event is triggered.

[0050] When a grass rendering event is detected, the grass clusters to be rendered corresponding to the grass rendering event are detected, that is, the relevant data information of the grass clusters to be rendered is obtained from the current grass rendering event. When performing grass rendering in this embodiment, first detecting the grass rendering event and obtaining the grass clusters to be rendered from the grass rendering event has the following advantages: The spatial positions of the grass to be rendered in the grass clusters to be rendered are relatively close, so the specular effects are similar. For the grass to be rendered in the same grass cluster obtained at one time, when calculating the specular calculation result of the grass to be rendered, the rendering results of other grass in the grass cluster to be rendered and the attribute information of the grass cluster to be rendered can be referred to, so that the specular rendering of the grass in the grass cluster to be rendered has better integrity.

[0051] In this embodiment, the number of grass in the grass cluster to be rendered is not limited and can be any value such as 1, 2, 3, etc. The number of grass in the grass cluster to be rendered is not a limitation for understanding the solution of this application.

[0052] The specular calculation is to superimpose two lighting models on the grass cluster to be rendered. The two lighting models include the first specular model and the second light transmission model.

[0053] The first specular model is a common local lighting model. In this embodiment, common specular models include the Phong model and the BlinnPhong model, but other specular calculation models can also be used for calculation. Both the Phong model and the BlinnPhong model are empirical models and can be used to calculate the light reflected along the perfectly specular reflection direction, making the object look more shiny.

[0054] The difference between the BlinnPhong model and the Phong model lies in the calculation method of the angle of the specular term. For the Phong model, the angle of the specular term requires calculating the data of the light reflection direction and the line-of-sight direction. The BlinnPhong model, however, calculates the data of the half-angle vector and the unit normal vector at the light incidence point. The half-angle vector is the intermediate vector between the light incidence direction and the view direction. Calculating the half-angle vector is relatively simple and has less computational complexity. Moreover, the Phong model may lead to uneven display effects in some cases. When the angle between the reflected light and the line of sight is greater than 90 degrees, since the cosine value is always limited to [0, 1] during actual rendering, the contribution of the Phong model calculation to the specular term is relatively low. When the specular reflectance of an object is very small, the specular radius will be very large, and an obvious fracture phenomenon will occur near the area where the reflection angle and the line-of-sight angle are 90 degrees. The BlinnPhong model does not have the fracture phenomenon, and the specular effect is smoother. Compared with the Phong model, the BlinnPhong model mixes the diffuse reflection part of the Lambert model and the standard specular highlight, and the rendering effect is softer and smoother than the specular highlight of the Phong model. In addition, the BlinnPhong model omits two multiplication operations for calculating the direction vector of the reflected light, making it faster. The BlinnPhong model simplifies the computational complexity of the Phong model and has higher computational efficiency than the Phong model.

[0055] The first-layer specular model is an improved BlinnPhong model, which sets the normal vector as a fixed value based on the BlinnPhong model.

[0056] In this embodiment, the improved BlinnPhong model sets the normal vector as a fixed value. In actual calculation, it is not necessary to obtain the direction of the normal vector of each vertex after polygon segmentation of the grass to be rendered in real time. On the premise of having the advantages of the BlinnPhong model, fixing the normal vector simplifies the calculation and reduces the computational complexity of the game engine. Moreover, in actual rendering, using a fixed normal vector to calculate the specular reflection of the grass model to be rendered can make the specular reflection effect of the grass model to be rendered more uniform, without changing the normal vector of the grass model to be rendered, and avoiding the situation where the calculated specular results are chaotic due to modifying the normal direction of the grass model to be rendered.

[0057] In this embodiment, setting the normal vector as a fixed value, the setting logic of the fixed value can be: 1. Set it according to the normal vector in the vertical direction of the spatial position where the grass to be rendered with the largest area is mainly located; 2. Set it as a unified fixed value in the rendering. In other embodiments based on the concept of this application, other setting logics can also be adopted. The two setting logics exemplified in this application are not used to limit the setting logic methods in other embodiments of this application.

[0058] In this embodiment, detecting the grass rendering event and obtaining the grass clusters to be rendered according to the grass rendering event also has the following advantages: it is convenient to obtain information related to the grass cluster model to be rendered in the current scene to be rendered, and when performing the first-layer specular rendering on the grass cluster model to be rendered, the normal vector in the rendering-related data of the grass cluster model to be rendered is set to a fixed value, so that the rendering effect of the grass is unified in the scene to be rendered in the same frame. In this embodiment, setting the normal vector in the vertical direction to a fixed value reduces the amount of data in data calculation, uses fewer model resources, reduces the rendering pressure on the game engine, and improves the overall performance of the game.

[0059] In this embodiment, the second-layer light transmission model calculates the light transmission intensity of the grass cluster to be rendered through dot product calculation based on the viewing direction information and the light direction information of the grass cluster to be rendered, obtains the light transmission color of the grass cluster to be rendered, and calculates the light transmission model rendering data of the grass cluster to be rendered based on the light transmission color and the light transmission intensity.

[0060] The fusion method of the specular model rendering data calculated by the first-layer specular model and the light transmission model rendering data calculated by the second-layer light transmission model is to superimpose the specular model rendering data on the light transmission model rendering data, and the calculation result of the current lighting model can be obtained.

[0061] In this embodiment, a custom lighting model is used to achieve the diffuse reflection, specular, and light transmission effects of the grass. The first-layer specular model uses the BlinnPhong model with a fixed normal vector, which reduces the calculation amount of the lighting model. Thus, while meeting the device performance requirements, a good rendering effect can also be achieved, making the rendering scene more integrated.

[0062] Optionally, in another embodiment, in the grass rendering method, when calculating the first-layer specular model and the second-layer light transmission model respectively, the calculations of the first-layer specular model and the second-layer light transmission model of the grass cluster to be rendered are performed at the vertices, and the calculated data is passed to the pixels to superimpose the calculated lighting effects in the pixels.

[0063] It should be noted that in this embodiment, the lighting effect is the result of the calculation of the first-layer specular model and the second-layer light transmission model. The calculations of both the first-layer specular model and the second-layer light transmission model are performed at the vertices formed by polygon segmentation of the grass cluster model to be rendered. While reducing the calculation amount of model rendering, transmitting the calculation result of the lighting model to the pixels also retains a good rendering effect.

[0064] Optionally, in another embodiment, the normal vector of the improved BlinnPhong model is fixed to (0, 1, 0). Fixing the normal vector to (0, 1, 0) simplifies the calculation amount of the improved BlinnPhong model. There is no need to recalculate the normal vector of each vertex of the grass model to be rendered, and the calculation amount of the normal vector is also saved.

[0065] Optionally, in another embodiment, the second-layer light transmittance model simulates the Fresnel highlights of PBR by performing light transmittance calculations based on the viewing direction and the light direction, and achieves the light transmittance effect of the grass to be rendered by simulating the Fresnel highlights of PBR, so that the grass to be rendered can be better integrated with the scene after rendering; and here, the use of viewing direction and light direction to perform light transmittance calculations to simulate the Fresnel highlights of PBR simplifies the calculation method of the Fresnel highlights, which not only improves the integration of the grass to be rendered with the scene, but also reduces the processing pressure of the game engine, making the game scene less likely to be stuck.

[0066] In this embodiment, the method of real-time calculation and simulation of PBR Fresnel highlights solves the dependence of the transparency effect of the existing model on the reflection map. When the scene changes, the grass to be rendered is well integrated with the scene, and the game screen quality is also better.

[0067] Optionally, the second-layer light transmission model also includes adjusting the local intrinsic color through the highlight color intensity of the vertex color A channel, and the intrinsic color attenuates as the angle between the field of view direction and the light direction increases.

[0068] In this embodiment, the intrinsic color is the color of the object itself. The local intrinsic color is adjusted through the vertex color A channel, and attenuated by the angle between the field of view and the light direction. The larger the angle between the field of view and the light direction, the greater the attenuation. The solution of this embodiment is used to locally correct the problem of color incompatibility caused by Fresnel calculation of the surface, and further improve the fusion degree between the rendered grass and the scene after rendering.

[0069] In the game scene, the model of the grass to be rendered is set on the ground surface, and the ground surface is rendered through the lighting model. When the grass to be rendered is rendered, the root of the grass model is close to the ground surface, which is easily affected by the color of the ground surface, resulting in the color calculation effect of the root being obviously different from that of the upper part of the grass to be rendered. The vertex color A channel is used to adjust the inherent color, and the inherent color is attenuated through the angle between the field of view direction and the light direction, so as to reduce the influence of the ground surface color on the lighting calculation of the grass to be rendered.

[0070] In the above embodiment, a double-layer high-gloss technology is adopted. First, an improved blinnphone model is used for the surface high-gloss, and a light-transmitting model is used for scene fusion, which simplifies the high-gloss calculation. On the premise of meeting the device performance, the grass can be well integrated into the scenes under different lighting models. Further, the high-gloss calculation can be placed in the vertex for calculation, further reducing the rendering consumption of the grass.

[0071] Referring to Figure 2 , optionally, in another embodiment, step S1 is further included before step S3;

[0072] S1: Judge the grass to be rendered, and adjust the density of the grass to be rendered and the intensity of the rendering effect according to the importance of the grass to be rendered.

[0073] In this embodiment, the LOD (Levels of Detail) technology is adopted to judge the grass to be rendered. LOD determines the resource allocation for object rendering according to the position and importance of the nodes of the object model in the display environment, reduces the number of faces and the level of detail of unimportant objects, so as to obtain high-efficiency rendering operations.

[0074] Adopting LOD has the following advantages: 1. The model fineness is controllable; 2. It does not require art resources to be consumed for production, saving a large amount of time; according to the different complexities of the grass to be rendered and the characteristics of the human eye observing the grass to be rendered, different details are used to describe and draw different areas of the grass to be rendered. When using the LOD technology to draw the grass to be rendered, without reducing the rendering effect of the grass to be rendered, the number of polygons divided by the grass to be rendered model can be minimized as much as possible to improve the graphics drawing efficiency and realize the real-time interactive visualization of the grass to be rendered.

[0075] In other embodiments, when judging the grass to be rendered, a preset judgment logic can also be adopted, such as setting the density of the grass to be rendered and the intensity of the rendering effect according to the information such as the position of the grass to be rendered in the screen space, the distance from the screen space, and the importance in the scene display.

[0076] Judging the grass to be rendered and thus setting the density of the grass to be rendered and the intensity of the rendering effect can reduce the calculation amount of the game engine. And when calculating the lighting model, key rendering can be performed according to the importance of the grass to be rendered, reasonably allocating device resources, and also making the effect of the game scene seen by the player more realistic.

[0077] Referring to 3, optionally, in another embodiment, steps S2 and S21 are further included before step S3;

[0078] S2: Judge the distance between the grass to be rendered and the screen, and the area of the grass to be rendered;

[0079] S21: If the distance between the grass to be rendered and the screen is greater than a preset distance and the area is greater than a preset area, then draw the grass to be rendered on the ground texture map.

[0080] In this embodiment, both the preset distance and the preset area are set according to the display precision required by the actual demand. Generally, the farther the grass to be rendered is from the screen, the lower the display precision requirement. In this embodiment, the area of the grass to be rendered is the area of the grass to be rendered displayed on the screen.

[0081] In this embodiment, the combination of the preset distance and the preset area is used as the condition for drawing the grass to be rendered on the ground texture map. The preset distance limits the precision requirement of the scene display, while the preset area limits the proportion of system resources occupied by the specular rendering of the scene. In actual use, there can be one or multiple preset distances, and the preset areas are set corresponding to the preset distances one by one; for example, if the preset distance is A and the preset area is B, then when the distance between the grass to be rendered and the screen is A and the area is greater than B, draw the grass to be rendered on the ground texture map; if the preset distance is C and the preset area is D, then when the distance between the grass to be rendered and the screen is greater than C and the area is greater than D, draw the grass to be rendered on the ground texture map. Setting multiple preset distances can achieve fine control, further save device resources, and reduce the calculation amount for the subsequent rendering of the grass to be rendered.

[0082] In this embodiment, by directly rendering to the ground texture, the grass in a large area in the distance is rendered, reducing the complexity of rendering and the workload of scene rendering.

[0083] It should be understood that the magnitudes of the sequence numbers of the steps in the above embodiments do not mean the order of execution. The execution order of each process should be determined according to its function and internal logic, and should not constitute any limitation to the implementation process of the embodiments of the present invention.

[0084] Refer to Figure 4 , in an embodiment of the present application, a grass rendering system is provided, and this grass rendering system corresponds one by one to the grass rendering method in the above embodiment. This grass rendering system includes:

[0085] A first specular calculation module, used to render the grass to be rendered using a first-layer specular model, where the first-layer specular model is an improved BlinnPhong model, and the improved BlinnPhong model sets the normal vector to a fixed value;

[0086] A second specular calculation module, used to render the grass to be rendered using a second-layer light transmission model.

[0087] Optionally, in another embodiment, it further includes a detection module for detecting a grass rendering event and obtaining the grass clusters to be rendered corresponding to the grass rendering event.

[0088] Optionally, in another embodiment, the improved BlinnPhong model sets the normal vector to (0, 1, 0).

[0089] Optionally, in another embodiment, in the grass rendering method, when calculating the first-layer specular model and the second-layer light transmission model respectively, the calculation of the first-layer specular model and the second-layer light transmission model of the grass clusters to be rendered is performed at the vertex, and the calculated data is passed to the pixel to superimpose the calculated lighting effect in the pixel.

[0090] Optionally, in another embodiment, the second-layer light transmission model simulates the Fresnel specular highlight of PBR by performing light transmission calculation through the view direction and the light direction.

[0091] Optionally, in another embodiment, the second-layer light transmission model adjusts the local base color through the specular color intensity of the A channel of the vertex color, and the base color attenuates as the angle between the view direction and the light direction increases.

[0092] Optionally, in another embodiment, the grass rendering system further includes a judgment module for judging the grass clusters to be rendered and adjusting the density and rendering effect intensity of the grass clusters to be rendered according to the importance of the grass clusters to be rendered.

[0093] Optionally, in another embodiment, the grass rendering system further includes a texture drawing module, and the judgment module is further used to judge the distance between the grass clusters to be rendered and the screen and the area of the grass clusters to be rendered; the texture drawing module is used to draw the grass clusters to be rendered on the ground texture if the distance between the grass clusters to be rendered and the screen is greater than a preset distance and the area is greater than a preset area.

[0094] Each module of the above grass rendering system can be implemented in whole or in part by software, hardware, and their combination. The above modules can be embedded in the processor of the electronic device in hardware form or be independent of it, or can be stored in the memory of the electronic device in software form so that the processor can call and execute the operations corresponding to the above respective modules.

[0095] Refer to Figure 5, in an embodiment of the present application, an electronic device is provided, and the electronic device may be a server. The electronic device includes a processor, a memory, and a network interface connected by a system bus. Among them, the processor of the electronic device is used to provide computing and control capabilities. The memory of the electronic device may be implemented by any type of volatile or non-volatile storage device or a combination thereof. The volatile or non-volatile storage devices include, but are not limited to: magnetic disks, optical disks, EEPROM (Electrically Erasable Programmable Read Only Memory), EPROM (Erasable Programmable Read Only Memory), SRAM (Static Random Access Memory), ROM (Read Only Memory), magnetic memories, flash memories, PROM (Programmable Read Only Memory). The memory of the electronic device provides an environment for the operation of the operating system and computer programs stored therein. The network interface of the electronic device is used to communicate with external terminals through a network connection. When the computer program is executed by the processor, the steps of the data processing method described in the above embodiment are implemented.

[0096] In an embodiment of the present application, a computer-readable storage medium is provided. The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the data processing method described in the above embodiment are implemented. The computer-readable storage medium includes ROM (Read Only Memory), RAM (Random Access Memory), CD-ROM (Compact Disc Read Only Memory), magnetic disks, floppy disks, etc.

[0097] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, only the above-mentioned division of each functional unit and module is used as an example. In actual applications, the above functions can be allocated to different functional units and modules as needed, that is, the internal structure of the system described in the present application is divided into different functional units or modules to complete all or part of the functions described above.

Claims

1. A grass rendering method, characterized in that, the method includes: Rendering the grass to be rendered using a first layer of specular model, where the first layer of specular model is an improved BlinnPhong model, and the improved BlinnPhong model sets the normal vector to a fixed value; Rendering the grass to be rendered using a second layer of light transmission model; Putting the calculations of the first layer of specular model and the second layer of light transmission model of the grass to be rendered into vertex calculations, and passing the calculated data to pixels, and superimposing the calculated lighting effects in the pixels; The second layer of light transmission model performs light transmission calculations through the viewing direction and the lighting direction to simulate the Fresnel specular highlights of PBR; The second layer of light transmission model also adjusts the local base color through the specular color intensity of the A channel of the vertex color, and the base color attenuates as the angle between the viewing direction and the lighting direction increases.

2. The grass rendering method according to claim 1, characterized in that, the improved BlinnPhong model sets the normal vector to (0, 1, 0).

3. The grass rendering method according to claim 1, characterized in that, Before rendering the grass to be rendered using the first layer of specular model, it further includes: Judging the grass to be rendered, and adjusting the density and rendering effect intensity of the grass to be rendered according to the importance of the grass to be rendered.

4. The grass rendering method according to claim 1, characterized in that, Before rendering the grass to be rendered using the first layer of specular model, it further includes: Judging the distance between the grass to be rendered and the screen and the area of the grass to be rendered; If the distance between the grass to be rendered and the screen is greater than a preset distance and the area is greater than a preset area, then draw the grass to be rendered on the ground texture map.

5. A grass rendering system, characterized in that, the system includes: A first specular calculation module for rendering the grass to be rendered using a first layer of specular model, where the first layer of specular model is an improved BlinnPhong model, and the improved BlinnPhong model sets the normal vector to a fixed value; A second specular calculation module for rendering the grass to be rendered using a second layer of light transmission model; putting the calculations of the first layer of specular model and the second layer of light transmission model of the grass to be rendered into vertex calculations, and passing the calculated data to pixels, and superimposing the calculated lighting effects in the pixels; A simulated specular highlight module for performing light transmission calculations through the viewing direction and the lighting direction by the second layer of light transmission model to simulate the Fresnel specular highlights of PBR; A base color adjustment module for adjusting the local base color through the specular color intensity of the A channel of the vertex color, and the base color attenuates as the angle between the viewing direction and the lighting direction increases.

6. An electronic device, characterized in that, It includes a memory, a processor, and a computer program stored in the memory and running on the processor. When the processor executes the computer program, it implements the steps of the grass rendering method according to any one of claims 1-4.

7. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the grass rendering method according to any one of claims 1-4 are implemented.