Rendering Method, Device, and Storage Medium

By constructing a baffle perpendicular to the ground plane in a three-dimensional virtual scene to crop the scene objects, the strange rendering problem caused by the non-parallel distance between the far cropping surface and the ground plane is solved, and a more reasonable rendering effect is achieved.

CN114494567BActive Publication Date: 2025-06-10ALIBABA INNOVATION PRIVATE LIMITED
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202111653544.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-30
Publication Date
2025-06-10
Estimated Expiration
2041-12-30

AI Technical Summary

Technical Problem

When rendering a three-dimensional virtual scene, the far cropping surface is not parallel to the ground plane, resulting in the bottom of the building being cut, and the upper half is in a suspended state, creating a weird rendering picture.

Method used

In a three-dimensional virtual scene, a baffle perpendicular to the ground plane is constructed along the intersection line between the far cropping surface of the virtual camera and the ground plane, and the scene object is cropped according to the baffle during rendering.

Benefits of technology

Ensure that the cropped objects in the three-dimensional scene are cropped perpendicular to the ground plane, avoiding the slanted cutting of the far-cut surface, thereby avoiding weird renderings and improving the rendering effect.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114494567B_ABST
    Figure CN114494567B_ABST
Patent Text Reader

Abstract

An embodiment of the present application provides a rendering method, device, and storage medium. Among them, the method includes the following steps: for a three-dimensional virtual scene to be rendered, determine the far clipping plane of the corresponding virtual camera; determine the intersection line between the far clipping plane and the ground plane in the three-dimensional virtual scene; for the three-dimensional virtual scene, construct a baffle perpendicular to the ground plane along the intersection line; when rendering the three-dimensional virtual scene, clip the scene objects in the three-dimensional virtual scene according to the baffle. The solution proposed by the embodiment of the present application can improve the rendering effect.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of rendering technology, and particularly to a rendering method, device and storage medium. Background Art

[0002] With the development of graphics technology and the improvement of computer performance, three-dimensional model rendering is widely used in industries such as electronic maps, games, and real estate.

[0003] Taking an electronic map as an example, the virtual camera in the three-dimensional map mimics the camera in the real world. In the world coordinate system of the three-dimensional map, the content of a single-frame map displayed on the screen is determined by setting the position, viewing angle, and wide angle of the virtual camera. Different content is displayed in different frames through the movement (translation, rotation, focus zoom, etc.) of the virtual camera. Summary of the Invention

[0004] Embodiments of this application provide a rendering method, device and storage medium to improve the rendering effect.

[0005] Therefore, in an embodiment of this application, a rendering method is provided. The method includes:

[0006] For a three-dimensional virtual scene to be rendered, determine the far clipping plane of its corresponding virtual camera;

[0007] Determine the intersection line of the far clipping plane and the ground plane in the three-dimensional virtual scene;

[0008] For the three-dimensional virtual scene, construct a baffle perpendicular to the ground plane along the intersection line;

[0009] When rendering the three-dimensional virtual scene, clip the scene objects in the three-dimensional virtual scene according to the baffle.

[0010] In another embodiment of this application, an electronic device is provided. The electronic device includes: a memory and a processor, where

[0011] The memory is used to store a program;

[0012] The processor is coupled to the memory and is used to execute the program stored in the memory to implement the rendering method described above.

[0013] In another embodiment of this application, a computer-readable storage medium storing a computer program is provided, where the computer program can implement the rendering method described above when executed by a computer.

[0014] In the technical solution provided by the embodiments of the present application, in a three-dimensional virtual scene, a baffle perpendicular to the ground plane is constructed along the intersection line of the far clipping plane of the virtual camera and the ground plane. When rendering the three-dimensional virtual scene, the scene objects in the three-dimensional virtual scene are clipped according to the baffle. Using a baffle perpendicular to the ground plane in the three-dimensional virtual scene to clip the scene objects in the three-dimensional virtual scene can ensure that the clipped objects in the three-dimensional scene are clipped in a manner perpendicular to the ground plane, rather than in an oblique cutting manner of the far clipping plane, thereby avoiding strange rendering images, for example: the bottom of a building is clipped and the upper half is in a suspended state, so as to improve the rendering effect. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the drawings in the following description are some embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.

[0016] Figure 1a A clipping schematic diagram provided by the present application;

