Image rendering method and device, storage medium and program product
By dividing the rendered object into multiple plane units and simulating ray tracing in the rasterization stage, the problem of high computational complexity of ray tracing technology is solved, efficient image rendering is achieved, and the requirements for hardware performance are reduced.
Patent Information
- Application Number
- CN202411570574.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-05
- Publication Date
- 2025-04-04
- Estimated Expiration
- 2044-11-05
AI Technical Summary
Ray tracing technology has high computational complexity in complex scenarios, which is difficult to meet the needs of real-time rendering applications, and has high requirements for hardware performance such as GPUs.
By dividing the rendered object into multiple plane units, and determining the reflected light rays of each plane unit in the rasterization stage, rasterization technology is used to simulate ray tracing to improve the efficiency of ray interception.
It improves image rendering quality, reduces the requirements for hardware performance, improves rendering efficiency, and is suitable for real-time rendering applications in complex scenes.
Smart Images

Figure CN119762655A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the technical field of computer graphics, and in particular, to an image rendering method, device, storage medium, and program product. Background Art
[0002] Ray tracing is a rendering technology based on physical light simulation. It can simulate complex light propagation and interaction effects, provide high-quality rendering results, and has been widely used in the field of computer graphics (CG) rendering. Since the ray tracing algorithm requires a lot of computing resources to simulate the propagation and interaction of light, it requires the graphics processing unit (GPU) to have very high performance. However, the computing resources of general GPUs are limited and it is difficult to meet the computing requirements of ray tracing algorithms. Summary of the invention
[0003] In view of this, embodiments of the present application provide an image rendering method, an image rendering device, a computer storage medium, and a computer program product that can both improve rendering quality and reduce hardware performance requirements.
[0004] To achieve the above purpose, the technical solution of the embodiment of the present application is implemented as follows:
[0005] An embodiment of the present application provides an image rendering method, the method comprising: dividing a rendering object into a plurality of plane units; performing rasterization processing on each plane unit to obtain a target block of each plane unit on a display plane; the target block comprises a plurality of pixels; for each of the plane units, determining a reflected light formed by each light source point of the rendering object in the plane unit; wherein the light source point is determined according to a preset initial light; and rendering the target block according to the reflected light.
[0006] In some embodiments, the plane unit includes multiple vertices; for each of the plane units, determining the reflected light formed by each light source point of the rendered object in the plane unit includes: determining the reflected light formed by the light source point at each vertex based on the light source point and the plane unit; determining the reflected light formed by the light source point in the plane unit based on the reflected light formed by the light source point at the vertex.
[0007] In some embodiments, determining the reflected light formed by the light source point at each of the vertices based on the light source point and the plane unit includes: determining the direction of the incident light of each vertex based on the coordinates of the light source point and the coordinates of each of the vertices; and determining the reflection direction corresponding to the reflected light of the vertex based on the direction of the incident light and the normal of the plane unit.
[0008] In some embodiments, the planar unit includes multiple reflection points corresponding to pixels; determining the reflection light formed by the light source point at the planar unit according to the reflection light formed by the light source point at the vertex includes: interpolating and determining the reflection direction corresponding to the reflection light formed by the light source point at the reflection point according to the reflection direction corresponding to the reflection light of the vertex.
[0009] In some embodiments, the method further includes: determining a first intersection point of each of the initial light rays with the rendering object as the light source point.
[0010] In some embodiments, rendering the target image block according to the reflected light includes: determining a set of reflected light on the planar unit according to the reflected light formed by each of the light source points on the planar unit; determining pixel parameters of the target image block according to the set of reflected light; and rendering the target image block according to the pixel parameters.
[0011] In some embodiments, rendering the target image block according to the reflected light includes: determining sub-pixel parameters of the target image block according to the reflected light formed by any of the light source points in the planar unit; the sub-pixel parameters correspond one-to-one to the light source points; superimposing the sub-pixel parameters to obtain pixel parameters of the target image block; and rendering the target image block according to the pixel parameters.
[0012] In some embodiments, dividing the rendering object into a plurality of plane units includes: dividing the surface of the rendering object into a plurality of triangular face elements; and determining one or more triangular face elements that are connected in the same plane as one of the plane units.
[0013] An embodiment of the present application provides an image rendering device, which includes: a geometry unit, a rasterization unit, a reflected light determination unit and a rendering unit. The geometry unit is configured to divide the rendering object into a plurality of plane units; the rasterization unit is configured to perform rasterization processing on each plane unit to obtain a target block of each plane unit on a display plane; the target block includes a plurality of pixels; the reflected light determination unit is configured to determine, for each of the plane units, a reflected light formed by each light source point of the rendering object on the plane unit; wherein the light source point is determined according to a preset initial light; and the rendering unit is configured to render the target block according to the reflected light.
[0014] In some embodiments, the plane unit includes multiple vertices; the reflected light determination unit is configured to determine the reflected light formed by the light source point at each of the vertices based on the light source point and the plane unit; and determine the reflected light formed by the light source point at the plane unit based on the reflected light formed by the light source point at the vertex.
[0015] In some embodiments, the reflected light determination unit is configured to determine the incident light direction of each vertex based on the coordinates of the light source point and the coordinates of each vertex; and determine the reflection direction corresponding to the reflected light of the vertex based on the incident light direction and the normal of the plane unit.
[0016] In some embodiments, the plane unit includes multiple reflection points corresponding to pixels; the reflected light determination unit is configured to interpolate and determine the reflection direction corresponding to the reflected light formed by the light source point at the reflection point according to the reflection direction corresponding to the reflected light of the vertex.
[0017] In some embodiments, the image rendering apparatus further includes a light source point determination unit configured to determine a first intersection point of each of the initial light rays with the rendering object as the light source point.
[0018] In some embodiments, the rendering unit is configured to determine a set of reflected light rays on the planar unit based on the reflected light rays formed by each of the light source points on the planar unit; determine pixel parameters of the target image block based on the set of reflected light rays; and render the target image block based on the pixel parameters.
[0019] In some embodiments, the rendering unit is configured to determine sub-pixel parameters of the target image block based on the reflected light formed by any of the light source points in the plane unit; the sub-pixel parameters correspond one-to-one to the light source points; superimpose the sub-pixel parameters to obtain pixel parameters of the target image block; and render the target image block based on the pixel parameters.
[0020] In some embodiments, the geometry unit is configured to divide the surface of the rendering object into a plurality of triangular face elements; and determine one or more triangular face elements that are connected in the same plane as one of the plane units.
[0021] An embodiment of the present application provides a computer storage medium, which includes: a memory and a processor; the computer memory is used to store computer instructions; and the processor is used to execute the above-mentioned image rendering method when running the computer instructions.
[0022] An embodiment of the present application provides a computer program product, including a computer program, which implements the above-mentioned image rendering method when executed by a processor.
[0023] The image rendering method in the embodiment of the present application uses rasterization technology to simulate ray tracing, by dividing the rendering object into multiple plane units, and determining the target tile of the plane unit on the display plane in the rasterization stage. By calculating the multiple reflected rays formed by each light source point on a certain plane unit, the intersection results of multiple rays in the plane unit can be calculated at one time, and then multiple pixels within the target tile range can be rendered according to the intersection results of multiple rays, which can effectively improve the intersection efficiency of rays, improve the rendering efficiency of images, reduce the complexity of calculations, and reduce the performance requirements for hardware such as GPUs and graphics cards. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] Figure 1 A step diagram of an image rendering method in an embodiment of the present application;
[0025] Figure 2 Schematic diagram of the initial light principle of the image rendering method in an embodiment of the present application;
[0026] Figure 3 Schematic diagram of the reflected light principle of the image rendering method in the embodiment of the present application;
[0027] Figure 4 A schematic diagram of surface division of a rendering object in an image rendering method in an embodiment of the present application;
[0028] Figure 5 Schematic diagram of the perspective projection principle of the image rendering method in the embodiment of the present application;
[0029] Figure 6 This is a schematic diagram of the structure of an image rendering device in an embodiment of the present application;
[0030] Figure 7 This is a schematic diagram of the structure of a computer storage medium in an embodiment of the present application;
[0031] Figure 8 This is a schematic diagram of the structure of the on-chip cache in an embodiment of the present application;
[0032] Fig. 9 It is a schematic diagram of the structure of the computer program product in the embodiment of the present application. DETAILED DESCRIPTION
[0033] The following will be combined with the embodiments of the present application and the accompanying drawings to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0034] In the following description, a large number of specific details are given to provide a more thorough understanding of the present application. However, it is obvious to those skilled in the art that the present application can be implemented without one or more of these details. In other examples, in order to avoid confusion with the present application, some technical features known in the art are not described; that is, all features of the actual embodiments are not described here, and well-known functions and structures are not described in detail.
[0035] The purpose of the terms used herein is only to describe specific embodiments and is not intended to be limiting of the present application. When used herein, the singular forms "one", "an" and "said / the" are also intended to include plural forms, unless the context clearly indicates otherwise. It should also be understood that the terms "consisting of" and / or "comprising", when used in this specification, determine the presence of the features, integers, steps, operations, elements and / or parts, but do not exclude the presence or addition of one or more other features, integers, steps, operations, elements, parts and / or groups. When used herein, the term "and / or" includes any and all combinations of the relevant listed items.
[0036] In order to thoroughly understand the present application, detailed steps and detailed structures will be presented in the following description to illustrate the technical solution of the present application. The preferred embodiments of the present application are described in detail below, but in addition to these detailed descriptions, the present application may also have other implementation methods.
[0037] The current ray tracing technology generally adopts a recursive algorithm, which is based on the interaction between light and objects in the scene, and simulates the propagation and interaction effects of light by recursively tracing the path of light. Specifically, ray tracing technology emits a number of rays from the virtual point of the camera or the human eye, which interact with objects in the scene and produce reflection or refraction when encountering objects in the scene. Ray tracing technology needs to trace the light reflected or refracted by the surface of the object in the scene, determine the intersection of each ray with the object in the scene and the path of each ray, so that the propagation of light in three-dimensional space can be simulated more accurately, thereby improving the image rendering quality. Although ray tracing technology can solve the problem of global illumination, since ray tracing technology needs to calculate the intersection of each ray and the object in the scene, including a large number of recursive calculations, the computational complexity of ray tracing is high and a long rendering time is required. Especially when the scene is very complex, the number of intersections between the light and the object increases, and the computational cost and time cost of rendering increase exponentially. This makes it difficult to apply it in some real-time rendering applications, such as games and interactive graphical interfaces. In addition, not all GPUs can meet the computing requirements of ray tracing technology, which also limits the application of ray tracing technology in the field of real-time rendering. Therefore, how to improve the parallel computing capabilities of ray tracing technology and reduce the performance requirements of ray tracing technology on GPUs, graphics cards and other hardware has become a key research direction of ray tracing technology.
[0038] Rasterization technology projects the rendered objects in a three-dimensional scene onto a two-dimensional display plane, uses pixels to approximate these rendered objects, and then shades these pixels to generate images. Rasterization technology uses a highly optimized graphics pipeline, fully utilizes hardware resources, can efficiently process geometric data and pixel data, has low requirements for hardware performance, and can provide faster rendering speeds and higher computing efficiency with limited computing resources. Therefore, rasterization technology has been widely used in some scenes that require fast rendering, such as the game field. However, rasterization technology has certain limitations in complex light and shadow effects and global illumination simulation, and it is difficult to simulate the lighting effects of the real world and obtain high-quality images.
[0039] In view of this, an embodiment of the present application provides an image rendering method that can improve rendering quality while reducing hardware performance. Figure 1 As shown, the image rendering method includes:
[0040] S100: Divide the rendering object into a plurality of plane units.
[0041] S200: performing rasterization processing on each plane unit to obtain a target image block of each plane unit on a display plane; the target image block includes a plurality of pixels.
[0042] S300: For each plane unit, determine the reflected light formed by each light source point of the rendering object in the plane unit, wherein the light source point is determined according to a preset initial light.
[0043] S400: Rendering a target tile according to the reflected light.
[0044] It is understandable that a scene to be rendered may include multiple objects to be rendered, namely, rendering objects. Figure 2 , the scene to be rendered includes rendering object A, rendering object B and rendering object C. In the actual rendering process, the rendering object is usually an object in a three-dimensional space, and its surface includes a curved surface or an irregular plane, etc. If the surface of the rendering object is divided into multiple smaller surfaces, these smaller surfaces can be approximately regarded as a plane unit, that is, a three-dimensional surface can be represented by multiple two-dimensional planes.
[0045] After being projected onto the scene to be rendered, the initial ray 3 may interact with the rendered objects in the scene. The initial ray 3 may refer to a number of rays starting from the viewpoint 1, passing through the display plane 2 and projected onto the scene to be rendered. The viewpoint 1 refers to the virtual human eye point or the virtual camera point; the initial direction of the initial ray 3 may be determined based on the line connecting the viewpoint 1 and the point (pixel point or sampling point) on the display plane.
[0046] The image rendering method in the embodiment of the present application uses rasterization technology to simulate ray tracing, by dividing the surface of the rendering object into multiple plane units, and determining the target tile range of the plane unit on the display plane in the rasterization stage. By calculating the multiple reflected rays formed by each light source point on a certain plane unit, the intersection results of multiple rays in the plane unit can be calculated at one time, and then multiple pixels within the target tile range can be rendered according to the intersection results of multiple rays, which can effectively improve the intersection efficiency of rays, improve the rendering efficiency of images, reduce the complexity of calculations, and reduce the performance requirements for hardware such as GPUs and graphics cards.
[0047] It should be noted that the image rendering method in the embodiment of the present application is based on target tile rendering, which can better utilize the parallel processing capability of the GPU. Since each target tile can be rendered independently, they can be assigned to different processing units of the GPU for parallel processing, thereby increasing the rendering speed.
[0048] In some embodiments, the above-mentioned image rendering method further includes: determining the first intersection point of each initial light ray with the rendering object as a light source point.
[0049] Continue to refer Figure 2, the initial light ray is projected onto the scene to be rendered and then interacts with the rendering object in the scene. Exemplarily, the initial light ray 3 intersects with the rendering object A for the first time at the intersection 4, and a light ray 5 is generated at the intersection 4 and intersects with the rendering object at the intersection 6, and then the reflected light ray 7 reaches the scene light source 8. Among them, the intersection 4 is the starting point of the reflected light ray 5, and the intersection 4 can be regarded as a light source point of the rendering object B, that is, the first intersection point of the initial light ray 3 and the rendering object A is a light source point of the rendering object B. It should be noted that the first intersection point of the initial light ray 3 with any rendering object (or plane unit) in the scene to be rendered may be a light source point of another rendering object (or plane unit).
[0050] In some embodiments, dividing the rendering object into a plurality of plane units includes: dividing the surface of the rendering object into a plurality of triangular face elements; and determining one or more triangular face elements that are connected in the same plane as a plane unit.
[0051] A triangle is a triangle defined by three vertices. A triangle is the simplest polygon. Using a triangle to represent the surface of a rendered object can further simplify subsequent operations and calculations. For example, two connected triangles are determined as a plane unit, that is, the two connected triangles include four vertices and a normal line.
[0052] In some embodiments, the plane unit includes multiple vertices; for each plane unit, the reflected light formed by each light source point of the rendering object in the plane unit is determined, including: according to the light source point and the plane unit, determining the reflected light formed by the light source point at each vertex; according to the reflected light formed by the light source point at the vertex, determining the reflected light formed by the light source point in the plane unit.
[0053] It should be noted that the information carried by the light source point may include its coordinate information in three-dimensional space, as well as coloring information such as the light intensity of the light source point.
[0054] In some embodiments, the reflected light formed by the light source point at each vertex is determined based on the light source point and the plane unit, including: determining the direction of the incident light at each vertex based on the coordinates of the light source point and the coordinates of each vertex; determining the reflection direction corresponding to the reflected light at the vertex based on the direction of the incident light and the normal of the plane unit.
[0055] Specifically, according to the coordinates of any light source point in three-dimensional space and the coordinates of each vertex of the plane unit in three-dimensional space, the direction of the incident light from the light source point to the vertex can be determined. Figure 3 As shown, if the coordinates of the light source point in three-dimensional space are P(P x , P y , P z), the plane unit X0X1X2X3 includes four vertices: X0(x0, y0, z0), X1(x1, y1, z1), X2(x2, y2, z2) and X3(x3, y3, z3). Then the vector pointing to vertex X0 can be used as the light source point P represents the incident light at vertex X0. Similarly, we can use the vector Represents the incident light at vertex X1, using the vector Represents the incident light at vertex X2, using the vector Representing the incident light at vertex X3, the unit vector of each incident light ray vector can represent the incident direction of the incident light ray.
[0056] The reflected light vector formed by the incident light at each vertex of the plane unit can be calculated according to formula (1):
[0057]
[0058] in, represents the reflected light vector; represents the incident light vector; represents the unit vector of the plane element normal; Represents the dot product operation of the incident light vector and the unit vector of the plane unit normal, and the calculation result is the cosine of the angle between the incident light and the normal.
[0059] In some embodiments, the plane unit includes a plurality of reflection points corresponding to pixels. Determining the reflection light formed by the light source point at the plane unit according to the reflection light formed by the light source point at the vertex includes: interpolating and determining the reflection direction corresponding to the reflection light formed by the light source point at the reflection point according to the reflection direction corresponding to the reflection light of the vertex.
[0060] Continue to refer Figure 2 In the case of giving priority to specular reflection, all reflected rays formed by the light source point P on the plane unit X0X1X2X3 are reflected rays and Reflected light and The reverse extension lines intersect at the convergence point F, and the cone 10 formed by all the reflected light rays can be regarded as the frustum during perspective projection. Then, the reflection direction of the reflected light rays formed by each reflection point of the light source point P on the plane unit X0X1X2X3 can be determined according to the direction of the reflected light rays at each vertex.
[0061] The rasterized plane unit corresponds to the target block. The target block includes multiple pixels, and the position information of each reflection point corresponding to each pixel in the plane unit is determined according to the pixel position information of the target block. The multiple pixels within the target block range correspond to the reflection points in the plane unit one by one, that is, the number of pixels included in the target block corresponding to the plane unit is the same as the number of reflection points in the plane unit.
[0062] It is understandable that for the same light source point, the direction of the incident light at each point on a plane unit changes linearly. Figure 3 As shown, in the case of giving priority to mirror reflection, the incident direction of the incident light at each point on the plane unit X0X1X2X3 changes linearly, and the normal direction in the plane unit X0X1X2X3 is the same, then the reflection direction of each point in the plane unit X0X1X2X3 also changes linearly. Therefore, the reflection direction of each point in the plane can be determined by interpolation method according to the reflection direction of the four vertices of the plane unit X0X1X2X3. By calculating the multiple reflected light rays formed by the light source point on the plane unit X0X1X2X3, the intersection results of the multiple light rays in the plane unit X0X1X2X3 are calculated at one time, which effectively improves the intersection efficiency of the light rays. In some embodiments, the calculation of the reflected light rays formed by each light source point in the plane unit can be obtained by a compute shader.
[0063] In some embodiments, after calculating the position information of each reflection point, the incident light of each reflection point can also be calculated, and based on the incident light and the normal of the plane unit, each reflected light vector is calculated by formula (1) to obtain the corresponding reflection direction of the reflected light.
[0064] In some embodiments, rendering a target image block according to reflected light includes: determining a set of reflected light on the plane unit according to reflected light formed by each light source point on the plane unit; determining pixel parameters of the target image block according to the set of reflected light; and rendering the target image block according to the pixel parameters.
[0065] In some embodiments, for the same plane unit, the reflected light rays formed by each reflection point in the plane unit are calculated for each light source point. For example, assuming that the plane unit includes n reflection points {r0, r1, ..., r n-1}, then the n reflected rays formed by the light source point P0 in the plane unit can be expressed as The n reflected rays formed by the light source point P1 in the plane unit can be expressed as By superimposing the reflected light rays formed by the light source point P0 and the light source point P1 in the plane unit, the set of reflected light rays can be obtained. Based on the set of reflected light rays of the plane unit, the pixel parameters of each pixel of all light source points within the target block range can be determined, and the pixel parameters include at least one of the following parameters: incident light direction, normal direction, reflected light direction, and light intensity. Then, the target block is rendered by the pixel parameters of each pixel within the target block range to obtain the final image for output. For example, the pixel parameters corresponding to each reflection point are used as input, and the mirror reflection illumination model is used to simulate the illumination effect of each light source point on objects with smooth surfaces such as metal, water surface, and glass, and the color value of the pixel corresponding to the reflection point is calculated. Exemplarily, for a certain reflection point, according to the multiple reflected light rays related to the reflection point in the set of reflected light rays, the vector sum of the reflection directions of these reflected light rays at the reflection point can be obtained. Then, the vector sum can be used as the input value of the illumination model to calculate the color value of the corresponding pixel.
[0066] In some embodiments, rendering a target image block according to reflected light includes: determining sub-pixel parameters in the target image block according to reflected light formed by any light source point in the plane unit; the sub-pixel parameters correspond one-to-one to the light source point; superimposing the sub-pixel parameters to obtain pixel parameters of the target image block; and rendering the target image block according to the pixel parameters.
[0067] In some embodiments, the sub-pixel parameters of the target block are determined based on the reflected light formed by any light source point in the plane unit, and the sub-pixel parameters include at least one of the following parameters: incident light direction, normal direction, reflected light direction, and light intensity. The sub-pixel parameters corresponding to each light source point are superimposed to obtain a set of sub-pixel parameters corresponding to all light source points, that is, the pixel parameters of the target block. Exemplarily, for a certain pixel, its pixel parameters may include the sub-pixel parameters corresponding to the light source point P0 and the sub-pixel parameters corresponding to the light source point P1. The target block is then rendered using the pixel parameters of each pixel within the target block range to obtain the final image for output.
[0068] In some embodiments, the target image block can be rendered according to the sub-pixel parameters of the target image block to obtain a sub-image, and the sub-images corresponding to the light source points P0, P1, etc. can be superimposed to obtain a rendering result. Among them, multiple sub-images can be regarded as multiple image layers, and the image layers are superimposed to obtain the final image for output.
[0069] This application also provides the following examples:
[0070] refer to Figure 3 and Figure 4, the surface of the rendering object in the scene to be rendered is divided into multiple triangular face elements; multiple connected triangular face elements in the same plane are determined as a plane unit. Select the light source point P, and all the light rays emitted by the light source point P that hit the plane unit are surrounded by the light rays that hit the four vertices. The principle can be referred to Figure 5 The perspective projection diagram shown in Figure 1 shows that under perspective projection, the projection lines converge at the projection center camera point F. ′ The frustum formed by the projection lines between the near plane (determined by the boundary lines 21, 22, 23 and 24) and the far plane is the viewing cone 20. If the far plane in the viewing cone 20 is approximated as the far plane at infinity, then Figure 3 The frustum 10 composed of the reflected light is regarded as the frustum 20. However, the perspective projection projects the objects in the frustum 20 onto the near plane of the frustum, while the present solution restores the reflected light to the frustum 10 from the distant focal point F.
[0071] Then, for the plane unit, determine the reflected light formed by the light source point P in the plane unit, including: calculating the incident light of each vertex of the plane unit. Exemplarily, the position information of the corresponding plane unit X0X1X2X3 is determined according to the position information of the triangular face element (triangular face element X0X1X3 and triangular face element X1X2X3), including the coordinates of the four vertices of the plane unit in three-dimensional space: X0 (x0, y0, z0), X1 (x1, y1, z1), X2 (x2, y2, z2) and X3 (x3, y3, z3). Subtract the vertex coordinates from the light source point coordinates to obtain the incident light vector of the vertex: and
[0072] For the plane unit, determining the reflected light formed by the light source point P in the plane unit also includes: calculating the reflected light of the vertex according to the position information of the vertex and the incident light. Specifically, the reflected light of each vertex is calculated according to formula (1): and
[0073] Each plane unit is rasterized to obtain the target tile of each plane unit on the display plane. Since each pixel after rasterization corresponds to the intersection point (reflection point) of the light and the object, that is, the coordinates of the pixel on the display plane correspond to the coordinates of the reflection point in three-dimensional space. Each pixel processed by the fragment shader can be regarded as a ray of light, and then the reflected light formed by the light source point at each reflection point can be determined according to the reflected light of the vertex and the position information of the reflection point on the plane unit, and then rendered.
[0074] Then calculate the reflected light formed by each light source point on the next plane unit. Superimposing the reflected light on all plane units is the comprehensive color of each point hitting each plane unit. Using rasterization instead of the light intersection process can complete the intersection process of multiple light rays in a plane unit at one time, improving rendering efficiency.
[0075] Based on the same inventive concept, the present application also provides an image rendering device, such as Figure 6 As shown, the image rendering device 100 includes: a geometry unit 110, a rasterization unit 120, a reflected light determination unit 130 and a rendering unit 140; the geometry unit 110 is configured to divide the rendering object into a plurality of plane units; the rasterization unit 120 is configured to perform rasterization processing on each plane unit to obtain a target block of each plane unit on the display plane; the target block includes a plurality of pixels; the reflected light determination unit 130 is configured to determine, for each plane unit, a reflected light formed by each light source point of the rendering object in the plane unit; wherein the light source point is determined according to a preset initial light. The rendering unit 140 is configured to render the target block according to the reflected light.
[0076] In some embodiments, the plane unit includes multiple vertices; the reflected light determination unit is configured to determine the reflected light formed by the light source point at each vertex based on the light source point and the plane unit; and determine the reflected light formed by the light source point at the plane unit based on the reflected light formed by the light source point at the vertex.
[0077] In some embodiments, the reflected light determination unit is configured to determine the incident light direction of each vertex according to the coordinates of the light source point and the coordinates of each vertex; and determine the reflection direction corresponding to the reflected light of the vertex according to the incident light direction and the normal of the plane unit.
[0078] In some embodiments, the plane unit includes multiple reflection points corresponding to pixels; the reflected light determination unit is configured to interpolate and determine the reflection direction corresponding to the reflected light formed by the light source point at the reflection point according to the reflection direction corresponding to the reflected light of the vertex.
[0079] In some embodiments, the image rendering apparatus further includes a light source point determination unit configured to determine a first intersection point of each initial light ray with the rendering object as a light source point.
[0080] In some embodiments, the rendering unit is configured to determine a set of reflected light rays on the planar unit based on the reflected light rays formed by each of the light source points on the planar unit; determine pixel parameters of the target block based on the set of reflected light rays; and render the target block based on the pixel parameters.
[0081] In some embodiments, the rendering unit is configured to determine the sub-pixel parameters of the target block based on the reflected light formed by any light source point in the plane unit; the sub-pixel parameters correspond one-to-one to the light source point; superimpose the sub-pixel parameters to obtain the pixel parameters of the target block; and render the target block according to the pixel parameters.
[0082] In some embodiments, the geometry unit is configured to divide the surface of the rendering object into a plurality of triangular face elements; and determine one or more triangular face elements that are connected in the same plane as a plane unit.
[0083] Based on the same inventive concept, the embodiment of the present application also provides a computer storage medium, such as Figure 7 As shown, the computer storage medium 200 includes: a memory 210 and a processor 220; the computer memory 210 is used to store computer instructions; the processor 220 is used to execute the above-mentioned image rendering method when running the computer instructions. Since the processor in the computer storage medium can execute the above-mentioned task processing method when running the computer instructions, the computer storage medium has a beneficial technical effect similar to the above-mentioned task processing method. Therefore, the beneficial effects of the computer storage medium will not be repeated here.
[0084] It should be noted that for each plane unit, the storage space required for the information of the reflected light formed by each light source point in the plane unit is relatively small, while when rendering a certain target block, the rendering process of each pixel on it may involve the reflected light corresponding to multiple light sources. If the information of these reflected lights is directly stored in the memory, it may cause the processor to access the memory frequently, increasing the pressure of memory access and management. Figure 8 As shown, in order to reduce the pressure of memory access and management and improve the operating efficiency of the processor, a storage area 231 corresponding to multiple rendering targets (RT) can be divided in the on-chip cache (On-chipCache) 230, wherein each storage area 231 is used to store information of reflected light formed by a light source point in a plane unit, and this information is used to represent an RT. Since the operation speed of the processor is much faster than the access speed of the memory, the use of the on-chip cache can alleviate the speed difference between the processor and the memory, improve the operating efficiency of the processor, and avoid frequent memory read and write operations.
[0085] Based on the same inventive concept, the present application embodiment also provides a computer program product, such as Fig. 9As shown, the computer program product 300 includes a computer program 310, and the computer program 310 implements the above-mentioned image rendering method when executed by the processor. Since the computer program in the computer program product can implement the above-mentioned task processing method when executed by the processor, the computer program product has similar beneficial technical effects as the above-mentioned task processing method. Therefore, the beneficial effects of the computer storage medium are not repeated here.
[0086] A person skilled in the art can understand that all or part of the steps of implementing the above method embodiment can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above method embodiment; and the aforementioned storage medium includes: mobile storage devices, read-only memories (ROM), magnetic disks or optical disks, etc., various media that can store program codes.
[0087] Alternatively, if the above-mentioned integrated unit of the present application is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application can be essentially or partly embodied in the form of a software product that contributes to the relevant technology. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROMs, magnetic disks, or optical disks.
[0088] The various embodiments / implementations provided in this application can be combined with each other without causing any contradiction.
[0089] The above description is only a preferred embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.
Claims
1. An image rendering method, characterized in that: The method comprises: Divide the rendering object into multiple plane units; Performing rasterization processing on each plane unit to obtain a target image block of each plane unit on a display plane; the target image block includes a plurality of pixels; For each of the plane units, determining the reflected light formed by each light source point of the rendering object in the plane unit; wherein the light source point is determined according to a preset initial light; The target tile is rendered according to the reflected light.
2. The image rendering method according to claim 1, characterized in that: The plane unit includes a plurality of vertices; and for each of the plane units, determining the reflected light formed by each light source point of the rendering object in the plane unit includes: Determine, according to the light source point and the plane unit, the reflected light formed by the light source point at each of the vertices; According to the reflected light formed by the light source point at the vertex, the reflected light formed by the light source point at the plane unit is determined.
3. The image rendering method according to claim 2, characterized in that: The step of determining, based on the light source point and the plane unit, reflected light formed by the light source point at each of the vertices includes: Determine the direction of incident light of each vertex according to the coordinates of the light source point and the coordinates of each vertex; The reflection direction corresponding to the reflected light of the vertex is determined according to the direction of the incident light and the normal of the plane unit.
4. The image rendering method according to claim 3, characterized in that: The plane unit includes a plurality of reflection points corresponding to pixels; The step of determining the reflected light formed by the light source point at the plane unit according to the reflected light formed by the light source point at the vertex comprises: According to the reflection direction corresponding to the reflection light of the vertex, the reflection direction corresponding to the reflection light formed by the light source point at the reflection point is determined by interpolation.
5. The image rendering method according to claim 1, characterized in that: The method further comprises: The first intersection point of each of the initial light rays and the rendering object is determined as the light source point.
6. The image rendering method according to claim 1, characterized in that: The step of rendering the target tile according to the reflected light comprises: Determine a set of reflected light rays on the plane unit according to the reflected light rays formed by each of the light source points on the plane unit; Determining pixel parameters of the target image block according to the set of reflected light rays; Rendering the target tile according to the pixel parameters.
7. The image rendering method according to claim 1, characterized in that: The step of rendering the target tile according to the reflected light comprises: Determine the sub-pixel parameters of the target image block according to the reflected light formed by any of the light source points on the plane unit; the sub-pixel parameters correspond to the light source points one by one; Superimposing the sub-pixel parameters to obtain pixel parameters of the target image block; Rendering the target tile according to the pixel parameters.
8. The image rendering method according to claim 1, characterized in that: The step of dividing the rendering object into a plurality of plane units comprises: Dividing the surface of the rendering object into a plurality of triangular facets; One or more triangular face elements that are connected to each other and located in the same plane are determined as one plane unit.
9. An image rendering device, characterized in that: The device comprises: A geometry unit, configured to divide a rendering object into a plurality of plane units; A rasterization unit is configured to perform rasterization processing on each plane unit to obtain a target image block of each plane unit on a display plane; the target image block includes a plurality of pixels; A reflected light determination unit is configured to determine, for each of the plane units, a reflected light formed by each light source point of the rendering object on the plane unit; wherein the light source point is determined according to a preset initial light; The rendering unit is configured to render the target image block according to the reflected light.
10. A computer storage medium, characterized in that: The storage medium includes: a memory and a processor; The computer memory is used to store computer instructions; The processor is used to execute the image rendering method according to any one of claims 1 to 8 when running the computer instructions.
11. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the computer program implements the image rendering method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Image processing method and related device
CN114581589A
Image rendering method and device, electronic equipment and storage medium
CN115496845A
Image rendering method and device, electronic equipment, storage medium and program product
CN118628634A
Scene rendering method and device, equipment, medium and program product
CN118674850A
Three-dimensional CG image editing method, device, program and recording medium
JP2010231620A