Vegetation instance rendering method and device, storage medium, equipment and program product
By generating vegetation instances on the base model and using the relative height information of the vegetation vertices to determine the simulated ambient light occlusion value for rendering, the problem of balancing the rendering efficiency of micro-vegetation with visual detail in existing technologies is solved, achieving a high-efficiency improvement in stereoscopic sense and visual realism.
Patent Information
- Application Number
- CN202610274750.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-03-05
- Publication Date
- 2026-04-28
AI Technical Summary
Existing technologies struggle to balance rendering efficiency and visual detail when rendering micro-vegetation, resulting in poor three-dimensionality and visual realism in vegetation rendering, and a noticeable 'floating' phenomenon.
By generating vegetation instances on the base model and using the relative height information of vegetation vertices relative to the surface of the base model to determine the simulated ambient light occlusion value for rendering, the complex light and shadow effects between microscopic vegetation clusters are accurately simulated.
It significantly improves the three-dimensionality and visual realism of vegetation rendering, eliminates visual flatness and floating phenomena, and has low computational cost.
Smart Images

Figure CN121937607A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of graphics rendering technology, specifically to a method, apparatus, storage medium, device, and program product for rendering vegetation instances. Background Technology
[0002] With the rapid development of computer graphics and virtual reality technologies, procedural content generation (PCG) has become a core method for constructing large-scale open-world scenes. In the simulation rendering of natural environments, micro-vegetation such as moss and lichen are frequently occurring environmental elements, and their rendering quality directly determines the scene's detail and immersion. Related technologies typically employ batch generation of vegetation models on base models such as rocks or ground, and then use a combination of texture mapping and lighting calculations to simulate the visual effect of vegetation cover.
[0003] However, when rendering such dense micro-vegetation, related technologies struggle to balance rendering efficiency and visual detail. Traditional rendering strategies typically rely on general ambient occlusion (AO) algorithms or high-precision physically based lighting models (such as subsurface scattering). This general approach, primarily based on screen-space depth information or complex global illumination calculations, struggles to accurately simulate the intricate shadows and gaps between vegetation clusters. This results in rendered moss appearing overly flat and lacking volume, exhibiting a noticeable "floating" effect.
[0004] Therefore, the three-dimensionality and visual realism of vegetation rendering in related technologies are poor. Summary of the Invention
[0005] This application provides a vegetation instance rendering method, apparatus, storage medium, device, and program product. By generating vegetation instances on a base model and using the relative height information of vegetation vertices relative to the surface of the base model to determine the simulated ambient light occlusion value for rendering, it can accurately simulate the complex light and shadow effects between microscopic vegetation clusters with low computational cost, significantly improving the three-dimensionality and visual realism of vegetation rendering.
[0006] On one hand, embodiments of this application provide a method for rendering vegetation instances, the method comprising: Obtain the base model; Multiple vegetation instances are generated on the base model; For each vegetation vertex of the vegetation instance, the simulated ambient light occlusion value of each vegetation vertex is determined based on the relative height information of the vegetation vertex relative to the surface of the base model. The vegetation instance is rendered based on the simulated ambient light occlusion value.
[0007] On the other hand, embodiments of this application provide a vegetation instance rendering apparatus, the apparatus comprising: Acquisition unit, used to acquire the base model; A generation unit is used to generate multiple vegetation instances on the base model; The determining unit is used to determine the simulated ambient light occlusion value of each vegetation vertex of the vegetation instance based on the relative height information of the vegetation vertex relative to the surface of the base model. The rendering unit is used to render the vegetation instance based on the simulated ambient light occlusion value.
[0008] On the other hand, embodiments of this application provide a computer-readable storage medium storing a computer program adapted for loading by a processor to execute the vegetation instance rendering method as described in any of the above embodiments.
[0009] On the other hand, embodiments of this application provide a computer device, which includes a processor and a memory. The memory stores a computer program, and the processor executes the vegetation instance rendering method as described in any of the above embodiments by calling the computer program stored in the memory.
[0010] On the other hand, embodiments of this application provide a computer program product, including computer instructions, which, when executed by a processor, implement the vegetation instance rendering method as described in any of the above embodiments.
[0011] The vegetation instance rendering method provided in this application provides the following steps: obtaining a base model; generating multiple vegetation instances on the base model; determining the simulated ambient occlusion value of each vegetation vertex based on the relative height information of the vegetation vertex relative to the surface of the base model; and rendering the vegetation instances based on the simulated ambient occlusion value. This method generates vegetation instances on the base model and uses the relative height information of the vegetation vertices relative to the surface of the base model to determine the simulated ambient occlusion value for rendering. This solves the problems of related technologies relying on general ambient occlusion algorithms, which lead to the loss of shadow details in vegetation gaps, planar visual presentation, and obvious floating phenomenon. It can accurately simulate the complex light and shadow effects between microscopic vegetation clusters with low computational cost, significantly improving the three-dimensionality and visual realism of vegetation rendering. Attached Figure Description
[0012] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0013] Figure 1 This is a schematic diagram of the architecture of a vegetation instance rendering system provided in one embodiment of this application.
[0014] Figure 2 This is a flowchart illustrating the vegetation instance rendering method provided in an embodiment of this application.
[0015] Figure 3 A schematic diagram of the base model provided in the embodiments of this application.
[0016] Figure 4 This is a material diagram of a vegetation example provided in an embodiment of this application.
[0017] Figure 5 A schematic diagram of a scene of artificially drawn growth potential provided for an embodiment of this application.
[0018] Figure 6 This is a diagram illustrating the effect of planting vegetation in an example provided in this application.
[0019] Figure 7 This is a schematic diagram illustrating the calculation of the target height value of the vegetation apex provided in an embodiment of this application.
[0020] Figure 8 This is a schematic diagram of simulated ambient light occlusion values provided in an embodiment of this application.
[0021] Figure 9 This is the original moss material effect provided in the embodiments of this application without applying simulated ambient light occlusion values.
[0022] Figure 10 The effect of moss material after calculating the ambient light occlusion value in the application simulation provided in this embodiment of the application.
[0023] Figure 11 This is a schematic diagram illustrating the effect of moss instance after overlaying stylized edge light components on top of the base rendering, as provided in an embodiment of this application.
[0024] Figure 12 This is a schematic diagram illustrating the effect of a moss instance after overlaying stylized edge light components and stylized specular components on top of a base rendering, as provided in an embodiment of this application.
[0025] Figure 13 This is a schematic diagram of the vegetation instance rendering device provided in an embodiment of this application.
[0026] Figure 14 A schematic diagram of the structure of a computer device provided in an embodiment of this application. Detailed Implementation
[0027] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0028] This application provides a vegetation instance rendering method, apparatus, storage medium, device, and program product. Specifically, the vegetation instance rendering method of this application can be executed by a computer device, which can be a terminal or a server. The terminal can be a smartphone, tablet, laptop, smart TV, wearable smart device, smart vehicle terminal, etc. The terminal can also include a client, which can be a game client, browser client, instant messaging client, or mini-program, etc. The server can be an independent physical server, a server cluster composed of multiple physical servers, or a distributed system. It can also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDN), and big data and artificial intelligence platforms.
[0029] It should be noted that, in this embodiment, the execution entity of the vegetation instance rendering method can be a terminal device or a server. The terminal device can be a local terminal device or a client device in the aforementioned cloud gaming. This embodiment does not limit the type of execution entity.
[0030] First, some of the nouns or terms that appear in the description of the embodiments of this application are explained as follows: Base model: A three-dimensional object that serves as an attachment carrier and provides a growth surface. More specifically, it refers to a three-dimensional mesh model in computer graphics, which contains geometric and topological information such as vertex coordinates, normal vectors, UV coordinates, and vertex colors. It is the geometric reference for calculating the distribution of vegetation and lighting relationships. In actual game or simulation scenarios, the base model can be a rock model, tree trunk model, terrain model, wall building model, or any static scene object that needs to be covered by micro-vegetation.
[0031] Vegetation Examples: Target rendering objects generated on the surface of the base model to represent the visual effects of micro-vegetation. Specifically, they are moss, lichen, low-lying ground cover plants, fungal clusters, or similar dense micro-vegetation attached to the surface of the base model.
[0032] Growth potential: refers to the weighted parameters used to control the distribution probability and growth scale of vegetation instances on the surface of the substrate model. For example, the intensity value stored in the red (R) channel of the substrate model vertex color; or ambient light occlusion data reflecting the depth of the gaps in the substrate model, calculated by an algorithm.
[0033] Noise intensity value: refers to a continuously changing value calculated or sampled in real time based on spatial coordinates using a pseudo-random algorithm. It ensures that vegetation does not appear mechanically artificially arranged, but rather presents a natural clustered or mottled distribution. Specifically, it can be a value calculated using Berlin noise or simplex noise functions, or a grayscale value obtained by sampling a preset Gaussian noise texture.
[0034] Simulated ambient occlusion value: refers to a decay coefficient related to the height of vegetation vertices. Unlike traditional AO calculations based on ray tracing or screen space, the simulated AO value in this application is calculated based on the ratio of the "shortest geometric distance from the vegetation vertex to the base surface" to the "maximum growth height," and is used to darken the root color during rendering. Specifically, it is represented as a floating-point number stored in the vertex attributes of the vegetation instance; the smaller the value, the closer to the root (darker), and the larger the value, the closer to the top (brighter).
[0035] Target normal vector: refers to the normal vector used in the lighting calculation stage to determine the direction of light reflection, thereby determining the final brightness and darkness of the pixel.
[0036] Distribution height parameter: refers to the comprehensive control parameter that determines the final generated state of vegetation instances (whether they exist and their specific size).
[0037] Please see Figure 1 , Figure 1 This is a schematic diagram of the architecture of a vegetation instance rendering system provided in one embodiment of this application. The system may include a terminal 1000, a server 2000, and a network 3000.
[0038] In some embodiments, server 2000 can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. Server 2000 is mainly used to store 3D model resources (such as base models), high-precision noise texture libraries, and pre-trained geometric analysis algorithm models.
[0039] Network 3000 is used to provide a communication link between terminal 1000 and server 2000. Network 3000 may include various connection types, such as wired, wireless communication links or fiber optic cables.
[0040] Terminal 1000 can be a smartphone, tablet, laptop, desktop computer, smart speaker, smartwatch, etc., but is not limited to these. Terminal 1000 has applications that support 3D graphics rendering (such as game engine editors, 3D modeling software, or large 3D game clients) installed and running on it.
[0041] Specifically, during system operation, terminal 1000 first obtains a base model (such as a rock, tree trunk, or ground surface model) from server 2000 via network 3000. Subsequently, terminal 1000 is configured to generate multiple vegetation instances (such as moss, lichen, etc.) on the base model.
[0042] During the generation phase, for each base vertex of the base model, terminal 1000 determines the growth potential energy and maximum height threshold of the base vertex. In some embodiments, terminal 1000 performs topological analysis on the base model through a built-in geometric analysis module, extracting curvature, slope, or base ambient light shading data to automatically calculate the growth potential energy; in other implementation scenarios, terminal 1000 obtains the growth potential energy by reading the base vertex color channel information (such as red channel intensity). Based on the spatial location information of the base vertices, terminal 1000 calls a preset noise generation algorithm (such as the Berlin noise algorithm or the simplex noise algorithm) to calculate the noise intensity value corresponding to the base vertex in real time, and multiplies the maximum height threshold, growth potential energy, and noise intensity value to obtain the distribution height parameter, and instantiates multiple vegetation instances on the surface of the base model according to the distribution height parameter.
[0043] During the data processing and pre-computation phase, for each generated vegetation instance, terminal 1000 calculates the shortest distance from each vegetation vertex to the surface of the base model as the target height value, and calculates the ratio of this target height value to the maximum generated height value to determine the simulated ambient occlusion value. To optimize runtime rendering efficiency, terminal 1000 writes or stores the calculated simulated ambient occlusion value into the second vertex attribute data (e.g., the alpha channel of the vertex color) of the vegetation instance.
[0044] During the rendering phase, the terminal 1000 executes the shader program to complete the final visual presentation. The terminal 1000 reads the simulated ambient occlusion value from the vertex attribute data of the vegetation instance and obtains the gap reference color (darker) and the original reference color (brighter). Using the simulated ambient occlusion value as an interpolation factor, it performs blending calculations to obtain the target rendered color. This step ensures that the roots or low-lying areas of the vegetation exhibit a natural shadow effect, eliminating a visually flat appearance. Furthermore, the terminal 1000 is configured to calculate additional effects, including acquiring the scene's lighting and viewing direction, calculating the edge light component based on the orthogonality of the normal and the viewing direction, and calculating the specular component based on the angle between the normal, lighting, and the viewing direction. Finally, the target rendered color is blended with the edge light component and specular component, and the final vegetation rendering is output to the display device.
[0045] Through the above system architecture, the embodiments of this application achieve highly realistic vegetation instance rendering with low performance overhead.
[0046] Please see Figure 2 , Figure 2 This is a flowchart illustrating a vegetation instance rendering method provided in an embodiment of this application. It should be noted that the steps shown may be executed in a different logical order than that shown in the flowchart. The method may include the following steps: Step 110: Obtain the base model.
[0047] Step 110 is used to obtain substrate model data as a vegetation growth carrier.
[0048] Please see Figure 3 , Figure 3 A schematic diagram of the base model provided in the embodiments of this application.
[0049] Specifically, the terminal device can load the base model's data file from local storage or a remote server. This data file contains topological information describing the object's geometry (such as vertex indices and triangle connectivity) as well as vertex attribute data.
[0050] In practical applications, the base model can be a boulder, an old wall, a fallen tree trunk, or a continuous terrain grid in a game scene.
[0051] Step 120: Generate multiple vegetation instances on the base model.
[0052] Vegetation instances are rendered objects generated on the surface of a base model to represent the visual effect of micro-vegetation. More specifically, they can be moss, lichen, low-lying ground cover plants, fungal clusters, or similar dense micro-vegetation attached to the surface of the base model.
[0053] Please see Figure 4 , Figure 4 This is a material diagram of a vegetation example provided in an embodiment of this application.
[0054] The material for vegetation instances (such as moss) uses a semi-transparent rendering type. In this embodiment, each individual vegetation unit can be represented and rendered using a lightweight patch model. This semi-transparent patch-based material scheme can accurately represent the irregular edge contours and subtle leaf structures of vegetation using alpha masking technology. Since vegetation is a frequently occurring microscopic vegetation in the scene, using patch models instead of high-poly geometry can significantly reduce the number of triangles in a single vegetation instance. When generating large-scale PCG, this combination of material and model can effectively reduce the computational burden on the graphics processor while maintaining stylized visual details, thus improving the frame rate performance of real-time rendering.
[0055] In some embodiments, multiple vegetation instances are generated on the base model, including the following steps 121 to 123: Step 121: For each base vertex of the base model, determine the growth potential energy and maximum height threshold of the base vertex, wherein the growth potential energy is used to indicate the probability and / or height of generating vegetation instances at the base vertex.
[0056] In this embodiment, the terminal device does not directly store the specific coordinates of each vegetation instance. Instead, at runtime, it calculates the growth potential energy and maximum height threshold of each base vertex to determine in real time whether vegetation should be generated at that location and the morphology of the vegetation. This approach significantly reduces memory usage and ensures that the vegetation distribution closely matches the geometric features of the base.
[0057] The growth potential energy can be a normalized value between 0 and 1, reflecting the degree to which the location corresponding to the basal vertex is suitable for vegetation growth. The closer the growth potential energy is to 1, the more likely that a vegetation instance is to be generated at that location, and the generated vegetation tends to be taller.
[0058] The maximum height threshold is a value expressed in world spatial units (such as meters or centimeters), which defines the theoretical maximum height that a vegetation instance may reach at the location corresponding to the base vertex.
[0059] To adapt to different development needs, this application provides two implementation paths for determining growth potential: a manual guidance path and an automatic calculation path.
[0060] In some embodiments, the step of determining the growth potential energy in the automated calculation path based on geometric feature analysis includes: Perform geometric topology analysis on the base model to extract geometric feature data, which includes at least one of curvature data, slope data, or base ambient light shading data. Growth potential energy is determined based on geometric feature data, which is positively correlated with substrate ambient light shading data and negatively correlated with curvature and slope data.
[0061] Curvature data describes the degree of curvature of a surface at a given point. Because raised areas with high curvature (such as the sharp edges of a rock) are easily weathered and eroded, they are less conducive to adhesion. Therefore, the greater the curvature, the lower the growth potential.
[0062] Slope data is used to describe the angle of inclination of the surface normal relative to the direction of gravity. Horizontal or slightly inclined surfaces (low slope) are conducive to root attachment and nutrient accumulation, while steep or vertical surfaces (high slope) are difficult for vegetation to grow due to gravity. Therefore, the growth potential should decrease as the slope increases.
[0063] Ambient occlusion data describes the degree to which points on the surface of a substrate model are occluded by surrounding geometry. It is typically pre-baked into vertex colors or textures during the modeling phase using ray tracing or spherical surface integration. A higher ambient occlusion value indicates a more hidden area, less susceptible to ambient light, and more suitable for moss growth; therefore, the growth potential should increase with the ambient occlusion value. For example, the ambient occlusion value deep within a rock crevice might reach 0.8-0.9, while the ambient occlusion value of an exposed surface might only be 0.1-0.2.
[0064] In other embodiments, the step of determining the growth potential energy in a manually drawn, artificially guided path includes: Obtain the first vertex attribute data of the base model, which includes the base vertex color channel information; The intensity values of preset channels in the base vertex color channel information are extracted as growth potential energy. The vertex color channel information is generated based on the drawing operation on the surface of the base model.
[0065] Vertex color is the RGBA color attribute that can be attached to each vertex of a mesh model. It is usually composed of four channels: red (R), green (G), blue (B), and transparency (A), with each channel having a value ranging from 0 to 1 or 0 to 255. In 3D modeling software, artists can use vertex drawing tools to directly draw color information on the model surface.
[0066] This implementation is typically used in scenes where artists need precise control over vegetation distribution. Vertex color channel information is generated based on drawing operations on the surface of the base model. For example, in the level editor, artists use a "moss brush" to paint on a stone model. The red channel value of the vertices in the area the brush passes over is modified (e.g., from 0.0 to 1.0).
[0067] The preset channel can be the R channel or A channel of the vertex color.
[0068] Intensity values: 0 represents no growth potential (clean area), 1 represents full growth potential (dense area), and values between 0 and 1 represent transition areas. The advantage of this design is that it fully reuses the existing vertex color data structure, requires no additional data textures, and intuitively preserves the artist's creative intent.
[0069] Please refer to 5. Figure 5 This is a schematic diagram illustrating a scenario of manually drawing growth potential energy according to an embodiment of this application. In actual operation, the color channel values of vertices in a specific region are modified by receiving drawing instructions for the surface of the base model. In this embodiment, taking the red (R) channel of the vertex color as an example, the default white area indicates that the channel value is 0 (or below a preset threshold), defined as a background area without vegetation generation; while the area drawn as red indicates that the channel value is 1 (or above a preset threshold), defined as a target area for vegetation generation.
[0070] The advantage of this method lies in its intuitiveness and flexibility. Artists do not need to understand complex mathematical formulas to control vegetation growth through painting, making it suitable for artistic scenes that require a high degree of customization.
[0071] Step 122: Determine the noise intensity value corresponding to the base vertex based on the spatial location information of the base vertex.
[0072] In nature, vegetation distribution is not completely uniform, but rather exhibits randomness and aggregation. Relying solely on growth potential may result in vegetation distribution that is too regular and lacks a natural feel. Therefore, this application also introduces a noise perturbation mechanism, superimposing a randomly varying value based on its spatial location onto each base vertex, resulting in a final vegetation height distribution that presents an organic and non-periodic visual effect.
[0073] In some embodiments, a preset procedural noise algorithm, such as Perlin noise or simplex noise, can be used to determine the noise intensity value corresponding to the base vertex based on the spatial location information of the base vertex.
[0074] More specifically, the noise intensity value corresponding to the base vertex. The specific calculation formula can be: ; in, For the spatial position information of the base vertices, Here is the function for calculating Berlin noise. This is the scaling factor.
[0075] Because the calculation is based on spatial coordinates, the noise texture of the surface remains consistent regardless of how the base model is rotated or scaled, and the calculation results at the same location are constant, ensuring the stability of the rendering results.
[0076] Step 123, set the maximum height threshold. Growth potential and noise intensity value Perform a product operation to obtain the distribution height parameters of the base vertices.
[0077] Specifically, the distribution height parameter The calculation formula can be: .
[0078] Step 124: Generate multiple vegetation instances on the base model based on the distribution height parameter.
[0079] Based on the calculation in step 123 Instantiate the vegetation model at the corresponding position on the surface of the base model.
[0080] After step 124, the surface of the base model will be covered with numerous vegetation instances. For example: Dense and tall moss instances are generated in the crevices of the stone wall (high growth potential, high noise value); Generate a suitable number of moss instances of moderate height in the flat middle section of the stone wall (medium growth potential, medium noise value). At the protruding edges of the stone wall (where growth potential is low or filtered by a threshold), no or only a very small number of dwarf moss instances are generated. The overall distribution exhibits a natural alternation of clustering and sparseness, without any obvious regular patterns.
[0081] Please refer to 6. Figure 6 This is an example of vegetation coverage pattern observed in an embodiment of this application. Figure 6As shown, the distribution of vegetation instances (such as mosses) exhibits a natural alternation of aggregation and sparseness. In areas with high color intensity and concentrated noise distribution at the base vertices, the generated vegetation instances are denser and taller; while at the edges of the distribution range or in areas with low growth potential, the vegetation instances are shorter and sparser. The overall vegetation community closely conforms to the geometry of the base model, avoiding the repetitive feeling of mechanical arrangement and initially achieving a programmed distribution effect with ecological rationality.
[0082] Step 130: For each vegetation vertex of the vegetation instance, determine the simulated ambient light occlusion value of each vegetation vertex based on the relative height information of the vegetation vertex relative to the surface of the base model.
[0083] Specifically, step 130 is used to calculate a simulated ambient light shading value for the vegetation vertices in each vegetation instance generated in step 120.
[0084] After generating vegetation instances, in order to solve the problems of "visual flatness" and "lack of gap details" in vegetation rendering in related technologies, this application embodiment introduces height-based simulated AO calculation.
[0085] The proposed method for simulating ambient light shading is based on a key observation: for vegetation growing on a substrate surface, the closer the apex is to the substrate surface, the greater the likelihood of it being shaded by the substrate and surrounding vegetation, and therefore the stronger the ambient light shading should be. This simplifying assumption is visually reasonable and computationally efficient, making it suitable for real-time or interactive applications.
[0086] In some embodiments, the simulated ambient light shading value of each vegetation vertex is determined based on the relative height information of the vegetation vertex relative to the surface of the base model, including the following steps 131 to 133: Step 131: Determine the shortest distance from each vegetation vertex in the vegetation instance to the surface of the base model, and use it as the target height value h.
[0087] Please see Figure 7 , Figure 7 This is a schematic diagram illustrating the calculation of the target height value of the vegetation apex provided in an embodiment of this application.
[0088] The target height value is defined as the shortest distance from the vegetation vertex to the surface of the base model, typically measured in meters or centimeters. This distance reflects the degree to which the vegetation vertex rises above the base surface in a direction perpendicular to the base surface.
[0089] Step 132: Determine the relative height information based on the ratio of the target height value to the maximum generated height value of the vegetation instance.
[0090] In some embodiments, the target height value h and the maximum generated height value of the vegetation instance are obtained. The ratio of the two values determines the relative height information. .
[0091] Step 133: Based on the relative height information, determine the simulated ambient light shading value of each vegetation vertex.
[0092] Please see Figure 8 , Figure 8 This is a schematic diagram of simulated ambient light occlusion values provided in an embodiment of this application.
[0093] In some embodiments, determining the simulated ambient light shading value for each vegetation vertex based on relative height information includes: The relative height information is used as the simulated ambient light shading value for each vegetation vertex. .
[0094] In other embodiments, the simulated ambient light shading value for each vegetation vertex is determined based on relative height information, including: The relative height information is processed by nonlinear transformation to obtain the simulated ambient light shading value of each vegetation vertex.
[0095] For example, to increase the controllability of stylization, a power function can be used to process the relative height to obtain the simulated ambient occlusion value of each vegetation vertex.
[0096] Step 140: Render the vegetation instance based on the simulated ambient light occlusion value.
[0097] After determining the simulated ambient occlusion value, the vegetation instance is rendered based on the simulated ambient occlusion value.
[0098] In some embodiments, rendering vegetation instances based on simulated ambient occlusion values includes: Read the simulated ambient occlusion value from the second vertex attribute data of the vegetation instance; The vegetation instance is rendered based on the read simulated ambient light occlusion value.
[0099] Specifically, in this embodiment, after the simulated ambient occlusion value is calculated, it is written into the second vertex attribute data of the vegetation instance. During rendering, the pre-calculated simulated ambient occlusion value can be read directly from the existing vertex attribute data at zero cost, and the brightness and darkness of the material can be directly driven by the shader mathematical operation, so that high-quality vegetation rendering can be achieved even on performance-limited platforms such as mobile devices.
[0100] In some embodiments, the vegetation instance is rendered based on the simulated ambient light occlusion value, including the following steps 141 to 143: Step 141: For each vegetation vertex of the vegetation instance, obtain the gap reference color and the original reference color of each vegetation vertex, wherein the brightness of the gap reference color is lower than that of the original reference color.
[0101] Among them, the original base color This refers to the color of the moss's illuminated side (usually bright green) as defined by the artist, representing the healthy leaf tip color of the moss. (Base color for crevices) This refers to the preset color in the material used to simulate deep shadows or withered leaves (usually dark brown or dark green), which is less bright than the original base color.
[0102] Step 142, to simulate ambient light shading values As an interpolation factor, the reference color of the gap and original baseline color Interpolation calculations are performed to obtain the target rendering color for each vegetation vertex. .
[0103] Specifically, the target rendering color The calculation formula can be: .
[0104] Please see Figures 9 to 10 , Figure 9 This is the original moss material effect provided in the embodiments of this application without applying simulated ambient light occlusion values. In this state, the vegetation instance only displays the original base color. Although it has basic texture colors, due to the lack of expression of light and shadow in microscopic gaps, the overall visual effect presents a planar characteristic with uniform brightness, making it difficult to distinguish the light and shadow layers inside the vegetation cluster.
[0105] Figure 10 This embodiment of the application demonstrates the effect of moss material after calculation using simulated ambient light occlusion values. By introducing simulated ambient light occlusion values as interpolation factors, the darker base color of the gaps is successfully mapped to the roots and deeper areas of the vegetation, while the leaf tips and outer areas retain the brightness of the original base color. This height-based color transition significantly enhances the volume of the moss vegetation without requiring additional physical lighting calculations, allowing it to naturally exhibit a 'self-shadow' effect in the gaps, eliminating... Figure 9 The visual floating effect in the image.
[0106] Specifically, when When the value is close to 0, it indicates that the vegetation vertex is located at a low point in the vegetation, its surface is occluded, and the ambient light received is reduced, causing the target rendered color to tend towards the darker base color of the gap; when When the value approaches 1, the surface receives sufficient ambient light, and the target rendered color tends towards the bright original base color. This process automatically gives the vegetation a sense of volume.
[0107] Step 143: Render the vegetation instance based on the target rendering color.
[0108] After calculating the target rendering color, the calculated target rendering color can be applied to the pixel output of the vegetation instance to complete the display of the vegetation instance.
[0109] To further enhance the refinement and stylistic features of the image, this application is not limited to basic target rendering colors, but can also overlay special lighting and shadow effects.
[0110] In some embodiments, the method further includes: Determine additional effects to be used for rendering vegetation instances, including rim lighting components. and / or highlight component ; Rendering vegetation instances based on the target rendering color includes: Based on target rendering color Add additional effects to render vegetation instances.
[0111] In some embodiments, based on the target rendering color And additional effects, rendering vegetation instances, including: Render color to target Edge light component and highlight component The final color is obtained by performing a blending process. ; Based on the final color Render the vegetation instance.
[0112] In some embodiments, the target color is rendered. Edge light component and highlight component The final color is obtained by performing a blending process. This includes: rendering the target color. Edge light component and highlight component Perform linear superposition to obtain the final color. .
[0113] Specifically, the final color. The calculation formula can be:
[0114] in, and These are the intensity coefficients of the stylized edge light component and the stylized highlight component, respectively.
[0115] In some embodiments, the additional effects include an edge lighting component. Determining the additional effects for rendering vegetation instances includes the following steps 01 to 05: Step 01: Obtain the lighting direction vector and viewing direction vector of the current scene.
[0116] The illumination direction vector represents the unit vector in the opposite direction from the main light source of the scene (such as parallel light / sunlight) as it shines on the object.
[0117] The observation direction vector represents a unit vector pointing from the currently rendered pixel to the camera (observer) position.
[0118] Step 02: For each vegetation vertex of the vegetation instance, determine the target normal vector of the vegetation vertex.
[0119] In some embodiments, for each vegetation vertex of a vegetation instance, determining the target normal vector of the vegetation vertex includes: For each vegetation vertex of the vegetation instance, obtain the initial normal vector of the vegetation vertex; Obtain the base normal vector of the base vertex of the base model that is spatially closest to the vegetation vertex; The initial normal vector and the base normal vector are fused to obtain the target normal vector of the vegetation vertex.
[0120] In this context, the initial normal vector of the vegetation vertex is the geometric normal of the vegetation patch model itself. Since vegetation patches are usually simple quadrilaterals, their original normals are often perpendicular to the patch, with a single and chaotic direction, resulting in fragmented lighting effects.
[0121] In this embodiment, the base normal vector of the base vertex of the base model that is spatially closest to the vegetation vertex is obtained, and the initial normal vector and the base normal vector are fused to obtain the target normal vector of the vegetation vertex. This eliminates the "floating" feeling between the vegetation instance and the base model, making the light and shadow changes of the vegetation instance (such as the lit side and the shadowed side) completely consistent with the base model below, so that visually it seems as if the vegetation instance is closely attached to the surface of the base model.
[0122] Step 03: Calculate the parameter that characterizes the degree of directional consistency between the target normal vector and the illumination direction vector, and use it as the illumination intensity factor.
[0123] In some embodiments, calculating a parameter characterizing the degree of directional consistency between the target normal vector and the illumination direction vector, as an illumination intensity factor, includes: The illumination intensity factor is obtained by calculating the dot product of the target normal vector and the illumination direction vector.
[0124] Specifically, the target normal vector N and the illumination direction vector can be calculated. The dot product of these two factors yields the light intensity factor.
[0125] The specific formula is: Light intensity factor = .
[0126] In other embodiments, a parameter characterizing the degree of directional consistency between the target normal vector and the illumination direction vector is calculated as an illumination intensity factor, including: Calculate the dot product of the target normal vector and the illumination direction vector, and perform interval remapping on the dot product calculation result to obtain the illumination intensity factor.
[0127] The specific formula is: Light intensity factor = .
[0128] In this embodiment, to represent the fluffiness of the vegetation and the translucency created by subsurface scattering, it is generally undesirable for the shaded areas to be completely black. By mapping the dot product calculation results from [-1, 1] to [0, 1], the originally shaded areas can also obtain a certain light intensity factor. This can significantly increase the bright areas of the vegetation, making it look softer and more cartoonish.
[0129] Step 04: Calculate the parameter that characterizes the degree of orthogonality between the target normal vector and the observation direction vector, and use it as the edge effect factor that characterizes the edge emission intensity.
[0130] The edge effect factor accurately extracts the edge region of vegetation to simulate backlight transmission or velvet reflection effects.
[0131] In some embodiments, calculating a parameter characterizing the orthogonality between the target normal vector and the viewing direction vector, as an edge effect factor characterizing the edge luminescence intensity, includes: Based on the target normal vector N and the viewing direction vector Calculate the Fresnel effect value to obtain the edge effect factor, which characterizes the edge luminescence intensity.
[0132] Specifically, the formula for calculating the edge effect factor can be: Edge effect factor = .
[0133] Step 05: Generate edge light components based on illumination intensity factor, edge effect factor, and preset edge light color parameters.
[0134] In some embodiments, generating an edge light component based on an illumination intensity factor, an edge effect factor, and preset edge light color parameters includes: [the process involves] combining the illumination intensity factor, the edge effect factor, and preset edge light color parameters... Multiplying them together yields the edge light component.
[0135] Specifically, edge light components The calculation formula can be: .
[0136] Among them, the light intensity factor restricts the light to only illuminate the edge of the light-facing surface, and the edge effect factor restricts the light to only appear at the contour edge. Multiplying the two together yields the edge contour light of the light-facing surface, i.e., the edge light component.
[0137] Please see Figure 11 , Figure 11 This is a schematic diagram illustrating the effect of moss instance after overlaying stylized edge light components on top of a base rendering, as provided in an embodiment of this application. Figure 11 As shown, by introducing an edge effect factor, the outline edges of the moss vegetation clusters (i.e., the areas where the line of sight is nearly perpendicular to the surface normal) exhibit a distinct bright halo. Simultaneously, constrained by the light intensity factor, this edge glow only appears on the outline of the lit surface, while the shaded surface remains naturally dim. This processing method visually simulates the light scattering effect of the microscopic vegetation surface's hairs, effectively outlining the volumetric contours of the vegetation, making it stand out from the background, and enhancing the image's transparency and depth.
[0138] In some embodiments, the additional effects include a specular component. Determining the additional effects for rendering vegetation instances includes steps 11 through 14: Step 11: Obtain the lighting direction vector and viewing direction vector of the current scene.
[0139] The illumination direction vector represents the unit vector in the opposite direction from the main light source of the scene (such as parallel light / sunlight) as it shines on the object.
[0140] The observation direction vector represents a unit vector pointing from the currently rendered pixel to the camera (observer) position.
[0141] Step 12: For each vegetation vertex of the vegetation instance, determine the target normal vector of the vegetation vertex.
[0142] The specific implementation principle of step 12 is completely the same as that of step 02 above, and will not be repeated here.
[0143] Step 13: Determine the specular intensity factor characterizing the specular reflection intensity based on the angular relationship between the target normal vector, the illumination direction vector, and the observation direction vector.
[0144] The specular intensity factor, which describes the proportion of light energy that enters the observer's eye after light is reflected from the surface of an object, refers to the intensity of specular reflection.
[0145] In some embodiments, the specular intensity factor characterizing the specular reflection intensity is determined based on the angular relationship between the target normal vector, the illumination direction vector, and the viewing direction vector, including: Calculate the midpoint between the illumination direction vector and the viewing direction vector, and use it as the half-angle vector; Calculate the dot product of the target normal vector and the half-angle vector to obtain the specular intensity factor, which characterizes the intensity of specular reflection.
[0146] In some embodiments, calculating the midpoint vector between the illumination direction vector and the viewing direction vector, as a half-angle vector, includes: Add the illumination direction vector to the observation direction vector and divide by 2.
[0147] The specific formula is: Half-angle vector = .
[0148] Calculate the dot product of the target normal vector and the half-angle vector to obtain the specular intensity factor, which characterizes the specular reflection intensity. The specific formula is as follows: High light intensity factor = .
[0149] Step 14: Multiply the highlight intensity factor with the preset highlight color parameter to obtain the highlight component.
[0150] Specifically, the formula for calculating the highlight component is: .
[0151] Please see Figure 12 , Figure 12 This illustration shows the effect of a moss instance after adding stylized edge lighting and stylized specular components on top of a base render, as provided in this embodiment. Through this multi-level fusion process, the moss vegetation visually presents a rich sense of depth: the shadows in the gaps enhance the sense of thickness, the rim lighting at the edges outlines the overall shape of the vegetation, and the surface highlights reflect the vibrant texture of the moss under light. Compared with traditional high-consumption physically based rendering, this embodiment successfully achieves a microscopic vegetation representation that combines three-dimensionality and artistic stylization with extremely low computational load (relying only on vertex shader interpolation), achieving the expected technical effect.
[0152] All of the above technical solutions can be combined in any way to form optional embodiments of this application, and will not be described in detail here.
[0153] The vegetation instance rendering method provided in this application provides the following steps: obtaining a base model; generating multiple vegetation instances on the base model; determining the simulated ambient occlusion value of each vegetation vertex based on the relative height information of the vegetation vertex relative to the surface of the base model; and rendering the vegetation instances based on the simulated ambient occlusion value. This method generates vegetation instances on the base model and uses the relative height information of the vegetation vertices relative to the surface of the base model to determine the simulated ambient occlusion value for rendering. This solves the problems of related technologies relying on general ambient occlusion algorithms, which lead to the loss of shadow details in vegetation gaps, planar visual presentation, and obvious floating phenomenon. It can accurately simulate the complex light and shadow effects between microscopic vegetation clusters with low computational cost, significantly improving the three-dimensionality and visual realism of vegetation rendering.
[0154] To facilitate better implementation of the vegetation instance rendering method of this application embodiment, this application embodiment also provides a vegetation instance rendering apparatus. Please refer to... Figure 13 , Figure 13 A schematic diagram of the vegetation instance rendering apparatus provided in an embodiment of this application. The vegetation instance rendering apparatus 200 may include: Acquisition unit 210 is used to acquire the base model; The generation unit 220 is used to generate multiple vegetation instances on the base model; The determining unit 230 is used to determine the simulated ambient light occlusion value of each vegetation vertex of the vegetation instance based on the relative height information of the vegetation vertex relative to the surface of the base model. Rendering unit 240 is used to render vegetation instances based on simulated ambient occlusion values.
[0155] In some embodiments, when the apparatus is used to generate multiple vegetation instances on a base model, it is specifically used for: For each base vertex of the base model, determine the growth potential and maximum height threshold of the base vertex, where the growth potential is used to indicate the probability and / or height of generating vegetation instances at the base vertex. Based on the spatial location information of the base vertices, determine the noise intensity value corresponding to the base vertices; The distribution height parameters of the base vertices are obtained by multiplying the maximum height threshold, growth potential energy, and noise intensity value. Multiple vegetation instances are generated on the base model based on the distribution height parameter.
[0156] In some embodiments, the device, when used to determine the growth potential energy at the base vertex, is specifically used for: Perform geometric topology analysis on the base model to extract geometric feature data, which includes at least one of curvature data, slope data, or base ambient light shading data. Growth potential energy is determined based on geometric feature data, which is positively correlated with substrate ambient light shading data and negatively correlated with curvature and slope data.
[0157] In some embodiments, the device, when used to determine the growth potential energy at the base vertex, is specifically used for: Obtain the first vertex attribute data of the base model, which includes the base vertex color channel information; The intensity values of preset channels in the base vertex color channel information are extracted as growth potential energy. The vertex color channel information is generated based on the drawing operation on the surface of the base model.
[0158] In some embodiments, when determining the simulated ambient light occlusion value of each vegetation vertex based on the relative height information of the vegetation vertex relative to the surface of the substrate model, the device is specifically used for: Determine the shortest distance from each vegetation vertex in the vegetation instance to the surface of the base model, and use it as the target height value; Relative height information is determined based on the ratio of the target height value to the maximum generated height value of the vegetation instance. Based on relative height information, the simulated ambient light shading value of each vegetation vertex is determined.
[0159] In some embodiments, when the apparatus is used to render vegetation instances based on simulated ambient light occlusion values, it is specifically used for: Read the simulated ambient occlusion value from the second vertex attribute data of the vegetation instance; The vegetation instance is rendered based on the read simulated ambient light occlusion value.
[0160] In some embodiments, when the apparatus is used to render vegetation instances based on simulated ambient light occlusion values, it is specifically used for: For each vegetation vertex of a vegetation instance, obtain the gap reference color and the original reference color of each vegetation vertex, wherein the brightness of the gap reference color is lower than that of the original reference color. Using the simulated ambient light occlusion value as the interpolation factor, the gap reference color and the original reference color are interpolated to obtain the target rendering color of each vegetation vertex. Render vegetation instances based on the target rendering color.
[0161] In some embodiments, the device is further configured to: Determine additional effects to be used for rendering vegetation instances, including rimlight and / or specular components; Rendering vegetation instances based on the target rendering color includes: Render vegetation instances based on target rendering colors and additional effects.
[0162] In some embodiments, when the apparatus is used to render vegetation instances based on target rendering colors and additional effects, it is specifically used for: The target rendering color, edge light component, and specular component are blended to obtain the final shading color; The vegetation instance is rendered based on the final color.
[0163] In some embodiments, the additional effects include an edge lighting component, and the apparatus, when determining the additional effects for rendering the vegetation instance, specifically uses: Obtain the current scene's lighting direction vector and viewing direction vector; For each vegetation vertex of a vegetation instance, determine the target normal vector of the vegetation vertex. Calculate the parameter that characterizes the degree of directional consistency between the target normal vector and the illumination direction vector, and use it as the illumination intensity factor; Calculate the parameter that characterizes the degree of orthogonality between the target normal vector and the observation direction vector, and use it as the edge effect factor characterizing the edge luminescence intensity; Edge light components are generated based on illumination intensity factor, edge effect factor, and preset edge light color parameters.
[0164] In some embodiments, when the device is used to calculate the parameter characterizing the degree of directional consistency between the target normal vector and the illumination direction vector as an illumination intensity factor, it is specifically used for: The illumination intensity factor is obtained by calculating the dot product of the target normal vector and the illumination direction vector.
[0165] In some embodiments, when the device is used to calculate the parameter characterizing the degree of orthogonality between the target normal vector and the viewing direction vector, as an edge effect factor characterizing the edge luminescence intensity, it is specifically used for: The Fresnel effect value is calculated based on the target normal vector and the observation direction vector to obtain the edge effect factor characterizing the edge luminescence intensity.
[0166] In some embodiments, the additional effects include a specular component, and the apparatus, when determining additional effects for rendering vegetation instances, specifically includes: Obtain the current scene's lighting direction vector and viewing direction vector; For each vegetation vertex of a vegetation instance, determine the target normal vector of the vegetation vertex. Based on the angular relationship between the target normal vector, the illumination direction vector, and the observation direction vector, the specular intensity factor characterizing the specular reflection intensity is determined. The highlight component is obtained by multiplying the highlight intensity factor with the preset highlight color parameter.
[0167] In some embodiments, when the device is used to determine the specular intensity factor characterizing the specular reflection intensity based on the angular relationship between the target normal vector, the illumination direction vector, and the viewing direction vector, it is specifically used for: Calculate the midpoint between the illumination direction vector and the viewing direction vector, and use it as the half-angle vector; Calculate the dot product of the target normal vector and the half-angle vector to obtain the specular intensity factor, which characterizes the intensity of specular reflection.
[0168] In some embodiments, when determining the target normal vector of a vegetation vertex for each vegetation vertex of a vegetation instance, the apparatus is specifically used for: For each vegetation vertex of the vegetation instance, obtain the initial normal vector of the vegetation vertex; Obtain the base normal vector of the base vertex of the base model that is spatially closest to the vegetation vertex; The initial normal vector and the base normal vector are fused to obtain the target normal vector of the vegetation vertex.
[0169] Each unit in the aforementioned vegetation instance rendering device can be implemented entirely or partially through software, hardware, or a combination thereof. These units can be embedded in or independent of the processor in a computer device in hardware form, or stored in the memory of a computer device in software form, so that the processor can call and execute the operations corresponding to each unit.
[0170] The vegetation instance rendering device 200 can be integrated into a terminal or server that has storage and a processor and thus computing power, or the vegetation instance rendering device 200 can be the terminal or server.
[0171] Optionally, this application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above-described method embodiments.
[0172] Figure 14 This is a schematic diagram of the structure of a computer device provided in an embodiment of this application. The computer device may include: a communication interface 301, a memory 302, a processor 303, and a communication bus 304. The communication interface 301, memory 302, and processor 303 communicate with each other via the communication bus 304. The communication interface 301 is used for data communication between the device 300 and external devices. The memory 302 can be used to store software programs and modules, and the processor 303 runs the software programs and modules stored in the memory 302, such as the software programs for corresponding operations in the aforementioned method embodiments.
[0173] In some embodiments, the processor 303 may invoke software programs and modules stored in the memory 302 to perform the following operations: obtain a base model; generate multiple vegetation instances on the base model; for each vegetation vertex of the vegetation instance, determine the simulated ambient light occlusion value of each vegetation vertex based on the relative height information of the vegetation vertex relative to the surface of the base model; and render the vegetation instance based on the simulated ambient light occlusion value.
[0174] In some embodiments, the computer device 300 may be integrated into a terminal or server that has storage and a processor, thus possessing computing capabilities; or the computer device 300 may be the terminal or server. The terminal may be a smartphone, tablet, laptop, smart TV, smart speaker, wearable smart device, personal computer, or other similar device. The server may be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms.
[0175] This application also provides a computer-readable storage medium for storing a computer program. This computer-readable storage medium can be applied to a computer device, and the computer program causes the computer device to execute the corresponding processes in the vegetation instance rendering method of the embodiments of this application; for the sake of brevity, these will not be elaborated further here.
[0176] This application also provides a computer program product including computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the corresponding process in the vegetation instance rendering method of this application embodiment. For simplicity, further details are omitted here.
[0177] This application also provides a computer program comprising computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the corresponding process in the vegetation instance rendering method of this application. For brevity, further details are omitted here.
[0178] It should be understood that the processor in this application may be an integrated circuit chip with signal processing capabilities. In implementation, the steps of the above method embodiments can be completed by integrated logic circuits in the processor's hardware or by instructions in software form. The processor described above can be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this application can be directly embodied in the execution of a hardware decoding processor, or executed by a combination of hardware and software modules in the decoding processor. The software modules can be located in random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or other mature storage media in the art. This storage medium is located in memory, and the processor reads information from the memory and, in conjunction with its hardware, completes the steps of the above method.
[0179] It is understood that the memory in the embodiments of this application can be volatile memory or non-volatile memory, or may include both volatile and non-volatile memory. The non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. The volatile memory can be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of RAM are available, such as Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDR SDRAM), Enhanced Synchronous DRAM (ESDRAM), Synchlink DRAM (SLDRAM), and Direct Rambus RAM (DR RAM). It should be noted that the memory used in the systems and methods described herein is intended to include, but is not limited to, these and any other suitable types of memory.
[0180] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0181] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0182] In the embodiments of this application, the terms "module" or "unit" refer to a computer program or part of a computer program that has a predetermined function and works with other related parts to achieve a predetermined goal, and can be implemented wholly or partially using software, hardware (such as processing circuitry or memory), or a combination thereof. Similarly, a processor (or multiple processors or memory) can be used to implement one or more modules or units. Furthermore, each module or unit can be part of an overall module or unit that includes the functionality of that module or unit.
[0183] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.
[0184] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0185] In addition, the functional units in this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0186] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer or a server) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, ROM, RAM, magnetic disks, or optical disks.
[0187] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application shall be determined by the scope of the claims.
Claims
1. A method for rendering vegetation instances, characterized in that, The method includes: Obtain the base model; Multiple vegetation instances are generated on the base model; For each vegetation vertex of the vegetation instance, the simulated ambient light occlusion value of each vegetation vertex is determined based on the relative height information of the vegetation vertex relative to the surface of the base model. The vegetation instance is rendered based on the simulated ambient light occlusion value.
2. The method as described in claim 1, characterized in that, Multiple vegetation instances are generated on the base model, including: For each base vertex of the base model, determine the growth potential energy and maximum height threshold of the base vertex, wherein the growth potential energy is used to indicate the probability and / or height of generating the vegetation instance at the base vertex; Based on the spatial location information of the base vertex, the noise intensity value corresponding to the base vertex is determined; The maximum height threshold, the growth potential energy, and the noise intensity value are multiplied to obtain the distribution height parameters of the base vertices; Multiple vegetation instances are generated on the base model based on the aforementioned distribution height parameter.
3. The method as described in claim 2, characterized in that, Determining the growth potential energy of the base vertex includes: Perform geometric topology analysis on the base model to extract geometric feature data, which includes at least one of curvature data, slope data, or base ambient light shading data. The growth potential is determined based on the geometric feature data, wherein the growth potential is positively correlated with the ambient light shading data of the substrate and negatively correlated with the curvature data and the slope data.
4. The method as described in claim 2, characterized in that, Determining the growth potential energy of the base vertex includes: Obtain the first vertex attribute data of the base model, wherein the first vertex attribute data includes base vertex color channel information; The intensity values of preset channels in the base vertex color channel information are extracted as the growth potential energy, wherein the vertex color channel information is generated based on the drawing operation of the base model surface.
5. The method as described in claim 1, characterized in that, The step of determining the simulated ambient occlusion value of each vegetation vertex based on its relative height information relative to the surface of the base model includes: Determine the shortest distance from each vegetation vertex in the vegetation instance to the surface of the base model, and use it as the target height value; The relative height information is determined based on the ratio of the target height value to the maximum generated height value of the vegetation instance; Based on the relative height information, the simulated ambient light shading value of each vegetation vertex is determined.
6. The method as described in claim 1, characterized in that, The rendering of the vegetation instance based on the simulated ambient light occlusion value includes: The simulated ambient light occlusion value is read from the second vertex attribute data of the vegetation instance; The vegetation instance is rendered based on the read simulated ambient light occlusion value.
7. The method as described in claim 1, characterized in that, The rendering of the vegetation instance based on the simulated ambient light occlusion value includes: For each vegetation vertex of the vegetation instance, obtain the gap reference color and the original reference color of each vegetation vertex, wherein the brightness of the gap reference color is lower than that of the original reference color. Using the simulated ambient light occlusion value as an interpolation factor, interpolation calculations are performed on the gap reference color and the original reference color to obtain the target rendering color of each vegetation vertex. The vegetation instance is rendered based on the target rendering color.
8. The method as described in claim 7, characterized in that, The method further includes: Determine additional effects for rendering the vegetation instance, including rimlight and / or specular components; The rendering of the vegetation instance based on the target rendering color includes: The vegetation instance is rendered based on the target rendering color and the additional effects.
9. The method as described in claim 8, characterized in that, The rendering of the vegetation instance based on the target rendering color and the additional effects includes: The target rendering color, the edge light component, and the specular component are fused to obtain the final tinting color; The vegetation instance is rendered based on the final color.
10. The method as described in claim 8, characterized in that, The additional effects include an edge lighting component, and determining the additional effects used to render the vegetation instance includes: Obtain the current scene's lighting direction vector and viewing direction vector; For each vegetation vertex of the vegetation instance, determine the target normal vector of the vegetation vertex; Calculate a parameter characterizing the degree of directional consistency between the target normal vector and the illumination direction vector, and use it as an illumination intensity factor; Calculate a parameter characterizing the degree of orthogonality between the target normal vector and the observation direction vector, and use it as an edge effect factor characterizing the edge luminescence intensity; The edge light component is generated based on the illumination intensity factor, the edge effect factor, and the preset edge light color parameters.
11. The method as described in claim 10, characterized in that, The parameter used to calculate and characterize the degree of directional consistency between the target normal vector and the illumination direction vector, as an illumination intensity factor, includes: The illumination intensity factor is obtained by calculating the dot product of the target normal vector and the illumination direction vector.
12. The method as described in claim 10, characterized in that, The parameter used to calculate the degree of orthogonality between the target normal vector and the observation direction vector, serving as an edge effect factor characterizing the edge luminescence intensity, includes: The Fresnel effect value is calculated based on the target normal vector and the observation direction vector to obtain the edge effect factor characterizing the edge luminescence intensity.
13. The method as described in claim 8, characterized in that, The additional effects include a specular component. The additional effects used to render the vegetation instance include: Obtain the current scene's lighting direction vector and viewing direction vector; For each vegetation vertex of the vegetation instance, determine the target normal vector of the vegetation vertex; Based on the angular relationship between the target normal vector, the illumination direction vector, and the observation direction vector, the specular intensity factor characterizing the specular reflection intensity is determined. The highlight component is obtained by multiplying the highlight intensity factor with the preset highlight color parameter.
14. The method as described in claim 13, characterized in that, The determination of the specular intensity factor, characterizing the specular reflection intensity, based on the angular relationship between the target normal vector, the illumination direction vector, and the observation direction vector, includes: Calculate the midpoint vector between the illumination direction vector and the observation direction vector, and use it as the half-angle vector; The dot product of the target normal vector and the half-angle vector is calculated to obtain the specular intensity factor, which characterizes the specular reflection intensity.
15. The method as described in claim 10 or 13, characterized in that, Determining the target normal vector of each vegetation vertex for the vegetation instance includes: For each vegetation vertex of the vegetation instance, obtain the initial normal vector of the vegetation vertex; Obtain the base normal vector of the base vertex of the base model that is spatially closest to the vegetation vertex; The initial normal vector and the base normal vector are fused to obtain the target normal vector of the vegetation vertex.
16. A vegetation instance rendering device, characterized in that, The device includes: Acquisition unit, used to acquire the basis model; A generation unit is used to generate multiple vegetation instances on the base model; The determining unit is used to determine the simulated ambient light occlusion value of each vegetation vertex of the vegetation instance based on the relative height information of the vegetation vertex relative to the surface of the base model. The rendering unit is used to render the vegetation instance based on the simulated ambient light occlusion value.
17. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program adapted for loading by a processor to execute the vegetation instance rendering method as described in any one of claims 1-15.
18. A computer device, characterized in that, The computer device includes a processor and a memory, the memory storing a computer program, and the processor executing the vegetation instance rendering method according to any one of claims 1-15 by calling the computer program stored in the memory.
19. A computer program product comprising computer instructions, characterized in that, When the computer instructions are executed by the processor, they implement the vegetation instance rendering method according to any one of claims 1-15.
