Image rendering method and electronic equipment
By counting the number of pixels on the image of the model, only rendering the unobstructed model, solving the problems of large amount of computing and serious computing power consumption caused by ray tracing technology, and improving rendering efficiency and real-time frame rate.
Patent Information
- Application Number
- CN202310974141.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-03
- Publication Date
- 2025-02-14
Smart Images

Figure CN119444965A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of image processing technology, and in particular to an image rendering method and an electronic device. Background Art
[0002] In graphics rendering related applications, such as games, virtual simulation, augmented reality (AR) / virtual reality (VR), etc., improving the realism of rendered images has always been the main goal of the industry. Ray tracing technology has attracted much attention because it is based on real physical laws and can generate rendering results that are close to the real world.
[0003] When using ray tracing technology to render images, a large number of rays need to be constructed and emitted into the three-dimensional scene. In the process of reflection / refracting of the rays with the model in the three-dimensional scene, a large number of new rays are generated, making the number of rays extremely large. In addition, using ray tracing technology to render images requires not only calculating the intersection points of all rays with the model (i.e., ray intersection), but also coloring each pixel in the image, which consumes a lot of computing power. Therefore, how to reduce the amount of calculations in the ray tracing process, reduce computing power consumption, and improve rendering efficiency is a technical problem that needs to be solved urgently. Summary of the invention
[0004] The embodiments of the present application provide an image rendering method and an electronic device for solving the problems of large amount of calculation and severe consumption of computing power in the image rendering process.
[0005] To achieve the above objectives, the embodiments of the present application adopt the following technical solutions:
[0006] In a first aspect, an image rendering method is provided, the method comprising: after an electronic device projects a first model in a three-dimensional scene onto an image to be rendered, the electronic device counts the number of pixels of the first model displayed on the image to be rendered. If the electronic device determines that the first model is blocked according to the number of pixels, the first model is not rendered; if the electronic device determines that the first model is not blocked according to the number of pixels, the first model is rendered.
[0007] Based on the first aspect, the electronic device projects the first model in the three-dimensional scene onto the image to be rendered, and determines whether the first model is blocked based on the number of pixels displayed by the first model on the image to be rendered; if the first model is blocked, the first model is not rendered, and if the first model is not blocked, the first model is rendered. In this way, the blocked model can be not rendered, reducing the amount of calculation in the image rendering process, reducing the computing resources and computing time consumed by the electronic device, and optimizing the computing performance of image rendering. In this way, the efficiency of image rendering can be improved, thereby improving the real-time frame rate of image rendering.
[0008] In a possible implementation manner of the first aspect, the first model being occluded includes: the first model partially or completely overlapping the second model; or, the first model is located inside the second model; or, the first model is in contact with the second model; wherein the second model is a model other than the first model in the three-dimensional scene.
[0009] In a possible implementation manner of the first aspect, the electronic device determines that the first model is blocked according to the number of pixels, including: if the number of pixels is less than a pixel number threshold, determining that the first model is blocked.
[0010] The electronic device determines that the first model is not blocked by isolating the number of pixels, including: if the number of pixels is greater than or equal to a pixel number threshold, determining that the first model is not blocked.
[0011] It can be understood that, in the present application, the fewer the number of pixels of the first model displayed on the image to be rendered, the more the first model is obscured.
[0012] In a possible implementation manner of the first aspect, the electronic device determines the number of pixels of the first model displayed on the image to be rendered, including: the electronic device calls an occlusion query capability to determine the number of pixels of the first model displayed on the image to be rendered.
[0013] In this implementation, the electronic device invokes the occlusion query capability to determine the number of pixels displayed by the first model on the image to be rendered, thereby improving the rate at which the electronic device determines the number of pixels and thereby improving the efficiency of image rendering.
[0014] In a possible implementation of the first aspect, the method also includes: the electronic device constructs at least one viewing cone based on the three-dimensional scene; the electronic device performs viewing cone clipping on the first model and each viewing cone in the at least one viewing cone respectively; when the first model is clipped through the viewing cone corresponding to the first viewing cone in the at least one viewing cone and the first viewing cone is confirmed to be a forward viewing cone, the electronic device does not project the first model onto the image to be rendered.
[0015] Among them, the forward viewing cone is a viewing cone constructed by the electronic device based on a virtual camera in a three-dimensional scene.
[0016] In this implementation, usually, most of the models inside the forward view cone will not be obstructed, so the first model clipped by the forward view cone will not be projected onto the image to be rendered, that is, there is no need to determine whether the first model is obstructed, thereby achieving the effect of reducing the load on the electronic device.
[0017] In a possible implementation of the first aspect, an electronic device projects a first model onto an image to be rendered, including: when the first model is clipped by a cone corresponding to a second cone in at least one cone and the second cone is not a forward cone, projecting the first model onto the image to be rendered.
[0018] In a possible implementation of the first aspect, the electronic device performs frustum clipping on the first model respectively with each frustum in at least one frustum, including: the electronic device performs frustum clipping on the first model respectively with each frustum in at least one frustum by running at least one thread; wherein at least one thread corresponds one-to-one to at least one frustum.
[0019] In this implementation, the electronic device runs at least one thread to perform frustum clipping on the first model and each frustum in at least one frustum, thereby improving the efficiency of the electronic device in performing frustum clipping.
[0020] In a possible implementation of the first aspect, an electronic device renders a first model, including: the electronic device renders the first model using ray tracing technology; wherein the ray tracing technology is used to render the model by tracing the path of light in units of pixels in an image to be rendered and simulating an effect of light meeting the model.
[0021] In this implementation, when the electronic device uses ray tracing technology to render the first model, since ray tracing technology can provide more realistic light and shadow effects and improve the overall quality of image rendering, the use of ray tracing technology can reduce the amount of ray tracing calculations without affecting the image quality, by reducing the number of models that need to be rendered, thereby reducing the computing resources and computing time consumed by the electronic device and improving the computing performance of ray tracing.
[0022] In other words, the occluded models in the three-dimensional scene are not rendered, while the unoccluded models in the three-dimensional scene are rendered. In this way, when the ray tracing technology is used to render the image to be rendered, the occluded models do not need to participate in the intersection calculation, thereby optimizing the computing performance of ray tracing.
[0023] In a possible implementation manner of the first aspect, the method further includes: the electronic device displays a rendered image; wherein the rendered image is obtained by rendering an unobstructed model in the three-dimensional scene.
[0024] In a second aspect, an electronic device is provided, which has the function of implementing any one of the methods in the first aspect, and the function can be implemented by hardware or by hardware executing corresponding software. The hardware or software includes one or more modules corresponding to the above functions.
[0025] According to a third aspect, an electronic device is provided, comprising: a memory and one or more processors, wherein the memory is used to store computer-executable instructions, and when the electronic device is running, the processor executes the computer-executable instructions stored in the memory so that the electronic device executes any one of the methods described in the first aspect.
[0026] In a fourth aspect, a chip system is provided, which is applied to an electronic device. The chip system includes a processor and an interface, wherein the interface is used to receive instructions and transmit them to at least one processor; at least one processor executes the instructions so that the electronic device executes any one of the methods described in the first aspect.
[0027] In a fifth aspect, a computer-readable storage medium is provided, wherein instructions are stored in the computer-readable storage medium, and when the computer-readable storage medium is executed on a computer, the computer can execute any of the methods described in the first aspect.
[0028] In a sixth aspect, a computer program product comprising instructions is provided, which, when executed on a computer, enables the computer to execute any of the methods described in the first aspect.
[0029] Among them, the technical effects brought about by any implementation method in the above-mentioned second to sixth aspects can refer to the technical effects brought about by different implementation methods in the first aspect, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] Figure 1 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application;
[0031] Figure 2 A schematic diagram of the principle of ray tracing provided in an embodiment of the present application;
[0032] Figure 3 A schematic diagram of another principle of ray tracing provided in an embodiment of the present application;
[0033] Figure 4 A schematic diagram of the principle of rasterization processing provided in an embodiment of the present application;
[0034] Figure 5 A schematic diagram of an image rendering process provided by an embodiment of the present application;
[0035] Figure 6 A schematic diagram of a first model being blocked by a second model provided in an embodiment of the present application;
[0036] Figure 7 A schematic diagram of another image rendering process provided by an embodiment of the present application;
[0037] Figure 8 A schematic diagram of a cube map provided in an embodiment of the present application;
[0038] Fig. 9 A schematic diagram of the structure of a viewing cone provided in an embodiment of the present application;
[0039] Fig.10 A diagram showing an example of the principle of frustum clipping provided in an embodiment of the present application;
[0040] Fig.11 A schematic diagram of a BVH provided in an embodiment of the present application;
[0041] Fig.12 A schematic diagram of the structure of a chip system provided in an embodiment of the present application. DETAILED DESCRIPTION
[0042] In the description of the embodiments of the present application, unless otherwise specified, “ / ” means or. For example, A / B can mean A or B. The “and / or” in this article is merely a way to describe the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone.
[0043] The following terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of the embodiments of the present application, unless otherwise specified, "multiple" means two or more.
[0044] In the embodiments of the present application, the words "exemplary" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific way.
[0045] In addition, in the embodiments of the present application, directional terms such as "up", "down", "left" and "right" may be defined including but not limited to the orientation relative to the schematic placement of the components in the drawings. It should be understood that these directional terms may be relative concepts, which are used for relative description and clarification, and may change accordingly according to changes in the orientation of the components in the drawings.
[0046] The image rendering method provided in the embodiment of the present application can be applied to electronic devices. For example, the electronic device can be a mobile phone, a tablet computer, a personal digital assistant (PDA), a personal computer (PC), an ultra-mobile personal computer (UMPC), a smart home device (e.g., a smart TV, a smart screen, a large screen, etc.), a wearable device (e.g., a smart watch, a smart bracelet, etc.), a vehicle-mounted device, an AR / VR device, and a console of an electronic device, etc. The embodiment of the present application does not impose any special restrictions on the specific form of the electronic device.
[0047] Please refer to Figure 1 , is a structural diagram of an electronic device 100 provided in an embodiment of the present application.
[0048] like Figure 1 As shown, the electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a positioning module 181, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc.
[0049] The processor 110 may include a central processing unit (CPU) and a graphics processor. The CPU is used to run the operating system and application programs of the electronic device. The application program may be a graphics application program, such as a game application, a video playback application program, etc. The operating system provides a system graphics library interface, and the application program generates an instruction stream for rendering graphics or image frames, and the required related rendering data through the system graphics library interface provided by the operating system and the driver provided by the operating system. The system graphics library interface includes, but is not limited to: an open graphics library for embedded system (OpenGL ES) interface, a Khronos platform graphics interface interface, or a graphics application program interface (Vulkan), etc. The instruction stream contains a series of instructions, which are usually call instructions for the system graphics library interface.
[0050] Exemplarily, the CPU may also include one or more of the following processing units: such as an application processor (AP), a modem processor, an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Among them, different processing units may be independent devices or integrated in one or more processors.
[0051] The controller may be the nerve center and command center of the electronic device 100. The controller may generate an operation control signal according to the instruction operation code and the timing signal to complete the control of fetching and executing instructions.
[0052] The CPU may also include a hardware accelerator, such as an application specific integrated circuit (ASIC), a field programmable gate array (FPGA), or an integrated circuit for implementing logic operations. The CPU may be coupled to one or more data buses for transmitting data and instructions between various components of the electronic device 100.
[0053] The graphics processor may include a general-purpose graphics processor that executes software, such as a graphics processing unit (GPU) or other types of dedicated graphics processing units. Figure 1 The processor 110 includes a CPU and a GPU as an example for illustration.
[0054] The GPU is used to receive the graphics instruction stream sent by the CPU, generate a rendering target through a rendering pipeline, and display the rendering target on the display screen 194 through the operating system of the electronic device 100. Among them, the rendering pipeline can also be called a rendering pipeline, a pixel pipeline or a pixel pipeline, which is a parallel processing unit inside the GPU for processing graphics signals. The GPU may include multiple rendering pipelines, and multiple rendering pipelines can process graphics signals in parallel independently of each other. For example, the rendering pipeline can perform a series of operations in the process of rendering graphics or image frames, and typical operations may include: vertex processing, primitive processing, rasterization, fragment processing, etc.
[0055] The processor 110 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may store instructions or data that the processor 110 has just used or cyclically used. If the processor 110 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.
[0056] In some embodiments, the processor 110 may include one or more interfaces. It is understood that the interface connection relationship between the modules illustrated in this embodiment is only a schematic illustration and does not constitute a structural limitation on the electronic device 100. In other embodiments, the electronic device 100 may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.
[0057] The electronic device 100 can realize the shooting function through the ISP, the camera 193, the video codec, the GPU, the display screen 194 and the application processor.
[0058] ISP is used to process the data fed back by camera 193. For example, when taking a photo, the shutter is opened, and the light is transmitted to the photosensitive element of camera 193 through the lens. The light signal is converted into an electrical signal, and the photosensitive element of camera 193 transmits the electrical signal to ISP for processing and converts it into an image visible to the naked eye. ISP can also perform algorithm optimization on the noise, brightness, and color of the image. ISP can also optimize the exposure, color temperature and other parameters of the shooting scene. In some embodiments, ISP can be set in camera 193.
[0059] The camera 193 is used to capture still images or videos. The object generates an optical image through the lens and projects it onto the photosensitive element. The photosensitive element can be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the optical signal into an electrical signal, and then passes the electrical signal to the ISP to be converted into a digital image signal. The ISP outputs the digital image signal to the DSP for processing. The DSP converts the digital image signal into an image signal in a standard RGB, YUV or other format. In some embodiments, the electronic device 100 may include 1 or N cameras 193, where N is a positive integer greater than 1.
[0060] The digital signal processor is used to process digital signals, and can process not only digital image signals but also other digital signals. For example, when the electronic device 100 is selecting a frequency point, the digital signal processor is used to perform Fourier transform on the frequency point energy.
[0061] Video codecs are used to compress or decompress digital videos. The electronic device 100 may support one or more video codecs. Thus, the electronic device 100 may play or record videos in a variety of coding formats, such as Moving Picture Experts Group (MPEG) 1, MPEG2, MPEG3, MPEG4, etc.
[0062] NPU is a neural network (NN) computing processor. By drawing on the structure of biological neural networks, such as the transmission mode between neurons in the human brain, it can quickly process input information and can also continuously self-learn. Through NPU, applications such as intelligent cognition of electronic device 100 can be realized, such as image recognition, face recognition, voice recognition, text understanding, etc.
[0063] The electronic device 100 implements the display function through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, which connects the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs that execute program instructions to generate or change display information.
[0064] The display screen 194 is used to display images, videos, etc. The display screen 194 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode or an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), Mini-LED, Micro-OLED, a quantum dot light-emitting diode (QLED), etc.
[0065] It is to be understood that the structure illustrated in this embodiment does not constitute a specific limitation on the electronic device 100. In other embodiments, the electronic device 100 may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
[0066] The methods in the following embodiments can all be implemented in the electronic device 100 having the above hardware structure. To facilitate understanding, the technical terms involved in the embodiments of the present application are first explained.
[0067] 1. Ray tracing technology
[0068] Ray tracing, also known as ray tracing, light trail tracing or ray tracing, is a technology used to achieve image rendering. Its main purpose is to project a three-dimensional space model (also called an object, model, etc.) into a two-dimensional space for display by calculating the color value of each pixel on the screen image.
[0069] Specifically, ray tracing is to render an image by tracing the path of light in pixels in the image plane and simulating the effect of the light meeting the model. For example, from the position of the virtual camera, a beam of light is emitted into the three-dimensional scene through the pixels on the image plane, the intersection point of the first intersection between the light and the model in the three-dimensional scene is calculated (hereinafter referred to as the main intersection point), and then the light energy of the main intersection point (also referred to as light intensity, coloring, etc.) is calculated. If the material of the main intersection point is reflective (or refractive), it can continue to be traced in the reflection (or refraction) direction of the main intersection point, and continue to obtain the light energy of the intersection point after reflection (or refraction), and the weighted sum of the light energy of all intersection points is used as the color value of the pixel. In an embodiment of the present application, for each pixel on the image plane, the color value of each pixel can be calculated through the above process, so that a frame of image can be rendered. In other words, ray tracing is to calculate the projection and global illumination by tracing the propagation process of light in a three-dimensional scene, thereby rendering a two-dimensional image.
[0070] Please refer to Figure 2 , is a schematic diagram of the principle of ray tracing provided in the embodiment of the present application. Figure 2 As shown, the principle of ray tracing is: a beam of light is emitted from the position of the virtual camera along the pixel position on the image plane. After the light passes through the pixel on the image plane and intersects with the model in the three-dimensional scene, reflection and refraction may occur. After reflection or refraction, a new light is formed, and the new light may also hit other models and reflect or refract. After multiple reflections or refractions, the light finally reaches the light source. In an embodiment of the present application, the path of the light emitted from the virtual camera that finally reaches the light source after multiple reflections or refractions can be called an effective light path.
[0071] For example, Figure 2 Four effective light paths are shown, and the initial light on each effective light path passes through a pixel on the image plane. The initial light can be understood as the light that starts from the virtual camera, passes through a pixel on the image plane, and intersects with the model in the three-dimensional scene for the first time.
[0072] like Figure 2 As shown, the initial light a1 of the effective light path a intersects with model 1 and is reflected to form light a2. Light a2 intersects with model 2 and is reflected to form light a3. Light a3 intersects with model 3 and is reflected to form light a4. Light a4 eventually reaches the light source.
[0073] The initial light ray b1 of the effective light path b intersects with the model 1 and is emitted to form the light ray b2. The light ray b2 intersects with the model 2 and is reflected to form the light ray b3. The light ray b3 finally reaches the light source.
[0074] The initial light ray c1 of the effective light path c intersects with the model 2 and is reflected to form the light ray c2. The light ray c2 intersects with the model 3 and is emitted to form the light ray c3. The light ray c3 finally reaches the light source.
[0075] The initial light d1 of the effective light path d intersects with the model 3 and is reflected to form the light d2, which eventually reaches the light source.
[0076] It should be noted that not all light rays emitted from the position of the virtual camera will eventually reach the light source. Some light rays may be reflected or refracted by the model and diffuse outward and away from the light source. In the embodiment of the present application, the path of light rays emitted from the virtual camera that does not reach the light source after multiple reflections or refractions can be called an invalid light path.
[0077] For ease of understanding, Figure 2 The number of intersections between the light and the model on each valid light path shown is small. In actual implementation, the light emitted from the virtual camera usually undergoes multiple reflections or refractions before reaching the light source, and there are many intersections on each valid light path. For example, Figure 3 As shown in the figure, the initial light O1 emitted from the virtual camera intersects with model 1 at point P1, and forms light O2 after reflection at point P1; the light O2 intersects with model 2 at point P2, and forms light O3 after reflection at point P2; the light O3 intersects with the model at point P3, and forms light O4 after reflection at point P3, and so on. Assuming that after k reflections, the light finally reaches the light source. Where k is an integer much greater than 1.
[0078] exist Figure 3 In the ray tracing process shown in FIG, the light energy at each intersection is calculated, and then the weighted sum of the light energy at all intersections is used as the color value of the corresponding pixel, and the corresponding pixel is rendered using the color value. Figure 3 The process shown calculates the color value of the pixel, thereby rendering each pixel and finally obtaining a rendered image.
[0079] For example, in Figure 3 In the effective light path shown, the color value of the pixel corresponding to the effective light path is the weighted sum of the light energy at P1, the light energy at P2, the light energy at P3, ... and the light energy at Pk.
[0080] (II) Rasterization
[0081] Rasterization is the process of converting the model in the three-dimensional scene into a two-dimensional matrix composed of pixels in the image plane, then calculating the color value of each pixel, and coloring each pixel according to the color value to generate the final rendered image.
[0082] Please refer to Figure 4 , is a schematic diagram of the principle of rasterization processing provided by the embodiment of the present application. Figure 4 As shown in the figure, the principle of rasterization is: divide the model in the 3D scene into triangles, convert the 3D coordinates of the vertices of the triangle in the 3D scene into 2D coordinates on the image plane through coordinate transformation, and interpolate inside the triangle to obtain the 2D coordinates of each pixel of the triangle on the image plane. Then calculate the color value according to the 2D coordinates of each pixel, and color each pixel according to the color value to generate the final rendered image.
[0083] For example, Figure 4 As shown, the three-dimensional coordinates of the vertices of the triangle in the three-dimensional scene include (a1, b1, c1), (a2, b2, c2), (a3, b3, c3). After mapping the three-dimensional coordinates of the vertices to the image plane, the two-dimensional coordinates of the vertices of the triangle on the image plane include (x1, y1), (x2, y2), (x3, y3).
[0084] It should be noted that the reason why the model in the 3D scene is divided into triangles is because triangles are the most basic polygons, and any other polygons can be split into triangles. The interior of a triangle must be planar, and the inside and outside of the triangle are clear. As long as the three vertices of the triangle are defined, the properties of any point inside the triangle can be obtained. For example, based on the 2D coordinates of the three vertices of the triangle, the 2D coordinates of other pixels inside the triangle can be obtained, that is, interpolation inside the triangle.
[0085] It can be seen that rasterization is to project the model in the three-dimensional scene directly onto the image plane and color the pixels on the image plane. The processing difficulty is relatively low, and the light and shadow effects provided are relatively poor. Ray tracing is to achieve real effects such as reflection, refraction, shadow, ambient occlusion, material and global illumination by tracing each ray emitted by the virtual camera. Therefore, ray tracing can provide more realistic light and shadow effects.
[0086] In the related technology, when using the ray tracing algorithm to render an image, it is necessary to calculate the light energy of the intersection of the light and the model (i.e., intersection). The more models there are in the three-dimensional scene, the more light energy of the intersections that need to be calculated. The calculation of the light energy at each intersection is a deep iterative process, which undoubtedly increases the amount of calculation for ray tracing.
[0087] Based on this, an embodiment of the present application provides an image rendering method, which can reduce the amount of calculation in the image rendering process without affecting the image quality rendering effect, reduce the computing resources and computing time consumed by the electronic device, and optimize the computing performance of image rendering. Specifically, the occluded model in the three-dimensional scene is not rendered, while the unoccluded model in the three-dimensional scene is rendered. In this way, the occluded model can be rendered without rendering, thereby improving the efficiency of image rendering, and then improving the real-time frame rate of image rendering.
[0088] It should be noted that the image to be rendered can be understood as the image plane described in the above embodiment. Figure 2 and Figure 4 It can be seen that the image plane is composed of multiple pixels, that is, the image to be rendered includes multiple pixels. Among them, a pixel refers to the smallest unit in an image represented by a digital sequence. In the embodiment of the present application, the color value of each pixel is calculated, and each pixel is colored according to the color value to achieve rendering of the image to be rendered, and the color value and position of the pixel can determine the final appearance of the image to be rendered.
[0089] In addition, the model described in the embodiments of the present application can be understood as a static object element in a three-dimensional scene (such as a game, virtual simulation, VR, etc.), such as grass, buildings, etc.; or, the model can also be an active object in a three-dimensional scene, such as a virtual character, virtual character, virtual animal, etc. in a game application. For ease of understanding, the model is constructed as a geometric figure such as a cube, cone, sphere, cylinder, etc. in the embodiments of the present application for illustration.
[0090] For example, the following embodiments will combine the above-mentioned ray tracing technology and rasterization processing to introduce the process of the image rendering method provided by the embodiment of the present application. Figure 5 , is a flow chart of an image rendering method provided in an embodiment of the present application, such as Figure 5 As shown, the method may include the following steps.
[0091] Step I: The electronic device obtains a first model in a three-dimensional scene.
[0092] The first model is any one of the multiple models included in the three-dimensional scene.
[0093] It should be noted that in the embodiment of the present application, for any model in the three-dimensional scene, the electronic device can determine whether the corresponding model is blocked by the following steps. The embodiment of the present application takes the first model of the three-dimensional scene as an example for explanation. For the implementation methods of whether other models are blocked, please refer to the following examples, which will not be repeated here.
[0094] Step II: The electronic device projects the first model onto the image to be rendered.
[0095] As an example, the electronic device may project the first model onto the image to be rendered using rasterization processing. Figure 4 As shown, based on the principle of rasterization processing, the electronic device divides the first model into triangles and directly projects the divided first model onto the image to be rendered (ie Figure 4 on the image plane shown).
[0096] Step III: The electronic device counts the number of pixels displayed by the first model on the image to be rendered.
[0097] It is understandable that when the first model is completely or partially blocked, even if the electronic device projects the first model onto the image to be rendered, the number of pixels displayed by the first model on the image to be rendered will be small because the first model is blocked; or the first model does not display pixels on the image to be rendered. Based on this, in an embodiment of the present application, the electronic device can determine whether the first model is blocked according to the number of pixels displayed by the first model on the image to be rendered.
[0098] As an example, the first model being blocked includes: the first model partially or completely overlapping the second model; or the first model being inside the second model; or the first model being in contact with the second model. The second model is a model other than the first model in the three-dimensional scene.
[0099] Take the partial overlap of the first model and the second model as an example. For example, please refer to Figure 6 , which shows a schematic diagram of the first model being blocked. Figure 6 As shown, the first model is a sphere, and the second model is a wall with an opening on the wall. The first model is located on the side of the second model away from the image to be rendered, that is, the first model is located behind the second model.
[0100] Depend on Figure 6 It can be seen that after the first model is projected onto the image to be rendered, some pixels of the first model can be displayed on the image to be rendered through the opening of the second model, while other parts of the first model are blocked by the second model, and the pixels of the blocked part are not displayed on the image to be rendered, that is, the number of pixels of the first model displayed on the image to be rendered is small. Therefore, it is possible to determine whether the first model is blocked by the number of pixels of the first model displayed on the image to be rendered.
[0101] Step III-1: If the electronic device determines that the first model is blocked according to the number of pixels, the electronic device does not render the first model.
[0102] Step III-2: If the electronic device determines that the first model is not blocked according to the number of pixels, the electronic device renders the first model.
[0103] In summary, by adopting the solution of the present application, the occluded model is rendered, while the unoccluded model is not rendered. In this way, without affecting the effect of image rendering, the amount of calculation in the image rendering process can be reduced, the computing resources and computing time consumed by the electronic device can be reduced, and the computing performance of image rendering can be optimized. In addition, by projecting the first model onto the image to be rendered, and counting the number of pixels displayed by the first model on the image to be rendered, it is determined based on the number of pixels whether the first model is occluded, which improves the image rendering efficiency, thereby improving the real-time frame rate of image rendering.
[0104] In addition, it can be understood that the embodiment of the present application can project the first model onto the image to be rendered through rasterization processing, and the rasterization processing is to divide the first model into triangles, and after determining that the first model is blocked, the first model is not rendered. In this way, by reducing the number of triangles corresponding to the first model in the image rendering process, the effect of reducing the amount of calculation for image rendering is achieved.
[0105] In some embodiments, if the first model is not blocked, the electronic device may render the first model using rasterization processing to further improve the image rendering effect, thereby improving the real-time frame rate of the image rendering. In other embodiments, if the first model is not blocked, the electronic device may render the first model using ray tracing technology to provide more realistic light and shadow effects and improve the overall quality of image rendering.
[0106] When the electronic device uses ray tracing technology to render the first model, since ray tracing technology can provide more realistic light and shadow effects and improve the overall quality of image rendering, the use of ray tracing technology can reduce the number of models that need to be rendered without affecting the image quality, thereby reducing the amount of ray tracing calculations, reducing the computing resources and computing time consumed by the electronic device, and improving the computing performance of ray tracing.
[0107] In other words, the occluded models in the three-dimensional scene are not rendered, while the unoccluded models in the three-dimensional scene are rendered. In this way, when the ray tracing technology is used to render the image to be rendered, the occluded models do not need to participate in the intersection calculation, thereby optimizing the computing performance of ray tracing.
[0108] It should be noted that in an embodiment of the present application, when the electronic device uses ray tracing technology to render the first model, the purpose of the electronic device using rasterization processing is to project the first model onto the image to be rendered. In order to count the number of pixels of the first model displayed on the image to be rendered, the pixels projected onto the image to be rendered are not colored.
[0109] In other words, in the embodiment of the present application, the electronic device determines whether the first model is obscured through rasterization processing. If the first model is not obscured, the electronic device uses ray tracing technology to render the first model. Through this image rendering method that is a mixture of rasterization processing and ray tracing technology, the overall rendering quality of the image rendering can be further improved.
[0110] As an example, if the number of pixels of the first model displayed on the image to be rendered is less than the pixel number threshold, the electronic device determines that the first model is blocked. Correspondingly, if the number of pixels of the first model displayed on the image to be rendered is greater than or equal to the pixel number threshold, the electronic device determines that the first model is not blocked.
[0111] It should be noted that the pixel number threshold may be pre-configured in the electronic device. In actual implementation, the electronic device may configure the pixel number threshold in the electronic device based on actual conditions. The embodiment of the present application does not impose any specific restrictions on the specific value of the pixel number threshold, which shall be subject to actual conditions.
[0112] It can be understood that, in the embodiment of the present application, the fewer the number of pixels of the first model displayed on the image to be rendered, the more the first model is obscured.
[0113] Among them, optionally, an optional implementation method of the number of pixels displayed by the above-mentioned first model on the image to be rendered is that the electronic device can call the occlusion query capability to determine the number of pixels displayed by the first model on the image to be rendered. Among them, the occlusion query capability is used to query the context and return the number of pixels displayed by the first model on the image to be rendered to the electronic device to accelerate the electronic device to determine the number of pixels. It should be understood that the occlusion query capability is actually an interface or function, which is implemented through technologies such as a bounding volume hierarchy (BVH), a ray tracing acceleration structure (such as a kd tree, ray space partitioning, etc.), and occlusion culling.
[0114] In an embodiment of the present application, the electronic device calls the occlusion query capability to determine the number of pixels displayed by the first model on the image to be rendered, thereby improving the rate at which the electronic device determines the number of pixels and thereby improving the efficiency of image rendering.
[0115] Optionally, after the first model is rendered, the electronic device obtains a rendered image and displays the rendered image on a display screen. For example, in a game scene, the electronic device renders all models in the game scene, and after all models are rendered, the electronic device displays the rendered game screen on the display screen. The game screen here can be understood as the above-mentioned image to be rendered, and the virtual characters, virtual characters, virtual props, etc. in the game screen can be models in the game scene.
[0116] For example, in the following embodiments, a hybrid rendering technology combining rasterization processing and ray tracing technology is used to introduce the method of the embodiment of the present application. Figure 7 , is a schematic diagram of an image rendering process provided by an embodiment of the present application. Figure 7 As shown, the method may include the following steps.
[0117] Step a: The electronic device constructs a cube frustum.
[0118] As an example, the electronic device renders all models in the three-dimensional scene to generate a cube map. The cube map includes six maps. In simple terms, the cube map is a texture map containing six 2D textures, each of which constitutes a face of a cube, thereby forming a textured cube.
[0119] The cube map may contain all models in the three-dimensional scene, that is, it can be considered that all models in the three-dimensional scene are wrapped in the cube map.
[0120] Please refer to Figure 8 , which shows a schematic diagram of a cube map. Figure 8 As shown in , the cube map includes six maps, each of which constitutes a face of a cube, and six maps can form a cube. Figure 8 As shown, the six maps included in the cube can be called maps in different directions; for example, the six maps included in the cube map are respectively called: front map (Front), back map (Back), top map (Top), bottom map (Bottom), left map (Left), and right map (Right).
[0121] In some embodiments, the electronic device constructs at least one viewing cone according to the above three-dimensional scene, such as the electronic device creates six viewing cones with the same attributes based on the above cube map, thereby constructing a cubic viewing cone. Exemplarily, the electronic device creates six virtual cameras, namely front, back, top, bottom, left, and right, at the current virtual camera position according to the position information of the virtual camera in the three-dimensional scene, and constructs a viewing cone corresponding to each virtual camera. The six viewing cones face forward, backward, top, bottom, left, and right, respectively, that is, each viewing cone looks in different directions of the three-dimensional scene, and the image data within the field of view of these virtual cameras can be spliced into a complete 360° panoramic image, including all models in the three-dimensional scene.
[0122] Please refer to Fig. 9 , which shows a schematic diagram of a viewing cone. Fig. 9 As shown in the figure, the viewing cone is composed of a near clipping plane, a far clipping plane and four viewing cone surfaces. The near clipping plane is set to prevent the model from being too close to the virtual camera and not visible, the far clipping plane is set to prevent the model from being too far away from the virtual camera and not visible, and the four viewing cone surfaces are the surfaces formed by the four lines diverging from the virtual camera and tangent to the two clipping planes.
[0123] like Fig. 9 As shown, the viewing cone also includes four vertices of the near clipping plane and four vertices of the far clipping plane. Exemplarily, the four vertices of the near clipping plane can be represented as: ntl, ntr, nbl and nbr respectively; the four vertices of the far clipping plane can be represented as: ftl, ftr, fbl and fbr respectively.
[0124] It can be understood that in the embodiments of the present application, Figure 8 The cubemaps shown in the figure have different orientations, including Fig. 9 The viewing cone shown is constructed into a cubic viewing cone.
[0125] After the electronic device constructs the cube frustum, the electronic device marks each frustum in the cube frustum. For example, the forward frustum (frustum Forward) is marked to indicate that the frustum faces forward; the backward frustum (frustum Backward) is marked to indicate that the frustum faces backward; the left frustum (frustum Leftward) is marked to indicate that the frustum faces left; the right frustum (frustum Rightward) is marked to indicate that the frustum faces right; the upper frustum (frustum Upward) is marked to indicate that the frustum faces upward; and the lower frustum (frustum Downward) is marked to indicate that the frustum faces downward.
[0126] It should be noted that the orientation of the view frustum can be understood as the far clipping plane of the view frustum being close to the six maps included in the stereo map. For example, the view frustum facing forward can be understood as: the far clipping plane of the view frustum is close to the front map in the cube map.
[0127] Step b: The electronic device performs cone cropping on the model in the three-dimensional scene based on the cube cone.
[0128] Exemplarily, the electronic device performs frustum clipping between the first model and each frustum in at least one frustum. When the first model is clipped by the frustum corresponding to the first frustum in at least one frustum, and the first frustum is a forward frustum, the first model is not projected onto the image to be rendered. When the first model is clipped by the frustum corresponding to the second frustum in at least one frustum, and the second frustum is not a forward frustum, the first model is projected onto the image to be rendered. The forward frustum is a frustum constructed by the electronic device based on a virtual camera in a three-dimensional scene.
[0129] In some embodiments, the electronic device performs frustum clipping of the first model with each frustum in at least one frustum through at least one thread; wherein at least one thread corresponds one-to-one to at least one frustum.
[0130] The frustum clipping refers to determining whether the model is within the frustum of the virtual camera. The electronic device performing frustum clipping on the model in the three-dimensional scene can be understood as the electronic device determining whether the model in the three-dimensional scene passes through the frustum clipping.
[0131] In some embodiments, if any model in the three-dimensional scene is within the visual cone of the virtual camera, the electronic device determines that the model passes the visual cone clipping. If any model in the three-dimensional scene is outside the visual cone of the virtual camera, the electronic device determines that the model does not pass the visual cone clipping.
[0132] In other embodiments, the electronic device creates an acceleration structure for the model in the three-dimensional scene, and then performs a frustum clipping on the model based on the acceleration structure. The acceleration structure can be understood as a bounding box created by the electronic device based on the model. The acceleration structure can be a structure such as a bounding volume hierarchy (BVH), a uniform grid (uniformgrid), a k-dimensional tree (kd-tree), or an axis-aligned bounding box (AABB). The embodiments of the present application do not specifically limit the acceleration structure.
[0133] Taking the acceleration structure as AABB as an example, illustratively, for each model in the three-dimensional scene, the electronic device determines whether the AABB of the model intersects with the view frustum. If the AABB of the model intersects with the view frustum or the AABB of the model is located inside the view frustum, the electronic device determines that the model passes the view frustum clipping. If the AABB of the model is located outside the view frustum, the electronic device determines that the model does not pass the view frustum clipping.
[0134] Please refer to Fig.10 , which shows a schematic diagram of the principle of frustum clipping. Fig.10 As shown in the figure, model 1 intersects with the viewing cone, and models 2, 3, and 4 are all inside the viewing cone, that is, models 1, 2, 3, and 4 are clipped by the viewing cone. Model 5 is outside the viewing cone, that is, model 5 is not clipped by the viewing cone.
[0135] As an example, the electronic device performs frustum clipping on the models in the three-dimensional scene through the forward frustum (i.e., frustum forward), and adds the models clipped through the frustum to the first model list (mesh list). The first model list can also be called a ray rendering list, that is, the models clipped through the forward frustum can be directly added to the ray rendering list. Subsequently, the electronic device can execute a ray tracing algorithm on the models in the ray tracing rendering list to render each model in the list.
[0136] It should be noted here that the reason why the models clipped by the forward view frustum are added to the ray rendering list and subsequently directly ray traced for rendering is that the models in the list have a greater impact on the final result of image rendering. For example, image rendering requires the calculation of reflection, shadow, and lighting information. Therefore, there is no need to determine whether the models clipped by the forward view frustum are blocked. All models clipped by the forward view frustum can be directly rendered to improve the final result of image rendering.
[0137] As for the models located in the other five view frustums, the final result of image rendering is mainly affected by the models that are not obstructed inside the other five view frustums. Therefore, for the models clipped by the view frustums of the other five view frustums, it is also necessary to determine whether the model is obstructed. For the unobstructed models, add them to the ray rendering list and perform ray tracing for rendering.
[0138] As another example, the electronic device performs the following operations on the remaining five frustums, such as the frustum Backward, the frustum Leftward, the frustum Rightward, the frustum Upward, and the frustum Downward. Fig.10 The frustum clipping operation shown in the figure is performed, and the model clipped by the frustum is added to the second model list. The second model list can also be called a rasterization list, that is, the models clipped by the frustum in the remaining five directions can be directly added to the rasterization list. Subsequently, the electronic device can perform rasterization processing on the models in the rasterization list to determine the number of pixels displayed by each model on the image to be rendered, thereby determining whether the corresponding model is blocked.
[0139] Exemplarily, the second model list includes multiple sub-lists, such as the second model list includes a backward model list (frustum Backward mesh list), a left model list (frustum Leftward mesh list), a right model list (frustum Rightward mesh list), an upper model list (frustum Upward mesh list), and a lower model list (frustum Downward mesh list).
[0140] In some embodiments, the electronic device runs multiple threads and performs frustum clipping operations on the remaining five frustums simultaneously. For example, the model clipped by the backward frustum is added to the backward model list (frustum Backward mesh list); the model clipped by the left frustum is added to the left model list (frustum Leftward mesh list); the model clipped by the right frustum is added to the right model list (frustum Rightward mesh list); the model clipped by the upper frustum is added to the upper model list (frustum Upward mesh list); the model clipped by the lower frustum is added to the lower model list (frustum Downward mesh list).
[0141] In the above solution, the electronic device runs multiple threads and performs the frustum clipping operation on the remaining five frustums at the same time, which can improve the efficiency of the electronic device in performing frustum clipping.
[0142] Step c: The electronic device determines whether the models included in the second model list are blocked.
[0143] Exemplarily, the electronic device projects each model in the second model list onto the image to be rendered, and counts the number of pixels of the corresponding model displayed on the image to be rendered. If the number of pixels is less than the pixel number threshold, the electronic device determines that the corresponding model is blocked. If the number of pixels is greater than or equal to the pixel number threshold, the electronic device determines that the corresponding model is not blocked.
[0144] In some embodiments, the electronic device adds the unobstructed models to the first model list, that is, to the ray rendering list. Subsequently, the electronic device may execute a ray tracing algorithm on the unobstructed models to render each unobstructed model.
[0145] In other embodiments, the electronic device will remove the occluded model, and subsequently, the electronic device will not render the occluded model.
[0146] Step d: The electronic device creates a ray tracing acceleration structure based on each model in the first model list.
[0147] Among them, the ray tracing acceleration structure is obtained based on the three-dimensional scene, and the ray tracing acceleration structure is used to quickly obtain the intersection of light rays. That is, by tracing rays through the ray tracing acceleration structure, the intersection of light rays and the model in the three-dimensional scene can be quickly obtained.
[0148] Exemplarily, the ray tracing acceleration structure may include BVH, uniform grid, k-dimensional tree or AABB, etc. The embodiment of the present application does not specifically limit the ray tracing acceleration structure.
[0149] Exemplarily, the ray tracing acceleration structure can quickly remove irrelevant objects (such as irrelevant models in a three-dimensional scene) by utilizing a space partitioning structure, so that only a small part of the model can be traversed to find the nearest intersection. For example, taking the ray tracing acceleration structure as the above-mentioned BVH as an example, the model in the three-dimensional scene is surrounded by the BVH, and before the light intersects with the model in the three-dimensional scene, it will first intersect with the BVH. If the light does not hit the BVH, it means that the light will not intersect with the model in the BVH; if the light hits the BVH, then it is calculated whether the light intersects with the model in the BVH.
[0150] Usually, a 3D scene includes multiple models. Using BVH actually uses a binary tree structure to manage the models in the 3D scene. For example, please refer to Fig.11 , which shows a schematic diagram of a BVH. Fig.11 As shown, different models are enclosed by bounding boxes of different sizes, and a corresponding binary tree structure is formed. Then, the binary tree structure is traversed in sequence to determine whether the light intersects with the model in the BVH. For example, when the light does not intersect with the bounding box B in the binary tree, it means that the light will not intersect with the four models in the bounding box B; when the light intersects with the bounding box C in the binary tree, it is further calculated whether the light intersects with the two models in the bounding box C. In this way, the process of detecting whether the light intersects with the four models in the bounding box B can be reduced, so as to quickly obtain the intersection point of the light and the model in the three-dimensional scene.
[0151] In some embodiments, a ray tracing acceleration structure can be created by the following steps. For example, the steps for an electronic device to create a ray tracing acceleration structure include: Step ①: The electronic device divides the model into triangles, then obtains the vertex data and index data of the triangles, and stores the vertex data of the triangles in a vertex buffer in the memory, and stores the index data of the triangles in an index buffer in the memory. The vertex buffer and the index buffer are a frame buffer created by the electronic device in the memory, and the vertex buffer and the index buffer are different buffers of the same frame buffer in the memory; or, the vertex buffer and the index buffer are different frame buffers in the memory.
[0152] Step ②: The electronic device creates an acceleration structure object by filling VkAccelerationStructureGeometryKHR and calling the BuildGeometryInfo function. Step ③: The electronic device calls the vkGetBufferDeviceAddressKHR function through the vulkan instruction to obtain the storage address of the vertex buffer and index buffer in the memory, and triggers the GPU to read the vertex data and index data of the triangle from the vertex buffer and index buffer based on the storage address of the vertex buffer and index buffer. Step ④: The electronic device calls the vkCmdBuildAccelerationStructuresKHR function through the vulkan instruction to fill the vertex data and index data of the triangle into the acceleration structure object to create a ray tracing acceleration structure.
[0153] Step e: The electronic device performs ray tracing based on the ray tracing acceleration structure to obtain a rendered image.
[0154] Step f: The electronic device displays the rendered image.
[0155] As an example, an electronic device can execute a ray tracing algorithm based on a ray tracing acceleration structure, material information of a model, and light data to render each pixel in an image to be rendered, thereby obtaining a rendered image.
[0156] The three-dimensional scene includes multiple models, each of which corresponds to a material information, which is pre-configured by the electronic device. For example, the material information may include one or more of roughness, basic color, refractive index, and reflectivity.
[0157] Ray data refers to the data required by electronic devices to execute ray tracing algorithms. For example, ray data includes the number of rays and the number of ray iterations. The number of rays refers to the number of rays emitted by the virtual camera to a single pixel on the image to be rendered, that is, the number of rays passing through a single pixel on the image to be rendered. The number of ray iterations is used to indicate the number of times each ray emitted by the virtual camera to a single pixel intersects with the model in the three-dimensional scene. For example, the virtual camera emits three different rays to a single pixel, and each ray intersects with the model three times in the three-dimensional scene.
[0158] For example, the electronic device can store the number of rays and the number of ray iterations in the ray data in a frame buffer in the memory, for example, in different channels on a map (or Mask image) included in the frame buffer. In other words, the ray data can be saved on a map, thereby achieving the effect of reducing the storage overhead of the ray data results.
[0159] For example, the electronic device may store the number of rays and the number of ray iterations in a preset format map on a frame buffer. The preset format map may include at least two channels. The two channels are used to store the number of rays and the number of ray iterations, respectively. For example, one channel may be used to store the number of rays, and the other channel may be used to store the number of ray iterations.
[0160] Taking the preset format of RG8 format as an example, illustratively, the electronic device can store the number of rays in the R channel of RG8 format on a frame buffer in the memory; the electronic device can store the number of ray iterations in the G channel of RG8 format on a frame buffer in the memory.
[0161] In some embodiments, the electronic device passes the material information of the ray tracing acceleration structure and model into the ray tracing rendering pipeline (RayTracingPipeline), and calls the VkDescriptorSets function to pass the texture storing the light data into the ray tracing rendering pipeline. Then, the electronic device calls the execution instruction vkCmdTraceRay to start ray tracing for each pixel in the ray tracing rendering pipeline, and renders each pixel based on the result of ray tracing, thereby obtaining a rendered image.
[0162] For example, in the shader of the ray tracing rendering pipeline, for each pixel in the image to be rendered, the electronic device calculates the coordinates of the intersection after the light intersects the model based on the ray tracing acceleration structure and the material information of the model. Then, based on the intersection coordinates of each intersection, the number of rays, and the number of iterations of each ray, the electronic device calculates the light energy at each intersection, takes the weighted sum of the light energy at all intersections as the color value of the corresponding pixel, and renders the corresponding pixel using the color value. At this point, the electronic device can output an image rendered based on ray tracing.
[0163] It should be noted that the specific implementation process of the ray tracing algorithm for electronic devices can be combined with Figure 2 and Figure 3 , and the description of the above embodiments will not be repeated here one by one.
[0164] It should be noted that the contents recorded in each embodiment of the present application can explain the technical solutions in other embodiments of the embodiments of the present application, and the technical features recorded in each embodiment can also be applied in other embodiments and combined with the technical features in other embodiments to form a new solution. The present application only exemplarily lists several embodiments for illustration, and does not mean that the present application is limited to this.
[0165] The present application provides an electronic device, which may include: a display screen, a memory, and one or more processors; the memory stores computer program code, which includes computer instructions. When the computer instructions are executed by the processor, the electronic device performs various functions or steps performed in the above electronic device. The structure of the electronic device can refer to the above Figure 1 The structure of the electronic device 100 is shown.
[0166] The present application also provides a chip system for use in electronic devices. Fig.12 As shown, the chip system 1100 includes at least one processor 1101 and at least one interface circuit 1102. The processor 1101 may be Figure 1 The processor 110 is shown. The interface circuit 1102 may be, for example, an interface circuit between the processor 110 and an external memory; or an interface circuit between the processor and the internal memory 121 .
[0167] The processor 1101 and the interface circuit 1102 can be interconnected via lines. For example, the interface circuit 1102 can be used to receive signals from other devices (such as the memory of the electronic device 100). For another example, the interface circuit 1102 can be used to send signals to other devices (such as the processor 1101). Exemplarily, the interface circuit 1102 can read the instructions stored in the memory and send the instructions to the processor 1101. When the instructions are executed by the processor 1101, the electronic device can execute the various functions or steps executed by the mobile phone in the above embodiment. Of course, the chip system can also include other discrete devices, which is not specifically limited in the embodiments of the present application.
[0168] An embodiment of the present application also provides a computer-readable storage medium, which includes computer instructions. When the computer instructions are executed on an electronic device, the electronic device executes each function or step executed by the electronic device in the above method embodiment.
[0169] The embodiment of the present application also provides a computer program product. When the computer program product is run on a computer, the computer is enabled to execute each function or step executed by the electronic device in the above method embodiment.
[0170] Through the description of the above implementation methods, technical personnel in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules according to the system, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.
[0171] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0172] The units described as separate components may or may not be physically separated, and the components shown as units may be one physical unit or multiple physical units, that is, they may be located in one place or distributed in multiple different places. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0173] In addition, each functional unit in each embodiment of the present application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The above integrated unit can be implemented in the form of hardware or in the form of software functional units.
[0174] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium, including several instructions to enable a device (which can be a single-chip microcomputer, chip, etc.) or a processor (processor) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read only memory (ROM), random access memory (RAM), disk or optical disk and other media that can store program code.
[0175] The above contents are only specific implementation methods of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions within the technical scope disclosed in the present application shall be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.
Claims
1. An image rendering method, characterized in that: The method comprises: Projecting a first model in the three-dimensional scene onto the image to be rendered; Counting the number of pixels displayed by the first model on the image to be rendered; If it is determined according to the number of pixels that the first model is blocked, then the first model is not rendered; If it is determined according to the number of pixels that the first model is not blocked, the first model is rendered.
2. The method according to claim 1, characterized in that The first model being blocked includes: The first model partially or completely overlaps with the second model; or, The first model is located inside the second model; or, The first model is in contact with the second model; The second model is a model in the three-dimensional scene other than the first model.
3. The method according to claim 1 or 2, characterized in that: The determining, according to the number of pixels, that the first model is blocked includes: If the number of pixels is less than the pixel number threshold, it is determined that the first model is blocked; Wherein, determining that the first model is not blocked according to the number of pixels includes: If the number of pixels is greater than or equal to the pixel number threshold, it is determined that the first model is not blocked.
4. The method according to claim 3, characterized in that The smaller the number of pixels is, the more the first model is obscured.
5. The method according to any one of claims 1 to 4, characterized in that The determining the number of pixels of the first model displayed on the image to be rendered includes: The occlusion query capability is called to determine the number of pixels of the first model displayed on the image to be rendered.
6. The method according to claim 1, characterized in that The method further comprises: constructing at least one viewing cone according to the three-dimensional scene; Perform frustum clipping on the first model and each frustum in the at least one frustum; When the first model is clipped by a view frustum corresponding to a first view frustum among the at least one view frustum, and the first view frustum is a forward view frustum, the first model is not projected onto the image to be rendered; The forward viewing cone is a viewing cone constructed based on a virtual camera in the three-dimensional scene.
7. The method according to claim 6, characterized in that The projecting the first model onto the image to be rendered includes: When the first model is clipped by a view frustum corresponding to a second view frustum in the at least one view frustum and the second view frustum is not a forward view frustum, the first model is projected onto the image to be rendered.
8. The method according to claim 6 or 7, characterized in that: The step of performing frustum clipping on the first model and each frustum in the at least one frustum comprises: The first model is subjected to frustum clipping with each frustum of the at least one frustum through at least one thread; wherein the at least one thread corresponds to the at least one frustum one by one.
9. The method according to any one of claims 1 to 8, characterized in that The rendering of the first model includes: The first model is rendered using ray tracing technology, wherein the ray tracing technology is used to render the model by tracing the path of light in the image to be rendered in units of pixels and simulating the effect of light meeting the model.
10. The method according to any one of claims 1 to 9, characterized in that The method further comprises: The rendered image is displayed; wherein the rendered image is obtained by rendering the unobstructed model in the three-dimensional scene.
11. An electronic device, characterized in that: include: a display screen, memory, and one or more processors; The memory stores computer program code, which includes computer instructions. When the computer instructions are executed by the processor, the electronic device executes the method according to any one of claims 1 to 10.
12. A chip system, characterized in that: Applied to electronic equipment, the chip system comprises: at least one processor and an interface; The interface is used to receive instructions and transmit them to the at least one processor; the at least one processor executes the instructions so that the electronic device executes the method as described in any one of claims 1-10.
13. A computer-readable storage medium, characterized in that: The method comprises computer instructions, and when the computer instructions are executed on an electronic device, the electronic device executes the method as claimed in any one of claims 1 to 10.
Citation Information
Cited By
Five-axis linkage numerical control machine tool machining simulation modeling method and system
CN121072072A
5-axis linkage numerical control machine tool machining simulation modeling method and system
CN121072072B