Image rendering method and device
The shape is expressed through the intersection of rays and the shape surface, which solves the problem that the prior art cannot effectively express non-closed and nested shapes, and realizes a more flexible and general image rendering method.
Patent Information
- Application Number
- CN202510297121.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-12
- Publication Date
- 2025-06-24
AI Technical Summary
Existing shape expression methods cannot effectively express non-closed shapes or nested shapes, limiting the flexibility and versatility of image rendering.
By emitting multiple rays in different directions from preset viewpoints, the intersection points of the ray and the initial shape are obtained, and the map information is obtained based on these intersection points, and the initial shape is finally rendered based on the map information and lighting data to generate the target rendered image.
This method can avoid the distinction between inside and outside the shape, realize the effective expression of non-closed and nested shapes, and improve the flexibility and versatility of the image rendering method.
Smart Images

Figure CN120198575A_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present application relate to the field of computer technologies, and in particular, to an image rendering method, apparatus, computer device, computer-readable storage medium, and computer program product. Background Art
[0002] In the field of 3D image rendering, a shape needs to be expressed as a data structure in a computer before it can be applied to an image rendering task. Existing shape expression methods include explicit shape expressions that are expressed in explicit methods such as point clouds, meshes, and voxels, and implicit shape expressions that are expressed by means of signed distance fields and the like.
[0003] The signed distance field's expression of the shape depends on the distinction between the inside and outside of the shape, and cannot express non-closed shapes or nested shapes.
[0004] It should be noted that the above content is not necessarily prior art and does not limit the patent protection scope of the present application. Summary of the Invention
[0005] Embodiments of the present application provide an image rendering method, apparatus, computer device, computer-readable storage medium, and computer program product to solve or alleviate one or more of the above technical problems.
[0006] One aspect of the embodiments of the present application provides an image rendering method, the method including: Obtain an initial shape; Emit a plurality of rays from a preset viewpoint, and directions of the plurality of rays are all different; Obtain a plurality of intersection points according to the plurality of rays and the initial shape; Obtain texture information corresponding to each of the plurality of intersection points; and Render the initial shape according to the plurality of texture information and preset lighting data to obtain a target rendered image.
[0007] Optionally, obtaining a plurality of intersection points according to the plurality of rays and the initial shape includes: Determine whether the ray intersects with the initial shape according to an initial length of the ray and the initial shape; In a case where the ray does not intersect with the initial shape, extend the ray one or more times until it intersects; Wherein, a step size of each extension is the same.
[0008] Optionally, the texture information includes a depth map; Obtaining texture information corresponding to each of the plurality of intersection points includes: Determine depth maps corresponding to the multiple intersections according to the lengths of the rays corresponding to the respective intersections.
[0009] Optionally, the texture information includes a color map; Obtaining texture information corresponding to the multiple intersections respectively includes: Obtain the material data corresponding to the initial shape; According to the material data, obtain color maps corresponding to the multiple intersections respectively.
[0010] Optionally, the texture information includes a normal map; Obtaining texture information corresponding to the multiple intersections respectively includes: Obtain the gradient of the initial shape at each of the intersections, where the gradient represents the shape change trend of the initial shape at the intersection; According to the gradients at the respective intersections, obtain normal maps corresponding to the respective intersections.
[0011] Optionally, the method is implemented by a neural network model; the method further includes: In the case where the target rendering image is obtained through the neural network model, quantize the neural network parameters of the neural network model to obtain a target floating-point number; Wherein, the target floating-point number is used to indicate that the neural network model outputs the target rendering image when being input into the neural network model.
[0012] Optionally, the training steps of the neural network model include: Obtain a sample shape and a preset ray starting point; Emit a target ray from the preset ray starting point to the sample shape; In the case where the target ray does not intersect with the sample shape, extend the target ray one or more times until intersection; Obtain one or more training step lengths corresponding to the one or more extensions, where the training step length is the length of each extension of the target ray; Determine one or more step length errors according to the preset step length and the one or more training step lengths; Adjust the model parameters of the shape generation model according to the one or more step length errors.
[0013] Another aspect of the embodiments of the present application provides an image rendering device, and the device includes: A first acquisition module, which acquires an initial shape; An emission module, configured to emit multiple rays from a preset viewpoint, and the directions of the multiple rays are all different; An obtaining module, configured to obtain a plurality of intersection points according to the plurality of rays and the initial shape; A second obtaining module, configured to obtain texture mapping information corresponding to each of the plurality of intersection points; and A rendering module, configured to render the initial shape according to the plurality of texture mapping information and preset lighting data to obtain a target rendered image.
[0014] Another aspect of the embodiments of the present application provides a computer device, including: At least one processor; and A memory communicatively connected to the at least one processor; Wherein: the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the method as described above.
[0015] Another aspect of the embodiments of the present application provides a computer-readable storage medium, in which computer instructions are stored, and when the computer instructions are executed by a processor, the method as described above is implemented.
[0016] Another aspect of the embodiments of the present application provides a computer program product, including a computer program, and when the computer program is executed by a processor, the method as described above is implemented.
[0017] The embodiments of the present application adopting the above technical solutions may include the following advantages: expressing the shape by using the intersection points of the rays and the shape surface. Thus, the distinction between the inside and outside of the shape can be avoided, so as to realize the expression of non-closed or nested shapes, and the flexibility and generality of the image rendering method are improved. BRIEF DESCRIPTION OF THE DRAWINGS The drawings exemplarily show embodiments and constitute a part of the specification, and are used together with the written description of the specification to explain the exemplary embodiments of the embodiments. The shown embodiments are only for illustrative purposes and do not limit the scope of the claims. In all the drawings, the same reference numerals refer to similar but not necessarily identical elements.
[0018] Figure 1 Schematically shows an operating environment diagram of an image rendering method according to Embodiment 1 of the present application; Figure 2 Schematically shows a flowchart of an image rendering method according to Embodiment 1 of the present application; Figure 3 Schematically shows Figure 2 The sub-step flowchart of step S202 in; Figure 4 Schematically shows Figure 2 The sub-step flowchart of step S206 in; Figure 5 Schematically shows Figure 2 Another sub-step flowchart of step S206 in Figure 6 Schematically shows an additional flowchart of the image rendering method according to Embodiment 1 of the present application; Figure 7 Schematically shows an application example diagram of the image rendering method according to Embodiment 1 of the present application; Figure 8 Schematically shows an application process example diagram of the image rendering method according to Embodiment 1 of the present application; Figure 9 Schematically shows a process schematic diagram for implementing the image rendering method in a neural network model; Figure 10 Schematically shows a block diagram of the image rendering apparatus according to Embodiment 2 of the present application; and Figure 11 Schematically shows a schematic diagram of the hardware architecture of a computer device according to Embodiment 3 of the present application. Detailed implementation manners
[0019] In order to make the objectives, technical solutions and advantages of the present application more clear and understandable, the present application will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application. All other embodiments obtained by those of ordinary skill in the art based on the embodiments in the present application without making creative efforts shall fall within the protection scope of the present application.
[0020] It should be noted that the descriptions involving "first", "second", etc. in the embodiments of the present application are only for descriptive purposes and cannot be understood as indicating or implying their relative importance or implicitly indicating the quantity of the indicated technical features. Thus, features defined with "first" and "second" may explicitly or implicitly include at least one of such features. In addition, the technical solutions between various embodiments may be combined with each other, but it must be based on the fact that those of ordinary skill in the art can implement them. When the combination of technical solutions results in contradictions or cannot be implemented, it should be considered that such a combination of technical solutions does not exist and is not within the protection scope required by the present application.
[0021] In the description of the present application, it should be understood that the numerical labels before the steps do not identify the order of execution of the steps, but are only used to facilitate the description of the present application and distinguish each step, and thus cannot be understood as a limitation to the present application.
[0022] First, the following provides the term explanations involved in the present application: Point cloud: A collection of a large number of 3D points, where each point contains spatial coordinates (X, Y, Z) and possibly additional color or intensity information.
[0023] Voxel: A basic unit for representing 3D spatial data. Each voxel occupies a fixed position in 3D space and has certain attribute values, such as color, density, or material information.
[0024] Implicit representation: A method of describing geometric shapes through mathematical functions or relationships. By defining a scalar field or vector field, each point in space is associated with a specific value, indirectly representing the boundaries and internal structures of the shape.
[0025] Explicit representation: A method of directly describing the shape and geometric information of an object, representing the surface or volume of the object through a clear mathematical model or data structure.
[0026] Signed distance field: A mathematical method for representing the shape of an object, defined by calculating the shortest distance from any point in space to the object's surface and assigning positive or negative signs according to the inside-outside relationship between the point and the object's surface.
[0027] Stepping: A method of gradually moving or iterating during a calculation process, usually referring to advancing step by step along the ray direction at a fixed or dynamic interval.
[0028] Viewpoint: Refers to the position and direction of an observer or camera in 3D space, defining the viewing angle of the observer relative to the observed object, including position coordinates and orientation.
[0029] Texture mapping: An image resource in computer graphics used to enhance the visual details of an object's surface. By mapping a 2D image onto the surface of a 3D model, visual attributes such as color, material, and details are assigned to the model.
[0030] Depth map: A 2D image that records the depth information of each pixel or intersection point in a scene to the camera plane, representing the 3D depth information of the scene by storing depth values (i.e., the distance from the camera to the object's surface).
[0031] Color map: Also known as a texture map, it is a 2D image file used to add color and texture details to the surface of a 3D model.
[0032] Normal map: A technique used to enhance the surface details of an object in graphics rendering, recording the changes in the normal direction of the object's surface.
[0033] Physically Based Rendering (PBR) model: A rendering technique that simulates the interaction of light and materials in the real world. By following physical laws to calculate the reflection, refraction, and scattering of light, the rendering results are made more realistic.
[0034] Quantization: It is a process of converting data from a high-precision representation to a low-precision representation.
[0035] Floating-point number: It is a numerical format used to represent real numbers, which supports a wider range of numerical values and higher precision by dividing numbers into an integer part and a fractional part.
[0036] Secondly, to facilitate the understanding of the technical solutions provided in the embodiments of the present application by those skilled in the art, the related technologies are described below: In the field of 3D image rendering, shapes need to be expressed as data structures in a computer in order to be applied to downstream image rendering tasks. Different shape expression methods will directly affect the accuracy, storage occupancy, and subsequent rendering processing efficiency of the shape in the computer. Usually, shapes are expressed in explicit methods such as point clouds, meshes, and voxels. These methods have high versatility and can adapt to most downstream tasks. In addition to explicit expression, the implicit expression method of shapes describes the relationship between space and shape, and has achieved obvious breakthroughs in the compactness and continuity of shapes. With the development of AI technology, deep learning methods provide powerful tools for constructing implicit expression methods of complex shapes.
[0037] However, limited by the limited storage space in the computer, explicit shape expression methods always need to make a compromise between accuracy and storage efficiency, and in application scenarios where the shape accuracy needs to be transformed, the existing expression methods cannot achieve efficient accuracy conversion. The implicit expression of shapes, such as signed distance fields, has many limitations on the shapes to be expressed, that is, it cannot express non-closed shapes, cannot express nested shapes, etc., and there are functional incompletenesses in shape rendering and storage.
[0038] Therefore, the embodiments of the present application provide an image rendering technical solution. In this technical solution, (1) the shape is implicitly expressed by describing the intersection and depth relationship between any ray in space and the shape surface, so as to realize the expression of non-closed and multi-layer nested shapes; (2) ray marching is performed by setting the ray step size to achieve the recursive constraint of omnidirectional rays and improve the accuracy of shape expression; (3) the storage efficiency is improved by quantizing neural network parameters without affecting the rendering quality. See the following for details.
[0039] Finally, for the convenience of understanding, an exemplary operating environment is provided below.
[0040] As Figure 1 shown, the operating environment diagram includes a server 2, a network 4, and a client 6, where: Server 2 may consist of a single or multiple computing devices. The multiple computing devices may include virtualized computing instances. The virtualized computing instances may include virtual machines, such as emulations of computer systems, operating systems, servers, etc. The computing devices may load virtual machines based on virtual images and / or other data that define specific software (e.g., operating systems, dedicated applications, servers) for the emulation. As the demand for different types of processing services changes, different virtual machines may be loaded and / or terminated on one or more computing devices. A hypervisor may be implemented to manage the use of different virtual machines on the same computing device.
[0041] Server 2 may be configured to communicate with a client 6 etc. via a network 4. The network 4 includes various network devices such as routers, switches, multiplexers, hubs, modems, bridges, repeaters, firewalls, proxy devices, and / or the like. The network 4 may include physical links such as coaxial cable links, twisted pair cable links, fiber optic links, combinations thereof, etc., or wireless links such as cellular links, satellite links, Wi-Fi links, etc.
[0042] Server 2 may provide services such as storage, reading, writing, querying, deleting, etc., such as providing an initial shape data upload service for a client.
[0043] Client 6 may be an electronic device running an operating system such as Windows, Android™, or iOS, such as a smartphone, tablet device, laptop computer, virtual reality device, gaming device, set-top box, in-vehicle terminal, smart TV. Based on the above operating systems, various applications may be run, such as an application for uploading initial shape data, an application for receiving target rendered image data and displaying the target rendered image.
[0044] Client 6 may provide / configure a user access page for manipulating Server 2 or uploading objects, etc.
[0045] It should be noted that the above devices are exemplary, and in different scenarios or according to different requirements, the number and types of devices are adjustable.
[0046] The following takes Server 2 as the execution entity and introduces the technical solutions of this application through multiple embodiments. It should be noted that these embodiments may be implemented in various different forms and should not be construed as being limited only to the embodiments described herein.
[0047] Embodiment 1 Figure 2 A flowchart of an image rendering method according to Embodiment 1 of this application is schematically shown.
[0048] As Figure 2As shown, the image rendering method may include steps S200 to S208, where: Step S200, obtain an initial shape.
[0049] Step S202, emit multiple rays from a preset viewpoint, and the directions of the multiple rays are all different.
[0050] Step S204, obtain multiple intersection points according to the multiple rays and the initial shape.
[0051] Step S206, obtain the texture mapping information corresponding to each of the multiple intersection points.
[0052] Step S208, render the initial shape according to the multiple texture mapping information and preset lighting data to obtain a target rendered image.
[0053] In the image rendering method provided in this embodiment, the shape is expressed by the intersection points of the rays and the shape surface. Thus, the distinction between the inside and outside of the shape can be avoided, so as to realize the expression of non-closed or nested shapes, and the flexibility and generality of the image rendering method are improved.
[0054] The following combines Figure 2 , and elaborates on each step in steps S200 to S208 and optional other steps in detail.
[0055] Step S200 , obtain an initial shape.
[0056] The initial shape can be a closed shape such as a rectangle, a square, a sphere, etc., or a non-closed shape such as a straight line, a parabola, a loop, etc., or any random shape defined by the user, etc. The initial shape can be expressed by display expression methods such as grid coordinates, point clouds, polygon surfaces, etc., or can also be expressed by display expression methods such as isosurfaces, neural implicit representations, functional equations, etc.
[0057] The data of the initial shape can be the data of the shape material obtained from the network, or the data of any shape material defined by the user through methods such as 3D scanning, computer-aided design (CAD) models, etc. Before rendering, the initial shape can also be processed such as optimized, simplified, transformed, or adapted to a specific rendering engine, etc.
[0058] Step S202 , emit multiple rays from a preset viewpoint, and the directions of the multiple rays are all different.
[0059] The directions of multiple rays can be arbitrary, or a direction range can be preset so that most rays can intersect with the initial shape. The rays in different directions can be evenly distributed, or the distribution density of the rays can be adjusted according to the characteristics of the initial shape. Each ray can correspond to a pixel point of the initial shape, or multiple rays can correspond to a pixel point of the initial shape to increase the sampling density.
[0060] In this embodiment, the initial shape is observed through multiple rays with different directions. Thus, the contact between light and the shape surface can be more accurately simulated, so as to obtain more accurate details of the shape surface, enhance the accuracy of rendering, and improve the quality and authenticity of the rendered image.
[0061] Step S204 , a plurality of intersection points are obtained according to the multiple rays and the initial shape.
[0062] A ray can complete the intersection with the initial shape during one forward process, or can complete the intersection with the initial shape through multiple forward processes. When the method of this embodiment is implemented through a neural network model, a corresponding training process can also be set: Using a specific shape as training data, obtaining the calculated distance from the preset ray starting point to the specific shape output by the neural network model, and the real distance from the preset starting point along the same direction to the specific shape calculated by a geometric method. Then, the model parameters are adjusted using the error between the calculated distance and the real distance.
[0063] In this embodiment, the shape is implicitly expressed by describing the intersection and depth relationship between any ray in space and the shape surface. Thus, the distinction between the inside and outside of the shape can be avoided, so as to realize the expression of non-closed and multi-layer nested shapes, and improve the versatility and flexibility of the image rendering method.
[0064] The ray and the initial shape can intersect in various ways, and an exemplary intersection way is provided below.
[0065] In an alternative embodiment, as Figure 3 shown, step S204 may include: S300, determining whether the ray intersects with the initial shape according to the initial length of the ray and the initial shape.
[0066] S302, in the case where the ray does not intersect with the initial shape, extending the ray one or more times until it intersects; wherein, the step size of each extension is the same.
[0067] The initial length of the ray can be a fixed value or can be adaptively set according to the relative positions of the preset viewpoint and the initial shape. The step length for each extension can be one unit length or can be adjusted according to the geometric characteristics of the initial shape and the requirements for rendering precision.
[0068] For different preset viewpoints and initial shapes, corresponding maximum number of steps or maximum distance can be set to identify whether the ray does not intersect with the initial shape.
[0069] For example, a ray L is emitted from a preset viewpoint P to an initial shape F with an initial length of three unit lengths. At this time, the ray L and the initial shape F do not intersect. Then the ray L is extended by one unit length, and at this time the ray L and the initial shape F still do not intersect; the ray L is extended by one unit length again, and at this time the ray L and the initial shape F still do not intersect; the ray L is extended by one unit length again, and at this time the ray L and the initial shape F intersect. Then it can be determined that the distance between the preset viewpoint P and the initial shape F is six unit lengths.
[0070] In this embodiment, ray stepping is performed by setting the ray step length. Thus, recursive constraints of omnidirectional rays can be achieved, improving the accuracy of image rendering. At the same time, when detecting intersections with a fixed step length, the computational amount of the intersection of the ray and the shape can be reduced, making the time complexity of the algorithm more controllable.
[0071] Step S206 Obtain the texture mapping information corresponding to each of the multiple intersections.
[0072] The texture mapping of the intersection can include color texture mapping, normal texture mapping, depth texture mapping, roughness texture mapping, etc. The texture mapping information can be pre-stored in the texture map of the initial shape or can be dynamically generated according to the algorithm or procedural method for generating texture mapping, etc.
[0073] In this embodiment, the obtained texture mapping information can provide the rendering details of each intersection during the rendering process, making the visual effect of the rendered image more rich and improving the quality and authenticity of the rendered image.
[0074] During the rendering process, there can be various types of obtained texture mapping information. The following provides several exemplary texture mapping information and their corresponding obtaining methods.
[0075] A. The texture mapping information includes depth texture mapping. In an alternative embodiment, step S206 further includes: Determine the depth texture mapping corresponding to each of the multiple intersections according to the lengths of the rays corresponding to each of the multiple intersections.
[0076] According to the shape characteristics of the initial shape and the accuracy requirements of image rendering, the sampling density of the rays can be adjusted or the multi-resolution depth map technology can be used. When generating the depth map, an error correction mechanism can also be introduced to avoid jagged or shadow errors during rendering.
[0077] The depth map records the depth information of each pixel point of the initial shape to the preset viewpoint. Using the depth map, the distance relationship of each pixel point of the initial shape can be described, and when rendering the image, it can be determined which shapes or surfaces are visible and which are occluded, so as to remove the invisible shapes or surfaces and reduce the rendering burden.
[0078] B. The map information includes the color map. In an alternative embodiment, as Figure 4 shown, step S206 further includes: S400, obtaining the material data corresponding to the initial shape.
[0079] S402, according to the material data, obtaining the color maps corresponding to the respective intersection points.
[0080] The material data may include the color information of the initial shape, and may also include information such as the roughness, metallicity, transparency, and reflectivity of the initial shape. In some embodiments, the material data may also be dynamic data, for example, including material properties that change over time (such as dynamic textures, animated materials) to achieve a richer visual effect.
[0081] The color maps with different resolutions can be generated according to the complexity and accuracy requirements of image rendering, as well as the feature density of different regions of the initial shape and the distance relationship to the preset viewpoint. For example, low-resolution maps are used in long-distance or low-detail regions, while high-resolution maps are used in close-distance or high-detail regions.
[0082] The color map records the color information of the shape surface. Using the color map, color details can be added to the shape surface, and the appearance of different materials can also be simulated to improve the realism of the rendered image.
[0083] C. The map information includes the normal map. In an alternative embodiment, as Figure 5 shown, step S206 further includes: S500, obtaining the gradient of the initial shape at each of the intersection points, where the gradient represents the shape change trend of the initial shape at the intersection point.
[0084] S502, according to the gradient at each of the intersection points, obtaining the normal maps corresponding to the respective intersection points.
[0085] The gradient at the intersection point can be directly calculated from the signed distance field of the initial shape, or numerical methods such as the finite difference method can be used to calculate the approximate gradient, or a neural network model can be used to predict the gradient at the intersection point.
[0086] The normal map records the normal direction of each point on the surface of the shape. By calculating the normal direction of each intersection point, the influence of light on the surface of the shape can be more accurately simulated, enhancing the detail performance of the rendered image. At the same time, the normal map can simulate complex surface bump effects and also improve the realism of the rendering.
[0087] After obtaining this texture information, the final rendering and imaging step can be carried out.
[0088] Step S208 , rendering the initial shape according to the multiple texture information and preset lighting data to obtain a target rendered image.
[0089] In some embodiments, the rendering process can adopt a deferred rendering pipeline technique to reduce memory occupancy and computational complexity and improve rendering efficiency. A lighting model such as a physically based rendering (PBR) model or a fragment shader can also be introduced for rendering to more realistically simulate the reflection, refraction, and scattering characteristics of the material.
[0090] In some embodiments, the light source represented by the preset lighting data can be a static fixed light source or a dynamic light source whose position and intensity can vary. Corresponding rendering parameters can also be set according to the rendering accuracy requirements, etc.
[0091] In this embodiment, rendering is performed by combining the texture information and the lighting data. Thus, the final color of each pixel under the lighting conditions can be calculated, thereby simulating the lighting phenomenon in the real world, improving the quality of the rendered image, and enhancing the realism of the rendered image.
[0092] The image rendering method of this embodiment can be implemented in various ways. The following are some features when this method is implemented in a neural network model. The schematic flow diagram of implementing this method in a neural network model is as Figure 9 shown.
[0093] In an alternative embodiment, the method is implemented by a neural network model, and the method further includes: When obtaining the target rendered image through the neural network model, quantizing the neural network parameters of the neural network model to obtain a target floating-point number; wherein, the target floating-point number is used to indicate that the neural network model outputs the target rendered image when being input into the neural network model.
[0094] The target floating-point number can be a 16-bit floating-point number. According to the actual neural network model training results and image rendering quality requirements, an 8-bit or floating-point number with other bit widths can also be used as the target floating-point number.
[0095] In this embodiment, the target floating-point number for obtaining the target rendered image is quantized. Without affecting the rendering quality, quantizing the neural network parameters can use floating-point numbers with relatively small storage space occupancy, reduce the storage pressure of the neural network parameters, and improve the storage efficiency of the rendered image.
[0096] In an alternative embodiment, as Figure 6 shown, the training steps of the neural network model include: S600, obtaining a sample shape and a preset ray starting point; S602, emitting a target ray from the preset ray starting point to the sample shape; S604, in the case where the target ray does not intersect the sample shape, extending the target ray one or more times until intersection; S606, obtaining one or more training step lengths corresponding to the one or more extensions, where the training step length is the length of each extension of the target ray; S608, determining one or more step length errors according to a preset step length and the one or more training step lengths; S610, adjusting the model parameters of the shape generation model according to the one or more step length errors.
[0097] It can be through the following formula:
[0098] Constraints are added to the neural network model to set the step length of each extension of the ray to 1 unit length.
[0099] The data of the sample shape can be an open-source dataset, a self-built high-precision model library, or a physical model obtained through a 3D scanning device. The sample shape can include closed shapes, non-closed shapes, multi-layer nested shapes, and shapes with complex topological structures, etc. The preset ray starting point can be a fixed point, a random point, or a point dynamically selected according to the shape characteristics of the sample shape.
[0100] The direction of the target ray can be any direction or can be restricted within a certain direction range so that most of the target rays can intersect the sample shape. The maximum number of extensions of the target ray can be set according to the spatial position of the sample shape and the preset ray starting point to identify target rays that cannot intersect the sample shape.
[0101] In this embodiment, by adjusting the model according to the length error of each ray extension, it is possible to ensure that the neural network model can extend the ray by the same length each time, thereby making the time complexity of image rendering more controllable and improving the computing efficiency of the neural network model.
[0102] To make the present application easier to understand, the following provides an exemplary application in conjunction with Figure 7 and Figure 8 : S11. Obtain the shape data and material data corresponding to an initial shape A; S12. Emit a ray from a preset viewpoint P c , where the initial length of the ray is d i ; S13. If the ray does not intersect with the initial shape A, extend the ray length multiple times, with each extension length being L; S14. After extending n times, the ray intersects with the initial shape at the intersection point Q i ; S15. According to the length of the ray at this time, obtain the depth map M1 of the intersection point Q i ; S16. According to the material data corresponding to the initial shape A, obtain the color map M2 of the intersection point Q i ; S17. According to the signed distance field of the initial shape A, calculate the gradient of the initial shape A at the intersection point Q i , and obtain the normal map M3 of the intersection point Q i ; S18. According to M1, M2, M3, and the preset lighting data, obtain the rendering result at the intersection point Q i ; S19. According to the steps of S12 to S18, obtain the rendering results of each pixel point of the initial shape A; S20. According to the obtained rendering results of each pixel point, generate the rendering image of the initial shape A.
[0103] Embodiment 2 Figure 10 FIG. schematically shows a block diagram of an image rendering apparatus according to Embodiment 2 of the present application. The apparatus can be divided into one or more program modules. One or more program modules are stored in a storage medium and executed by one or more processors to complete the embodiments of the present application. The program modules referred to in the embodiments of the present application refer to a series of computer program instruction segments that can complete specific functions. The following description will specifically introduce the functions of each program module in this embodiment. As Figure 10As shown, the device 1000 may include: a first acquisition module 1100, a transmission module 1200, a obtaining module 1300, a second acquisition module 1400, and a rendering module 1500, where: The first acquisition module 1100 acquires an initial shape; The transmission module 1200 is configured to transmit multiple rays from a preset viewpoint, and the directions of the multiple rays are all different; The obtaining module 1300 is configured to obtain multiple intersection points according to the multiple rays and the initial shape; The second acquisition module 1400 is configured to acquire the texture mapping information corresponding to each of the multiple intersection points; and The rendering module 1500 is configured to render the initial shape according to the multiple texture mapping information and preset lighting data to obtain a target rendered image.
[0104] As an optional embodiment, the obtaining module 1300 is further configured to: Determine whether the ray intersects the initial shape according to the initial length of the ray and the initial shape; In the case where the ray does not intersect the initial shape, extend the ray one or more times until it intersects; Wherein, the step size of each extension is the same.
[0105] As an optional embodiment, the texture mapping information includes a depth map, and the second acquisition module 1400 is further configured to: Determine the depth map corresponding to each of the multiple intersection points according to the lengths of the rays corresponding to each of the multiple intersection points.
[0106] As an optional embodiment, the texture mapping information includes a color map, and the second acquisition module 1400 is further configured to: Acquire the material data corresponding to the initial shape; Acquire the color map corresponding to each of the multiple intersection points according to the material data.
[0107] As an optional embodiment, the texture mapping information includes a normal map, and the second acquisition module 1400 is further configured to: Acquire the gradient of the initial shape at each of the intersection points, where the gradient represents the shape change trend of the initial shape at the intersection point; Acquire the normal map corresponding to each of the intersection points according to the gradients at each of the intersection points.
[0108] As an optional embodiment, the method is implemented by a neural network model, and the device 1000 further includes a quantization module for: In the case of obtaining the target rendering image through the neural network model, quantize the neural network parameters of the neural network model to obtain a target floating point number; wherein, the target floating point number is used to instruct the neural network model to output the target rendering image when being input into the neural network model.
[0109] As an optional embodiment, the apparatus 1000 further includes a training module, configured to: Obtain a sample shape and a preset ray starting point; Emit a target ray from the preset ray starting point to the sample shape; In the case that the target ray does not intersect with the sample shape, extend the target ray one or more times until intersection; Obtain one or more training step lengths corresponding to the one or more extensions, where the training step length is the length of each extension of the target ray; Determine one or more step length errors according to a preset step length and the one or more training step lengths; Adjust the model parameters of the shape generation model according to the one or more step length errors.
[0110] Embodiment III Figure 11 Schematically shows a hardware architecture diagram of a computer device 10000 suitable for implementing an image rendering method according to Embodiment III of the present application. In some embodiments, the computer device 10000 may be a terminal device such as a smart phone, a wearable device, a tablet computer, a personal computer, a vehicle-mounted terminal, a game console, a virtual device, a workbench, a digital assistant, a set-top box, a robot, etc. In other embodiments, the computer device 10000 may be a rack server, a blade server, a tower server or a cabinet server (including an independent server, or a server cluster composed of multiple servers), etc. As Figure 11 shown, the computer device 10000 includes, but is not limited to: a memory 10010, a processor 10020, and a network interface 10030 that can communicate with each other through a system bus. Among them: The memory 10010 includes at least one type of computer-readable storage medium. The readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (such as SD or DX memory), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, magnetic disk, optical disc, etc. In some embodiments, the memory 10010 may be an internal storage module of the computer device 10000, such as the hard disk or memory of the computer device 10000. In other embodiments, the memory 10010 may also be an external storage device of the computer device 10000, such as a plug-in hard disk, Smart Media Card (SMC), Secure Digital (SD) card, Flash Card, etc. equipped on the computer device 10000. Of course, the memory 10010 may also include both the internal storage module and the external storage device of the computer device 10000. In this embodiment, the memory 10010 is generally used to store the operating system and various application software installed in the computer device 10000, such as the program code of the image rendering method. In addition, the memory 10010 may also be used to temporarily store various data that have been output or will be output.
[0111] In some embodiments, the processor 10020 may be a central processing unit (CPU), controller, microcontroller, microprocessor, or other chip. The processor 10020 is generally used to control the overall operation of the computer device 10000, such as performing control and processing related to data interaction or communication with the computer device 10000. In this embodiment, the processor 10020 is used to run the program code stored in the memory 10010 or process data.
[0112] The network interface 10030 may include a wireless network interface or a wired network interface, which is generally used to establish a communication link between the computer device 10000 and other computer devices. For example, the network interface 10030 is used to connect the computer device 10000 to an external terminal through a network, and establish a data transmission channel and a communication link between the computer device 10000 and the external terminal. The network may be a wireless or wired network such as an enterprise intranet (Intranet), the Internet, Global System of Mobile communication (GSM for short), Wideband Code Division Multiple Access (WCDMA for short), 4G network, 5G network, Bluetooth, Wi-Fi, etc.
[0113] It should be noted that Figure 11 Only the computer device with components 10010 - 10030 is shown, but it should be understood that it is not required to implement all the shown components, and more or fewer components can be alternatively implemented.
[0114] In this embodiment, the image rendering method stored in the memory 10010 can also be divided into one or more program modules and executed by one or more processors (such as the processor 10020) to complete the embodiments of the present application.
[0115] Embodiment 4 The embodiments of the present application also provide a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the image rendering method in the embodiments are implemented.
[0116] In this embodiment, the computer-readable storage medium includes flash memory, hard disks, multimedia cards, card-type memories (such as SD or DX memories, etc.), random access memories (RAM), static random access memories (SRAM), read-only memories (ROM), electrically erasable programmable read-only memories (EEPROM), programmable read-only memories (PROM), magnetic memories, magnetic disks, optical disks, etc. In some embodiments, the computer-readable storage medium may be an internal storage unit of a computer device, such as the hard disk or memory of the computer device. In other embodiments, the computer-readable storage medium may also be an external storage device of the computer device, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) card, a Flash Card, etc., equipped on the computer device. Of course, the computer-readable storage medium may also include both the internal storage unit and the external storage device of the computer device. In this embodiment, the computer-readable storage medium is generally used to store the operating system installed on the computer device and various application software, such as the program code of the image rendering method in the embodiment. In addition, the computer-readable storage medium may also be used to temporarily store various data that have been output or are to be output.
[0117] Embodiment 5 The embodiment of the present application also provides a computer program product, including a computer program, which implements the method in the above embodiment when executed by a processor.
[0118] Obviously, those skilled in the art should understand that the above-mentioned modules or steps of the embodiments of the present application can be implemented by a general-purpose computer device. They can be concentrated on a single computer device or distributed on a network composed of multiple computer devices. Optionally, they can be implemented by program codes executable by the computer device. Thus, they can be stored in a storage device and executed by the computer device. And in some cases, the steps shown or described can be executed in a different order from here, or they can be separately fabricated into individual integrated circuit modules, or multiple modules or steps among them can be fabricated into a single integrated circuit module to implement. In this way, the embodiments of the present application are not limited to any specific combination of hardware and software.
[0119] It should be noted that the above are only the preferred embodiments of the present application, and do not limit the patent protection scope of the present application. Any equivalent structure or equivalent process transformation made by using the content of the specification and drawings of the present application, or directly or indirectly applied in other related technical fields, shall be equally included in the patent protection scope of the present application.
Claims
1. An image rendering method, characterized in that: The method comprises: Get the initial shape; emitting a plurality of rays from a preset viewpoint, wherein the directions of the plurality of rays are all different; According to the plurality of rays and the initial shape, a plurality of intersection points are obtained; Obtaining the mapping information corresponding to each of the plurality of intersection points; and The initial shape is rendered according to the plurality of mapping information and preset lighting data to obtain a target rendered image.
2. The method according to claim 1, characterized in that According to the plurality of rays and the initial shape, a plurality of intersection points are obtained, including: Determining whether the ray intersects the initial shape according to the initial length of the ray and the initial shape; When the ray does not intersect the initial shape, extending the ray one or more times until the ray intersects with the initial shape; The length of each extension is the same.
3. The method according to claim 1, characterized in that The texture information includes a depth map; Obtaining the mapping information corresponding to each of the plurality of intersection points, including: Determine the depth maps corresponding to the plurality of intersection points according to the lengths of the rays corresponding to the plurality of intersection points.
4. The method according to claim 1, characterized in that The map information includes a color map; Obtaining the mapping information corresponding to each of the plurality of intersection points, including: Acquire material data corresponding to the initial shape; According to the material data, color maps corresponding to each of the plurality of intersection points are obtained.
5. The method according to claim 1, characterized in that The mapping information includes a normal map; Obtaining the mapping information corresponding to each of the plurality of intersection points, including: Acquire the gradient of the initial shape at each of the intersections, the gradient representing the shape change trend of the initial shape at the intersection; According to the gradient at each of the intersections, a normal map corresponding to each of the intersections is obtained.
6. The method according to claim 1, characterized in that The method is implemented by a neural network model; the method also includes: When the target rendered image is obtained through the neural network model, quantizing the neural network parameters of the neural network model to obtain a target floating point number; Among them, the target floating-point number is used to instruct the neural network model to output the target rendered image when being input into the neural network model.
7. The method according to claim 6, characterized in that The training steps of the neural network model include: Get the sample shape and the preset ray starting point; emitting a target ray from the preset ray starting point toward the sample shape; When the target ray does not intersect the sample shape, extending the target ray one or more times until the target ray intersects with the sample shape; Acquire one or more training step lengths corresponding to one or more extensions, where the training step length is the length of each extension of the target ray; Determining one or more step length errors based on a preset step length and one or more of the training step lengths; Model parameters of the shape generation model are adjusted based on the one or more step length errors.
8. An image rendering device, characterized in that: The device comprises: A first acquisition module acquires an initial shape; A transmitting module, used for transmitting a plurality of rays from a preset viewpoint, wherein the directions of the plurality of rays are all different; An obtaining module, used for obtaining a plurality of intersection points according to the plurality of rays and the initial shape; A second acquisition module is used to acquire the mapping information corresponding to each of the plurality of intersections; and A rendering module is used to render the initial shape according to the plurality of mapping information and preset lighting data to obtain a target rendered image.
9. A computer device, characterized in that: include: at least one processor; and a memory communicatively connected to the at least one processor; wherein: The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and when the computer instructions are executed by a processor, the method according to any one of claims 1 to 7 is implemented.
11. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.