Mountain rendering method, device and electronic equipment
By generating and rendering tree planting inserts, the problem of low generation efficiency of mountain tree planting models in the existing technology is solved, the effect of improving model generation efficiency and reducing rendering pressure is achieved, and the rapid iteration of game development is supported.
Patent Information
- Application Number
- CN202111650364.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-30
- Publication Date
- 2025-01-21
- Estimated Expiration
- 2041-12-30
AI Technical Summary
In the prior art, the generation efficiency of mountain tree planting models is low, resulting in the rapid iteration of game development being limited.
Based on the height information of each mountain grid of the target mountain, tree planting inserts are generated within the mountain grid used to distribute tree planting, and their vertex normal information is changed to the vertex normal information of the corresponding mountain grid. Use the vertex shader to perform lighting calculations and generate vertex lighting results for rendering.
It improves the efficiency of mountain tree plant model generation, reduces rendering pressure, supports rapid iteration of game development, and conforms to the distribution pattern of tree plants on mountains in the Chinese painting style.
Smart Images

Figure CN114299221B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of computer graphics, and in particular to a method, device and electronic equipment for rendering a mountain. Background Art
[0002] With the rise of the national style cultural trend, more and more games and animations are gradually developing from shoddy production to fine production. In games with Chinese painting style as the theme, the scene production often needs to restore the traditional landscape painting. Among them, the mountain covered with trees is usually an indispensable element of the Chinese painting style. Especially in traditional Chinese style landscape paintings, the steep edge of the mountain is often represented by relatively dense brushstrokes, and the thick and light colors of the brushstrokes are used to express the influence of the tree and the light changes, which is difficult to restore.
[0003] In existing 3D game works, the distribution of trees on the mountain can be generated by manually placing the tree models one by one on the mountain, or using the object generation brush tool to manually brush the tree models onto the mountain. Whether it is placement or using the brush tool, manual editing is required, which requires a certain amount of manpower and time, resulting in low efficiency in model generation, which is not conducive to the rapid iteration of game development. Summary of the invention
[0004] The object of the present invention is to provide a mountain rendering method, device and electronic device to alleviate the technical problem of low efficiency in generating mountain tree planting models in the prior art.
[0005] In order to achieve the above purpose, the technical solution adopted by the embodiment of the present invention is as follows:
[0006] In a first aspect, an embodiment of the present invention provides a method for rendering a mountain, the method comprising:
[0007] Based on the height information of each mountain grid of the target mountain, a plurality of tree planting inserts are generated in the mountain grid for distributing tree planting; each of the tree planting inserts includes the insert vertex normal information;
[0008] Changing the vertex normal information of each of the tree planting inserts to the vertex normal information of the corresponding mountain mesh;
[0009] A vertex shader is used to perform illumination calculation on each of the tree inserts to generate a vertex illumination result, so as to render the tree inserts and the target mountain according to the vertex illumination result to obtain the target mountain including the tree inserts.
[0010] In some possible implementations, the method further includes: acquiring the curvature of each mountain grid of the target mountain; and determining the mountain grid for distributing tree planting from the mountain grids according to the curvature.
[0011] In some possible implementations, the above-mentioned height information of each mountain grid of the target mountain is used to generate a number of tree planting plugs in the mountain grid used for distributing tree planting, including: based on the height information of each mountain grid of the target mountain, determining the weights corresponding to each of the above-mentioned mountain grids, wherein the above-mentioned weights are directly proportional to the height in the above-mentioned height information; determining the number of tree planting plugs to be generated in the corresponding mountain grids according to the weights corresponding to the above-mentioned mountain grids; and generating a corresponding number of tree planting plugs in the mountain grids used for distributing tree planting.
[0012] In some possible implementations, based on the height information of each mountain grid of the target mountain, the weights corresponding to each of the mountain grids are determined, including: based on the height information of each mountain grid of the target mountain, dividing the target mountain into two or more regions; configuring corresponding weights for the two or more regions respectively; and determining the weights corresponding to each of the mountain grids according to the regions to which the mountain grids belong and the weights corresponding to the regions.
[0013] In some possible implementations, dividing the target mountain into more than two regions includes: dividing the target mountain into an upper region and a lower region; the upper region includes a range from a top plane of the target mountain to a first dividing plane; the lower region includes a range from a bottom plane of the target mountain to the first dividing plane; the distance between the first dividing plane and the bottom plane of the target mountain is three quarters of the total height of the target mountain.
[0014] In some possible implementations, the method further includes: determining, from among the mountain grids of the target mountain, a mountain grid that is shortest in distance to and adjacent to the target tree planting patch in the tree planting patch as the mountain grid corresponding to the target tree planting patch.
[0015] In some possible implementations, after the step of changing the vertex normal information of each of the tree planting inserts to the vertex normal information of the corresponding mountain mesh, the method further includes: determining the model space coordinates for each of the tree planting inserts; each of the model space coordinates includes the axis point of the tree planting insert.
[0016] In some possible implementations, after changing the vertex normal information of each of the above-mentioned tree planting inserts to the vertex normal information of the corresponding above-mentioned mountain mesh, the above-mentioned method also includes: scaling each of the above-mentioned tree planting inserts in the corresponding above-mentioned model space coordinates according to the first preset parameters to generate a scaled tree planting insert; the above-mentioned first preset parameters include: scaling center coordinates and scaling ratio.
[0017] In some possible implementations, the method further includes: based on the model space coordinates, using billboard technology to rotate each scaled tree insert toward the virtual camera.
[0018] In some possible implementations, after the step of generating vertex lighting results, the method further includes: using a fragment shader to clip the tree inserts to obtain a clipping result; rendering the tree inserts and the target mountain according to the vertex lighting results includes: rendering the tree inserts and the target mountain according to the vertex lighting results and the clipping results.
[0019] In a second aspect, an embodiment of the present invention provides a device for rendering a mountain, the device comprising:
[0020] A tree planting patch generation module is used to generate a number of tree planting patches in the mountain meshes used for distributing tree planting based on the height information of each mountain mesh of the target mountain; each of the above-mentioned tree planting patches includes patch vertex normal information;
[0021] A normal information updating module, used to change the vertex normal information of each of the tree planting inserts to the vertex normal information of the corresponding mountain mesh;
[0022] The lighting calculation module is used to perform lighting calculation on each of the tree planting inserts using a vertex shader to generate vertex lighting results, so as to render the tree planting inserts and the target mountain according to the vertex lighting results to obtain the target mountain containing the tree planting inserts.
[0023] In a third aspect, an embodiment of the present invention provides an electronic device, comprising a memory and a processor, wherein the memory stores a computer program executable on the processor, and the processor implements the steps of any one of the methods of the first aspect when executing the computer program.
[0024] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores machine-executable instructions. When the computer-executable instructions are called and executed by a processor, the computer-executable instructions prompt the processor to execute any one of the above methods in the first aspect.
[0025] The present invention provides a method, device and electronic device for rendering a mountain, the method comprising: firstly, based on the height information of each mountain grid of the target mountain, respectively generating a plurality of tree planting inserts in the mountain grid for distributing tree planting; then changing the vertex normal information of each tree planting insert to the vertex normal information of the corresponding mountain grid; then using the vertex shader to perform lighting calculations on each tree planting insert, generating a vertex lighting result, so as to render the tree planting insert and the target mountain according to the vertex lighting result, and obtain the target mountain including the tree planting insert. The above method can alleviate the problems of low efficiency in generating mountain tree planting models and high rendering pressure in the prior art, thereby improving the efficiency of model generation and facilitating game development. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0027] Figure 1 A schematic diagram of a flow chart of a mountain rendering method provided by an embodiment of the present invention;
[0028] Figure 2 A schematic diagram of the effect of determining the tree distribution area on a mountain in a mountain rendering method provided by an embodiment of the present invention;
[0029] Figure 3 A location effect diagram of tree planting inserts generated in a mountain tree planting distribution area provided by an embodiment of the present invention;
[0030] Figure 4 A schematic diagram of the structure of a mountain rendering device provided by an embodiment of the present invention;
[0031] Figure 5 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0032] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Generally, the components of the embodiments of the present invention described and shown in the drawings here can be arranged and designed in various different configurations.
[0033] Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the invention claimed for protection, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0034] It should be noted that similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in the subsequent drawings. Some embodiments of the present invention are described in detail below in conjunction with the drawings. The following embodiments and features in the embodiments can be combined with each other without conflict.
[0035] At present, in the game works with the theme of Chinese painting style, its scene production often needs to restore the traditional landscape painting, among which the mountain covered with trees is usually an indispensable element of the Chinese painting style. Especially in traditional Chinese style landscape paintings, the steep edges of the mountains are often represented by relatively dense brushstrokes, and the shades of the brushstrokes are used to express the influence of the changes in light on the trees, which is difficult to restore. In existing three-dimensional game works, the distribution of trees on the mountain can be generated by manual placement, placing the tree models one by one on the mountain, or using the object generation brush tool to manually brush the tree models onto the mountain. Whether it is placement or using the brush tool, manual editing is required, which requires a certain amount of manpower and time, resulting in low efficiency of model generation, which is not conducive to the rapid iteration of game development.
[0036] Based on this, the embodiments of the present invention provide a mountain rendering method, device and electronic device to alleviate the technical problems of low efficiency in generating mountain tree planting models and high rendering pressure in the prior art.
[0037] To facilitate understanding of this embodiment, a mountain rendering method disclosed in an embodiment of the present invention is first described in detail. Figure 1 The flowchart of a method for rendering a mountain is shown in FIG. 1 . The method can be executed by an electronic device and mainly includes the following steps S120 to S140:
[0038] S120: Based on the height information of each mountain grid of the target mountain, a plurality of tree planting inserts are generated in the mountain grid for distributing tree planting; each tree planting insert includes insert vertex normal information;
[0039] Among them, the tree planting insert is a quadrilateral plane patch. Usually, the existing tree planting insert is usually in the form of multiple quadrilateral plane inserts or a three-dimensional polygonal mesh. Under the total number of trees in the entire scene, it will cause the rendering pressure of a huge number of model faces, resulting in low rendering efficiency, which is not conducive to the rapid iteration of game development. In the embodiment of the present invention, only one quadrilateral plane insert is used to form the tree planting insert, which can greatly reduce the pressure of the rendering stage and improve the rendering efficiency.
[0040] S130: changing the vertex normal information of each tree planting patch to the vertex normal information of the corresponding mountain mesh;
[0041] The vertex normal information of the mountain mesh corresponding to the tree patch includes: the normal information of the vertex of the mountain mesh adjacent to the tree patch and with the shortest distance to the tree patch. Figure 3 .
[0042] S140: Perform illumination calculation on each tree insert using a vertex shader to generate a vertex illumination result, so as to render the tree insert and the target mountain according to the vertex illumination result to obtain the target mountain including the tree insert.
[0043] In traditional Chinese painting, trees are often represented by dense brushstrokes at the steep edge of a mountain, and sparse brushstrokes are used to represent trees at the flat part of a mountain. Therefore, the area with a larger curvature of the mountain mesh can be calculated in Houdini and used as the generation range of the tree inserts for tree insert distribution. In the embodiment of the present invention, before the above step S120, the method may further include:
[0044] S21: Obtain the curvature of each mountain grid of the target mountain;
[0045] S22: Determine a mountain grid for distributing tree planting from the mountain grids according to the curvature.
[0046] The target mountain may be a pre-acquired mountain model in the style of traditional Chinese painting, and its three-body mesh may be established in advance through three-dimensional modeling software. The established target mountain includes information of several mesh vertices.
[0047] The mesh curvature can be obtained through the Curvature function node of Houdini software.
[0048] See also Figure 2 As shown in the figure, the highlighted part indicates the area with larger curvature of the mountain mesh, that is, the convex area of the mountain, which can be used as the generation range of the tree planting inserts representing the brushstrokes of Chinese painting and used to distribute the tree planting inserts; Figure 2The shaded part in the middle represents the area with smaller curvature of the mountain mesh, that is, the concave area of the mountain, and no tree planting inserts are distributed. The present invention provides a method for rendering a mountain, comprising: based on the height information of each mountain mesh of the target mountain, respectively generating a number of tree planting inserts in the mountain mesh used for distributing trees; then changing the vertex normal information of the tree planting inserts to the vertex normal information of the corresponding mountain mesh; and then using the vertex shader to perform lighting calculations on each tree planting insert to generate a vertex lighting result, so as to render the tree planting inserts and the target mountain according to the vertex lighting result, and obtain the target mountain containing the tree planting inserts. The above method can alleviate the problems of low efficiency in generating mountain tree planting models and high rendering pressure, thereby improving the efficiency of model generation and facilitating rapid game development.
[0049] In one embodiment, in the above step S120, based on the height information of each mountain grid of the target mountain, the step of generating a plurality of tree planting inserts in the mountain grids for distributing tree planting may specifically include:
[0050] (1) Based on the height information of each mountain grid of the target mountain, determine the weight corresponding to each mountain grid, where the weight is proportional to the height in the height information;
[0051] (2) According to the weights corresponding to the mountain grids, the number of tree planting inserts to be generated in the corresponding mountain grids is determined;
[0052] (3) Generate a corresponding number of tree planting inserts in the mountain grid used for distributing tree planting.
[0053] As a specific example, in the above step (1), based on the height information of the target mountain, the target mountain can be divided into two or more regions, and then corresponding weights are configured for the two or more regions respectively, and then the weights corresponding to each mountain grid are determined according to the region to which each mountain grid belongs and the weight corresponding to each region.
[0054] In an embodiment of the present invention, the target mountain can be divided into two areas, namely: an upper area and a lower area, the upper area includes the range from the top plane of the target mountain to the first dividing plane; the lower area includes the range from the bottom plane of the target mountain to the first dividing plane; wherein the distance between the first dividing plane and the bottom plane of the target mountain can be three quarters of the total height of the target mountain.
[0055] In one embodiment, the method further includes: determining, from the mountain grids of the target mountain, a mountain grid that is shortest in distance to and adjacent to the target tree planting patch in the tree planting patch as the mountain grid corresponding to the target tree planting patch.
[0056] In the embodiment of the present invention, the vertex normal information of the mountain mesh corresponding to the tree planting patch includes: the vertex normal information of the mountain mesh that is shortest in distance to and adjacent to the target tree planting patch among the mountain meshes of the target mountain.
[0057] In one embodiment, after the above step S130, the method may further include: determining a model space coordinate for each tree planting insert; each model space coordinate includes an axis point of the tree planting insert.
[0058] The specific performance of this step in software operation can be to export the model generated by the above steps S21, S22 and S120, and then establish each tree planting insert as an independent level, that is, each tree planting insert has an independent axis point.
[0059] As a specific example, you can use Python scripts to process the plane surface of each tree insert into an independent Geo level in Houdini, and then export it to an independent GameObject level in Unity, thereby retaining the Pivot information (coordinate information of the origin of the model space) of each insert object. This Pivot information is used to prepare for the subsequent Billboard technology around the camera.
[0060] In one embodiment, the above method may further include: scaling each tree planting insert in the corresponding model space coordinates according to first preset parameters to generate scaled tree planting inserts; the first preset parameters include: scaling center coordinates and scaling ratio.
[0061] That is to say, in the vertex shader part of the insert object Shader, the GameObject's own scale, rotation and displacement Transform is not used. Instead, the vertex position is multiplied by the custom scale parameter in the object model space to customize the insert size, thereby achieving independent scaling of the entire insert object.
[0062] Furthermore, the method further includes: based on the coordinate information of the origin of the model space, using billboard technology to rotate each scaled tree insert toward the virtual camera, so that the tree insert will not be exposed at any angle.
[0063] The method provided in the above embodiment uses a multi-GameObject strategy in Unity to maintain the Pivot center of each tree insert, so that each tree insert Billboard Shader rotates with the camera perspective with its own independent Pivot center, thereby achieving the final effect of the tree insert being seamless at all angles.
[0064] In one embodiment, after the above step S140 uses a vertex shader to perform illumination calculation on each tree insert and generates a vertex illumination result, the method may further include: using a fragment shader to clip the tree insert to obtain a clipping result. Rendering the tree insert and the target mountain according to the vertex illumination result includes: rendering the tree insert and the target mountain according to the vertex illumination result and the clipping result.
[0065] The embodiment of the present application provides a mountain rendering method, which can alleviate the problems of low efficiency in generating mountain tree models and high rendering pressure, thereby improving the efficiency of model generation and facilitating rapid game development. In addition, the tree inserts and target mountain rendered by this method conform to the distribution law of trees on the mountain in the style of Chinese painting, can generate the distribution of vegetation inserts according to the curvature of the mountain, and are consistent with the mountain grid in terms of lighting changes. Finally, the Pivot information of each tree insert is maintained in the batch, avoiding the failure of the Billboard technology to cause the solution to go wrong.
[0066] In addition, the present application embodiment also provides a mountain rendering device, see Figure 4 As shown, the device comprises:
[0067] The tree planting patch generation module 420 is used to generate a plurality of tree planting patches in the mountain meshes used for distributing tree planting based on the height information of each mountain mesh of the target mountain; each tree planting patch includes the normal information of the vertex of the patch;
[0068] The normal information updating module 430 is used to change the vertex normal information of each tree planting patch to the vertex normal information of the corresponding mountain mesh;
[0069] The lighting calculation module 440 is used to perform lighting calculation on each tree insert using a vertex shader to generate a vertex lighting result, so as to render the tree insert and the target mountain according to the vertex lighting result to obtain the target mountain containing the tree insert.
[0070] In one embodiment, the above-mentioned device may further include: a curvature acquisition module, used to acquire the curvature of each mountain grid of the target mountain; and determine the mountain grid for distributing tree planting from the mountain grids according to the curvature.
[0071] In one embodiment, the tree planting plug generation module is further used to: determine the weights corresponding to each mountain grid based on the height information of each mountain grid of the target mountain, wherein the weight is directly proportional to the height in the height information; determine the number of tree planting plugs to be generated in the corresponding mountain grid according to the weight corresponding to the mountain grid; and generate a corresponding number of tree planting plugs in the mountain grids used for distributing tree planting.
[0072] In one embodiment, the tree planting patch generation module is further used to: divide the target mountain into two or more areas based on the height information of each mountain grid of the target mountain; configure corresponding weights for the two or more areas respectively; determine the weights corresponding to each mountain grid according to the area to which each mountain grid belongs and the weight corresponding to each area.
[0073] As a specific example, the target mountain is divided into more than two areas, including: dividing the target mountain into an upper area and a lower area; the upper area includes the range from the top plane of the target mountain to the first dividing plane; the lower area includes the range from the bottom plane of the target mountain to the first dividing plane; the distance between the first dividing plane and the bottom plane of the target mountain is three quarters of the total height of the target mountain.
[0074] In one embodiment, the device further includes: a mountain grid determination module, which is used to determine, from the various mountain grids of the target mountain, a mountain grid that is shortest in distance and adjacent to the target tree planting patch in the tree planting patch as the mountain grid corresponding to the target tree planting patch. In one embodiment, the device further includes: a model space coordinate determination module, which is used to determine the model space coordinate for each tree planting patch; each model space coordinate includes the axis point of the tree planting patch.
[0075] In one embodiment, the device further includes: a scaling module for scaling each tree planting insert in the corresponding model space coordinates according to a first preset parameter to generate a scaled tree planting insert; the first preset parameter includes: a scaling center coordinate and a scaling ratio.
[0076] In one embodiment, the device further includes: a rotation module for rotating each scaled tree insert toward the virtual camera based on the model space coordinates using a billboard technique.
[0077] In one embodiment, the device further includes: a rendering module for clipping the tree planting inserts using a fragment shader to obtain a clipping result; the rendering module is also used to render the tree planting inserts and the target mountain according to the vertex lighting results and the clipping results.
[0078] The embodiments of the present application provide a method, device and electronic device for rendering a mountain, the method comprising: first, based on the height information of each mountain grid of the target mountain, respectively generating a plurality of tree planting inserts in the mountain grid used for distributing tree planting; then changing the vertex normal information of each tree planting insert to the vertex normal information of the corresponding mountain grid; and then using a vertex shader to perform lighting calculations on each tree planting insert to generate a vertex lighting result, so as to render the tree planting inserts and the target mountain according to the vertex lighting result to obtain the target mountain containing the tree planting inserts.
[0079] The above method can alleviate the problems of low efficiency in generating mountain tree models and high rendering pressure, and improve the efficiency of model generation, which is convenient for rapid game development. In addition, the tree inserts and target mountains rendered by this method conform to the distribution law of trees on mountains in the style of traditional Chinese painting, and can generate the distribution of vegetation inserts according to the curvature of the mountain, and are consistent with the mountain grid in terms of lighting changes. Finally, the Pivot information of each tree insert is maintained in the batch, avoiding the failure of the Billboard technology to cause the solution to go wrong.
[0080] Figure 5 A structural schematic diagram of an electronic device provided in an embodiment of the present application, the electronic device 400 includes: a processor 40, a memory 41, a bus 42 and a communication interface 43, wherein the processor 40, the communication interface 43 and the memory 41 are connected via the bus 42; the processor 40 is used to execute an executable module stored in the memory 41, such as a computer program.
[0081] The memory 41 may include a high-speed random access memory (RAM), and may also include a non-volatile memory, such as at least one disk memory. The communication connection between the system network element and at least one other network element is realized through at least one communication interface 43 (which may be wired or wireless), and the Internet, wide area network, local area network, metropolitan area network, etc. may be used.
[0082] The bus 42 may be an ISA bus, a PCI bus, or an EISA bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 5 Only one bidirectional arrow is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0083] Among them, the memory 41 is used to store programs, and the processor 40 executes the program after receiving the execution instruction. The method executed by the device for flow process definition disclosed in any embodiment of the above-mentioned embodiment of the present invention can be applied to the processor 40 or implemented by the processor 40.
[0084] The processor 40 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit or software instructions in the processor 40. The above processor 40 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present invention can be implemented or executed. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor. The steps of the method disclosed in the embodiments of the present invention can be directly embodied as a hardware decoding processor to execute, or can be executed by a combination of hardware and software modules in the decoding processor. The software module can be located in a mature storage medium in the field such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory 41, and the processor 40 reads the information in the memory 41 and completes the steps of the above method in combination with its hardware.
[0085] Corresponding to the above method, an embodiment of the present application also provides a computer-readable storage medium, which stores machine-executable instructions. When the computer-executable instructions are called and executed by a processor, the computer-executable instructions prompt the processor to execute the steps of the above method.
[0086] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.
[0087] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0088] In addition, each functional unit in the embodiments provided in the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0089] If the functions are implemented in the form of 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 the present invention, in essence, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, electronic device, or network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0090] It should be noted that similar numbers and letters represent similar items in the accompanying drawings. Therefore, once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings. In addition, the terms "first", "second", "third", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.
[0091] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for rendering a mountain, characterized in that: include: Based on the height information of each mountain grid of the target mountain, a plurality of tree planting inserts are generated in the mountain grids used for distributing tree planting; Each of the tree planting inserts includes insert vertex normal information; Changing the vertex normal information of each of the tree planting inserts to the vertex normal information of the corresponding mountain mesh; Performing illumination calculation on each of the tree inserts using a vertex shader to generate a vertex illumination result, so as to render the tree inserts and the target mountain according to the vertex illumination result to obtain the target mountain including the tree inserts; The method also includes: obtaining the curvature of each mountain grid of the target mountain, determining to distribute tree planting inserts for the convex area grid of the mountain whose curvature is greater than a preset curvature threshold, and determining the convex area grid as the mountain grid for distributing tree planting.
2. The rendering method according to claim 1, characterized in that: The method of generating a plurality of tree planting inserts in the mountain grids for distributing tree planting based on the height information of each mountain grid of the target mountain includes: Based on the height information of each mountain grid of the target mountain, determine the weights corresponding to each mountain grid, wherein the weight is in direct proportion to the height in the height information; According to the weights corresponding to the mountain grids, the number of tree planting inserts to be generated in the corresponding mountain grids is determined respectively; A corresponding number of tree planting inserts are generated in the mountain grid used for distributing tree planting.
3. The rendering method according to claim 2, characterized in that: Based on the height information of each mountain grid of the target mountain, the weights corresponding to each mountain grid are determined, including: Based on the height information of each mountain grid of the target mountain, the target mountain is divided into two or more regions; configuring corresponding weights for the two or more regions respectively; The weights corresponding to the respective mountain grids are determined according to the regions to which the respective mountain grids belong and the weights corresponding to the respective regions.
4. The rendering method according to claim 3, characterized in that: The step of dividing the target mountain into two or more regions includes: Dividing the target mountain into an upper area and a lower area; The upper area includes the range from the top plane of the target mountain to the first dividing plane; The lower area includes the range from the bottom plane of the target mountain to the first dividing plane; The distance between the first dividing plane and the bottom plane of the target mountain is three quarters of the total height of the target mountain.
5. The rendering method according to claim 1, characterized in that: The method further comprises: A mountain grid which is shortest in distance to and adjacent to a target tree planting patch in the tree planting patches is determined from each mountain grid of the target mountain as the mountain grid corresponding to the target tree planting patch.
6. The rendering method according to claim 1, characterized in that: After the step of changing the vertex normal information of each tree planting insert to the vertex normal information of the corresponding mountain mesh, the method further includes: The model space coordinates are determined for each of the tree planting inserts; each of the model space coordinates includes the axis point of the tree planting insert.
7. The rendering method according to claim 6, characterized in that: After changing the vertex normal information of each tree planting insert to the vertex normal information of the corresponding mountain mesh, the method further includes: According to first preset parameters, each of the tree planting inserts is scaled in the corresponding model space coordinates to generate a scaled tree planting insert; the first preset parameters include: scaling center coordinates and scaling ratio.
8. The rendering method according to claim 6, characterized in that: The method further includes: based on the model space coordinates, using billboard technology to rotate each scaled tree insert toward the virtual camera.
9. The rendering method according to claim 1, characterized in that: After the step of generating vertex lighting results, the method further includes: Using a fragment shader to clip the tree planting insert to obtain a clipping result; The rendering of the tree planting inserts and the target mountain body according to the vertex lighting result includes: rendering the tree planting inserts and the target mountain body according to the vertex lighting result and the clipping result.
10. A mountain rendering device, characterized in that: include: A tree planting insert generation module is used to generate a plurality of tree planting inserts in the mountain grids used for distributing tree planting based on the height information of each mountain grid of the target mountain; each of the tree planting inserts includes insert vertex normal information; A normal information updating module, used for changing the vertex normal information of each tree planting insert to the vertex normal information of the corresponding mountain mesh; A lighting calculation module, used for performing lighting calculation on each of the tree planting inserts using a vertex shader to generate a vertex lighting result, so as to render the tree planting inserts and the target mountain according to the vertex lighting result to obtain the target mountain containing the tree planting inserts; The device also includes: a curvature acquisition module, which is used to acquire the curvature of each mountain grid of the target mountain, determine the distribution of tree planting inserts for the convex area grid of the mountain whose curvature is greater than a preset curvature threshold, and determine the convex area grid as the mountain grid for distributing tree planting.
11. An electronic device comprising a memory and a processor, wherein the memory stores a computer program that can be run on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 9 are implemented.
12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores machine executable instructions. When the computer-executable instructions are called and executed by a processor, the computer-executable instructions cause the processor to execute the method according to any one of claims 1 to 9.
Citation Information
Patent Citations
Surface vegetation treatment method and device
CN110264553A
Method and device for rendering virtual object in virtual environment, equipment and medium
CN112884873A