[0017] Figure 1b Another clipping schematic diagram provided by the present application;

[0018] Figure 1c An electronic map interface diagram in the prior art;

[0019] Figure 1d An electronic map interface diagram provided by an embodiment of the present application;

[0020] Figure 1e Another electronic map interface diagram provided by an embodiment of the present application;

[0021] Figure 1f A flowchart of a rendering method for a three-dimensional virtual scene provided by an embodiment of the present application;

[0022] Figure 2 A flowchart of a rendering method for a three-dimensional map provided by an embodiment of the present application;

[0023] Figure 3 A structural block diagram of a rendering device provided by an embodiment of the present application;

[0024] Figure 4 A structural block diagram of an electronic device provided by an embodiment of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0025] In the prior art, a far clipping plane is usually set for a virtual camera in a three-dimensional virtual scene, and the far clipping plane defines the farthest distance that the virtual camera can see. Specifically, a viewing frustum is set for the virtual camera in the three-dimensional virtual scene. The viewing frustum includes a far clipping plane and a near clipping plane. During subsequent rendering, only the content inside the viewing frustum is drawn, and the content outside the viewing frustum is automatically clipped off.

[0026] Taking a three-dimensional map as an example, in the prior art, when a building is in the distance, it will be cut by the far clipping plane, and the remaining display part is irregular. As Figure 1a and Figure 1b shown, since the pitch angle of the virtual camera 50 in the three-dimensional map is usually negative (i.e., the pitch angle is pressed down), that is, the far clipping plane of the virtual camera is not parallel to the side of the building, it often occurs that the bottom of the building 10 in the three-dimensional map is clipped off by the far clipping plane 30 of the viewing frustum 40. According to the existing rendering scheme, the remaining part of the building clipped by the far clipping plane will be rendered in the rendering image. In this way, in the rendering image, it will be shown that the bottom of the building is beveled and the upper half is in a suspended state (as Figure 1c shown, the bottom of the building 10 is completely beveled and the whole is in a suspended state), thus generating a strange image.

[0027] In order to avoid such a strange rendering image, in this solution, in the three-dimensional virtual scene, a baffle perpendicular to the ground plane is constructed along the intersection line of the far clipping plane of the virtual camera and the ground plane. When rendering the three-dimensional virtual scene, the scene objects in the three-dimensional virtual scene are clipped according to the baffle. Using a baffle perpendicular to the ground plane in the three-dimensional virtual scene to clip the scene objects in the three-dimensional virtual scene can ensure that the clipped objects in the three-dimensional scene are clipped in a manner perpendicular to the ground plane, rather than in a beveled manner of the far clipping plane, thereby avoiding strange rendering images, for example: the bottom of the building is clipped and the upper half is in a suspended state, so as to improve the rendering effect.

[0028] In order to enable those skilled in the art to better understand the solution of this application, the technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of this application. Obviously, the described embodiments are only a part of the embodiments of this application, rather than all the embodiments. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative efforts fall within the scope of protection of this application.

[0029] In addition, in some processes described in the specification, claims, and the above-mentioned drawings of the present application, multiple operations that appear in a specific order are included. These operations can be executed not in the order in which they appear herein or in parallel. The serial numbers of the operations, such as 101, 102, etc., are only used to distinguish different operations, and the serial numbers themselves do not represent any execution order. Additionally, these processes can include more or fewer operations, and these operations can be executed sequentially or in parallel. It should be noted that the descriptions such as "first", "second", etc. in this article are used to distinguish different messages, devices, modules, etc., do not represent a sequence, and do not limit that "first" and "second" are of different types.

[0030] Figure 1f The flowchart shows a rendering method provided by an embodiment of the present application. The execution subject of this method can include a client and / or a server. Among them, the client can be a hardware with an embedded program integrated on the terminal, an application software installed in the terminal, or a tool software embedded in the terminal operating system, etc. The embodiments of the present application do not make any limitations in this regard. The terminal can be any terminal device including mobile phones, tablets, etc. Among them, the server can be a common server, cloud, or virtual server, etc. The embodiments of the present application do not make specific limitations in this regard. As Figure 1f shown, the method includes:

[0031] 101. For the three-dimensional virtual scene to be rendered, determine the far clipping plane of its corresponding virtual camera.

[0032] 102. Determine the intersection line between the far clipping plane and the ground plane in the three-dimensional virtual scene.

