A method, device, equipment and storage medium for grass highlight rendering
By combining the grass normal line and the terrain normal line, using the target specular reflection model and light irradiation intensity to calculate the grass highlights, the problem of messy grass highlight rendering effects in the existing technology is solved, and the integrity and user experience of the rendering effect are improved.
Patent Information
- Application Number
- CN202110696019.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-06-23
- Publication Date
- 2024-11-12
- Estimated Expiration
- 2041-06-23
AI Technical Summary
The grass highlights rendered in the prior art are messy, resulting in poor user experience.
By obtaining the grass and grass to be rendered corresponding to the grass highlight rendering event, highlight rendering is performed based on the grass normal and terrain normal, combining the target specular reflection model and light irradiation intensity, grass highlights are calculated to ensure the specificity and integrity of the rendering effect.
It realizes the integrity and specificity of the grass highlight rendering effect, and improves the uniformity of the rendering effect and user experience.
Smart Images

Figure CN113379883B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the field of computer application technology, and in particular to a grass highlight rendering method, device, equipment and storage medium. Background Art
[0002] When light hits an object, it will be reflected into the human eye. The brightest part of the object is called highlight. Grass highlight rendering has always been the top priority in three-dimensional rendering and two-dimensional cartoon rendering.
[0003] In the process of implementing the present invention, the inventors found that the prior art has the following technical problems: the grass highlights currently rendered are relatively messy in terms of performance. For example, see Figure 1 , the user experience is not good. Summary of the invention
[0004] The embodiments of the present invention provide a grass highlight rendering method, device, equipment and storage medium, which solve the problem that the grass highlights currently rendered are relatively messy in performance.
[0005] In a first aspect, an embodiment of the present invention provides a grass highlight rendering method, which may include:
[0006] When a grass highlight rendering event is detected, the grass to be rendered corresponding to the grass highlight rendering event and the grass bush to be rendered where the grass to be rendered is located are obtained;
[0007] Based on the grass normal of the grass to be rendered, highlight rendering is performed on the grass to be rendered to obtain first highlight data, and based on the terrain normal of the current position where the grass to be rendered is located, highlight rendering is performed on the grass to be rendered to obtain second highlight data;
[0008] The grass highlight of the grass to be rendered is obtained according to the first highlight data and the second highlight data.
[0009] Optionally, performing highlight rendering on the grass to be rendered based on the terrain normal of the current position where the grass to be rendered is located to obtain second highlight data may include:
[0010] Get the world matrix of the grass to be rendered, and determine the terrain normal of the current position of the grass to be rendered from the world matrix;
[0011] Perform highlight rendering on the grass to be rendered based on the terrain normal to obtain the second highlight data.
[0012] Optionally, performing highlight rendering on the grass to be rendered based on the terrain normal of the current position where the grass to be rendered is located to obtain second highlight data may include:
[0013] Obtain the terrain normal of the current position of the grass to be rendered, the grass color of the grass to be rendered, and the light normal of the light to be irradiated for irradiating the grass to be rendered;
[0014] The grass to be rendered is subjected to highlight rendering based on the terrain normal, grass color and light normal to obtain second highlight data.
[0015] Optionally, performing highlight rendering on the grass to be rendered based on the grass normal of the grass to be rendered to obtain first highlight data may include:
[0016] The grass normal and depth information of the grass to be rendered are obtained, a horizontal ambient occlusion map of the grass to be rendered is obtained according to the grass normal and the depth information, and highlight rendering is performed on the grass to be rendered according to the horizontal ambient occlusion map to obtain first highlight data.
[0017] Optionally, performing highlight rendering on the grass to be rendered based on the grass normal of the grass to be rendered to obtain first highlight data may include:
[0018] Get the grass normal of the grass to be rendered and the preset target specular reflection model;
[0019] The grass normal is input into the target specular reflection model, and the first highlight data is obtained according to the output result of the target specular reflection model;
[0020] Accordingly, performing highlight rendering on the grass to be rendered based on the terrain normal of the current position where the grass to be rendered is located to obtain second highlight data may include:
[0021] Get the terrain normal of the current position of the grass to be rendered;
[0022] The terrain normal is input into the target specular reflection model, and the second highlight data is obtained according to the output result of the target specular reflection model.
[0023] On this basis, optionally, the terrain normal is input into the target specular reflection model, which may include:
[0024] Obtaining the light intensity preset in the target specular reflection model, adjusting the light intensity, and updating the light intensity according to the adjustment result;
[0025] The terrain normal and the light intensity are input into the target specular reflection model.
[0026] Optionally, obtaining the grass highlight of the grass to be rendered according to the first highlight data and the second highlight data may include:
[0027] Respectively obtain a preset first weight corresponding to the grass normal and a second weight corresponding to the terrain normal;
[0028] Obtain first intermediate data according to the first highlight data and the first weight, and obtain second intermediate data according to the second highlight data and the second weight;
[0029] The grass highlight of the grass to be rendered is obtained according to the first intermediate data and the second intermediate data.
[0030] In a second aspect, an embodiment of the present invention further provides a grass highlight rendering device, which may include:
[0031] A grass bush to be rendered acquisition module is used to acquire the grass to be rendered corresponding to the grass highlight rendering event and the grass bush to be rendered where the grass to be rendered is located when a grass highlight rendering event is detected;
[0032] A highlight data obtaining module is used to perform highlight rendering on the grass to be rendered based on the grass normal of the grass to be rendered to obtain first highlight data, and to perform highlight rendering on the grass to be rendered based on the terrain normal of the current position where the grass to be rendered is located to obtain second highlight data;
[0033] The grass highlight rendering module is used to obtain the grass highlight of the grass to be rendered according to the first highlight data and the second highlight data.
[0034] In a third aspect, an embodiment of the present invention further provides a grass highlight rendering device, which may include:
[0035] one or more processors;
[0036] A memory for storing one or more programs;
[0037] When one or more programs are executed by one or more processors, the one or more processors implement the grass highlight rendering method provided by any embodiment of the present invention.
[0038] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the grass highlight rendering method provided by any embodiment of the present invention.
[0039] The technical solution of the embodiment of the present invention can perform highlight rendering on the grass to be rendered based on the grass normal of the grass to be rendered, and obtain the first highlight data that can represent the specificity of the grass to be rendered in the highlight effect, and perform highlight rendering on the grass to be rendered based on the terrain normal of the current position of the grass to be rendered, and obtain the second highlight data that can make the highlight effect of each blade of grass to be rendered in the grass to be rendered have better integrity; further, according to the first highlight data and the second highlight data, the grass highlight of the grass to be rendered that can take into account both specificity and integrity can be obtained. The above technical solution takes into account both the grass normal and the terrain normal during the highlight rendering process, thereby ensuring that the highlight effect of the grass to be rendered is consistent with the actual situation, and achieving the effect that each blade of grass to be rendered in the same grass to be rendered has better integrity in the highlight effect. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] Figure 1 This is the effect diagram of grass highlight rendering in the prior art;
[0041] Figure 2 is a flow chart of a grass highlight rendering method in Embodiment 1 of the present invention;
[0042] Figure 3 is a flow chart of a grass highlight rendering method in Embodiment 2 of the present invention;
[0043] Figure 4 is a flow chart of a grass highlight rendering method in Embodiment 3 of the present invention;
[0044] Figure 5 This is an effect diagram of grass highlight rendering in a grass highlight rendering method in Embodiment 3 of the present invention;
[0045] Figure 6 It is a structural block diagram of a grass highlight rendering device in Embodiment 4 of the present invention;
[0046] Figure 7 It is a structural schematic diagram of a grass highlight rendering device in Embodiment 5 of the present invention. DETAILED DESCRIPTION
[0047] The present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the present invention, rather than to limit the present invention. It is also necessary to explain that, for ease of description, only parts related to the present invention, rather than all structures, are shown in the accompanying drawings.
[0048] Before introducing the embodiments of the present invention, the research and development ideas of the grass highlight rendering method described in the embodiments of the present invention are briefly described: Since the normals of each grass to be rendered (i.e., the grass normal) may be slightly different, if the highlight rendering of each grass to be rendered is completed based only on the grass normal, this may cause the grass highlights of each grass to be rendered to have a messy light and shadow in the overall performance effect, and the integrity is poor. Based on this, after fully analyzing various situations in actual applications, the inventors proposed to complete the highlight rendering of the grass to be rendered based on both the grass normal and the terrain normal of the current position of the grass to be rendered, thereby ensuring the integrity and specificity of the rendering effect at the same time.
[0049] Embodiment 1
[0050] Figure 2 This is a flow chart of a grass highlight rendering method provided in the first embodiment of the present invention. This embodiment is applicable to the case of performing highlight rendering on grass to be rendered, and is particularly applicable to the case of performing highlight rendering on grass to be rendered based on the grass normal of the grass to be rendered and the terrain normal of the current position of the grass bush to be rendered including the grass to be rendered. This method can be executed by the grass highlight rendering device provided in the embodiment of the present invention, which can be implemented by software and / or hardware, and can be integrated in a grass highlight rendering device, which can be various user terminals or servers.
[0051] See also Figure 2 The method of the embodiment of the present invention specifically includes the following steps:
[0052] S110 . When a grass highlight rendering event is detected, obtain the grass to be rendered corresponding to the grass highlight rendering event and the grass bush to be rendered where the grass to be rendered is located.
[0053] Among them, the grass highlight rendering event may be an event triggered when highlight rendering is performed on the grass to be rendered, such as an event triggered when a loading interface containing grass to be rendered is loaded. The grass to be rendered corresponding to the grass highlight rendering event may be the grass to be highlight rendered, and the grass bush to be rendered may be a bush including the grass to be rendered. In actual applications, optionally, the number of grass to be rendered in the bush to be rendered may be one, two or more grasses, which is not specifically limited here.
[0054] It should be noted that the significance of obtaining the grass to be rendered here is that, in practical applications, the various grasses to be rendered in the grass to be rendered are relatively close in spatial position, and their highlight effects usually have a certain similarity. Therefore, when performing highlight rendering on each grass to be rendered later, some attribute information of the grass to be rendered in which it is located can be considered, thereby allowing the highlight effects of the various grasses to be rendered belonging to the same grass to be rendered to have better integrity.
[0055] S120 , performing highlight rendering on the grass to be rendered based on the grass normal of the grass to be rendered to obtain first highlight data, and performing highlight rendering on the grass to be rendered based on the terrain normal of the current position where the grass to be rendered is located to obtain second highlight data.
[0056] Among them, the highlight data can be a kind of data that can show the highlight effect, which can be displayed in the form of a picture, but it is not the final highlight effect. In practical applications, optionally, the highlight data can be data related to Lambert shading, or data related to other shading, which is not specifically limited here. The first highlight data can be the highlight data obtained after highlight rendering of the grass to be rendered based on the grass normal of the grass to be rendered, which can reflect the characteristics of the grass to be rendered, thereby avoiding the situation where the grass highlights of all the grass to be rendered are exactly the same. Exemplarily, when the grass to be rendered is bent by the wind, its grass normal will also bend accordingly, then the highlight effect shown by the first highlight data rendered based on the grass normal will also bend accordingly, that is, the highlight effect of the grass to be rendered can move with the wind, which is completely consistent with the actual situation of the grass to be rendered. In practical applications, optionally, the above-mentioned grass normal can be stored in the G buffer, which helps to quickly obtain the grass normal; of course, it can also be stored in other storage areas, which is not specifically limited here.
[0057] The second highlight data may be highlight data obtained after highlight rendering of the grass to be rendered based on the terrain normal of the current position where the grass to be rendered is located. Since the terrain normal is applicable to each grass to be rendered in the grass to be rendered, this means that the second highlight data of each grass to be rendered in the grass to be rendered is the same, which can make the highlight effect of the grass to be rendered have better integrity, and appear more fluffy and soft under certain lighting conditions, thereby solving the problem of messy light and shadow. The above-mentioned terrain normal may be the normal of the terrain at the current position. In practical applications, optionally, if the current position is rugged, that is, the number of terrain normals at the current position includes at least two, the above-mentioned terrain normal used for highlight rendering may be the normal obtained after processing the normals of each terrain, such as using the mean, median, mode, etc. of each terrain normal as the terrain normal used for highlight rendering.
[0058] S130 . Obtain grass highlights of the grass to be rendered according to the first highlight data and the second highlight data.
[0059] Among them, the first highlight data can reflect the specificity of the highlight effect of each grass to be rendered, and the second highlight data can reflect the integrity of the highlight effect of each grass to be rendered. Therefore, the grass highlight of the grass to be rendered obtained according to the first highlight data and the second highlight data can be a highlight effect that can reflect both specificity and integrity, that is, it can show the actual light and shadow conditions of the grass to be rendered, and will not cause a relatively messy highlight effect of the light and shadow of the grass to be rendered composed of the various grasses to be rendered.
[0060] In practical applications, optionally, the grass highlight can be obtained in a variety of ways, such as processing the summed mean of two highlight data to obtain the grass highlight, or processing the weighted sum of two highlight data to obtain the grass highlight. Of course, other ways can also be used to obtain the grass highlight, which are not specifically limited here. On this basis, optionally, the specific implementation method of obtaining the grass highlight by processing the weighted sum of two highlight data can be: respectively obtaining a pre-set first weight corresponding to the grass normal and a second weight corresponding to the terrain normal; obtaining first intermediate data according to the first highlight data and the first weight, and obtaining second intermediate data according to the second highlight data and the second weight; obtaining the grass highlight of the grass to be rendered according to the first intermediate data and the second intermediate data. Among them, the first weight can represent the influence of the grass normal (or the first highlight data) on the grass highlight, and the second weight can represent the influence of the terrain normal (or the second highlight data) on the grass highlight. In other words, the numerical value between the pre-set first weight and the second weight can represent whether the final grass highlight is more affected by the grass normal (i.e. specificity) or the terrain normal (i.e. integrity), thereby obtaining a grass highlight that is consistent with actual performance requirements.
[0061] The technical solution of the embodiment of the present invention can perform highlight rendering on the grass to be rendered based on the grass normal of the grass to be rendered, and obtain the first highlight data that can represent the specificity of the grass to be rendered in the highlight effect, and perform highlight rendering on the grass to be rendered based on the terrain normal of the current position of the grass to be rendered, and obtain the second highlight data that can make the highlight effect of each blade of grass to be rendered in the grass to be rendered have better integrity; further, according to the first highlight data and the second highlight data, the grass highlight of the grass to be rendered that can take into account both specificity and integrity can be obtained. The above technical solution takes into account both the grass normal and the terrain normal during the highlight rendering process, thereby ensuring that the highlight effect of the grass to be rendered is consistent with the actual situation, and achieving the effect that each blade of grass to be rendered in the same grass to be rendered has better integrity in the highlight effect.
[0062] On this basis, optionally, highlight rendering of the grass to be rendered based on the terrain normal of the current position of the grass to be rendered to obtain the second highlight data may include: obtaining the world matrix of the grass to be rendered, determining the terrain normal of the current position of the grass to be rendered from the world matrix; and highlight rendering of the grass to be rendered based on the terrain normal to obtain the second highlight data. Among them, the world matrix (The object-to-world matrix) can be a matrix for storing the conversion results after the grass model (object) of the grass to be rendered is placed in the world space and the data originally stored in the vertices of the grass model is converted into world space coordinates. The world matrix may store the magnification, distortion, deformation and other parameters of the grass to be rendered. On this basis, in order to quickly obtain the terrain normal corresponding to the grass to be rendered, the embodiment of the present invention proposes to store the terrain normal in the world matrix in advance, so that the terrain normal can be directly obtained from the world matrix when the grass is highlighted, thereby improving the rendering speed of the grass highlight.
[0063] Optionally, highlight rendering of the grass to be rendered based on the terrain normal of the current position where the grass to be rendered is located to obtain the second highlight data may include: obtaining the terrain normal of the current position where the grass to be rendered is located, the grass color of the grass to be rendered, and the light normal of the light to be illuminated for illuminating the grass to be rendered; highlight rendering of the grass to be rendered based on the terrain normal, the grass color and the light normal to obtain the second highlight data. Among them, when highlight rendering of the grass based on the terrain normal, the grass color of the grass to be rendered and the light normal of the light to be illuminated for illuminating the grass to be rendered (i.e., the light propagation direction of the light to be illuminated) may also be considered at the same time, thereby obtaining the second highlight data that can represent the grass color and the light propagation direction, thereby improving the matching degree of the subsequently obtained grass highlight with the actual situation.
[0064] Optionally, highlight rendering of the grass to be rendered based on the grass normal of the grass to be rendered to obtain first highlight data may include: obtaining the grass normal and depth information of the grass to be rendered, obtaining a horizontal ambient occlusion (HBAO) map of the grass to be rendered based on the grass normal and the depth information, and then highlight rendering of the grass to be rendered based on the HBAO map to obtain first highlight data. Wherein, when performing grass highlight rendering based on the grass normal, the depth information of the grass to be rendered may also be considered at the same time. The depth information may indicate the distance between the grass to be rendered and the picture capturing device (such as a video camera or a camera), thereby obtaining an HBAO map in real time based on the two, and then completing grass highlight rendering based on the HBAO map, thereby obtaining first highlight data that can indicate the depth information, thereby improving the matching degree between the subsequently obtained grass highlights and the actual situation.
[0065] Embodiment 2
[0066] Figure 3 It is a flow chart of a grass highlight rendering method provided in the second embodiment of the present invention. This embodiment is optimized based on the above-mentioned technical solutions. In this embodiment, optionally, highlight rendering of the grass to be rendered is performed based on the grass normal of the grass to be rendered to obtain the first highlight data, which may include: obtaining the grass normal of the grass to be rendered, and a pre-set target mirror reflection model; inputting the grass normal into the target mirror reflection model, and obtaining the first highlight data according to the output result of the target mirror reflection model; correspondingly, highlight rendering of the grass to be rendered is performed based on the terrain normal of the current position where the grass to be rendered is located to obtain the second highlight data, which may include: obtaining the terrain normal of the current position where the grass to be rendered is located; inputting the terrain normal into the target mirror reflection model, and obtaining the second highlight data according to the output result of the target mirror reflection model. Among them, the explanations of the terms that are the same or corresponding to the above-mentioned embodiments are not repeated here.
[0067] See also Figure 3 The method of this embodiment may specifically include the following steps:
[0068] S210 . When a grass highlight rendering event is detected, obtain the grass to be rendered corresponding to the grass highlight rendering event and the grass bush to be rendered where the grass to be rendered is located.
[0069] S220, obtaining a grass normal of the grass to be rendered and a preset target mirror reflection model, inputting the grass normal into the target mirror reflection model, and obtaining first highlight data according to an output result of the target mirror reflection model.
[0070] Among them, considering that the grass to be rendered is brighter along the light to be irradiated, this is a bit like the lighting characteristics of plastic, that is, it has a certain light-gathering property. Therefore, in order to better show the highlight effect of the grass to be rendered, the embodiment of the present invention proposes that the lighting model (i.e., the rendering equation) used in the grass highlight rendering process can be a target specular reflection model, which can be a model that can present a specular reflection effect, such as a Blinn-Phong specular reflection model, a Phongspecular specular reflection model, etc., thereby brightening the highlight effect of the grass to be rendered. The above-mentioned target specular reflection model can be applied in the process of obtaining the first highlight data and / or the second highlight data, and no specific limitation is made here. Accordingly, the grass normal can be input into the target specular reflection model, and the first highlight data can be obtained according to the output result of the target specular reflection model.
[0071] S230, obtaining the terrain normal of the current position where the grass to be rendered is located, and inputting the terrain normal into the target specular reflection model, and obtaining the second highlight data according to the output result of the target specular reflection model.
[0072] Among them, the target mirror reflection model that uses the grass normal as input data and the target mirror reflection model that uses the terrain normal as input data can be completely the same in model parameters, or there can be some differences, which are not specifically limited here.
[0073] S240 , obtaining grass highlights of the grass to be rendered according to the first highlight data and the second highlight data.
[0074] The technical solution of the embodiment of the present invention fully takes into account the light-gathering property of the grass to be rendered, and applies a target specular reflection model that can present a specular reflection effect as a lighting model in the process of grass highlight rendering, thereby achieving the effect of brightening the grass highlights finally rendered.
[0075] An optional technical solution, inputting the terrain normal into the target mirror reflection model, may include: obtaining the light irradiation intensity pre-set in the target mirror reflection model, adjusting the light irradiation intensity, and updating the light irradiation intensity according to the adjustment result; inputting the terrain normal and the light irradiation intensity into the target mirror reflection model. Among them, in order to allow the target mirror reflection model to better adapt to the characteristics of the grass to be rendered, the light irradiation intensity pre-set in the target mirror reflection model may be adjusted according to the characteristics, and the light irradiation intensity may represent the irradiation intensity of the light to be irradiated, and then the terrain normal and the adjusted light irradiation intensity are input into the target mirror reflection model. That is to say, when the light irradiation intensity is not adjusted, it is not necessary to input the light irradiation intensity as input data into the target mirror reflection model, because the target mirror reflection model can obtain the default light irradiation intensity from itself; accordingly, after the light irradiation intensity is adjusted, the adjusted light irradiation intensity may be input as input data into the target mirror reflection model so that it can be applied to the latest light irradiation intensity. The above technical solution can obtain second highlight data that better matches the characteristics of the grass to be rendered, further brightening the grass highlights rendered subsequently. In practical applications, optionally, the above light intensity adjustment process can also be applied to the process of obtaining the first highlight data, that is, inputting the grass normal into the target mirror reflection model, and obtaining the first highlight data based on the output result of the target mirror reflection model, which may include: inputting the grass normal and the light intensity (i.e., the adjusted light intensity) into the target mirror reflection model, and obtaining the first highlight data based on the output result of the target mirror reflection model, etc., which are not specifically limited here.
[0076] Embodiment 3
[0077] Figure 4 1 is a flow chart of a grass highlight rendering method provided in Embodiment 3 of the present invention. This embodiment is optimized based on the above technical solutions. The explanations of the terms that are the same or corresponding to the above embodiments are not repeated here.
[0078] See also Figure 4 The method of this embodiment may specifically include the following steps:
[0079] S310 . When a grass highlight rendering event is detected, obtain the grass to be rendered corresponding to the grass highlight rendering event and the grass bush to be rendered where the grass to be rendered is located.
[0080] S320. Input the grass normal and depth information of the grass to be rendered into a preset target mirror reflection model, so that the target mirror reflection model obtains a horizontal ambient occlusion map of the grass to be rendered according to the grass normal and depth information, and outputs the first highlight data of the grass to be rendered according to the horizontal ambient occlusion map.
[0081] Among them, another implementation process of this step can be to first obtain a horizontal ambient occlusion map based on the grass normal and depth information, then input the horizontal ambient occlusion map into the target mirror reflection model, and obtain the first highlight data based on the output result in the target mirror reflection model, which has a faster processing speed.
[0082] S330, determining the terrain normal of the current position of the grass to be rendered from the world matrix of the grass to be rendered, and adjusting the light illumination intensity pre-set in the target mirror reflection model.
[0083] S340, input the terrain normal, the grass color of the grass to be rendered, the light normal of the light to be illuminated for illuminating the grass to be rendered, and the adjusted light illumination intensity into the target mirror reflection model, and obtain the second highlight data of the grass to be rendered according to the output result of the target mirror reflection model.
[0084] Among them, S340 may be a step executed after S330, and S320 may be a step executed after S310 and before S350. The order of execution relative to S330 and S340 is arbitrary and is not specifically limited here.
[0085] S350, obtaining first intermediate data according to the first weight and first highlight data corresponding to the grass normal, and obtaining second intermediate data according to the second weight and second highlight data corresponding to the terrain normal, and obtaining grass highlights of the grass to be rendered according to the first intermediate data and the second intermediate data.
[0086] For example, the highlight effect of the grass to be rendered composed of multiple grasses to be rendered by the above technical solution is as follows: Figure 5 As shown, it can be seen that the grasses to be rendered have a certain degree of uniformity in light and shadow effects, and can also reflect the sense of bending after being affected by the wind, which is consistent with the actual situation.
[0087] The technical solution of the embodiment of the present invention can ensure the integrity of the highlight effect of each grass to be rendered in the same grass to be rendered through the application of terrain normals, and can further brighten the highlight effect through the application of a target mirror reflection model, thereby improving the user experience from different angles.
[0088] Embodiment 4
[0089] Figure 6 This is a structural block diagram of a grass highlight rendering device provided in Embodiment 4 of the present invention. The device is used to execute the grass highlight rendering method provided in any of the above embodiments. The device and the grass highlight rendering method in the above embodiments belong to the same inventive concept. For details not described in detail in the embodiments of the grass highlight rendering device, please refer to the embodiments of the above grass highlight rendering method. Figure 6 The device may specifically include: a grass acquisition module 410 for rendering, a highlight data acquisition module 420 and a grass highlight rendering module 430.
[0090] The to-be-rendered grass bush acquisition module 410 is used to acquire the to-be-rendered grass corresponding to the grass highlight rendering event and the to-be-rendered grass bush where the to-be-rendered grass is located when a grass highlight rendering event is detected;
[0091] The highlight data obtaining module 420 is used to perform highlight rendering on the grass to be rendered based on the grass normal of the grass to be rendered to obtain first highlight data, and to perform highlight rendering on the grass to be rendered based on the terrain normal of the current position where the grass to be rendered is located to obtain second highlight data;
[0092] The grass highlight rendering module 430 is used to obtain grass highlights of the grass to be rendered according to the first highlight data and the second highlight data.
[0093] Optionally, the highlight data obtaining module 420 may include:
[0094] A terrain normal determination unit, used for obtaining a world matrix of the grass to be rendered, and determining a terrain normal of a current position of the grass to be rendered from the world matrix;
[0095] The second highlight data obtaining unit is used to perform highlight rendering on the grass to be rendered based on the terrain normal to obtain second highlight data.
[0096] Optionally, the highlight data obtaining module 420 may include:
[0097] A light normal acquisition unit, used to acquire the terrain normal of the current position where the grass to be rendered is located, the grass color of the grass to be rendered, and the light normal of the light to be irradiated for irradiating the grass to be rendered;
[0098] The second highlight data obtaining unit is used for performing highlight rendering on the grass to be rendered based on the terrain normal, the grass color and the light normal to obtain second highlight data.
[0099] Optionally, the highlight data obtaining module 420 may include:
[0100] The first highlight data obtaining unit is used to obtain the grass normal and depth information of the grass to be rendered, obtain the horizontal ambient occlusion map of the grass to be rendered according to the grass normal and depth information, and perform highlight rendering on the grass to be rendered according to the horizontal ambient occlusion map to obtain the first highlight data.
[0101] Optionally, the highlight data obtaining module 420 may include:
[0102] A target mirror reflection model acquisition unit, used to acquire the grass normal of the grass to be rendered and a preset target mirror reflection model;
[0103] A first highlight data obtaining unit, used for inputting the grass normal into a target mirror reflection model, and obtaining first highlight data according to an output result of the target mirror reflection model;
[0104] A terrain normal acquisition unit, used to acquire the terrain normal of the current position where the grass to be rendered is located;
[0105] The second highlight data obtaining unit is used to input the terrain normal into the target mirror reflection model, and obtain the second highlight data according to the output result of the target mirror reflection model.
[0106] On this basis, optionally, the second highlight data obtaining unit may include:
[0107] The light intensity updating subunit is used to obtain the light intensity preset in the target mirror reflection model, adjust the light intensity, and update the light intensity according to the adjustment result;
[0108] The light intensity input subunit is used to input the terrain normal and the light intensity into the target specular reflection model.
[0109] Optionally, the grass highlight rendering module 430 may include:
[0110] A weight acquisition unit, used to respectively acquire a preset first weight corresponding to a grass normal and a second weight corresponding to a terrain normal;
[0111] An intermediate data obtaining unit, configured to obtain first intermediate data according to the first highlight data and the first weight, and obtain second intermediate data according to the second highlight data and the second weight;
[0112] The grass highlight rendering unit is used to obtain the grass highlight of the grass to be rendered according to the first intermediate data and the second intermediate data.
[0113] The grass highlight rendering device provided in the fourth embodiment of the present invention cooperates with the grass to be rendered acquisition module and the highlight data acquisition module. After obtaining the grass to be rendered corresponding to the detected grass highlight rendering event and the grass to be rendered where the grass to be rendered is located, the grass to be rendered can be highlighted based on the grass normal of the grass to be rendered to obtain the first highlight data that can represent the specificity of the grass to be rendered in the highlight effect, and the grass to be rendered can be highlighted based on the terrain normal of the current position where the grass to be rendered is located to obtain the second highlight data that can make the highlight effect of each grass to be rendered in the grass to be rendered where the grass to be rendered is located better. In addition, the grass highlight rendering module can obtain the grass highlight of the grass to be rendered that can take into account both the specificity and the integrity according to the first highlight data and the second highlight data. The above device takes into account the grass normal and the terrain normal at the same time during the highlight rendering process, thereby ensuring that the highlight effect of the grass to be rendered is consistent with the actual situation, and achieving the effect that each grass to be rendered in the same grass to be rendered has a better integrity in the highlight effect.
[0114] The grass highlight rendering device provided in the embodiment of the present invention can execute the grass highlight rendering method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0115] It is worth noting that in the embodiment of the above-mentioned grass highlight rendering device, the various units and modules included are only divided according to functional logic, but are not limited to the above-mentioned division, as long as the corresponding functions can be achieved; in addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of the present invention.
[0116] Embodiment 5
[0117] Figure 7 A structural schematic diagram of a grass highlight rendering device provided in Embodiment 5 of the present invention is shown as follows: Figure 7 As shown, the device includes a memory 510, a processor 520, an input device 530, and an output device 540. The number of processors 520 in the device can be one or more. Figure 7 A processor 520 is used as an example; the memory 510, the processor 520, the input device 530 and the output device 540 in the device can be connected via a bus or other means. Figure 7 The connection via bus 550 is taken as an example.
[0118] The memory 510, as a computer-readable storage medium, can be used to store software programs, computer executable programs and modules, such as program instructions / modules corresponding to the grass highlight rendering method in the embodiment of the present invention (for example, the to-be-rendered grass acquisition module 410, the highlight data acquisition module 420 and the grass highlight rendering module 430 in the grass highlight rendering device). The processor 520 executes various functional applications and data processing of the device by running the software programs, instructions and modules stored in the memory 510, that is, implements the above-mentioned grass highlight rendering method.
[0119] The memory 510 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system and at least one application required for a function; the data storage area may store data created according to the use of the device, etc. In addition, the memory 510 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some instances, the memory 510 may further include a memory remotely arranged relative to the processor 520, and these remote memories may be connected to the device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0120] The input device 530 may be used to receive input digital or character information and generate key signal input related to user settings and function control of the device. The output device 540 may include a display device such as a display screen.
[0121] Embodiment 6
[0122] Embodiment 6 of the present invention provides a storage medium including computer executable instructions, wherein the computer executable instructions are used to execute a grass highlight rendering method when executed by a computer processor. The method may include:
[0123] When a grass highlight rendering event is detected, the grass to be rendered corresponding to the grass highlight rendering event and the grass bush to be rendered where the grass to be rendered is located are obtained;
[0124] Based on the grass normal of the grass to be rendered, highlight rendering is performed on the grass to be rendered to obtain first highlight data, and based on the terrain normal of the current position where the grass to be rendered is located, highlight rendering is performed on the grass to be rendered to obtain second highlight data;
[0125] The grass highlight of the grass to be rendered is obtained according to the first highlight data and the second highlight data.
[0126] Of course, the storage medium containing computer executable instructions provided by an embodiment of the present invention is not limited to the method operations described above, and the computer executable instructions can also execute related operations in the grass highlight rendering method provided by any embodiment of the present invention.
[0127] Through the above description of the implementation methods, the technicians in the relevant field can clearly understand that the present invention can be implemented by means of software and necessary general hardware, and of course it can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as a computer floppy disk, read-only memory (ROM), random access memory (RAM), flash memory (FLASH), hard disk or optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, server, or network device, etc.) to execute the methods described in each embodiment of the present invention.
[0128] Note that the above are only preferred embodiments of the present invention and the technical principles used. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present invention, and the scope of the present invention is determined by the scope of the appended claims.
Claims
1. A grass highlight rendering method, characterized in that: include: When a grass highlight rendering event is detected, obtaining the grass to be rendered corresponding to the grass highlight rendering event and the grass bush to be rendered where the grass to be rendered is located; Performing highlight rendering on the grass to be rendered based on the grass normal of the grass to be rendered to obtain first highlight data, and performing highlight rendering on the grass to be rendered based on the terrain normal of the current position where the grass to be rendered is located to obtain second highlight data; wherein the highlight effect shown by the first highlight data rendered based on the grass normal of the grass to be rendered changes with the change of the grass normal of the grass to be rendered; Obtaining grass highlights of the grass to be rendered according to the first highlight data and the second highlight data; The step of performing highlight rendering on the grass to be rendered based on the grass normal of the grass to be rendered to obtain first highlight data includes: Acquire grass normal and depth information of the grass to be rendered, obtain a horizontal ambient occlusion map of the grass to be rendered according to the grass normal and the depth information, and perform highlight rendering on the grass to be rendered according to the horizontal ambient occlusion map to obtain the first highlight data; The step of performing highlight rendering on the grass to be rendered based on the terrain normal of the current position of the grass to be rendered to obtain second highlight data includes: Acquire the terrain normal of the current position of the grass to be rendered, the grass color of the grass to be rendered, and the light normal of the light to be irradiated for irradiating the grass to be rendered; The terrain normal, the grass color of the grass to be rendered, the light normal of the light to be irradiated for irradiating the grass to be rendered, and the adjusted light irradiation intensity are input into the target mirror reflection model, and the second highlight data is obtained according to the output result of the target mirror reflection model.
2. The method according to claim 1, characterized in that Obtaining the terrain normal of the current position of the grass to be rendered, including: The world matrix of the grass to be rendered is obtained, and the terrain normal of the current position of the grass to be rendered is determined from the world matrix.
3. The method according to claim 1, characterized in that The obtaining of the grass normal and depth information of the grass to be rendered, obtaining a horizontal ambient occlusion map of the grass to be rendered according to the grass normal and the depth information, and performing highlight rendering on the grass to be rendered according to the horizontal ambient occlusion map to obtain the first highlight data includes: Acquire the grass normal and depth information of the grass to be rendered, obtain a horizontal ambient occlusion map of the grass to be rendered according to the grass normal and the depth information, input the horizontal ambient occlusion map into the target specular reflection model, and obtain the first highlight data according to an output result in the target specular reflection model; or, Obtain the grass normal and depth information of the grass to be rendered, input the grass normal and the depth information into the target mirror reflection model, obtain the horizontal ambient occlusion map of the grass to be rendered, and output the first highlight data of the grass to be rendered according to the horizontal ambient occlusion map.
4. The method according to claim 1, characterized in that: The step of inputting the terrain normal, the grass color of the grass to be rendered, the light normal of the light to be irradiated for irradiating the grass to be rendered, and the adjusted light irradiation intensity into the target specular reflection model comprises: Obtaining the light irradiation intensity preset in the target specular reflection model, adjusting the light irradiation intensity, and updating the light irradiation intensity according to the adjustment result; The terrain normal, the grass color of the grass to be rendered, the light normal of the light to be irradiated for irradiating the grass to be rendered, and the adjusted light irradiation intensity are input into the target specular reflection model.
5. The method according to claim 1, characterized in that The obtaining the grass highlight of the grass to be rendered according to the first highlight data and the second highlight data includes: Respectively obtaining a preset first weight corresponding to the grass normal and a second weight corresponding to the terrain normal; Obtaining first intermediate data according to the first highlight data and the first weight, and obtaining second intermediate data according to the second highlight data and the second weight; The grass highlight of the grass to be rendered is obtained according to the first intermediate data and the second intermediate data.
6. A grass highlight rendering device, characterized in that: include: A grass bush to be rendered acquisition module is used to acquire the grass to be rendered corresponding to the grass highlight rendering event and the grass bush to be rendered where the grass to be rendered is located when a grass highlight rendering event is detected; A highlight data obtaining module, configured to perform highlight rendering on the grass to be rendered based on the grass normal of the grass to be rendered to obtain first highlight data, and to perform highlight rendering on the grass to be rendered based on the terrain normal of the current position where the grass to be rendered is located to obtain second highlight data; wherein the highlight effect expressed by the first highlight data rendered based on the grass normal of the grass to be rendered changes with the change of the grass normal of the grass to be rendered; A grass highlight rendering module, used for obtaining grass highlights of the grass to be rendered according to the first highlight data and the second highlight data; The highlight data acquisition module includes: a first highlight data obtaining unit, configured to obtain a grass normal and depth information of the grass to be rendered, obtain a horizontal ambient occlusion map of the grass to be rendered according to the grass normal and the depth information, and perform highlight rendering on the grass to be rendered according to the horizontal ambient occlusion map to obtain the first highlight data; Wherein, the highlight data obtaining module further includes: A light normal acquisition unit, used to acquire the terrain normal of the current position where the grass to be rendered is located, the grass color of the grass to be rendered, and the light normal of the light to be irradiated for irradiating the grass to be rendered; The second highlight data obtaining unit is used to input the terrain normal, the grass color of the grass to be rendered, the light normal of the light to be irradiated for irradiating the grass to be rendered, and the adjusted light irradiation intensity into the target mirror reflection model, and obtain the second highlight data according to the output result of the target mirror reflection model.
7. A grass highlight rendering device, characterized in that: include: one or more processors; A memory for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the grass highlight rendering method as described in any one of claims 1-5.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the grass highlight rendering method as described in any one of claims 1-5 is implemented.
Citation Information
Patent Citations
Picture rendering method and device, equipment and medium
CN111882637A
Picture rendering method and device, equipment and medium
CN111882638A
Target vegetation model rendering display method and device, equipment and storage medium
CN112862968A
