Model rendering method and device, electronic equipment and readable storage medium
By dividing the model to be rendered into a flat part and a concave part, and conducting template testing and depth testing, the problem in the existing technology that the downward concave effect does not support re-rendering is solved, and a more realistic ground cracking skill effect and The ability to re-render objects in recessed space.
Patent Information
- Application Number
- CN202311525445.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-15
- Publication Date
- 2025-01-21
AI Technical Summary
In the prior art, the downward depression effect does not support rendering new objects in the depression space it renders, and parallax mapping technology can easily lead to effects mutations and distortions when observing angle changes.
Divide the model to be rendered on the virtual ground into a flat part and a concave part, set them as flat material and concave material respectively, obtain the target depth value through template testing and depth testing, and write it into the material file of the concave material. Finally, according to the plane Materials and concave materials are rendered in sequence.
It is possible to control sunken spaces of different shapes and depths in areas with terrain without changing the existing terrain rendering template values, avoiding mutations and distortions in parallax mapping technology, and providing more realistic ground cracking skills. effect, and supports rendering a real object in the generated concave space.
Smart Images

Figure CN119338972A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of game production, and in particular to a model rendering method, device, electronic device and readable storage medium. Background Art
[0002] In game scenes, it is sometimes necessary to generate special effects under the ground, such as ground collapse, cracking and other concave effects.
[0003] In the related art, parallax mapping technology is used to achieve the concave special effect. However, parallax mapping technology will cause the mapping effect to change with the change of the viewing angle. If the perspective of the protagonist is controlled to change freely, the effect obtained by parallax mapping is prone to mutation and distortion when the protagonist's perspective is moved quickly and changed. In addition, the spatial effect produced by parallax mapping is a pseudo-spatial effect formed based on multiple loop sampling of the map, and does not render a real concave space. Therefore, the downward concave effect produced by parallax mapping does not support the rendering of new objects in the concave space rendered by it. Summary of the invention
[0004] In view of this, the present application provides a model rendering method, device, electronic device and readable storage medium to solve the problem in the related art that the downward concave effect does not support rendering new objects in the concave space rendered by it.
[0005] In a first aspect, an embodiment of the present application provides a model rendering method, comprising:
[0006] Dividing the model to be rendered on the virtual ground into a plane part and a concave part, wherein the plane part is a plane in the model to be rendered that fits the virtual ground, and the concave part is a curved surface in the model to be rendered that is sunken under the virtual ground;
[0007] Setting the planar portion to a planar material, and setting the concave portion to a concave material;
[0008] Setting a first template value for the plane material, and performing a template test and a depth test on the concave material in sequence based on the first template value to obtain a target depth value, and writing the target depth value into a material file of the concave material;
[0009] The model to be rendered is rendered in the order of the plane material and the concave material.
[0010] According to the above method of the embodiment of the present application, the following additional technical features may also be provided:
[0011] In the above technical solution, optionally, the concave surface material includes a first sub-material and a second sub-material, and the spatial position corresponding to the first sub-material coincides with the spatial position corresponding to the second sub-material;
[0012] The step of sequentially performing a template test and a depth test on the concave material based on the first template value to obtain a target depth value includes:
[0013] Performing a template test on the first sub-material based on the first template value to obtain a second template value of the first sub-material, and performing a template test on the second sub-material based on the second template value;
[0014] A depth test is performed on the second sub-material after the template test passes to obtain the target depth value of the second sub-material.
[0015] In any of the above technical solutions, optionally, performing a template test on the first sub-material based on the first template value to obtain a second template value of the first sub-material includes:
[0016] Using the first template value as a template reference value of the first sub-material, and comparing it with the buffer template value of the first sub-material, if the buffer template value of the first sub-material is equal to the first template value, determining that the first sub-material template test passes, and updating the buffer template value of the first sub-material to a second template value;
[0017] The performing a template test on the second sub-material based on the second template value includes:
[0018] The second template value is used as the template reference value of the second sub-material and compared with the buffer template value of the second sub-material. If the buffer template value of the second sub-material is equal to the second template value, it is determined that the second sub-material template test passes, and the buffer template value of the second sub-material is retained.
[0019] In any of the above technical solutions, optionally, the method further includes:
[0020] Set the condition for the first sub-material to always pass the depth test;
[0021] The condition for the second sub-material to perform a depth test is set to be less than or equal to pass the test.
[0022] In any of the above technical solutions, optionally, the rendering level of the concave portion is higher than the rendering levels of the virtual ground and the planar portion.
[0023] In any of the above technical solutions, optionally, the method further includes:
[0024] Set the rendering sequence number of the plane material to N, the rendering sequence number of the first sub-material to N+1, and the rendering sequence number of the second sub-material to N+2, where N is a positive integer.
[0025] In any of the above technical solutions, optionally, the method further includes:
[0026] When rendering the model to be rendered, the generation height of the plane part is set to be higher than or equal to the terrain height of the virtual ground.
[0027] In a second aspect, an embodiment of the present application provides a model rendering device, including:
[0028] A model division module is used to divide the model to be rendered on the virtual ground into a plane part and a concave part, wherein the plane part is a plane in the model to be rendered that fits the virtual ground, and the concave part is a curved surface in the model to be rendered that is concave under the virtual ground; and set the plane part to a plane material, and set the concave part to a concave material
[0029] A testing module, used for setting a first template value for the plane material, and performing a template test and a depth test on the concave material in sequence based on the first template value to obtain a target depth value, and writing the target depth value into a material file of the concave material;
[0030] A rendering module is used to render the model to be rendered in the order of the plane material and the concave material.
[0031] In a third aspect, an embodiment of the present application provides an electronic device, which includes a processor and a memory, wherein the memory stores programs or instructions that can be run on the processor, and when the programs or instructions are executed by the processor, the steps of the method of the first aspect are implemented.
[0032] In a fourth aspect, an embodiment of the present application provides a readable storage medium, on which a program or instruction is stored, and when the program or instruction is executed by a processor, the steps of the method of the first aspect are implemented.
[0033] In a fifth aspect, an embodiment of the present application provides a chip, which includes a processor and a communication interface, wherein the communication interface and the processor are coupled, and the processor is used to run programs or instructions to implement the method of the first aspect.
[0034] In a sixth aspect, an embodiment of the present application provides a computer program product, which is stored in a storage medium and is executed by at least one processor to implement the method of the first aspect.
[0035] In an embodiment of the present application, the model to be rendered that needs to realize concave rendering on the virtual ground is divided into two parts according to the model requirements, including a plane part and a concave part. Different materials are assigned to the plane part and the concave part respectively, and a specific first template value is written to the plane material. The concave material is subsequently tested for the template according to the first template value, and the depth test is performed on the patch that passes the template test. For the patch that passes the depth test, its target depth value is written into the material file of the concave material to overwrite the original depth value in the depth buffer, and the color of the patch is used to overwrite the original color. Rendering is performed in the order of plane material and concave material in the rendering queue to achieve the concave special effect.
[0036] In the embodiment of the present application, the model to be rendered is split into a flat part and a concave part according to the model requirements, and a real sunken space with depth is rendered in the concave part, so as to control the sunken space of different shapes and depths in the area with terrain without changing the existing terrain rendering template value, and show different skill special effects. In addition, compared with the parallax mapping technology in the related art, the embodiment of the present application can avoid mutations and distortion, provide a more realistic ground cracking skill effect, and the method of the embodiment of the present application can give the sunken space a correct depth value, thereby supporting the rendering of a real object in the generated sunken space, and there will be no problem of spatial relationship not being able to connect and mutual occlusion.
[0037] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0039] Figure 1 One of the flow diagrams of the model rendering method according to an embodiment of the present application is shown;
[0040] Figure 2 The second flowchart of the model rendering method according to the embodiment of the present application is shown;
[0041] Figure 3 A structural block diagram of a model rendering device according to an embodiment of the present application is shown;
[0042] Figure 4 A structural block diagram of an electronic device according to an embodiment of the present application is shown. DETAILED DESCRIPTION
[0043] The following will be combined with the drawings in the embodiments of the present application to clearly describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments in the present application belong to the scope of protection of this application.
[0044] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.
[0045] The model rendering method, device, electronic device and readable storage medium provided in the embodiments of the present application are described in detail below with reference to the accompanying drawings through specific embodiments and their application scenarios.
[0046] The present application embodiment provides a model rendering method, such as Figure 1 As shown, the method includes:
[0047] Step 101, dividing the model to be rendered on the virtual ground into a plane part and a concave part, wherein the plane part is a plane in the model to be rendered that fits the virtual ground, and the concave part is a curved surface in the model to be rendered that is sunken into the virtual ground.
[0048] In this step, the model to be rendered that needs to achieve concave rendering on the virtual ground is divided into two parts according to the model requirements. It is determined that one of the faces of the model to be rendered is a plane that fits the virtual ground, with the normal pointing upward, as the plane part; the remaining curved surface that is sunken in the virtual ground is the other part, that is, the concave part. The direction of the normal of the concave part is flipped so that the normal of the concave part is perpendicular to the concave surface and points upward.
[0049] The above model requirements refer to the shape of the concave space that you want to achieve, which can be a cylinder, a hemisphere, or any other desired spatial geometric shape.
[0050] It should be noted that after adopting the polygonal modeling method, the normal of the concave part is facing the convex side of the surface. In order to achieve that the normal is facing the direction of sight when looking down from the ground, the normal needs to be flipped to ensure the correct rendering of the model to be rendered.
[0051] Step 102, setting the planar part as a planar material, and setting the concave part as a concave material.
[0052] In this step, write a shader that can control the writing of template values, set the depth test method, and control the value of the color channel writing mask (Color Mask).
[0053] Different materials are assigned to the plane part and the concave part respectively. Specifically, the plane part is set to the plane material, and the concave part is set to the concave material.
[0054] Step 103, setting a first template value for the plane material, and based on the first template value, sequentially performing a template test and a depth test on the concave material to obtain a target depth value, and writing the target depth value into the material file of the concave material.
[0055] In this step, a specific first template value is written to the plane material, and a subsequent template test is performed on the concave material according to the first template value, and a depth test is performed on the patches that pass the template test, that is, the depth value of each patch is compared with the value in its corresponding depth buffer to determine whether the depth buffer and color buffer need to be updated. If the depth test fails, the patch will be discarded. For patches that pass the depth test, their target depth value is written into the material file of the concave material to overwrite the original depth value in the depth buffer, and the color of the patch is used to overwrite the original color.
[0056] Step 104: Render the model to be rendered in the order of the plane material and the concave material.
[0057] In this step, the plane material and the concave material are rendered in the rendering queue in order to achieve the sunken special effect.
[0058] In the embodiment of the present application, the model to be rendered is split into a flat part and a concave part according to the model requirements, and a real sunken space with depth is rendered in the concave part, so as to control the sunken space of different shapes and depths in the area with terrain without changing the existing terrain rendering template value, and show different skill special effects. In addition, compared with the parallax mapping technology in the related art, the embodiment of the present application can avoid mutations and distortion, provide a more realistic ground cracking skill effect, and the method of the embodiment of the present application can give the sunken space a correct depth value, thereby supporting the rendering of a real object in the generated sunken space, and there will be no problem of spatial relationship not being able to connect and mutual occlusion.
[0059] In addition, the parallax mapping technology in the related art is to render the sunken underground space by cyclically sampling the depth map that records the depth information. If you want to obtain a better artistic effect, hundreds of samplings are required, which consumes a lot of calculations. However, the embodiment of the present application does not rely on sampling maps to achieve the depth part, so the real-time rendering pressure is reduced.
[0060] In the embodiment of the present application, further, the concave surface material includes a first sub-material and a second sub-material, and the spatial position corresponding to the first sub-material coincides with the spatial position corresponding to the second sub-material;
[0061] The step of sequentially performing a template test and a depth test on the concave material based on the first template value to obtain a target depth value includes:
[0062] Performing a template test on the first sub-material based on the first template value to obtain a second template value of the first sub-material, and performing a template test on the second sub-material based on the second template value;
[0063] A depth test is performed on the second sub-material after the template test passes to obtain the target depth value of the second sub-material.
[0064] In this embodiment, the plane part of the model to be rendered is assigned to a plane material, such as material a, and the concave part of the model to be rendered is assigned to a concave material, which includes two sub-materials, a first sub-material (such as material b) and a second sub-material (such as material c). Different materials have different material parameters recorded on them, among which parameters such as template value, template test mode, depth test mode, etc. are all stored on the material in the form of material parameters.
[0065] It should be noted that the spatial positions of the first sub-material and the second sub-material overlap, and the difference between the two lies in the different material parameters recorded on the two materials.
[0066] A stencil test is performed on the first sub-material based on the first stencil value, that is, the first stencil value is compared with the stencil value already written in the stencil buffer corresponding to the first sub-material, and the second stencil value of the first sub-material is determined according to the comparison result. A stencil test is then performed on the second sub-material based on the second stencil value, that is, the second stencil value is compared with the stencil value already written in the stencil buffer corresponding to the second sub-material. Finally, a depth test is performed on the second sub-material that passes the stencil test to obtain the target depth value of the second sub-material.
[0067] Through the above method, it is possible to give the sunken space a correct depth value and render a real sunken space, thereby supporting the superposition of a new space with a depth effect based on this effect.
[0068] In the embodiment of the present application, further, performing a template test on the first sub-material based on the first template value to obtain a second template value of the first sub-material includes:
[0069] Using the first template value as a template reference value of the first sub-material, and comparing it with the buffer template value of the first sub-material, if the buffer template value of the first sub-material is equal to the first template value, determining that the first sub-material template test passes, and updating the buffer template value of the first sub-material to a second template value;
[0070] The performing a template test on the second sub-material based on the second template value includes:
[0071] The second template value is used as the template reference value of the second sub-material and compared with the buffer template value of the second sub-material. If the buffer template value of the second sub-material is equal to the second template value, it is determined that the second sub-material template test passes, and the buffer template value of the second sub-material is retained.
[0072] In this embodiment, the first template value is used as a template reference value, and the first template value is compared with the buffer template value corresponding to the first sub-material. If the two are equal, it is determined that the first sub-material template test passes, and the buffer template value of the part of the patch that passes the template test is updated to the second template value. The purpose of updating to the second template value is to make a distinction and prepare for comparison with the second sub-material.
[0073] Then use the second template value as a template reference value and compare the second template value with the buffer template value corresponding to the second sub-material. If the two are equal, it is determined that the second sub-material template test has passed, and the buffer template values of some patches that have passed the template test will be retained, that is, the value of the template depth cache will not be modified after passing.
[0074] It should be noted that the above changes are all about the stencil values in the stencil buffer, which are used as a reference for subsequent rendering. The stencil reference values of the first and second sub-materials remain unchanged, and the stencil reference values are used to compare with the values in the stencil buffer.
[0075] Through the above process, the second sub-material has the correct depth value when rendering. The concave part can be rendered later. Since the correct depth value information is already available, rendering can be performed according to the normal depth comparison method.
[0076] In the embodiment of the present application, further, the method also includes:
[0077] Set the condition for the first sub-material to always pass the depth test;
[0078] The condition for the second sub-material to perform a depth test is set to be less than or equal to pass the test.
[0079] In this embodiment, the condition for the depth test of the first sub-material is set to always pass the test, that is, the depth test mode of the first sub-material is set to Ztest Always, which always passes the test; the condition for the depth test of the second sub-material is set to less than or equal to pass the test, that is, the depth test mode of the second sub-material is set to ZtestLessEqual, and the depth writing of the second sub-material is enabled.
[0080] Depth test is to compare the depth value of the pixel. Setting ZtestAlways means that all pixels corresponding to the first sub-material pass and the depth comparison will not be eliminated. Setting ZtestLessEqual means that the part less than or equal to it passes.
[0081] In the embodiment of the present application, further, the rendering level of the concave portion is higher than the rendering levels of the virtual ground and the planar portion.
[0082] The rendering serial number of the plane material is set to N, the rendering serial number of the first sub-material is set to N+1, and the rendering serial number of the second sub-material is set to N+2, where N is a positive integer.
[0083] In this embodiment, the rendering level of the concave part is set higher than that of the virtual ground and the flat part, and a higher rendering level means rendering later, and a lower rendering level means rendering first. That is, the virtual ground and the flat part are rendered first, and then the concave part is rendered.
[0084] Specifically, the rendering queue is set, the rendering sequence number of the plane material is N, the rendering sequence number of the first sub-material is N+1, and the rendering sequence number of the second sub-material is N+2. For example, the rendering sequence number of the virtual ground is defined as 2000, the rendering sequence number of the plane material is also set to 2000, the rendering sequence number of the first sub-material is set to 2001, and the rendering sequence number of the second sub-material is set to 2002. The virtual ground and the plane part are rendered first, and then the first sub-material and the second sub-material are rendered in sequence.
[0085] Through the above method, a real sunken space with depth is rendered in the concave part, so that the sunken space of different shapes and depths can be controlled in the area with terrain without changing the existing terrain rendering template value, thereby showing different skill special effects.
[0086] In the embodiment of the present application, further, the method also includes:
[0087] When rendering the model to be rendered, the generation height of the plane part is set to be higher than or equal to the terrain height of the virtual ground.
[0088] In this embodiment, the height of the plane part is higher than or equal to the height of the virtual ground, that is, the plane part cannot be lower than the height of the virtual ground to ensure the ground concave effect and meet the skill special effect requirements.
[0089] Preferably, the height of the plane part is higher than the height of the virtual ground, so that when the virtual ground has a small fluctuation, it can be ensured that the ground depression effect will not disappear.
[0090] As a refinement and extension of the above embodiment, the embodiment of the present invention provides another model rendering method, such as Figure 2 As shown, the method includes:
[0091] Step 201 , dividing the model to be rendered into two parts, including a planar part and a concave part.
[0092] Step 202, write a shader that can control the writing of template values, set the depth test mode, and control the value of the color channel writing mask (ColorMask).
[0093] Step 203: The flat surface portion is assigned a material a, and the concave surface portion is assigned two different sub-materials, namely, sub-material b and sub-material c.
[0094] Step 204, for material a, write a specific first template value, such as 100, and set ColorMask to 0, and do not perform actual rendering.
[0095] Step 205, for sub-material b, set Ztest Always to always pass the depth test, set the template reference value of sub-material b to 100, if it is equal to 100, it passes the test, and add 1 to the template value of the passed part, which is 101.
[0096] Step 206, for sub-material c, the depth test is normally turned on according to the setting of less than or equal to (LessEqual), and the depth writing is turned on; the template reference value of sub-material c is set to 101, and if it is equal to 101, the test passes, and the current template value is saved.
[0097] There are specific locations with template values 101 that are areas for sunken rendering, and locations without this template value are rendered normally, thus rendering a sunken ground effect.
[0098] Step 207, setting the rendering queue, setting the terrain rendering sequence to 2000, then the material a rendering sequence is also 2000, and the sub-material b and sub-material c rendering sequences are set to 2001.
[0099] In one embodiment, the sub-material b rendering sequence may be set to 2001, and the sub-material c rendering sequence may be set to 2002.
[0100] Step 208, place the model to be rendered in the scene so that the plane part is slightly higher than the ground part.
[0101] It should be noted that the plane material and the first sub-material b are only used for template testing in the rendering pipeline. Colormask0 is set for both the plane material and the first sub-material b, so that they do not output color in the rendering channel, that is, they are not used for actual rendering. The second sub-material c is used to actually render the interior.
[0102] This application scheme is implemented in three layers of models. The first layer is the plane part, which is used to fit the shape of the ground and write specific template values. The second layer is a model patch that makes a concave space downward, which fits tightly with the edge of the first layer model, allowing it to pass the template test of the first layer and overwrite a new template value. The third layer uses the same model as the second layer, which is actually used for rendering, and performs depth testing and depth writing, so that the desired ground concave effect can be rendered only at specific locations with template values.
[0103] This application generates a downwardly sunken space on the already rendered ground, and objects can be rendered normally in the sunken space without remaking the terrain and changing the entire existing rendering sequence rules.
[0104] Furthermore, as a specific implementation of the above-mentioned model rendering method, an embodiment of the present application provides a model rendering device. Figure 3 As shown, the model rendering device 300 includes: a model division module 301, a testing module 302 and a rendering module 303.
[0105] The model division module 301 is used to divide the model to be rendered on the virtual ground into a plane part and a concave part, wherein the plane part is a plane in the model to be rendered that fits the virtual ground, and the concave part is a curved surface in the model to be rendered that is concave under the virtual ground; and set the plane part as a plane material, and set the concave part as a concave material.
[0106] A testing module 302 is used to set a first template value for the plane material, and perform a template test and a depth test on the concave material in sequence based on the first template value to obtain a target depth value, and write the target depth value into a material file of the concave material;
[0107] The rendering module 303 is used to render the model to be rendered in the order of the plane material and the concave material.
[0108] In this embodiment, the model to be rendered that needs to realize concave rendering on the virtual ground is divided into two parts according to the model requirements, including a plane part and a concave part. Different materials are assigned to the plane part and the concave part respectively, and a specific first template value is written to the plane material. The concave material is subsequently tested for the template according to the first template value, and the depth test is performed on the patch that passes the template test. For the patch that passes the depth test, its target depth value is written into the material file of the concave material to overwrite the original depth value in the depth buffer, and the color of the patch is used to overwrite the original color. Rendering is performed in the order of plane material and concave material in the rendering queue to achieve the concave special effect.
[0109] In the embodiment of the present application, the model to be rendered is split into a flat part and a concave part according to the model requirements, and a real sunken space with depth is rendered in the concave part, so as to control the sunken space of different shapes and depths in the area with terrain without changing the existing terrain rendering template value, and show different skill special effects. In addition, compared with the parallax mapping technology in the related art, the embodiment of the present application can avoid mutations and distortion, provide a more realistic ground cracking skill effect, and the method of the embodiment of the present application can give the sunken space a correct depth value, thereby supporting the rendering of a real object in the generated sunken space, and there will be no problem of spatial relationship not being able to connect and mutual occlusion.
[0110] Furthermore, the concave surface material includes a first sub-material and a second sub-material, and a spatial position corresponding to the first sub-material coincides with a spatial position corresponding to the second sub-material;
[0111] The testing module 302 is specifically used for:
[0112] Performing a template test on the first sub-material based on the first template value to obtain a second template value of the first sub-material, and performing a template test on the second sub-material based on the second template value;
[0113] A depth test is performed on the second sub-material after the template test passes to obtain the target depth value of the second sub-material.
[0114] Furthermore, the testing module 302 is specifically configured to:
[0115] Using the first template value as a template reference value of the first sub-material, and comparing it with the buffer template value of the first sub-material, if the buffer template value of the first sub-material is equal to the first template value, determining that the first sub-material template test passes, and updating the buffer template value of the first sub-material to a second template value;
[0116] The second template value is used as the template reference value of the second sub-material and compared with the buffer template value of the second sub-material. If the buffer template value of the second sub-material is equal to the second template value, it is determined that the second sub-material template test passes, and the buffer template value of the second sub-material is retained.
[0117] Furthermore, the testing module 302 is also used for:
[0118] Set the condition for the first sub-material to always pass the depth test;
[0119] The condition for the second sub-material to perform a depth test is set to be less than or equal to pass the test.
[0120] Furthermore, the rendering level of the concave portion is higher than the rendering levels of the virtual ground and the planar portion.
[0121] Furthermore, the rendering module 303 is further used to set the rendering serial number of the plane material to N, the rendering serial number of the first sub-material to N+1, and the rendering serial number of the second sub-material to N+2, where N is a positive integer.
[0122] Furthermore, the rendering module 303 is further configured to set the generation height of the plane part to be higher than or equal to the terrain height of the virtual ground when rendering the model to be rendered.
[0123] The model rendering device 300 in the embodiment of the present application can be an electronic device, or a component in an electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal, or other devices other than a terminal. Exemplarily, the electronic device can be a mobile phone, a tablet computer, a laptop computer, a PDA, a vehicle-mounted electronic device, a mobile Internet device (Mobile Internet Device, MID), an augmented reality (Augmented Reality, AR) / virtual reality (Virtual Reality, VR) device, a robot, a wearable device, an ultra-mobile personal computer (Ultra-Mobile Personal Computer, UMPC), a netbook or a personal digital assistant (Personal Digital Assistant, PDA), etc., and can also be a server, a network attached storage (Network Attached Storage, NAS), a personal computer (Personal Computer, PC), a television (Television, TV), etc., which is not specifically limited in the embodiment of the present application.
[0124] The model rendering device 300 provided in the embodiment of the present application can realize Figure 1 and Figure 2 To avoid repetition, the various processes implemented by the method embodiment are not described here.
[0125] The present application also provides an electronic device, such as Figure 4 As shown, the electronic device 400 includes a processor 401 and a memory 402. The memory 402 stores programs or instructions that can be executed on the processor 401. When the program or instructions are executed by the processor 401, the various steps of the above-mentioned model rendering method embodiment are implemented and the same technical effect can be achieved. To avoid repetition, they are not repeated here.
[0126] It should be noted that the electronic devices in the embodiments of the present application include the above-mentioned mobile electronic devices and non-mobile electronic devices.
[0127] The memory 402 can be used to store software programs and various data. The memory 402 may mainly include a first storage area for storing programs or instructions and a second storage area for storing data, wherein the first storage area may store an operating system, an application program or instructions required for at least one function (such as a sound playback function, an image playback function, etc.), etc. In addition, the memory 402 may include a volatile memory or a non-volatile memory, or the memory 402 may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), a static random access memory (SRAM), a dynamic random access memory (DRAM), a synchronous dynamic random access memory (SDRAM), a double data rate synchronous dynamic random access memory (DDRSDRAM), an enhanced synchronous dynamic random access memory (ESDRAM), a synchronous link dynamic random access memory (SLDRAM) and a direct memory bus random access memory (DRRAM). The memory 402 in the embodiment of the present application includes but is not limited to these and any other suitable types of memory.
[0128] The processor 401 may include one or more processing units; optionally, the processor 401 integrates an application processor and a modem processor, wherein the application processor mainly processes operations related to an operating system, a user interface, and application programs, and the modem processor mainly processes wireless communication signals, such as a baseband processor. It is understandable that the modem processor may not be integrated into the processor 401.
[0129] An embodiment of the present application also provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, each process of the above-mentioned model rendering method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0130] An embodiment of the present application also provides a chip, which includes a processor and a communication interface. The communication interface and the processor are coupled, and the processor is used to run programs or instructions to implement the various processes of the above-mentioned model rendering method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0131] It should be understood that the chip mentioned in the embodiments of the present application can also be called a system-level chip, a system chip, a chip system or a system-on-chip chip, etc.
[0132] An embodiment of the present application also provides a computer program product, which is stored in a storage medium. The program product is executed by at least one processor to implement the various processes of the above-mentioned model rendering method embodiment and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0133] It should be noted that, in this article, the terms "comprise", "include" or any other variant thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise one..." do not exclude the presence of other identical elements in the process, method, article or device including the element. In addition, it should be pointed out that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in reverse order according to the functions involved, for example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.
[0134] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.
Claims
1. A model rendering method, characterized in that: include: Dividing the model to be rendered on the virtual ground into a plane part and a concave part, wherein the plane part is a plane in the model to be rendered that fits the virtual ground, and the concave part is a curved surface in the model to be rendered that is sunken under the virtual ground; Setting the planar portion to a planar material, and setting the concave portion to a concave material; Setting a first template value for the plane material, and performing a template test and a depth test on the concave material in sequence based on the first template value to obtain a target depth value, and writing the target depth value into a material file of the concave material; The model to be rendered is rendered in the order of the plane material and the concave material.
2. The method according to claim 1, characterized in that The concave material includes a first sub-material and a second sub-material, and a spatial position corresponding to the first sub-material coincides with a spatial position corresponding to the second sub-material; The step of sequentially performing a template test and a depth test on the concave material based on the first template value to obtain a target depth value includes: Performing a template test on the first sub-material based on the first template value to obtain a second template value of the first sub-material, and performing a template test on the second sub-material based on the second template value; A depth test is performed on the second sub-material after the template test passes to obtain the target depth value of the second sub-material.
3. The method according to claim 2, characterized in that The performing a template test on the first sub-material based on the first template value to obtain a second template value of the first sub-material includes: Using the first template value as a template reference value of the first sub-material, and comparing it with the buffer template value of the first sub-material, if the buffer template value of the first sub-material is equal to the first template value, determining that the first sub-material template test passes, and updating the buffer template value of the first sub-material to a second template value; The performing a template test on the second sub-material based on the second template value includes: The second template value is used as the template reference value of the second sub-material and compared with the buffer template value of the second sub-material. If the buffer template value of the second sub-material is equal to the second template value, it is determined that the second sub-material template test passes, and the buffer template value of the second sub-material is retained.
4. The method according to claim 2, characterized in that: The method further comprises: Set the condition for the first sub-material to always pass the depth test; The condition for the second sub-material to perform a depth test is set to be less than or equal to pass the test.
5. The method according to claim 2, characterized in that: The rendering level of the concave portion is higher than the rendering levels of the virtual ground and the flat portion.
6. The method according to claim 5, characterized in that The method further comprises: Set the rendering sequence number of the plane material to N, the rendering sequence number of the first sub-material to N+1, and the rendering sequence number of the second sub-material to N+2, where N is a positive integer.
7. The method according to any one of claims 1 to 6, characterized in that The method further comprises: When rendering the model to be rendered, the generation height of the plane part is set to be higher than or equal to the terrain height of the virtual ground.
8. A model rendering device, characterized in that: include: A model division module is used to divide the model to be rendered on the virtual ground into a plane part and a concave part, wherein the plane part is a plane in the model to be rendered that fits the virtual ground, and the concave part is a curved surface in the model to be rendered that is concave under the virtual ground; and set the plane part to a plane material, and set the concave part to a concave material A testing module, used for setting a first template value for the plane material, and performing a template test and a depth test on the concave material in sequence based on the first template value to obtain a target depth value, and writing the target depth value into a material file of the concave material; A rendering module is used to render the model to be rendered in the order of the plane material and the concave material.
9. An electronic device, characterized in that: The method comprises a processor and a memory, wherein the memory stores a program or instruction running on the processor, and when the program or instruction is executed by the processor, the steps of the model rendering method according to any one of claims 1 to 7 are implemented.
10. A readable storage medium having a program or instruction stored thereon, characterized in that: When the program or instruction is executed by a processor, the steps of the model rendering method according to any one of claims 1 to 7 are implemented.