[0033] 103. For the three-dimensional virtual scene, construct a baffle perpendicular to the ground plane along the intersection line.

[0034] 104. When rendering the three-dimensional virtual scene, clip the scene objects in the three-dimensional virtual scene according to the baffle.

[0035] In the above 101, the three-dimensional virtual scene can specifically be a three-dimensional map, a three-dimensional game scene, etc. The far clipping plane can be determined according to the current pose information of the virtual camera in the three-dimensional virtual scene. Among them, the current pose information includes the current camera position and camera attitude of the virtual camera.

[0036] In practical applications, the frustum corresponding to the virtual camera in the three-dimensional virtual scene can be determined; the frustum includes a near clipping plane and a far clipping plane. Specifically, the frustum corresponding to the virtual camera can be determined according to the current pose information of the virtual camera in the three-dimensional virtual scene. The specific determination process of the frustum can refer to the prior art and will not be elaborated here.

[0037] In the above 102, the ground plane in the three-dimensional virtual scene can be determined according to the model data corresponding to the ground in the three-dimensional virtual scene. In one example, in the three-dimensional virtual scene, the intersection line between the far clipping plane and the ground plane can be determined according to the positions of the far clipping plane and the ground plane.

[0038] In the above 103, in the three-dimensional virtual scene, a baffle perpendicular to the ground plane can be constructed along the above intersection line, that is, the baffle is parallel to the intersection line.

[0039] In the above 104, in order to ensure a suitable viewing area for the virtual camera, the distance between the above intersection line and the plane where the baffle is located can be minimized. For example, the distance between the above intersection line and the plane where the baffle is located can be less than or equal to the first preset distance threshold. The size of the first preset distance threshold can be set according to actual needs, and the embodiments of the present application do not make specific limitations in this regard. In one example, the intersection line of the baffle and the ground plane can coincide with the intersection line of the far clipping plane and the ground plane.

[0040] During the process of rendering the three-dimensional virtual scene, the baffle perpendicular to the ground plane in the three-dimensional virtual scene is used to clip the object to be rendered instead of the far clipping plane.

[0041] In actual application, in order to reduce the construction difficulty, the above baffle can specifically be a baffle surface. As Figure 1a 、 1b shown, the intersection line of the baffle 60 (being a baffle surface) and the ground plane 20 coincides with the intersection line of the far clipping plane 30 and the ground plane 20.

[0042] Figure 1a In, if the building 10 to be rendered is clipped by the far clipping plane 30, the effect of the rendered image can be referred to Figure 1c , that is, the upper half of the building 10 to be rendered is suspended; if it is clipped by the baffle 60, the effect of the rendered image can be referred to Figure 1d , that is, the building 10 to be rendered completely disappears. Figure 1b In, if the building 10 to be rendered is clipped by the baffle 60, the effect of the rendered image can be referred to Figure 1e That is, the building to be rendered is cut in a manner perpendicular to the ground. It can be seen that using a baffle perpendicular to the ground to clip the object to be rendered can make the object to be rendered that was originally clipped obliquely by the far clipping plane be completely clipped by the baffle or be clipped by the baffle in a manner perpendicular to the ground, which can avoid the appearance of strange rendered images and improve the rendering effect.

[0043] In a feasible solution, the above method may further include:

[0044] 105. Configure the baffle to be invisible.

[0045] Specifically, the baffle can be configured to be transparent or configured to be the background color. If the baffle is configured to be transparent, then after the baffle is rendered, it is invisible in the rendered image. If the baffle is configured to be the background color, then after the baffle is rendered, it will blend with the background and is still invisible to the user.

[0046] In actual application, the baffle can be configured to be invisible according to the actual situation.

[0047] Correspondingly, for "clipping the scene object in the three-dimensional virtual scene according to the baffle" in the above 104, the following steps can be adopted to implement it:

[0048] 1041a. Render the baffle.

[0049] 1042a. During the process of rendering the baffle, update the depth buffer of the rendered image corresponding to the three-dimensional virtual scene according to the depth information of the baffle.

[0050] 1043a. Render the scene object through depth testing according to the updated depth buffer.

[0051] In the above 1041a, after the baffle is rendered, it is invisible in the rendered image. Therefore, during the process of rendering the three-dimensional virtual scene, rendering the baffle will not affect the final rendered image effect.

