Object rendering method and device, equipment, medium and program product
By acquiring the depth information of the 3D mask and the object to be rendered, the masked portion is determined and rendered, solving the problem of insufficient flexibility in occlusion display in existing technologies and achieving higher accuracy and flexibility.
Patent Information
- Application Number
- CN202411107095.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-12
- Publication Date
- 2026-02-13
AI Technical Summary
Existing technologies offer limited flexibility in occluding objects based on target areas on the screen, and cannot handle complex occlusion requirements.
By acquiring the depth information of the 3D mask and the object to be rendered, the masked parts are determined and rendered. The 3D mask is used to achieve a fine masking effect based on the depth information, and the system controls which parts of the object to be rendered should be rendered and which parts should be hidden.
It improves the accuracy and flexibility of occlusion for rendered objects, meeting the complex occlusion requirements in the scene construction process.
Smart Images

Figure CN121527273A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of rendering, and in particular to an object rendering method, apparatus, device, medium, and program product. Background Technology
[0002] In game development, computer graphics, and animation, rendering (also known as painting) is a crucial process used to convert 3D models, 2D images, lighting, shadows, textures, and other objects into a 2D image that the player sees on the screen. During actual rendering, there is a need to occlude the objects being rendered.
[0003] In related technologies, taking a 3D model as an example, before rendering the 3D model, a target area on the screen is defined. When rendering the 3D model to the screen, only the 3D model within the target area is rendered, and the 3D model outside the target area is not rendered, thereby achieving the occlusion effect of the 3D model.
[0004] However, the related technologies have low flexibility in occluding objects to be rendered based on target areas on the screen, and cannot handle complex occlusion requirements. Summary of the Invention
[0005] This application provides an object rendering method, apparatus, device, medium, and program product, which can improve the accuracy and flexibility of occlusion of objects to be rendered, thereby meeting the complex occlusion requirements in the scene construction process. The technical solution is as follows:
[0006] On the one hand, an object rendering method is provided, the method comprising:
[0007] Obtain a 3D mask and a virtual object to be rendered within the field of view of a virtual camera. The 3D mask is an invisible object used to mask the virtual object. The 3D mask corresponds to a first depth information relative to the virtual camera, and the virtual object corresponds to a second depth information relative to the virtual camera.
[0008] The masking portion of the virtual object is determined based on the first depth information and the second depth information; the masking portion is used to indicate that the virtual object is in a first part within the masking space corresponding to the three-dimensional mask body, or the masking portion is used to indicate that the virtual object is in a second part outside the masking space;
[0009] The masked portion of the virtual object is rendered to obtain the rendering result of the virtual object.
[0010] On the other hand, an object rendering apparatus is provided, the apparatus comprising:
[0011] The acquisition module is used to acquire a three-dimensional mask and a virtual object to be rendered within the field of view of the virtual camera. The three-dimensional mask is an invisible object used to mask the virtual object. The three-dimensional mask corresponds to a first depth information relative to the virtual camera, and the virtual object corresponds to a second depth information relative to the virtual camera.
[0012] The determining module is used to determine the masking portion of the virtual object based on the first depth information and the second depth information; the masking portion is used to indicate that the virtual object is in a first part within the masking space corresponding to the three-dimensional mask body, or the masking portion is used to indicate that the virtual object is in a second part outside the masking space;
[0013] The rendering module is used to render the masked portion of the virtual object to obtain the rendering result of the virtual object.
[0014] On the other hand, a computer device is provided, the computer device including a processor and a memory, the memory storing at least one instruction, at least one program, code set or instruction set, the at least one instruction, the at least one program, the code set or instruction set being loaded and executed by the processor to implement any of the above-described object rendering methods.
[0015] On the other hand, a computer-readable storage medium is provided, wherein at least one instruction, at least one program, code set, or instruction set is stored therein, wherein the at least one instruction, the at least one program, the code set, or the instruction set is loaded and executed by a processor to implement any of the object rendering methods described above.
[0016] On the other hand, a computer program product or computer program is provided, comprising computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform any of the object rendering methods described above.
[0017] The beneficial effects of the technical solutions provided in this application include at least the following:
[0018] A 3D masking body was designed for masking objects to be rendered. For objects to be rendered that are within the field of view of a virtual camera, the masking body determines whether to render the portion of the object within the masking space or the portion outside the masking space, based on the depth information of the 3D masking body relative to the virtual camera and the depth information of the object to be rendered relative to the virtual camera. The 3D masking body can achieve fine masking effects based on depth information, controlling which parts of the object to be rendered should be rendered and which parts should be hidden, thus improving the accuracy and flexibility of occlusion of objects to be rendered and meeting the complex occlusion requirements in the scene construction process. Attached Figure Description
[0019] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0020] Figure 1 This is a structural block diagram of a computer system provided in an exemplary embodiment of this application;
[0021] Figure 2 This is a schematic diagram of an object rendering method provided in an exemplary embodiment of this application;
[0022] Figure 3 This is a flowchart of an object rendering method provided in an exemplary embodiment of this application;
[0023] Figure 4 This is a schematic diagram of an object rendering method provided in another exemplary embodiment of this application;
[0024] Figure 5 This is a schematic diagram of an object rendering method provided in yet another exemplary embodiment of this application;
[0025] Figure 6 This is a flowchart of an object rendering method provided in another exemplary embodiment of this application;
[0026] Figure 7 This is a flowchart of an object rendering method provided in yet another exemplary embodiment of this application;
[0027] Figure 8 This is a flowchart of masking an object provided in an exemplary embodiment of this application;
[0028] Figure 9 This is a schematic diagram of the costume masking effect in a game provided by an exemplary embodiment of this application;
[0029] Figure 10 This is a structural block diagram of an object rendering apparatus provided in an exemplary embodiment of this application;
[0030] Figure 11 This is a structural block diagram of a computer system provided in an exemplary embodiment of this application. Detailed Implementation
[0031] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0032] In this application, the terms "first" and "second" are used to distinguish between identical or similar items that have essentially the same function. It should be understood that there is no logical or temporal dependency between "first" and "second", nor is there any limitation on the quantity or execution order.
[0033] It should be noted that this application may display prompt interfaces, pop-ups, or output voice prompts before and during the collection of user data. These prompt interfaces, pop-ups, or voice prompts are used to inform the user that their data is being collected. This ensures that the application only begins the steps for collecting user data after receiving confirmation from the user regarding the prompt interface or pop-up; otherwise (i.e., without user confirmation), the steps for collecting user data end, meaning no user data is collected. In other words, all user data collected in this application is collected with the user's consent and authorization, and the collection, use, and processing of related user data must comply with relevant laws, regulations, and standards.
[0034] Figure 1 This is a structural block diagram of a computer system provided in an exemplary embodiment of this application. The computer system can implement a system architecture for an object rendering method. The computer system includes a terminal 110 and a server 120, which are connected via a communication network 130. The communication network 130 can be a wired network or a wireless network; this embodiment does not limit its use.
[0035] In some embodiments, terminal 110 may be a smartphone, tablet, laptop, desktop computer, smart home appliance, smart vehicle terminal, etc., but is not limited thereto. Terminal 110 has a target application installed. Indicatively, the target application may be a traditional application, a cloud application, a mini-program or application module within a host application, or a web platform; this embodiment does not limit this. The target application provides rendering functionality. Optionally, the target application may include, but is not limited to, game development engines, 3D modeling and animation software, architectural design and visualization software, virtual reality and augmented reality applications, film and television special effects software, simulation and training software, and applications with user-generated content (UGC) editors (e.g., party casual games).
[0036] In some embodiments, server 120 provides background services for the target application installed on the terminal. It is worth noting that server 120 can be a standalone physical server, a server cluster or distributed system consisting of multiple physical servers, a cloud server providing basic cloud computing services, or a node in a blockchain system.
[0037] For example, server 120 includes processor 124 and memory 122. Memory 122 includes receiving module 1221, control module 1222 and sending module 1223. Receiving module 1221 is used to receive requests sent by terminal 110; control module 1222 is used to control the rendering of the screen; sending module 1223 is used to send responses to terminal 110.
[0038] Optionally, server 120 undertakes the main computing work and terminal 110 undertakes the secondary computing work; or, server 120 undertakes the secondary computing work and terminal 110 undertakes the main computing work; or, server 120 and terminal 110 adopt a distributed computing architecture for collaborative computing.
[0039] The object rendering method provided in this application embodiment can be executed by a computer device, which refers to an electronic device with data computing, processing, and storage capabilities. Figure 1 Taking the implementation environment of the scheme shown as an example, the object rendering method can be executed by the terminal 110 (for example, the target application installed and running in the terminal 110 executes the object rendering method), or the object rendering method can be executed by the server 120, or the terminal 110 and the server 120 can interact and cooperate to execute it. This application does not limit this.
[0040] Those skilled in the art will understand that the number of terminals 110 described above can be more or less. For example, there may be only one terminal 110, or there may be dozens or hundreds of terminals 110, or even more. This application does not limit the number or type of terminals 110 in its embodiments.
[0041] In game development, computer graphics, and animation, rendering (also known as painting) is a crucial process used to convert 3D models, 2D images, lighting, shadows, textures, and other objects into a 2D image that the player sees on the screen. During actual rendering, there is a need to occlude the objects being rendered. In related technologies, taking 3D models as an example, a target area on the screen is defined before rendering the 3D model. When rendering the 3D model to the screen, only the 3D model within the target area is rendered; the 3D model outside the target area is not rendered, thus achieving an occlusion effect. However, this technology, based on a target area on the screen, has limited flexibility in occluding objects and cannot handle complex occlusion requirements.
[0042] Based on this, this application provides an object rendering method, please refer to... Figure 2 It illustrates a schematic diagram of an object rendering method provided in an exemplary embodiment of this application, such as... Figure 2 As shown, interface 200 displays the rendering effect of object 201 without a 3D mask. Without a 3D mask, after rendering object 201, the portion of object 201 exposed within the virtual camera's field of view is fully displayed in interface 200. When a spherical mask 202 is added to object 201, during rendering, the depth of the spherical mask 202 relative to the virtual camera is compared with the depth of object 201 relative to the virtual camera. This determines the object portion 203 within the spherical mask 202's internal space. After determining the object portion 203, it is rendered, resulting in the rendering effect of object portion 203 as shown in interface 210. It should be noted that the spherical mask 202 displayed in interface 200 is only for illustrative purposes; the spherical mask 202 is not actually visible in interface 200.
[0043] In summary, the object rendering method provided in this application provides a three-dimensional masking body for masking objects to be rendered. For objects to be rendered that are within the field of view of a virtual camera, the masking portion of the object to be rendered within the masking space is determined based on the depth information of the three-dimensional masking body relative to the virtual camera and the depth information of the object to be rendered relative to the virtual camera. The masked portion is then rendered. The three-dimensional masking body can achieve a fine masking effect based on depth information, controlling which parts of the object to be rendered should be rendered and which parts should be hidden, thus improving the accuracy and flexibility of occlusion of objects to be rendered and meeting the complex occlusion requirements in the scene construction process.
[0044] Figure 3 This is a flowchart illustrating an exemplary embodiment of this application providing an object rendering method. The method is executed by a computer device, which may be... Figure 1 The terminal or server shown can also be Figure 1 The method, which includes steps 310 to 330, involves the terminal and server shown.
[0045] Step 310: Obtain the 3D mask and the virtual object to be rendered within the field of view of the virtual camera.
[0046] A virtual camera is a mathematical model that simulates a real-world camera. It is not an actual physical device, but a concept in computer graphics used to capture and present images in a virtual scene. The virtual scene is the scene displayed when the target application runs, including but not limited to game development engines, 3D modeling and animation software, etc.
[0047] To illustrate, let's take the virtual scene as an example of the world space in a game development engine. The world space is a three-dimensional space with meters as the unit. Developers can place and move various objects in the world space, such as characters, buildings, props, etc., and observe the display effect of these objects on the screen through a virtual camera.
[0048] The field of view of a virtual camera refers to the area of the virtual scene covered by the camera, starting from its current position and orientation, based on the size of its field of view. For example, the field of view of a virtual camera is a cone-shaped space with the camera position as the vertex, the camera orientation as the axis, and the camera's field of view as the angle. The virtual scene content within this cone-shaped space will be "seen" by the virtual camera and incorporated into the subsequent rendering process, thus resulting in the virtual scene interface displayed on the screen.
[0049] The field of view of a virtual camera includes visible and invisible objects. Visible objects are those that need to be rendered onto the screen, and the virtual objects within the field of view of the virtual camera are visible objects. Invisible objects are those that do not need to be rendered onto the screen. The 3D masking volume within the field of view of the virtual camera is an invisible object used to mask virtual objects. The 3D masking volume itself is not rendered onto the screen, but it defines which parts of the virtual object should be rendered and which parts can be omitted.
[0050] Optionally, the shape of the 3D mask is a pre-defined shape. Illustratively, the 3D mask can be a regular shape such as a sphere, cube, or cone, or an irregular shape such as a ring. The 3D mask can be customized according to the developer's needs; no limitations are imposed here.
[0051] The 3D mask body corresponds to the first depth information relative to the virtual camera, and the virtual object corresponds to the second depth information relative to the virtual camera. The first depth information is used to indicate the distance between the 3D mask body and the virtual camera, and the second depth information is used to indicate the distance between the virtual object and the virtual camera.
[0052] Step 320: Determine the masked portion of the virtual object based on the first depth information and the second depth information.
[0053] Optionally, the three-dimensional mask body corresponds to a mask space, which is the space defined by the surface of the three-dimensional mask body. The masked portion indicates that the virtual object is located within the first part of the mask space corresponding to the three-dimensional mask body, or the masked portion indicates that the virtual object is located outside the mask space.
[0054] In some embodiments, the first depth information refers to the distance between the plurality of first vertices constituting the three-dimensional mask and the virtual camera, and the second depth information refers to the distance between the plurality of second vertices constituting the virtual object and the virtual camera.
[0055] In 3D modeling and computer graphics, vertices are one of the basic elements that make up a polygonal mesh. They are connected by edges to form faces, which in turn constitute a 3D shape. Each vertex has an associated 3D coordinate system, which defines the vertex's position in 3D space. In the embodiments of this application, multiple first vertices constitute the shape of a 3D mask, and multiple second vertices constitute the shape of a virtual object.
[0056] It should be noted that the vertices mentioned in the embodiments of this application include all points that define the shape characteristics of the model (such as a three-dimensional mask or virtual object), including at least one of the following vertices: (1) surface vertices, which are located on the outer boundary of the model and define the appearance shape of the model; (2) internal vertices, which are located inside the model.
[0057] Optionally, the process of determining the masked portion of the virtual object based on the first depth information and the second depth information further includes the following steps:
[0058] Step 1: For the x-th second vertex among multiple second vertices, determine the specified vertex corresponding to the x-th second vertex among multiple first vertices, where x is a positive integer.
[0059] Among them, the xth second vertex and the specified vertex are on the same line of sight (i.e., the mapping direction mentioned below) corresponding to the virtual camera.
[0060] Optionally, taking the mapping method of the virtual camera as an example of center mapping, the specified vertex refers to the point through which the x-th ray passes in the three-dimensional mask volume, where the x-th ray is the ray with the virtual camera position as the endpoint and passes through the x-th second vertex.
[0061] Step 2: If the distance between the xth second vertex and the virtual camera, and the distance between the specified vertex and the virtual camera meet the distance requirements, determine that the xth second vertex is within the masking space corresponding to the 3D masking volume.
[0062] Optionally, the number of vertices can be one or more.
[0063] If there exists a single specified vertex, and the distance between the x-th second vertex and the virtual camera is greater than or equal to the distance between the specified vertex and the virtual camera, then the x-th second vertex is determined to be within the masking space.
[0064] Indicative, such as Figure 4 As shown, in the world space 400 of the virtual engine, the field of view of the virtual camera 401 includes a three-dimensional mask 402 and a virtual object 403, where the three-dimensional mask 402 is a curved surface. For a ray 404 emanating from the virtual camera 401 that passes through point a on the virtual object 403, if ray 404 intersects the three-dimensional mask 402 at point b, and the distance between point a and the virtual camera 401 is greater than or equal to the distance between the intersection point b and the virtual camera 401, then point a is within the masking space of the three-dimensional mask 402.
[0065] If there are multiple specified vertices, and the distance between the xth second vertex and the virtual camera is greater than or equal to the first distance and less than or equal to the second distance, the xth second vertex is determined to be within the masking space; wherein, the first distance indicates the minimum distance among the distances between the multiple specified vertices and the virtual camera, and the second distance indicates the maximum distance among the distances between the multiple specified vertices and the virtual camera.
[0066] like Figure 5 As shown, in the world space 500 of the virtual engine, the field of view of the virtual camera 501 includes a 3D mask 502 and a virtual object 503. The 3D mask 502 is a cube. For a line of sight 505 emanating from the virtual camera 501 passing through point c on the virtual object 503, the intersection points of the line of sight 505 and the 3D mask 502 include intersection point d and intersection point e. Intersection point d is the point on the 3D mask 502 furthest from the virtual camera on the line of sight 505, and intersection point e is the point on the 3D mask 502 closest to the virtual camera on the line of sight 505. If the distance between point c and the virtual camera 501 is greater than or equal to the distance between intersection point e and the virtual camera 501, and less than or equal to the distance between intersection point d and the virtual camera 501, then point c is within the masking space of the 3D mask 502.
[0067] Among them, the multiple specified vertices include at least one of the surface vertices and internal vertices of the 3D mask volume.
[0068] It should be noted that the above example of determining the masking portion when multiple specified vertices exist is merely illustrative and not intended to be limiting. In practical application of this solution, when there are at least 3 specified vertices, and these 3 specified vertices are surface vertices of the 3D mask volume, the at least 3 specified vertices are sorted from largest to smallest according to their distance from the virtual camera. For example, the order of the 3 specified vertices is as follows: specified vertex 1, specified vertex 2, and specified vertex 3. The xth second vertex is determined to be in the masking space when it falls within at least one of the following ranges: the range between specified vertex 1 and specified vertex 2, or the range between specified vertex 2 and specified vertex 3.
[0069] Step 3: Based on the second vertex among multiple second vertices that is located within the mask space corresponding to the 3D mask volume, determine the masking portion of the virtual object.
[0070] Optionally, the object portion constructed by the second vertex within the masking space is determined as the masking portion; or, the object portion constructed by the second vertex outside the masking space is determined as the masking portion.
[0071] Optionally, the multiple first vertices refer to the vertices of the three-dimensional mask within the field of view of the virtual camera, and the multiple second vertices refer to the vertices of the virtual objects within the field of view of the virtual camera.
[0072] Step 330: Render the masked part of the virtual object to obtain the rendering result of the virtual object.
[0073] In illustrative terms, after determining the masked portion of the virtual object, only the masked portion of the virtual object is rendered to obtain the rendering result of the virtual object. The rendering result of the virtual object is used to display the masked portion of the virtual object on the screen, while hiding the other parts of the virtual object outside the masked portion.
[0074] In summary, this application provides an object rendering method, which designs a three-dimensional mask body for masking objects to be rendered. For objects to be rendered that are within the field of view of a virtual camera, the method determines whether to render the masked portion of the object within the mask space or the masked portion outside the mask space, based on the depth information of the three-dimensional mask body relative to the virtual camera and the depth information of the object to be rendered relative to the virtual camera. The three-dimensional mask body can achieve a fine masking effect based on depth information, controlling which parts of the object to be rendered should be rendered and which parts should be hidden, thus improving the accuracy and flexibility of occlusion of objects to be rendered and meeting the complex occlusion requirements in the scene construction process.
[0075] In some embodiments, the first depth information mentioned above is the depth information obtained after rendering the three-dimensional mask volume. For illustrative purposes, please refer to... Figure 6 , Figure 3 The illustrated embodiment can also be implemented as steps 601 to 604 below.
[0076] Step 601: Obtain the 3D mask and the virtual object to be rendered within the field of view of the virtual camera.
[0077] The 3D masking volume is an invisible object used to mask virtual objects.
[0078] Optionally, the three-dimensional masking body used to mask the virtual object can be one or more.
[0079] Optionally, the 3D mask volume corresponds to multiple first vertices, and the virtual object corresponds to multiple second vertices. The multiple first vertices are used to construct the shape of the 3D mask volume, and the multiple second vertices are used to construct the shape of the virtual object.
[0080] Optionally, the multiple first vertices refer to the vertices of the three-dimensional mask within the field of view of the virtual camera, and the multiple second vertices refer to the vertices of the virtual objects within the field of view of the virtual camera.
[0081] Step 602: Render the 3D mask within the field of view of the virtual camera to obtain m first pixels corresponding to the 3D mask.
[0082] Among them, m first pixels each store depth information, and the depth information stored in the j-th first pixel includes the depth information corresponding to the j-th first pixel when at least one first vertex on the 3D mask is mapped to the acquisition plane of the virtual camera. m and j are positive integers, and j≤m.
[0083] Indicatively, the first mapping plane is the mapping plane corresponding to the 3D mask. The first mapping plane is obtained as the acquisition plane of the virtual camera. The first mapping plane is composed of multiple empty pixels. Each empty pixel has a corresponding mapping direction. This direction starts from the position of the virtual camera and reaches the empty pixel. When the mapping direction passes through at least one first vertex on the 3D mask, at least one first vertex is mapped to the empty pixel. The mapping operation includes storing the depth information of at least one first vertex in the empty pixel, thereby obtaining the mapped empty pixel as the first pixel.
[0084] Multiple first vertices corresponding to the three-dimensional mask within the field of view of the virtual camera are mapped to m empty pixels among multiple empty pixels, thus obtaining m first pixels. The depth information stored in the m first pixels is used as the first depth information.
[0085] Optionally, if there is a single first vertex in the mapping direction corresponding to the j-th first pixel, the depth information stored in the j-th first pixel includes the distance between the single first vertex and the virtual camera.
[0086] Optionally, if there are multiple first vertices in the mapping direction corresponding to the j-th first pixel, the depth information stored in the j-th first pixel includes multiple distance nodes. For example, assuming there are first vertex 1, first vertex 2 and first vertex 3, the depth information stored in the j-th first pixel includes at least two of the distances between first vertex 1 and the virtual camera, first vertex 2 and the virtual camera, and first vertex 3 and the virtual camera.
[0087] In some embodiments, when there are multiple first vertices in the mapping direction corresponding to the j-th first pixel, the depth information stored in the j-th first pixel refers to a first depth and a second depth. The first depth indicates the depth of the first vertex that is farthest from the virtual camera among the multiple first vertices, and the second depth indicates the depth of the first vertex that is closest to the virtual camera among the multiple first vertices.
[0088] In some embodiments, the aforementioned first depth information is stored in a first rendering target. The rendering target refers to buffered image data used to store rendering results; that is, the rendering target stores the output of the graphics processing unit (GPU) rendering operations. This output may include pixel color values, depth information, and other information reflecting visual effects. The rendering target is not directly displayed to the user but serves as an intermediate step in the rendering pipeline. The GPU can read and write to the rendering target to complete tasks during the rendering process, such as the task of determining the mask portion of a virtual object as described in this application. It should be noted that the aforementioned first mapping plane is the mapping plane indicated by the first rendering target.
[0089] Optionally, the three-dimensional mask within the field of view of the virtual camera is rendered to obtain the first rendering object.
[0090] The first rendering object refers to the buffered image data that stores the rendering result of the three-dimensional mask, and the multiple first pixels constituting the first rendering object include m first pixels corresponding to the three-dimensional mask.
[0091] Step 603: Based on the m first pixels and second depth information corresponding to the three-dimensional mask body, determine the masked part of the virtual object.
[0092] The second depth information includes the distances between the virtual object's multiple second vertices and the virtual camera.
[0093] To illustrate, before rendering the virtual object, the mask information corresponding to the virtual object is obtained, that is, the m first pixels corresponding to the three-dimensional mask volume are obtained.
[0094] In some embodiments, the m first pixels corresponding to the three-dimensional mask body are included in the plurality of first pixels of the first rendering object, and obtaining the mask information corresponding to the virtual object is equivalent to obtaining the first rendering object.
[0095] Optionally, when there is at least one second vertex in the mapping direction corresponding to the j-th first pixel, the target vertex in the masking space is determined from the at least one second vertex, and the distance between the target vertex and the virtual camera meets the distance requirement corresponding to the depth information stored in the j-th first pixel.
[0096] In some embodiments, the mapping direction corresponding to the j-th first pixel refers to the mapping direction of the target pixel corresponding to the j-th first pixel in the second mapping plane.
[0097] Indicatively, the second mapping plane is the mapping plane corresponding to the virtual object. The second mapping plane is composed of multiple empty pixels, and each empty pixel has a corresponding mapping direction. This direction starts from the position of the virtual camera and eventually reaches the empty pixel on the second mapping plane.
[0098] The number of empty pixels constituting the first mapping plane is the same as the number of empty pixels constituting the second mapping plane, and the size of each empty pixel is the same. That is to say, the size of the first mapping plane and the second mapping plane is the same, and the mapping directions corresponding to the multiple empty pixels constituting the first mapping plane correspond one-to-one with the mapping directions corresponding to the multiple empty pixels constituting the second mapping plane. For example, the empty pixel located in the first row and first column in the first mapping plane has the same mapping direction as the empty pixel located in the first row and first column in the second mapping plane.
[0099] In the second mapping plane, determine the pixel point corresponding to the j-th first pixel point. The mapping direction corresponding to the empty pixel point is the target pixel point. The mapping direction of the target pixel point is the same as the mapping direction of the j-th first pixel point.
[0100] In some embodiments, the mapping directions corresponding to m pixels are traversed, and the masking portion is determined based on the existence of the second vertex in the mapping directions corresponding to the m pixels. It should be noted that although the mapping directions corresponding to m pixels are traversed to determine the masking portion, the masking portion is not rendered on the first mapping plane, but on the second mapping plane.
[0101] In other embodiments, the mapping directions corresponding to multiple pixels on the second mapping plane (or the first mapping plane) are traversed, and the masking portion is determined based on the existence of the second vertex in the mapping direction corresponding to the multiple pixels.
[0102] Optionally, the above-mentioned determination of the masking portion based on the presence of the second vertex in the mapping direction includes at least one of the following:
[0103] Case 1: When there is a single first vertex in the mapping direction corresponding to the j-th first pixel, the depth information stored in the j-th first pixel includes the distance between the single first vertex and the virtual camera; wherein, the distance between the target vertex and the virtual camera is greater than or equal to the distance between the single first vertex and the virtual camera.
[0104] To illustrate, assume that there is only one first vertex V1 in the mapping direction corresponding to the j-th first pixel, and the distance between the first vertex V1 and the virtual camera is d1. If the distance between the first vertex V1 and the virtual camera is greater than or equal to d, then the first vertex V1 is in the masking space.
[0105] Case 2: When there are multiple first vertices in the mapping direction corresponding to the j-th first pixel, the depth information stored in the j-th first pixel includes multiple distance nodes; the distance between the target vertex and the virtual camera is between at least two specified distance nodes.
[0106] Optionally, multiple first vertices refer to the surface vertices of the three-dimensional mask volume.
[0107] Optionally, if there are two first vertices in the mapping direction corresponding to the j-th first pixel, the target vertex is determined from the distance range less than that of the first vertex in the mapping direction and the distance range greater than that of the second vertex in the mapping direction; or, the target vertex is determined from the distance range between the two vertices in the mapping direction.
[0108] Schematic: If there are only two vertices in the mapping direction, then the second vertex within a distance range smaller than the first vertex or greater than the second vertex can be identified as the target vertex; or, the second vertex within a distance range between the two vertices can be identified as the target vertex.
[0109] Suppose there are two first vertices V1 and V2 in the mapping direction corresponding to the j-th first pixel, and their distances from the virtual camera are d1 and d2 (d1 < d2), then the target vertex can be a second vertex with a distance less than d1 or greater than d2; or, the target vertex can be a second vertex between these two first vertices.
[0110] Optionally, if there are at least three first vertices in the mapping direction corresponding to the j-th first pixel, the target vertex is determined from the distance range less than the first first vertex in the mapping direction and the distance range between the 2kth first vertex and the 2k+1th first vertex; or, the target vertex is determined from the distance range between the 2k-1th first vertex and the 2kth first vertex and the distance range greater than the last first vertex in the mapping direction.
[0111] To illustrate, assume that there are three first vertices V1, V2 and V3 in the mapping direction corresponding to the j-th first pixel, and their distances from the virtual camera are d1, d2 and d3 respectively (d1 < d2 < d3).
[0112] The target vertex can be the second vertex whose distance is less than d1, or the second vertex located between d2 and d3; or, the target vertex can be the second vertex whose distance is greater than d3, or the second vertex located between d1 and d2.
[0113] After determining the masking portion, if the masking portion is used to indicate that the virtual object is in the first part of the masking space corresponding to the 3D masking volume, then the object portion constructed by the second vertex in the masking space corresponding to the 3D masking volume is the masking portion of the virtual object. If the masking portion is used to indicate that the virtual object is in the second part outside the masking space, then the object portion constructed by the second vertex outside the masking space corresponding to the 3D masking volume is the masking portion of the virtual object.
[0114] Step 604: Render the masked part of the virtual object to obtain the rendering result of the virtual object.
[0115] In some embodiments, the rendering result refers to a second rendered object obtained by rendering the masked portion of a virtual object.
[0116] Schematic, during the execution of step 603, if the masking part is used to indicate that the virtual object is in the first part of the masking space corresponding to the three-dimensional mask body, when it is determined that the second vertex is in the masking space, the second vertex is mapped to the empty pixel of the second mapping plane. After traversing the multiple empty pixels constituting the second mapping plane, the obtained second mapping plane is the second rendering object; if the masking part is used to indicate that the virtual object is in the second part outside the masking space corresponding to the three-dimensional mask body, when it is determined that the second vertex is outside the masking space, the second vertex is mapped to the empty pixel of the second mapping plane. After traversing the multiple empty pixels constituting the second mapping plane, the obtained second mapping plane is the second rendering object.
[0117] In summary, this application provides an object rendering method that generates m first pixels containing depth information by rendering a three-dimensional mask within the field of view of a virtual camera. This depth information accurately reflects the depth information of each vertex on the three-dimensional mask when mapped to the virtual camera's acquisition plane, thereby achieving a precise representation of the three-dimensional mask's position in the virtual scene and ensuring the accuracy of the subsequently determined mask portion.
[0118] In addition, embodiments of this application can also render the three-dimensional mask body as m first pixels on the first rendering object. By reading the first rendering object, depth information for determining whether the second vertex is in the mask space can be quickly obtained, thereby saving computing resources and improving rendering efficiency.
[0119] In some embodiments, the field of view of the virtual camera described above includes multiple three-dimensional mask objects. For illustrative purposes, please refer to... Figure 7 , Figure 3 The illustrated embodiment can also be implemented as steps 701 to 704 below.
[0120] Step 701: Obtain multiple 3D mask bodies and virtual objects to be rendered that are within the field of view of the virtual camera.
[0121] Several of these 3D masking bodies are invisible objects used to mask virtual objects.
[0122] Optionally, the 3D mask volume corresponds to multiple first vertices, and the virtual object corresponds to multiple second vertices. The multiple first vertices are used to construct the shape of the 3D mask volume, and the multiple second vertices are used to construct the shape of the virtual object. Optionally, the position, shape, and other parameters of the multiple 3D mask volumes can be the same or different.
[0123] Optionally, the multiple first vertices refer to the vertices of the three-dimensional mask within the field of view of the virtual camera, and the multiple second vertices refer to the vertices of the virtual objects within the field of view of the virtual camera.
[0124] Step 702: Render multiple 3D mask objects within the field of view of the virtual camera to obtain the first rendering object.
[0125] The first rendering object indicates buffered image data that stores the rendering results corresponding to multiple 3D mask bodies. Among the multiple first pixels constituting the first rendering object, m pixels respectively store depth information, and the depth information stored in the j-th first pixel includes the depth information corresponding to at least one of the multiple 3D mask bodies.
[0126] Indicatively, assume there are mask body 1 and mask body 2. Render mask body 1 and 2 to obtain a first rendering object. Mask body 1 and 2 are mapped to m pixels among a plurality of first pixel points, wherein the depth information stored in the j-th first pixel point contains at least one of the depth information of mask body 1 and the depth information of mask body 2.
[0127] The following explanation uses a three-dimensional mask body, including a first mask body and a second mask body, as an example.
[0128] Optionally, a rendering process is performed to render the first mask and the second mask onto a first candidate rendering object, where the first candidate rendering object includes n first candidate pixels, where n is a positive integer. During the rendering process, when there is a first vertex in the first mask that maps to a target candidate pixel among the n first candidate pixels, the depth information corresponding to the first vertex in the first mask is stored in the first storage channel corresponding to the target candidate pixel. During the rendering process, when there is a first vertex in the second mask that maps to a target candidate pixel, the depth information corresponding to the first vertex in the second mask is stored in the second storage channel corresponding to the target candidate pixel. When the rendering of the first mask and the second mask is completed, the first candidate rendering object after storage processing is obtained as the first rendering object.
[0129] Schematic illustration: The first candidate rendering object includes multiple empty pixels, each corresponding to a first storage channel and a second storage channel. Multiple first vertices corresponding to the first mask within the virtual camera's field of view are mapped to p empty pixels. Values are assigned to each of the p empty pixels, and the assignment results are stored in the first storage channel, resulting in p empty pixels as p first pixels. Multiple first vertices corresponding to the second mask within the virtual camera's field of view are mapped to q empty pixels. Values are assigned to each of the q empty pixels, and the assignment results are stored in the second storage channel, resulting in q empty pixels as q first pixels. The assignment results include the depth information of the first vertices; for details, refer to step 602, which will not be repeated here. There may be overlapping pixels between the p and q first pixels, and the intersection of the p and q first pixels is m first pixels.
[0130] In some embodiments, the above assignment result may also include a mask identifier.
[0131] Optionally, when there is a first vertex in the first mask that is mapped to a target candidate pixel among the n first candidate pixels, the first mask identifier of the first mask is stored in the first storage channel corresponding to the target candidate pixel; when there is a first vertex in the second mask that is mapped to a target candidate pixel, the second mask identifier of the second mask is stored in the second storage channel corresponding to the target candidate pixel.
[0132] For example: if the first vertex on the first mask is mapped to the target empty pixel, then the mask identifier of the first mask is stored in the first storage channel of the target empty pixel, for example: L1; if the first vertex on the second mask is mapped to the target empty pixel, then the mask identifier of the second mask is stored in the second channel of the target empty pixel, for example: L2.
[0133] Step 703: Determine the masked portion of the virtual object based on the first rendering object and the second depth information.
[0134] The second depth information refers to the distance between the virtual camera and the multiple second vertices of the virtual object within the virtual camera's field of view.
[0135] Optionally, the masking portion is determined based on the masking body identifiers corresponding to the multiple second vertices, the depth information stored in the first storage channel corresponding to the m first pixels, the depth information stored in the second storage channel corresponding to the m pixels, and the distances between the multiple second vertices of the virtual object and the virtual camera.
[0136] Optionally, when there is at least one second vertex in the mapping direction corresponding to the j-th first pixel, the masking body identifier corresponding to at least one second vertex is obtained; when the j-th first pixel stores the first masking body identifier and the masking body identifier corresponding to at least one second vertex matches the first masking body identifier, a first target vertex within the masking space is determined among the at least one second vertex, and the distance between the first target vertex and the virtual camera conforms to the distance requirement corresponding to the depth information stored in the first storage channel of the j-th first pixel; when the j-th first pixel stores the second masking body identifier and the masking body identifier corresponding to at least one second vertex matches the second masking body identifier, a second target vertex within the masking space is determined among the at least one second vertex, and the distance between the second target vertex and the virtual camera conforms to the distance requirement corresponding to the depth information stored in the second storage channel of the j-th first pixel; based on the target vertex within the masking space, the masking portion of the virtual object is determined.
[0137] Indicatively, the process searches along the mapping direction corresponding to the j-th first pixel to determine if there exists at least one second vertex, which belongs to a virtual object in the virtual scene. For each found second vertex, the mask identifier to which it belongs is obtained. The mask identifier is a unique identifier used to distinguish different masks, and the mask identifier corresponding to the second vertex can be pre-set. If the j-th first pixel stores a first mask identifier, the process iterates through the mask identifiers of all second vertices along the mapping direction to find a vertex that matches the first mask identifier. If the j-th first pixel also stores a second mask identifier, the process similarly iterates through the mask identifiers of all second vertices along the mapping direction to find a vertex that matches the second mask identifier.
[0138] For vertices matching the first mask body identifier, determine whether their distance to the virtual camera meets the distance requirement corresponding to the depth information stored in the first storage channel of the j-th first pixel. Vertices meeting these conditions are marked as first target vertices. For vertices matching the second mask body identifier, determine whether their distance to the virtual camera meets the distance requirement corresponding to the depth information stored in the second storage channel of the j-th first pixel. Vertices meeting these conditions are marked as second target vertices. The method for determining whether the distance requirement is met can be found in step 602, and will not be elaborated here. By traversing m pixels, all first target vertices and second target vertices are obtained. This allows the construction of a masked portion of the virtual object that is either inside or outside the masking space. The masking space may contain at least one of the masking spaces corresponding to the first mask body and the second mask body, respectively.
[0139] Step 704: Render the masked part of the virtual object to obtain the rendering result of the virtual object.
[0140] In some embodiments, the rendering result refers to a second rendered object obtained by rendering the masked portion of a virtual object.
[0141] Schematic, during the execution of step 603, if the masking part is used to indicate that the virtual object is in the first part of the masking space corresponding to the three-dimensional mask body, when it is determined that the second vertex is in the masking space, the second vertex is mapped to the empty pixel of the second mapping plane. After traversing the multiple empty pixels constituting the second mapping plane, the obtained second mapping plane is the second rendering object; if the masking part is used to indicate that the virtual object is in the second part outside the masking space corresponding to the three-dimensional mask body, when it is determined that the second vertex is outside the masking space, the second vertex is mapped to the empty pixel of the second mapping plane. After traversing the multiple empty pixels constituting the second mapping plane, the obtained second mapping plane is the second rendering object.
[0142] In summary, this application provides an object rendering method, which designs a three-dimensional mask body for masking objects to be rendered. For objects to be rendered that are within the field of view of a virtual camera, the method determines whether to render the masked portion of the object within the mask space or the masked portion outside the mask space, based on the depth information of the three-dimensional mask body relative to the virtual camera and the depth information of the object to be rendered relative to the virtual camera. The three-dimensional mask body can achieve a fine masking effect based on depth information, controlling which parts of the object to be rendered should be rendered and which parts should be hidden, thus improving the accuracy and flexibility of occlusion of objects to be rendered and meeting the complex occlusion requirements in the scene construction process.
[0143] In addition, in this embodiment, multiple three-dimensional masking bodies are rendered as a first rendering object. When traversing multiple second vertices corresponding to the virtual object, the depth information of the specified masking body in the first rendering object can be read according to the masking body identifier indicated by the second vertex, thereby determining the masking part. The first rendering object may contain different masking body identifiers. In other words, the object rendering method provided by this application can perform cross-masking of virtual objects based on multiple masking bodies contained in the first rendering object, enriching the methods for masking virtual objects and meeting the complex occlusion requirements in the scene construction process.
[0144] This is illustrative; please refer to it. Figure 8 It demonstrates a method for masking objects, such as... Figure 8 As shown, the process includes the following steps:
[0145] Step 1: Render the mask body 801 onto the mask RT.
[0146] Here, RT refers to the Render Target (RT). Illustratively, rendering a mask onto the mask RT requires the following input information: the mask's ID, channel (1 or 0), and the mask's geometric information. The mask can be any model. Each pixel of the mask RT has four floating-point numbers storing the following information: the mask ID for channel 0, the depth information for channel 0, the mask ID for channel 1, and the depth information for channel 1. For example, if the input channel for mask 1 is 0, then mask 1 will be written into the first two floating-point numbers of the mask RT pixel (the last two floating-point numbers remain unchanged).
[0147] Step 2: Input the mask RT and render the masked object 802 onto the screen RT.
[0148] The screen RT and the mask RT are exactly the same size, meaning they correspond pixel-by-pixel. Illustratively, when rendering the masked object, the mask RT is used as input. The mask reads the information from the mask RT pixel by pixel, determining whether the vertices of the masked object mapped to that pixel are rendered or discarded. Finally, the rendered portion of the masked object is projected onto the screen RT and displayed as the final rendering result on the screen.
[0149] Optionally, when rendering the masked object, the logic for each pixel is as follows:
[0150] (1) Input the mask ID (recorded as I1) of the masked object and the channel C (0 or 1). At this time, the depth of the pixel to be rendered on the masked object is denoted as D1. D1 includes the depths of each vertex of the masked object rendered onto this pixel. Optionally, a single masked object can also have multiple mask IDs. Then, set the mask ID corresponding to each vertex of the masked object as the input. For example, the mask ID of vertex a is 01, and the channel corresponding to 01 is 0; the mask ID of vertex b is 02, and the channel corresponding to 02 is 1.
[0151] (2) Read the pixel value R at the same position in the mask RT. R has four floating-point values, which are respectively recorded as R1, R2, R3, and R4.
[0152] (3) If the channel C is 0, then take R1 and R2 as the channel ID and depth value; if C is 1, then take R3 and R4. The obtained mask ID and depth are recorded as I2 and D2.
[0153] (4) If I1 is not equal to I2, then do not render this vertex.
[0154] (5) If D1 < D2, it means that this vertex of the masked object exceeds the range of the mask object, and it is also not rendered, ensuring that the masked object is only rendered in the area inside the mask object. Here, D1 < D2 means that D1 exceeds the range indicated by D2. If D2 refers to the depth of a single vertex, then D1 < D2 means that the vertex of the masked object is less than D2 and is not rendered; if D2 refers to the depth range determined by two vertices, then D1 < D2 means that the vertex of the masked object is outside the range between the two vertices and is not rendered.
[0155] If I1 is equal to I2 and D1 ≥ D2, then render this vertex normally.
[0156] In summary, in this application, the object to be rendered is set as the "masked object", and the "masked object" corresponds to a "mask object". In each frame of rendering, provide an RT with the same size as the screen, and render the "mask object" on this RT. The RT records the ID and depth of the "mask object". When rendering the "masked object", read this RT to determine which parts of which "masked objects" should be rendered and which should be blocked, thereby achieving the effect of object masking.
[0157] Please refer to Figure 9 , which shows an interface diagram rendered by using the method provided in the embodiment of this application, as Figure 9As shown, interface 900 displays the character outfit designed in the game, which is rendered using the method provided in this application embodiment. The outfit consists of two channels of masks: Channel 1 renders the character model, displaying it with a gold outline, and sets a mask for it so that only half of the model is actually displayed (the position of the mask can be adjusted by animation to give it a dynamic effect), that is, the half-body outline effect 901 shown in interface 900; Channel 2 renders a gold cylinder, but through an irregular ring mask, only the waist part of the gold cylinder is displayed, that is, the waist effect 902 shown in interface 900.
[0158] This is illustrative; please refer to it. Figure 10 The diagram illustrates a structural block diagram of an object rendering apparatus, which includes:
[0159] The acquisition module 1010 is used to acquire a three-dimensional mask and a virtual object to be rendered within the field of view of the virtual camera. The three-dimensional mask is an invisible object used to mask the virtual object. The three-dimensional mask corresponds to a first depth information relative to the virtual camera, and the virtual object corresponds to a second depth information relative to the virtual camera.
[0160] The determining module 1020 is used to determine the masking portion of the virtual object based on the first depth information and the second depth information; the masking portion is used to indicate that the virtual object is in a first part within the masking space corresponding to the three-dimensional mask body, or the masking portion is used to indicate that the virtual object is in a second part outside the masking space;
[0161] The rendering module 1030 is used to render the masked portion of the virtual object to obtain the rendering result of the virtual object.
[0162] In some embodiments, the acquisition module 1010 is used to render the three-dimensional mask body within the field of view of the virtual camera to obtain m first pixels corresponding to the three-dimensional mask body. The m first pixels respectively store depth information, wherein the depth information stored in the j-th first pixel includes the depth information corresponding to the j-th first pixel when at least one first vertex on the three-dimensional mask body is mapped to the acquisition plane of the virtual camera. m and j are positive integers, and j≤m. The depth information stored in the m first pixels is used as the first depth information.
[0163] In some embodiments, the second depth information includes the distances between a plurality of second vertices corresponding to the virtual object and the virtual camera; the determining module 1020 is configured to, when there is at least one second vertex in the mapping direction corresponding to the j-th first pixel, determine a target vertex within the masking space from the at least one second vertex, wherein the distance between the target vertex and the virtual camera conforms to the distance requirement corresponding to the depth information stored in the j-th first pixel; and determine the masking portion of the virtual object based on the target vertex within the masking space.
[0164] In some embodiments, when there is a single first vertex in the mapping direction corresponding to the j-th first pixel, the depth information stored in the j-th first pixel includes the distance between the single first vertex and the virtual camera; wherein the distance between the target vertex and the virtual camera is greater than or equal to the distance between the single first vertex and the virtual camera.
[0165] In some embodiments, when there are multiple first vertices in the mapping direction corresponding to the j-th first pixel, the depth information stored in the j-th first pixel includes multiple distance nodes; wherein the distance between the target vertex and the virtual camera is between at least two specified distance nodes.
[0166] In some embodiments, the determining module 1020 is configured to: determine the target vertex from a distance range less than that of the first vertex in the mapping direction and a distance range greater than that of the second vertex in the mapping direction when there are two first vertices in the mapping direction corresponding to the j-th first pixel; or determine the target vertex from a distance range between two vertices in the mapping direction; determine the target vertex from a distance range less than that of the first first vertex in the mapping direction and a distance range between the 2k-th and 2k+1-th first vertices when there are at least three first vertices in the mapping direction corresponding to the j-th first pixel; or determine the target vertex from a distance range between the 2k-1-th and 2k-th first vertices and a distance range greater than that of the last first vertex in the mapping direction when there are two first vertices in the mapping direction corresponding to the j-th first pixel; or determine the target vertex from a distance range between the 2k-1-th and 2k-th first vertices and a distance range greater than that of the last first vertex in the mapping direction.
[0167] In some embodiments, the field of view of the virtual camera includes multiple three-dimensional mask bodies; the acquisition module 1010 is used to render the multiple three-dimensional mask bodies within the field of view of the virtual camera to obtain a first rendering object, wherein the first rendering object indicates buffered image data storing the rendering results of the multiple three-dimensional mask bodies; wherein the depth information stored in the j-th first pixel includes the depth information corresponding to at least one of the multiple three-dimensional mask bodies.
[0168] In some embodiments, the plurality of three-dimensional mask bodies include a first mask body and a second mask body; the acquisition module 1010 is used to perform a rendering process of rendering the first mask body and the second mask body to a first candidate rendering object, wherein the first candidate rendering object includes n first candidate pixels, where n is a positive integer; during the rendering process, when there is a first vertex in the first mask body that maps to a target candidate pixel among the n first candidate pixels, the depth information corresponding to the first vertex in the first mask body is stored in the first storage channel corresponding to the target candidate pixel; during the rendering process, when there is a first vertex in the second mask body that maps to the target candidate pixel, the depth information corresponding to the first vertex in the second mask body is stored in the second storage channel corresponding to the target candidate pixel; when the rendering of the first mask body and the second mask body is completed, the first candidate rendering object after storage processing is obtained as the first rendering object.
[0169] In some embodiments, the plurality of three-dimensional mask bodies include a first mask body and a second mask body; the acquisition module 1010 is configured to store the first mask body identifier of the first mask body into the first storage channel corresponding to the target candidate pixel when there is a first vertex in the first mask body that maps to the target candidate pixel among n first candidate pixel points; and to store the second mask body identifier of the second mask body into the second storage channel corresponding to the target candidate pixel when there is a first vertex in the second mask body that maps to the target candidate pixel.
[0170] In some embodiments, the second depth information includes the distances between the virtual object and the virtual camera at the plurality of second vertices corresponding to the virtual object; the determining module 1020 is used to determine the masking portion based on the mask body identifiers corresponding to the plurality of second vertices, the depth information stored in the first storage channels corresponding to the m first pixels, the depth information stored in the second storage channels corresponding to the m pixels, and the distances between the virtual object and the virtual camera at the plurality of second vertices corresponding to the virtual object.
[0171] In some embodiments, the determining module 1020 is configured to: obtain a masking body identifier corresponding to the at least one second vertex when there is at least one second vertex in the mapping direction corresponding to the j-th first pixel; determine a first target vertex among the at least one second vertex that is located within the masking space when the first masking body identifier is stored in the j-th first pixel and the masking body identifier corresponding to the at least one second vertex matches the first masking body identifier, wherein the distance between the first target vertex and the virtual camera conforms to the distance requirement corresponding to the depth information stored in the first storage channel of the j-th first pixel; determine a second target vertex among the at least one second vertex that is located within the masking space when the second masking body identifier is stored in the j-th first pixel and the masking body identifier corresponding to the at least one second vertex matches the second masking body identifier, wherein the distance between the second target vertex and the virtual camera conforms to the distance requirement corresponding to the depth information stored in the second storage channel of the j-th first pixel; and determine the masking portion of the virtual object based on the target vertex located within the masking space.
[0172] In summary, the object rendering apparatus provided in this application provides a three-dimensional masking body for masking objects to be rendered. For objects to be rendered that are within the field of view of a virtual camera, the apparatus determines whether to render the masked portion of the object within the masking space or the masked portion outside the masking space, based on the depth information of the three-dimensional masking body relative to the virtual camera and the depth information of the object to be rendered relative to the virtual camera. The three-dimensional masking body can achieve a fine masking effect based on depth information, controlling which parts of the object to be rendered should be rendered and which parts should be hidden, thus improving the accuracy and flexibility of occlusion of objects to be rendered and meeting the complex occlusion requirements in the scene construction process.
[0173] It should be noted that the object rendering apparatus provided in the above embodiments is only an example of the division of the above functional modules. In practical applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the object rendering apparatus and object rendering method embodiments provided in the above embodiments belong to the same concept, and their specific implementation process can be found in the method embodiments, which will not be repeated here.
[0174] Figure 11 A structural block diagram of a computer device provided in an exemplary embodiment of this application is shown.
[0175] The computer device 1100 may be a portable mobile terminal, such as a smartphone, tablet, MP3 player (Moving Picture Experts Group Audio Layer III), or MP4 player (Moving Picture Experts Group Audio Layer IV). The computer device 1100 may also be referred to as a user device, portable terminal, or other names.
[0176] Typically, computer device 1100 includes a processor 1101 and a memory 1102.
[0177] Processor 1101 may include one or more processing cores, such as a quad-core processor, an eleven-core processor, etc. Processor 1101 may be implemented using at least one hardware form selected from DSP (Digital Signal Processing), FPGA (Field Programmable Gate Array), and PLA (Programmable Logic Array). Processor 1101 may also include a main processor and a coprocessor. The main processor, also known as a CPU (Central Processing Unit), is used to process data in the wake-up state; the coprocessor is a low-power processor used to process data in the standby state. In some embodiments, processor 1101 may integrate a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the screen. In some embodiments, processor 1101 may also include an AI (Artificial Intelligence) processor, which is used to handle computational operations related to machine learning.
[0178] The memory 1102 may include one or more computer-readable storage media, which may be tangible and non-transitory. The memory 1102 may also include high-speed random access memory and non-volatile memory, such as one or more disk storage devices or flash memory devices. In some embodiments, the non-transitory computer-readable storage media in the memory 1102 are used to store at least one instruction, which is executed by the processor 1101 to implement the object rendering method provided in the embodiments of this application.
[0179] In some embodiments, the computer device 1100 may also optionally include: a peripheral device interface 1103 and at least one peripheral device. Specifically, the peripheral device includes at least one of: a radio frequency circuit 1104, a touch display screen 1105, a camera 1106, an audio circuit 1107, and a power supply 1108.
[0180] Peripheral device interface 1103 can be used to connect at least one I / O (Input / Output) related peripheral device to processor 1101 and memory 1102. In some embodiments, processor 1101, memory 1102 and peripheral device interface 1103 are integrated on the same chip or circuit board; in some other embodiments, any one or two of processor 1101, memory 1102 and peripheral device interface 1103 can be implemented on separate chips or circuit boards, which is not limited in this embodiment.
[0181] The radio frequency (RF) circuit 1104 is used to receive and transmit RF (Radio Frequency) signals, also known as electromagnetic signals. The RF circuit 1104 communicates with communication networks and other communication devices via electromagnetic signals. The RF circuit 1104 converts electrical signals into electromagnetic signals for transmission, or converts received electromagnetic signals back into electrical signals. Optionally, the RF circuit 1104 includes: an antenna system, an RF transceiver, one or more amplifiers, a tuner, an oscillator, a digital signal processor, a codec chipset, a user identity module card, etc. The RF circuit 1104 can communicate with other terminals through at least one wireless communication protocol. This wireless communication protocol includes, but is not limited to: the World Wide Web, metropolitan area networks, intranets, various generations of mobile communication networks (2G, 3G, 4G, and 5G), wireless local area networks, and / or WiFi (Wireless Fidelity) networks. In some embodiments, the RF circuit 1104 may also include circuitry related to NFC (Near Field Communication), which is not limited in this application.
[0182] The touch display screen 1105 is used to display a UI (User Interface). This UI may include graphics, text, icons, videos, and any combination thereof. The touch display screen 1105 also has the ability to collect touch signals on or above its surface. These touch signals can be input as control signals to the processor 1101 for processing. The touch display screen 1105 is used to provide virtual buttons and / or a virtual keyboard, also known as soft buttons and / or a soft keyboard. In some embodiments, there may be one touch display screen 1105, located on the front panel of the computer device 1100; in other embodiments, there may be at least two touch display screens, respectively located on different surfaces of the computer device 1100 or in a folded design; in some embodiments, the touch display screen 1105 may be a flexible display screen, located on a curved or folded surface of the computer device 1100. Furthermore, the touch display screen 1105 may be configured as a non-rectangular, irregular shape, i.e., a non-rectangular screen. The touch display screen 1105 may be made of materials such as LCD (Liquid Crystal Display) or OLED (Organic Light-Emitting Diode).
[0183] The camera assembly 1106 is used to acquire images or videos. Optionally, the camera assembly 1106 includes a front-facing camera and a rear-facing camera. Typically, the front-facing camera is used for video calls or selfies, and the rear-facing camera is used for taking photos or videos. In some embodiments, there are at least two rear-facing cameras, which are any one of a main camera, a depth-sensing camera, and a wide-angle camera, to achieve background blurring by fusion of the main camera and the depth-sensing camera, and panoramic shooting and VR (Virtual Reality) shooting by fusion of the main camera and the wide-angle camera. In some embodiments, the camera assembly 1106 may also include a flash. The flash can be a single-color temperature flash or a dual-color temperature flash. A dual-color temperature flash is a combination of a warm-light flash and a cool-light flash, which can be used for light compensation at different color temperatures.
[0184] Audio circuitry 1107 provides an audio interface between the user and computer device 1100. Audio circuitry 1107 may include a microphone and a speaker. The microphone is used to collect sound waves from the user and the environment, converting the sound waves into electrical signals that are input to processor 1101 for processing, or input to radio frequency circuitry 1104 for voice communication. For stereo sound acquisition or noise reduction purposes, multiple microphones may be used, each located at a different location within computer device 1100. The microphone may also be an array microphone or an omnidirectional microphone. The speaker is used to convert electrical signals from processor 1101 or radio frequency circuitry 1104 into sound waves. The speaker may be a conventional diaphragm speaker or a piezoelectric ceramic speaker. When the speaker is a piezoelectric ceramic speaker, it can convert electrical signals not only into audible sound waves but also into inaudible sound waves for purposes such as distance measurement. In some embodiments, audio circuitry 1107 may also include a headphone jack.
[0185] Power supply 1108 is used to supply power to the various components in computer device 1100. Power supply 1108 can be AC power, DC power, a disposable battery, or a rechargeable battery. When power supply 1108 includes a rechargeable battery, the rechargeable battery can be a wired rechargeable battery or a wireless rechargeable battery. A wired rechargeable battery is a battery that is charged via a wired line, and a wireless rechargeable battery is a battery that is charged via a wireless coil. The rechargeable battery can also be used to support fast charging technology.
[0186] In some embodiments, the computer device 1100 further includes one or more sensors 1109. The one or more sensors 1109 include, but are not limited to: an accelerometer 1110, a gyroscope 1111, a pressure sensor 1112, an optical sensor 1113, and a proximity sensor 1114.
[0187] Accelerometer 1110 can detect the magnitude of acceleration along the three coordinate axes of a coordinate system established by computer device 1100. For example, accelerometer 1110 can be used to detect the components of gravitational acceleration along the three coordinate axes. Processor 1101 can control touchscreen 1105 to display the user interface in landscape or portrait view based on the gravitational acceleration signal acquired by accelerometer 1110. Accelerometer 1110 can also be used for games or for acquiring user motion data.
[0188] The gyroscope sensor 1111 can detect the orientation and rotation angle of the computer device 1100. The gyroscope sensor 1111 can work in conjunction with the accelerometer sensor 1110 to collect 3D motion data from the user on the computer device 1100. Based on the data collected by the gyroscope sensor 1111, the processor 1101 can perform the following functions: motion sensing (e.g., changing the UI based on the user's tilt), image stabilization during shooting, game control, and inertial navigation.
[0189] Pressure sensor 1112 can be disposed on the side bezel of computer device 1100 and / or on the lower layer of touch display screen 1105. When pressure sensor 1112 is disposed on the side bezel of computer device 1100, it can detect the user's grip signal on computer device 1100 and perform left / right hand recognition or quick operation based on the grip signal. When pressure sensor 1112 is disposed on the lower layer of touch display screen 1105, it can control operable controls on the UI interface based on the user's pressure operation on touch display screen 1105. Operable controls include at least one of button controls, scroll bar controls, icon controls, and menu controls.
[0190] Optical sensor 1113 is used to collect ambient light intensity. In one embodiment, processor 1101 can control the display brightness of touch screen 1105 based on the ambient light intensity collected by optical sensor 1113. Specifically, when the ambient light intensity is high, the display brightness of touch screen 1105 is increased; when the ambient light intensity is low, the display brightness of touch screen 1105 is decreased. In another embodiment, processor 1101 can also dynamically adjust the shooting parameters of camera assembly 1106 based on the ambient light intensity collected by optical sensor 1113.
[0191] The proximity sensor 1114, also known as a distance sensor, is typically located on the front of the computer device 1100. The proximity sensor 1114 is used to detect the distance between the user and the front of the computer device 1100. In one embodiment, when the proximity sensor 1114 detects that the distance between the user and the front of the computer device 1100 is gradually decreasing, the processor 1101 controls the touchscreen display 1105 to switch from a screen-on state to a screen-off state; when the proximity sensor 1114 detects that the distance between the user and the front of the computer device 1100 is gradually increasing, the processor 1101 controls the touchscreen display 1105 to switch from a screen-off state to a screen-on state.
[0192] Those skilled in the art will understand that Figure 11 The structure shown does not constitute a limitation on the computer device 1100 and may include more or fewer components than shown, or combine certain components, or use different component arrangements.
[0193] In an exemplary embodiment, this application provides a chip that includes programmable logic circuits and / or program instructions, which, when run on a computer device, are used to implement the object rendering method provided in the above method embodiments.
[0194] This application provides a computer-readable storage medium storing a computer program that is loaded and executed by a processor to implement the object rendering method provided in the above-described method embodiments.
[0195] This application provides a computer program product or computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the processor of the computer device to load and execute the object rendering method provided in the above-described method embodiments.
[0196] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0197] Those skilled in the art will understand that all or part of the steps of the above embodiments can be implemented by hardware or by a program instructing related hardware. The program can be stored in a computer-readable storage medium, such as a read-only memory, a disk, or an optical disk.
[0198] Those skilled in the art will recognize that the functions described in the embodiments of this application in one or more of the above examples can be implemented using hardware, software, firmware, or any combination thereof. When implemented using software, these functions can be stored in a computer-readable medium or transmitted as one or more instructions or code on a computer-readable medium. Computer-readable media include computer storage media and communication media, wherein communication media include any medium that facilitates the transfer of a computer program from one place to another. Storage media can be any available medium that can be accessed by a general-purpose or special-purpose computer.
[0199] The above description is merely an optional embodiment of this application and is not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.
Claims
1. An object rendering method, characterized in that, The method includes: Obtain a 3D mask and a virtual object to be rendered within the field of view of a virtual camera. The 3D mask is an invisible object used to mask the virtual object. The 3D mask corresponds to a first depth information relative to the virtual camera, and the virtual object corresponds to a second depth information relative to the virtual camera. The masking portion of the virtual object is determined based on the first depth information and the second depth information; the masking portion is used to indicate that the virtual object is in a first part within the masking space corresponding to the three-dimensional mask body, or the masking portion is used to indicate that the virtual object is in a second part outside the masking space; The masked portion of the virtual object is rendered to obtain the rendering result of the virtual object.
2. The method according to claim 1, characterized in that, Before determining the masked portion of the virtual object based on the first depth information and the second depth information, the method further includes: The three-dimensional mask within the field of view of the virtual camera is rendered to obtain m first pixels corresponding to the three-dimensional mask. Each of the m first pixels stores depth information, wherein the depth information stored in the j-th first pixel includes the depth information corresponding to the j-th first pixel when at least one first vertex on the three-dimensional mask is mapped to the acquisition plane of the virtual camera. m and j are positive integers, and j≤m. The depth information stored in the m first pixels is used as the first depth information.
3. The method according to claim 2, characterized in that, The second depth information includes the distances between the virtual object and the virtual camera, respectively, for each of the multiple second vertices corresponding to the virtual object. Determining the masked portion of the virtual object based on the first depth information and the second depth information includes: When there is at least one second vertex in the mapping direction corresponding to the j-th first pixel, a target vertex within the masking space is determined from the at least one second vertex, and the distance between the target vertex and the virtual camera meets the distance requirement corresponding to the depth information stored in the j-th first pixel; The masking portion of the virtual object is determined based on the target vertices located within the masking space.
4. The method according to claim 3, characterized in that, If there is a single first vertex in the mapping direction corresponding to the j-th first pixel, the depth information stored in the j-th first pixel includes the distance between the single first vertex and the virtual camera; Wherein, the distance between the target vertex and the virtual camera is greater than or equal to the distance between the single first vertex and the virtual camera.
5. The method according to claim 3, characterized in that, When there are multiple first vertices in the mapping direction corresponding to the j-th first pixel, the depth information stored in the j-th first pixel includes multiple distance nodes; The distance between the target vertex and the virtual camera is between at least two specified distance nodes.
6. The method according to claim 5, characterized in that, When there is at least one second vertex in the mapping direction corresponding to the j-th first pixel, determining the target vertex within the masking space from the at least one second vertex includes: If there are two first vertices in the mapping direction corresponding to the j-th first pixel, the target vertex is determined from a distance range smaller than that of the first vertex in the mapping direction and a distance range larger than that of the second vertex in the mapping direction; or, the target vertex is determined from the distance range between the two vertices in the mapping direction. If there are at least three first vertices in the mapping direction corresponding to the j-th first pixel, the target vertex is determined from the distance range less than that of the first first vertex in the mapping direction and the distance range between the 2k-th first vertex and the 2k+1-th first vertex; or, the target vertex is determined from the distance range between the 2k-1-th first vertex and the 2k-th first vertex and the distance range greater than that of the last first vertex in the mapping direction.
7. The method according to any one of claims 2 to 6, characterized in that, The field of view of the virtual camera includes multiple three-dimensional mask bodies; The rendering of the 3D mask within the field of view of the virtual camera to obtain m first pixels corresponding to the 3D mask includes: Render the plurality of three-dimensional mask objects within the field of view of the virtual camera to obtain a first rendering object, wherein the first rendering object indicates buffered image data storing the rendering results of the plurality of three-dimensional mask objects; The depth information stored in the j-th first pixel includes the depth information corresponding to at least one of the plurality of three-dimensional mask bodies.
8. The method according to claim 7, characterized in that, The plurality of three-dimensional mask bodies include a first mask body and a second mask body; The rendering of the plurality of three-dimensional mask bodies within the field of view of the virtual camera to obtain a first rendering object includes: The rendering process of rendering the first mask and the second mask to the first candidate rendering object is executed. The first candidate rendering object includes n first candidate pixels, where n is a positive integer. During the rendering process, when there is a first vertex in the first mask that maps to a target candidate pixel among the n first candidate pixels, the depth information corresponding to the first vertex in the first mask is stored in the first storage channel corresponding to the target candidate pixel. During the rendering process, when there is a first vertex in the second mask that is mapped to the target candidate pixel, the depth information corresponding to the first vertex in the second mask is stored in the second storage channel corresponding to the target candidate pixel. After the rendering of the first mask and the second mask is completed, the first candidate rendering object after storage processing is obtained as the first rendering object.
9. The method according to claim 7, characterized in that, The plurality of three-dimensional mask bodies include a first mask body and a second mask body; The method further includes: When there is a first vertex in the first mask that is mapped to a target candidate pixel among n first candidate pixels, the first mask identifier of the first mask is stored in the first storage channel corresponding to the target candidate pixel. When there is a first vertex in the second mask that is mapped to the target candidate pixel, the second mask identifier of the second mask is stored in the second storage channel corresponding to the target candidate pixel.
10. The method according to claim 9, characterized in that, The second depth information includes the distances between the virtual object and the virtual camera, respectively, for each of the multiple second vertices corresponding to the virtual object. Determining the masked portion of the virtual object based on the first depth information and the second depth information includes: The masking portion is determined based on the masking body identifiers corresponding to the plurality of second vertices, the depth information stored in the first storage channel corresponding to the m first pixels, the depth information stored in the second storage channel corresponding to the m pixels, and the distances between the plurality of second vertices corresponding to the virtual object and the virtual camera.
11. The method according to claim 10, characterized in that, The step of determining the masking portion based on the mask body identifiers corresponding to the plurality of second vertices, the depth information stored in the first storage channels corresponding to the m first pixels, the depth information stored in the second storage channels corresponding to the m pixels, and the distances between the plurality of second vertices corresponding to the virtual object and the virtual camera includes: When there is at least one second vertex in the mapping direction corresponding to the j-th first pixel, obtain the mask body identifier corresponding to the at least one second vertex; If the first mask body identifier is stored in the j-th first pixel, and the mask body identifier corresponding to the at least one second vertex matches the first mask body identifier, then a first target vertex in the at least one second vertex that is located within the mask space is determined, and the distance between the first target vertex and the virtual camera meets the distance requirement corresponding to the depth information stored in the first storage channel of the j-th first pixel. If the second mask body identifier is stored in the j-th first pixel, and the mask body identifier corresponding to the at least one second vertex matches the second mask body identifier, then a second target vertex in the at least one second vertex that is located within the mask space is determined, and the distance between the second target vertex and the virtual camera meets the distance requirement corresponding to the depth information stored in the second storage channel of the j-th first pixel. The masking portion of the virtual object is determined based on the target vertices located within the masking space.
12. An object rendering apparatus, characterized in that, The device includes: The acquisition module is used to acquire a three-dimensional mask and a virtual object to be rendered within the field of view of the virtual camera. The three-dimensional mask is an invisible object used to mask the virtual object. The three-dimensional mask corresponds to a first depth information relative to the virtual camera, and the virtual object corresponds to a second depth information relative to the virtual camera. The determining module is used to determine the masking portion of the virtual object based on the first depth information and the second depth information; the masking portion is used to indicate that the virtual object is in a first part within the masking space corresponding to the three-dimensional mask body, or the masking portion is used to indicate that the virtual object is in a second part outside the masking space; The rendering module is used to render the masked portion of the virtual object to obtain the rendering result of the virtual object.
13. A computer device, characterized in that, The computer device includes a processor and a memory, the memory storing at least one program, which is loaded and executed by the processor to implement the object rendering method as described in any one of claims 1 to 11.
14. A computer-readable storage medium, characterized in that, The storage medium stores at least one program segment, which is loaded and executed by a processor to implement the object rendering method as described in any one of claims 1 to 11.
15. A computer program product, characterized in that, Includes a computer program that, when executed by a processor, implements the object rendering method as described in any one of claims 1 to 11.