[0052] In the above 1042a, during the process of rendering the baffle, update the depth buffer of the rendered image corresponding to the three-dimensional virtual scene according to the depth information of the baffle. In actual application, the depth information of each rendering point on the baffle can be calculated according to the vertex position information of the baffle in the three-dimensional virtual scene.

[0053] After the baffle is rendered, the depth information of its respective rendering points will be left in the depth buffer; the color of the pixels of its respective points to be rendered will be left in the color buffer. This color can be a transparent color or the background color.

[0054] In actual application, the baffle can be rendered before rendering the scene object in the three-dimensional virtual scene.

[0055] In the above 1043a, render the scene object through depth testing according to the updated depth buffer.

[0056] Depth testing is to compare the depth value of the point to be rendered on the scene object with the depth value of the corresponding pixel cached in the depth buffer of the rendering frame. When the depth value of the point to be rendered is less than the depth value of the corresponding pixel cached in the depth buffer, the color value of the pixel of the point to be rendered is written to the corresponding pixel in the color buffer, and the depth value of the point to be rendered is written to the corresponding pixel in the depth buffer; when the depth value of the point to be rendered is greater than or equal to the depth value of the corresponding pixel cached in the depth buffer, the pixel of the point to be rendered is ignored, that is, the color value and depth value of the pixel of the point to be rendered are not used to update the color buffer and depth buffer respectively.

[0057] During the rendering process, each point to be rendered on the object to be rendered can be traversed in a traversal manner.

[0058] It should be noted that after the rendering of the three-dimensional virtual scene is completed, the picture displayed on the screen can be determined according to the color buffer.

[0059] In this embodiment, the baffle is configured to be invisible, and the baffle is first rendered, and then the scene object is rendered.

[0060] In another implementable solution, in the above 104, "when rendering the three-dimensional virtual scene, the scene object in the three-dimensional virtual scene is clipped according to the baffle", which can be specifically implemented by the following steps:

[0061] 1041b. Determine the first point to be rendered on the scene object in the three-dimensional virtual scene.

[0062] 1042b. Determine the first reference point on the baffle according to the first point to be rendered.

[0063] Among them, the first reference point, the first point to be rendered, and the viewpoint of the virtual camera are collinear.

[0064] 1043b. If the depth value corresponding to the first point to be rendered is greater than or equal to the depth value corresponding to the first reference point, the first point to be rendered is marked as a point to be clipped off.

[0065] 1044b. When rendering the three-dimensional virtual scene, the scene object is clipped based on the mark of the first point to be rendered.

[0066] In the embodiment, there is no need to render the baffle, and only the depth information of the baffle needs to be considered when rendering the scene object.

[0067] In one example, the above 1044b, "when rendering the three-dimensional virtual scene, the scene object is clipped based on the mark of the first point to be rendered" may include one or more of the following steps:

[0068] S11. When rendering the three-dimensional virtual scene, when the first point to be rendered is marked as a point to be clipped, ignore the rendering of the first point to be rendered.

[0069] S12. When rendering the three-dimensional virtual scene, when the first point to be rendered is marked as a point to be clipped, perform fogging processing on the pixel of the first point to be rendered to obtain the fogged pixel of the first point to be rendered, and render the first point to be rendered according to the fogged pixel of the first point to be rendered.

[0070] In the above S11, that is, do not update the color buffer and the depth buffer by using the color value and the depth value of the pixel of the first point to be rendered respectively.

[0071] In the above S12, performing fogging processing on the pixel of the first point to be rendered means correcting the color value of the pixel of the first point to be rendered to the color of the fog, then updating the color buffer by using the corrected color value of the pixel of the first point to be rendered, and updating the depth buffer by using the depth value of the first point to be rendered.

[0072] In this embodiment, there is no need to render the baffle in advance. When rendering the scene object, only need to compare the depth of each point to be rendered with the depth of the corresponding reference point on the baffle in real time, so as to remove or fog the part of the scene object that exceeds the baffle.

[0073] Optionally, the above method further includes:

[0074] 106. When the depth value corresponding to the first point to be rendered is less than the depth value corresponding to the first reference point, update the depth buffer and the color buffer of the rendering image corresponding to the three-dimensional virtual scene respectively according to the depth value corresponding to the first point to be rendered and the color value of the pixel corresponding to the first point to be rendered.

[0075] Considering that when rendering a scene object, in addition to considering the depth of the baffle, it is also necessary to consider the occlusion of other scene objects in the three-dimensional virtual scene on this scene object. Therefore, the above method may further include:

[0076] Compare the depth value corresponding to the first point to be rendered with the depth value of the corresponding pixel cached in the depth buffer; if the depth value corresponding to the first point to be rendered is less than the depth value of the corresponding pixel cached in the depth buffer, it indicates that the pixel of the first point to be rendered is not occluded by other rendered objects. Therefore, update the depth buffer and the color buffer of the rendering image corresponding to the three-dimensional virtual scene according to the depth value corresponding to the first point to be rendered and the color value of the pixel corresponding to the first point to be rendered; if the depth value corresponding to the first point to be rendered is greater than or equal to the depth value of the corresponding pixel cached in the depth buffer, it indicates that the pixel of the first point to be rendered is occluded by other rendered objects. Therefore, the rendering of the first point to be rendered needs to be ignored.

[0077] Among them, updating the depth buffer and the color buffer of the rendering image corresponding to the three-dimensional virtual scene according to the depth value corresponding to the first point to be rendered and the color value of the pixel corresponding to the first point to be rendered means: writing the depth value corresponding to the first point to be rendered to the corresponding pixel point in the depth buffer; writing the color value of the pixel corresponding to the first point to be rendered to the corresponding pixel point in the color buffer.

[0078] In an actual application scenario, the above three-dimensional virtual scene can be a three-dimensional map scene; the scene object can be a building object. Figure 2 The flowchart of a rendering method for a three-dimensional map is shown.

[0079] As Figure 2 shown, the method includes:

[0080] 201. For the three-dimensional map scene to be rendered, determine the far clipping plane of the corresponding virtual camera.

[0081] 202. Determine the intersection line between the far clipping plane and the ground plane in the three-dimensional map scene.

[0082] 203. For the three-dimensional map scene, construct a baffle perpendicular to the ground plane along the intersection line.

[0083] 204. When rendering the three-dimensional map scene, clip the building objects in the three-dimensional map scene according to the baffle.

[0084] For the specific implementation of the above steps 201, 202, 203, and 204, reference can be made to the corresponding content in the above embodiments, which will not be elaborated here.

[0085] In the technical solution provided by the embodiment of the present application, in a three-dimensional map scene, a baffle perpendicular to the ground plane is constructed along the intersection line of the far clipping plane of the virtual camera and the ground plane. When rendering the three-dimensional map scene, the scene objects in the three-dimensional map scene are clipped according to the baffle. Using a baffle perpendicular to the ground plane in the three-dimensional map scene to clip the scene objects in the three-dimensional map scene can ensure that the clipped objects in the three-dimensional map scene are clipped in a manner perpendicular to the ground plane, rather than in an oblique cutting manner of the far clipping plane, thereby avoiding strange rendering images, for example: the bottom of the building is clipped and the upper half is in a suspended state, so as to improve the rendering effect.

[0086] It should be noted here that: for the content not detailed in each step of the method provided by the embodiment of the present application, reference can be made to the corresponding content in the above embodiments, and details will not be repeated here. In addition, in the method provided by the embodiment of the present application, in addition to the above steps, it may also include other parts or all of the steps in the above embodiments. For specific reference, see the corresponding content in the above embodiments, and details will not be repeated here.

[0087] Next, a technical solution provided by an embodiment of the present application will be introduced in conjunction with Figure 1a A technical solution provided by an embodiment of the present application will be introduced:

[0088] Step 401: Determine the current position information and attitude information of the virtual camera 50 in the three-dimensional map.

[0089] Step 402: Determine the viewing frustum 40 of the virtual camera according to the current position information and attitude information of the virtual camera 50.

[0090] After determining the viewing frustum 40, the far clipping plane 30 is obtained.

[0091] Step 403: Determine the intersection line position of the far clipping plane 30 and the ground plane 20 in the three-dimensional map.

[0092] Step 404: At the intersection line position of the far clipping plane 30 and the ground plane 20 in the three-dimensional map, construct a baffle 60 perpendicular to the ground plane 20.

[0093] Among them, the baffle 60 can be vertically elevated upward from the intersection line of the far clipping plane and the ground plane.

[0094] Among them, the intersection line of the baffle 60 and the ground plane 20 coincides with the intersection line of the far clipping plane 30 and the ground plane 20.

[0095] Step 405: Configure the baffle object to have a transparent attribute.

[0096] Step 406: Before rendering the building to be rendered, render the baffle so that after the baffle is rendered, the depth information of the baffle is left in the depth buffer corresponding to the screen.

[0097] When rendering the baffle, the depth test and depth writing functions in the open graphics engines OpenGL and Metal can be enabled.

[0098] After the baffle is rendered, start rendering the buildings within the frustum. The rendering process includes the following steps:

[0099] Step 407: Determine the first point to be rendered on the building.

[0100] Step 408: Obtain the depth value of the corresponding pixel cached in the depth buffer.

[0101] Herein, the corresponding pixel refers to the pixel in the depth buffer corresponding to the first point to be rendered. It can be understood that the first point to be rendered, the corresponding pixel, and the viewpoint of the virtual camera are collinear.

[0102] Step 409: When the depth value of the first point to be rendered is less than the depth value of the corresponding pixel cached in the depth buffer, replace the color value of the pixel of the first point to be rendered with the color value of the corresponding pixel in the color buffer; replace the depth value of the first point to be rendered with the depth value of the corresponding pixel in the depth buffer.

[0103] Step 410: When the depth value of the first point to be rendered is greater than or equal to the depth value of the corresponding pixel cached in the depth buffer, ignore the rendering of the first point to be rendered.

[0104] That is to say, when rendering the building, the depth value of the building is compared with the depth value of the baffle, and the part farther than the baffle will be clipped. Moreover, in this solution, when the building is clipped by the baffle, it will be cut in a way perpendicular to the ground, rather than obliquely.

[0105] This solution can achieve regular vertical cutting of distant buildings, avoid oblique cutting, and thus avoid the alien effect. Moreover, by introducing the baffle with a transparent attribute, the impact on the map rendering effect is small, or even has a positive impact.

[0106] Next, another technical solution provided by the embodiments of the present application will be introduced in conjunction with Figure 1a Step 501: Determine the current position information and attitude information of the virtual camera 50 in the three-dimensional map.

[0107] Step 502: Determine the frustum 40 of the virtual camera according to the current position information and attitude information of the virtual camera 50.

[0108] After determining the frustum 40, the far clipping plane 30 is obtained.

[0109] Determining the frustum 40 also obtains the far clipping plane 30.

[0110] Step 503: Determine the intersection position of the far clipping plane 30 and the ground plane 20 in the three-dimensional map.

[0111] Step 504: At the position of the intersection line between the far clipping plane 30 and the ground plane 20 in the 3D map, construct a baffle 60 perpendicular to the ground plane 20.

[0112] Wherein, the intersection line of the baffle 60 and the ground plane 20 coincides with the intersection line of the far clipping plane 30 and the ground plane 20.

[0113] In this embodiment, instead of rendering the baffle, the position where the baffle is located is passed to the building rendering shader, and through real-time calculation, the excess part of the building can be vertically removed or atomized. The rendering process of the building includes the following steps:

[0114] Step 505: Determine the first point to be rendered on the scene object in the 3D virtual scene; according to the first point to be rendered, determine the first reference point on the baffle.

[0115] Wherein, the first reference point, the first point to be rendered, and the view point of the virtual camera are collinear.

[0116] Step 506: If the depth value corresponding to the first point to be rendered is greater than or equal to the depth value corresponding to the first reference point, mark the first point to be rendered as a point to be clipped; when rendering the 3D virtual scene, when the first point to be rendered is marked as a point to be clipped, ignore the rendering of the first point to be rendered.

[0117] Step 507: When the depth value corresponding to the first point to be rendered is less than the depth value corresponding to the first reference point, compare the depth value corresponding to the first point to be rendered with the depth value of the corresponding pixel point cached in the depth buffer.

[0118] Step 508: If the depth value corresponding to the first point to be rendered is less than the depth value of the corresponding pixel point cached in the depth buffer, write the depth value corresponding to the first point to be rendered to the corresponding pixel point in the depth buffer, and write the color value of the pixel corresponding to the first point to be rendered to the corresponding pixel point in the color buffer.

[0119] Step 509: If the depth value corresponding to the first point to be rendered is greater than or equal to the depth value of the corresponding pixel point cached in the depth buffer, ignore the rendering of the first point to be rendered.

[0120] Figure 3 The block diagram of a rendering device for a 3D virtual scene provided by another embodiment of the present application is shown. As Figure 3 shown, the device includes:

[0121] The first determination module 301 is used to determine the far clipping plane of the corresponding virtual camera for the 3D virtual scene to be rendered

[0122] A second determination module 302, configured to determine an intersection line between the far clipping plane and the ground plane in the three-dimensional virtual scene;

[0123] A construction module 303, configured to construct a baffle perpendicular to the ground plane along the intersection line for the three-dimensional virtual scene;

[0124] A rendering module 304, configured to clip a scene object in the three-dimensional virtual scene according to the baffle when rendering the three-dimensional virtual scene.

[0125] In the technical solution provided by the embodiment of the present application, in a three-dimensional virtual scene, a baffle perpendicular to the ground plane is constructed along an intersection line between the far clipping plane of a virtual camera and the ground plane. When rendering the three-dimensional virtual scene, a scene object in the three-dimensional virtual scene is clipped according to the baffle. Using a baffle perpendicular to the ground plane in the three-dimensional virtual scene to clip a scene object in the three-dimensional virtual scene can ensure that the clipped object in the three-dimensional scene is clipped in a manner perpendicular to the ground plane, rather than in an oblique cutting manner of the far clipping plane, thereby avoiding strange rendering pictures, for example: the bottom of a building is clipped and the upper half is in a suspended state, so as to improve the rendering effect.

[0126] Optionally, an intersection line between the baffle and the ground plane coincides with an intersection line between the far clipping plane and the ground plane.

[0127] Optionally, the above device further includes:

[0128] A configuration module, configured to configure the baffle to be transparent;

[0129] The rendering module 304 is specifically configured to:

[0130] Render the baffle;

[0131] During the process of rendering the baffle, update a depth buffer of a rendering picture corresponding to the three-dimensional virtual scene according to depth information of the baffle;

[0132] Render the scene object through depth testing according to the updated depth buffer.

[0133] Optionally, the rendering module 304 is specifically configured to:

[0134] Determine a first point to be rendered on a scene object in the three-dimensional virtual scene;

[0135] Determine a first reference point on the baffle according to the first point to be rendered; the first reference point, the first point to be rendered, and a viewpoint of the virtual camera are collinear;

[0136] When the depth value corresponding to the first point to be rendered is greater than or equal to the depth value corresponding to the first reference point, mark the first point to be rendered as a point to be clipped.

[0137] When rendering the three-dimensional virtual scene, perform clipping on the scene object based on the marking of the first point to be rendered.

[0138] Optionally, the rendering module 304 is specifically configured to:

[0139] When rendering the three-dimensional virtual scene, when the first point to be rendered is determined to be a point to be clipped, ignore the rendering for the first point to be rendered.

[0140] Optionally, the rendering module 304 is specifically configured to:

[0141] When rendering the three-dimensional virtual scene, when the first point to be rendered is determined to be a point to be clipped, perform fogging processing on the pixels of the first point to be rendered to obtain the fogged pixels of the first point to be rendered;

[0142] Render the first point to be rendered according to the fogged pixels of the first point to be rendered.

[0143] Optionally, the rendering module 304 is further configured to:

[0144] When the depth value corresponding to the first point to be rendered is less than the depth value corresponding to the first reference point, update the depth buffer and the color buffer of the rendering image corresponding to the three-dimensional virtual scene respectively according to the depth value corresponding to the first point to be rendered and the color value of the pixels corresponding to the first point to be rendered.

[0145] Optionally, the three-dimensional virtual scene includes a three-dimensional map scene.

[0146] It should be noted here that: the rendering device provided in the above embodiments can implement the technical solutions and technical effects described in the above method embodiments. The specific implementation principles of the above modules or units can refer to the corresponding content in the above method embodiments, which will not be elaborated here.

[0147] Figure 4 Shows a schematic structural diagram of an electronic device provided in an embodiment of the present application. As Figure 4As shown, the electronic device includes a memory 1101 and a processor 1102. The memory 1101 can be configured to store various other data to support operations on the electronic device. Examples of such data include instructions for any application or method operating on the electronic device. The memory 1101 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disks, or optical disks.

[0148] The memory 1101 is used to store programs;

[0149] The processor 1102, coupled to the memory 1101, is used to execute the program stored in the memory 1101 to implement the rendering method steps or functions provided in the above embodiments.

[0150] Among them, when the processor 1102 executes the program in the memory 1101, in addition to the above functions, other functions can also be implemented. For specific details, please refer to the descriptions of the previous embodiments.

[0151] Furthermore, as Figure 4 shown, the electronic device further includes: a communication component 1103, a display 1104, a power supply component 1105, an audio component 1106, and other components. Figure 4 Only some components are schematically shown in Figure 4 the figure, which does not mean that the electronic device only includes

[0152] the components shown in the figure.

[0153] Correspondingly, an embodiment of the present application further provides a computer-readable storage medium storing a computer program, and when the computer program is executed by a computer, it can implement the rendering method steps or functions provided in the above embodiments.

[0154] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on such an understanding, the essence of the above technical solution, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0155] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, and are not intended to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions recorded in the foregoing embodiments, or perform equivalent replacements for some of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims

1. A rendering method, wherein, it includes: For a three-dimensional virtual scene to be rendered, determine the far clipping plane of the frustum corresponding to the virtual camera corresponding thereto; Determine the intersection line between the far clipping plane and the ground plane in the three-dimensional virtual scene; For the three-dimensional virtual scene, construct a baffle perpendicular to the ground plane along the intersection line; When rendering the three-dimensional virtual scene, clip the scene objects in the three-dimensional virtual scene according to the baffle.

2. The method according to claim 1, wherein, The intersection line between the baffle and the ground plane coincides with the intersection line between the far clipping plane and the ground plane.

3. The method according to claim 1 or 2, wherein, it further includes: Configure the baffle to be transparent; The clipping of the scene objects in the three-dimensional virtual scene according to the baffle includes: Render the baffle; During the rendering of the baffle, update the depth buffer of the rendering image corresponding to the three-dimensional virtual scene according to the depth information of the baffle; According to the updated depth buffer, render the scene objects through depth testing.

4. The method according to claim 1 or 2, wherein, When rendering the three-dimensional virtual scene, the clipping of the scene objects in the three-dimensional virtual scene according to the baffle includes: Determine the first point to be rendered on the scene object in the three-dimensional virtual scene; According to the first point to be rendered, determine the first reference point on the baffle; the first reference point, the first point to be rendered, and the viewpoint of the virtual camera are collinear; If the depth value corresponding to the first point to be rendered is greater than or equal to the depth value corresponding to the first reference point, mark the first point to be rendered as a point to be clipped; When rendering the three-dimensional virtual scene, clip the scene objects based on the marking of the first point to be rendered.

5. The method according to claim 4, wherein, When rendering the three-dimensional virtual scene, the clipping of the scene objects based on the marking of the first point to be rendered includes: When rendering the three-dimensional virtual scene, when the first point to be rendered is marked as a point to be clipped, ignore the rendering of the first point to be rendered.

6. The method according to claim 4, wherein, When rendering the three-dimensional virtual scene, the clipping of the scene objects based on the marking of the first point to be rendered includes: When rendering the three-dimensional virtual scene, when the first point to be rendered is marked as a point to be clipped, perform fogging processing on the pixel of the first point to be rendered to obtain the fogged pixel of the first point to be rendered; Render the first point to be rendered according to the fogged pixel of the first point to be rendered.

7. The method according to claim 4, wherein, it further includes: If the depth value corresponding to the first point to be rendered is less than the depth value corresponding to the first reference point, update the depth buffer and the color buffer of the rendering image corresponding to the three-dimensional virtual scene according to the depth value corresponding to the first point to be rendered and the color value of the pixel corresponding to the first point to be rendered, respectively.

8. The method according to claim 1 or 2, wherein, The three-dimensional virtual scene includes a three-dimensional map scene.

9. An electronic device, wherein, comprising: a memory and a processor, wherein, the memory is used for storing a program; the processor is coupled to the memory and is used for executing the program stored in the memory to implement the rendering method according to any one of claims 1 to 8.

10. A computer-readable storage medium storing a computer program, wherein, the computer program, when executed by a computer, is capable of implementing the rendering method according to any one of claims 1 to 8.

Citation Information

Patent Citations

  • Live-action three-dimensional model cutting method and device and computer equipment

    CN113706713A