Image rendering method and device, electronic equipment, storage medium and program product

By projecting the reflection source and reflection plane in the virtual scene to determine the target reflection point, the problem of reflection image errors caused by multiple reflection planes in the virtual scene is solved, and the accuracy and efficiency of image rendering are improved.

CN118628634APending Publication Date: 2024-09-10TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202310257658.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-03-07
Publication Date
2024-09-10

AI Technical Summary

Technical Problem

When there are multiple reflection planes in the virtual scene, the reflection image of the virtual object appears incorrectly, resulting in a waste of computing resources and an impact on the user experience.

Method used

By obtaining the image to be reflected, including multiple reflection sources and reflection planes, projection processing is performed on each reflection source, the target reflection point of each reflection source is determined, and the reflection map is determined based on the reflection source and the target reflection point, and image rendering is performed. Accurately render reflected images.

Benefits of technology

The accurate relationship processing between the reflection source and the reflection plane is realized, which avoids the waste of computing resources and improves the image rendering effect.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118628634A
    Figure CN118628634A
Patent Text Reader

Abstract

The invention provides an image rendering method and device, electronic equipment, a computer readable storage medium and a computer program product. The method comprises the steps that a to-be-reflected image is acquired, and the to-be-reflected image comprises a plurality of reflection sources and a plurality of reflection planes; performing projection processing based on a plurality of reflection planes on each reflection source to obtain a plurality of reflection points corresponding to each reflection source; determining a target reflection point of each reflection source from the plurality of reflection points corresponding to each reflection source; determining a reflection map of the to-be-reflected image based on each reflection source and the target reflection point of each reflection source; and based on the reflection chartlet of the to-be-reflected image, performing image rendering processing on the to-be-reflected image to obtain a reflection image corresponding to the to-be-reflected image. According to the application, the relationship between the reflection source and the plurality of reflection planes can be correctly processed so as to accurately present the reflection image.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to computer graphics and image technology, and in particular to an image rendering method, device, electronic device, computer-readable storage medium, and computer program product. Background Art

[0002] Display technology based on graphics processing hardware has expanded the channels for perceiving the environment and obtaining information, especially the display technology of virtual scenes. It can realize diversified interactions between virtual objects controlled by users or artificial intelligence according to actual application needs, and has various typical application scenarios. For example, in virtual scenes such as games, it can simulate the real battle process between virtual objects.

[0003] With the continuous development of computer technology, the images (including various virtual objects) presented by applications (especially game applications) are becoming more and more sophisticated. Virtual objects can project reflective objects through reflective planes. For example, the reflections of trees in a virtual scene are projected through the lake surface to vividly display the virtual scene.

[0004] In the related art, when there are multiple reflection planes in a virtual scene, although the virtual object (including multiple reflection sources) can be projected and reflected through the reflection planes, the reflected image presented is erroneous, so this method will cause a large amount of computing resources to be wasted, thereby affecting the user experience. Summary of the invention

[0005] The embodiments of the present application provide an image rendering method, device, electronic device, computer-readable storage medium, and computer program product, which can correctly process the relationship between a reflection source and multiple reflection planes to accurately present a reflection image.

[0006] The technical solution of the embodiment of the present application is implemented as follows:

[0007] The present application embodiment provides an image rendering method, including:

[0008] Acquire an image to be reflected, wherein the image to be reflected includes a plurality of reflection sources and a plurality of reflection planes;

[0009] Performing projection processing on each of the reflection sources based on the multiple reflection planes to obtain multiple reflection points corresponding to each of the reflection sources;

[0010] Determining a target reflection point of each reflection source from a plurality of reflection points corresponding to each reflection source;

[0011] Determine a reflection map of the image to be reflected based on each of the reflection sources and a target reflection point of each of the reflection sources;

[0012] Based on the reflection map of the image to be reflected, image rendering processing is performed on the image to be reflected to obtain a reflection image corresponding to the image to be reflected.

[0013] The present application provides an image rendering device, including:

[0014] An acquisition module, used for acquiring an image to be reflected, wherein the image to be reflected includes a plurality of reflection sources and a plurality of reflection planes;

[0015] A projection module, used for performing projection processing on each of the reflection sources based on the multiple reflection planes to obtain multiple reflection points corresponding to each of the reflection sources;

[0016] Determining a target reflection point of each reflection source from a plurality of reflection points corresponding to each reflection source;

[0017] A reflection module, used to determine a reflection map of the image to be reflected based on each of the reflection sources and a target reflection point of each of the reflection sources;

[0018] A rendering module is used to perform image rendering processing on the image to be reflected based on the reflection map of the image to be reflected, so as to obtain a reflection image corresponding to the image to be reflected.

[0019] In the above technical solution, the projection module is also used to determine the screen space coordinates of each of the reflection sources and determine the world coordinates of each of the reflection planes;

[0020] Convert the screen space coordinates of each of the reflection sources into a target space coordinate system to obtain a first target space coordinate of each of the reflection sources;

[0021] Convert the world coordinates of each of the reflection planes into the target space coordinate system to obtain the second target space coordinates of each of the reflection planes;

[0022] Based on the first target space coordinates of each of the reflection sources and the second target space coordinates of each of the reflection planes, physical projection processing is performed on each of the reflection sources to obtain a plurality of reflection points corresponding to each of the reflection sources.

[0023] In the above technical solution, the projection module is further used to perform the following processing on any of the multiple reflection planes:

[0024] In the target space coordinate system, projection processing is performed based on the second target space coordinates of the reflection plane and the first target space coordinates of each of the reflection sources to obtain a symmetric point of each of the reflection sources relative to the reflection plane;

[0025] In the target space coordinate system, constructing a line connecting the symmetric point and the camera;

[0026] The intersection point of the connecting line and the reflecting plane is determined as the reflection point corresponding to each of the reflecting sources.

[0027] In the above technical solution, the projection module is also used to determine the distance between each of the reflection points and the camera;

[0028] When any one of the multiple reflection points is within the range of the reflection plane and the distance between any one of the reflection points and the camera is the smallest, any one of the reflection points is determined as a target reflection point of each of the reflection sources.

[0029] In the above technical solution, before determining any of the reflection points as the target reflection point of each of the reflection sources, the projection module is further used to determine the origin coordinates of the reflection plane and the size of the reflection plane;

[0030] Determine the range of the reflection plane based on the origin coordinates of the reflection plane and the size of the reflection plane;

[0031] When any of the reflection points falls within the range of the reflection plane, it is determined that any of the multiple reflection points is within the range of the reflection plane.

[0032] In the above technical solution, the reflection module is further used to perform the following processing on any of the reflection sources among the multiple reflection sources:

[0033] Determining a color value of the reflection source based on a correspondence between the reflection source and the target reflection point;

[0034] Determine the color value of the reflection source as the color value of the target reflection point;

[0035] The color value of the target reflection point is written into the rendering target to obtain the reflection map of the image to be reflected.

[0036] In the above technical solution, the reflection module is further used to perform encoding processing on the screen space coordinates of the reflection source based on the encoding format to obtain the encoded coordinates of the reflection source;

[0037] Based on the correspondence between the reflection source and the target reflection point, the encoded coordinates of the reflection source are written into the screen space coordinates of the target reflection point of the reflection source to obtain a projection buffer;

[0038] Performing decoding processing based on the projection buffer to obtain the decoded coordinates of the reflection source;

[0039] The screen color is sampled based on the decoded coordinates of the reflection source to obtain the color value of the reflection source.

[0040] In the above technical solution, the screen space coordinates of the reflection source include a horizontal axis coordinate value and a vertical axis coordinate value; the reflection module is also used to store the integer part of the vertical axis coordinate value of the reflection source in the first coding bit of the coding format, store the decimal part of the vertical axis coordinate value of the reflection source in the second coding bit of the coding format, store the integer part of the horizontal axis coordinate value of the reflection source in the third coding bit of the coding format, and store the decimal part of the horizontal axis coordinate value of the reflection source in the fourth coding bit of the coding format when the angle between the reflection plane and the horizontal plane is less than the angle threshold, so as to obtain the coded coordinates of the reflection source.

[0041] In the above technical solution, the screen space coordinates of the reflection source include a horizontal axis coordinate value and a vertical axis coordinate value; the reflection module is also used to store the integer part of the horizontal axis coordinate value of the reflection source in the fifth coding bit of the coding format, store the decimal part of the horizontal axis coordinate value of the reflection source in the sixth coding bit of the coding format, store the integer part of the vertical axis coordinate value of the reflection source in the seventh coding bit of the coding format, and store the decimal part of the vertical axis coordinate value of the reflection source in the eighth coding bit of the coding format when the angle between the reflection plane and the vertical plane is less than the angle threshold, so as to obtain the coded coordinates of the reflection source.

[0042] In the above technical solution, the reflection module is further used to compare the coded coordinates of the reflection source and the coded coordinates of the other reflection sources when the screen space coordinates of the target reflection point of the reflection source have been written into the coded coordinates of other reflection sources.

[0043] When the encoding coordinates of the reflection source at the target encoding position of the encoding format are smaller than the encoding coordinates of the other reflection sources, writing the encoding coordinates of the reflection source into the screen space coordinates of the target reflection point of the reflection source; or

[0044] When the screen space coordinates of the target reflection point of the reflection source are not written into the coded coordinates of other reflection sources, the coded coordinates of the reflection source are written into the screen space coordinates of the target reflection point of the reflection source.

[0045] In the above technical solution, before performing the projection processing based on the multiple reflection planes on each of the reflection sources, the acquisition module is further used to perform frustum culling processing on the multiple reflection planes to obtain the culled reflection planes;

[0046] Based on the sizes of the removed reflection planes, the removed reflection planes are sorted in descending order;

[0047] The reflection plane after removing the part arranged in front in the sorting result is used as the reflection plane for projection processing.

[0048] An embodiment of the present application provides an electronic device for image rendering, the electronic device comprising:

[0049] Memory for storing computer programs or computer executable instructions;

[0050] The processor is used to implement the image rendering method provided in the embodiment of the present application when executing the computer program or computer executable instructions stored in the memory.

[0051] An embodiment of the present application provides a computer-readable storage medium storing a computer program or computer-executable instructions, which, when executed by a processor, can implement the image rendering method provided in the embodiment of the present application.

[0052] An embodiment of the present application provides a computer program product, including a computer program or computer executable instructions, which, when executed by a processor, can implement the image rendering method provided in the embodiment of the present application.

[0053] The embodiments of the present application have the following beneficial effects:

[0054] By accurately determining the target reflection point that uniquely corresponds to the reflection source from multiple reflection points corresponding to the reflection source, a one-to-one correspondence between the reflection source and the reflection point is achieved, thereby accurately determining the relationship between the reflection source and multiple reflection planes, and performing image rendering based on the one-to-one correspondence between the reflection source and the reflection point to accurately present the reflection image, thereby avoiding a large amount of waste of computing resources and improving image rendering effects. BRIEF DESCRIPTION OF THE DRAWINGS

[0055] Figure 1A-1B is a schematic diagram of an application mode of the image rendering method provided in an embodiment of the present application;

[0056] Figure 2 is a schematic diagram of the structure of an electronic device for image rendering provided by an embodiment of the present application;

[0057] Figure 3A-3B It is a flowchart of an image rendering method provided in an embodiment of the present application;

[0058] Figure 4 is a schematic diagram of a physical projection provided in an embodiment of the present application;

[0059] Figure 5 is a flowchart of a high-performance multi-plane reflection method based on screen space provided in an embodiment of the present application;

[0060] Figure 6 is a schematic diagram of a reflection point provided in an embodiment of the present application;

[0061] Figure 7 is a schematic diagram of a projection buffer provided in an embodiment of the present application;

[0062] Figure 8 is a schematic diagram of screen colors provided in an embodiment of the present application;

[0063] Fig. 9 is a schematic diagram of a reflective buffer provided in an embodiment of the present application;

[0064] Fig.10 is a schematic diagram of the reflection result provided in the embodiment of the present application;

[0065] Fig.11A It is a lake reflection effect diagram provided by relevant technology;

[0066] Fig. 11B This is a lake reflection effect diagram provided by an embodiment of the present application;

[0067] Fig. 12A It is a reflection effect diagram of multiple reflection planes provided by the related technology;

[0068] Fig. 12B It is a reflection effect diagram of multiple reflection planes provided in an embodiment of the present application. DETAILED DESCRIPTION

[0069] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings. The described embodiments should not be regarded as limiting the present application. All other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of this application.

[0070] In the following description, the terms "first\second" involved are merely used to distinguish similar objects and do not represent a specific ordering of the objects. It can be understood that "first\second" can be interchanged with a specific order or sequence where permitted, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein.

[0071] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.

[0072] Before further describing the embodiments of the present application in detail, the nouns and terms involved in the embodiments of the present application are explained. The nouns and terms involved in the embodiments of the present application are subject to the following interpretations.

[0073] 1) In response to: used to indicate the conditions or states on which the executed operations depend. When the dependent conditions or states are met, one or more operations executed may be in real time or have a set delay. Unless otherwise specified, there is no restriction on the order in which the multiple operations executed may be executed.

[0074] 2) Client: An application running in a terminal to provide various services, such as a video player client, a game client, etc.

[0075] 3) Virtual scene: A virtual game scene displayed (or provided) when the game application is running on the terminal. The virtual scene can be a simulation of the real world, a semi-simulated and semi-fictional virtual environment, or a purely fictional virtual environment. The virtual scene can be any of a two-dimensional virtual scene, a 2.5-dimensional virtual scene, or a three-dimensional virtual scene. The embodiment of the present application does not limit the dimension of the virtual scene. For example, the virtual scene may include the sky, land, ocean, etc. The land may include environmental elements such as deserts and cities, and users can control virtual objects to move in the virtual scene.

[0076] 4) Virtual objects: images of various people and objects that can interact in a virtual scene, or movable objects in a virtual scene. The movable objects can be virtual characters, virtual animals, cartoon characters, etc., such as characters and animals displayed in a virtual scene. The virtual object can be a virtual image in a virtual scene that represents a user. A virtual scene can include multiple virtual objects, each of which has its own shape and volume in the virtual scene and occupies a part of the space in the virtual scene.

[0077] 5) Image rendering: The process of converting three-dimensional light energy transfer processing into a two-dimensional image. Scenes and objects are represented in three-dimensional form, which is closer to the real world and easier to manipulate and transform. Most image display devices are two-dimensional raster displays and dot matrix printers. The representation of N-dimensional raster and dot matrix of three-dimensional scenes is image rendering. Raster display can be regarded as a pixel matrix. Any image displayed on a raster display is actually a collection of pixels with one or more colors and grayscales.

[0078] 6) Screen space coordinate system: A two-dimensional coordinate system based on the entire hardware screen, which is related to the screen resolution. It is based on pixels, with the lower left corner of the screen at (0,0) and the upper right corner at (screen.width, screen.height), where screen.width represents the screen width and screen.height represents the screen height.

[0079] 7) World coordinate system: It is a three-dimensional coordinate system established with any point as the center in the three-dimensional space of the real world, also known as the three-dimensional world coordinate system. It is the absolute coordinate system of the objective three-dimensional world, also known as the objective coordinate system. It is the coordinate of the object in the real world. The world coordinate system changes with the size and position of the object, and the unit is the unit of length. Since the camera is placed in the three-dimensional space, the world coordinate system is used as the reference coordinate system to describe the position of the camera, and it is used to describe the position of any other object placed in this three-dimensional environment.

[0080] 8) View space coordinate system: A three-dimensional coordinate system based on observation space or camera space. The view space coordinate system is the coordinate system that rotates and translates the world coordinate system of the virtual object into the camera's field of view.

[0081] 9)32-bit unsigned integer (uint32): An encoding format consisting of 32 bits of unsigned integer.

[0082] 10) Render Target (RT): A buffer used to store drawing information (such as base color, normal, screen color). The graphics card in the electronic device can use this buffer to draw the pixels of the virtual scene using an Effect class to render the image and obtain a rendered image.

[0083] The embodiments of the present application provide an image rendering method, device, electronic device, computer-readable storage medium, and computer program product, which can correctly handle the relationship between a reflection source and multiple reflection planes to accurately present a reflection image. In order to facilitate easier understanding of the image rendering method provided by the embodiments of the present application, an exemplary implementation scenario of the image rendering method provided by the embodiments of the present application is first described. The virtual object in the image rendering method provided by the embodiments of the present application can be completely based on terminal output, or based on the coordinated output of the terminal and the server.

[0084] In one implementation scenario, see Figure 1A , Figure 1A It is a schematic diagram of the application mode of the image rendering method provided in the embodiment of the present application, which is suitable for some application modes that completely rely on the graphics processing hardware computing power of the terminal 400 to complete the relevant data calculation of the rendered image, such as stand-alone / offline mode games, and the output of the rendered image is completed through various types of terminals 400 such as smart phones, tablet computers and virtual reality / augmented reality devices.

[0085] As an example, types of graphics processing hardware include a central processing unit (CPU) and a graphics processing unit (GPU).

[0086] When forming a visual perception of a virtual scene included in a rendered image, terminal 400 calculates the data required for display through graphics computing hardware, and completes the loading, parsing and rendering of display data, and outputs video frames that can form a visual perception of the virtual scene through graphics output hardware, for example, presenting two-dimensional video frames on the display screen of a smartphone, or projecting video frames that achieve a three-dimensional display effect on the lenses of augmented reality / virtual reality glasses; in addition, in order to enrich the perception effect, terminal 400 can also use different hardware to form one or more of auditory perception, tactile perception, motion perception and taste perception.

[0087] As an example, a client 410 (e.g., a stand-alone game application) is running on the terminal 400. During the operation of the client 410, a rendered image including a virtual scene 100 is output. The virtual scene may be an environment for game characters to interact, such as a plain, street, valley, etc. for game characters to fight against each other. Taking the first-person perspective display of the virtual scene as an example, a virtual object is displayed in the virtual scene 100. The virtual object may be a game character controlled by a user (or player), and may also remain still, jump, and use various functions (such as skills and props). It may also be an artificial intelligence (AI) trained to fight in a virtual scene. It may also be an immovable object or a movable object in the virtual scene 100.

[0088] For example, taking the first-person perspective display of the virtual scene 100 as an example, the terminal 400 obtains an image to be reflected, wherein the image to be reflected includes a virtual object 101 and multiple reflection planes, and the virtual object 101 includes multiple reflection sources; each reflection source is projected based on the multiple reflection planes to obtain multiple reflection points corresponding to each reflection source; from the multiple reflection points corresponding to each reflection source, the target reflection point of each reflection source is determined; based on each reflection source and the target reflection point of each reflection source, a reflection map of the image to be reflected is determined; based on the reflection map of the image to be reflected, the image to be reflected is rendered to obtain a reflection image 102 corresponding to the image to be reflected, that is, a rendered image including the virtual scene 100, and the virtual scene includes the virtual object 101 and the reflection object 102 of the virtual object 101, so as to display the rendered image including the virtual scene 100 on the client 410.

[0089] In another implementation scenario, see Figure 1B , Figure 1B It is a schematic diagram of an application mode of the image rendering method provided in an embodiment of the present application, which is applied to a terminal 400 and a server 200, and is suitable for an application mode that relies on the computing power of the server 200 to complete virtual scene calculations and output virtual scenes at the terminal 400.

[0090] Taking the visual perception of a virtual scene included in a rendered image as an example, the server 200 calculates display data related to the virtual scene (such as scene data) and sends it to the terminal 400 through the network 300. The terminal 400 relies on graphics computing hardware to complete the loading, parsing and rendering of the display data, and relies on graphics output hardware to output the virtual scene to form a visual perception. For example, a two-dimensional video frame can be presented on the display screen of a smartphone, or a video frame with a three-dimensional display effect can be projected on the lenses of augmented reality / virtual reality glasses. As for the perception of the form of the virtual scene, it can be understood that the corresponding hardware output of the terminal 400 can be used, such as using a microphone to form auditory perception, using a vibrator to form tactile perception, and so on.

[0091] As an example, a client 410 (eg, a network version of a game application) is running on the terminal 400 , which interacts with other users in a game by connecting to a server 200 (eg, a game server), and the terminal 400 outputs a virtual scene of the client 410 .

[0092] For example, taking the first-person perspective display of the virtual scene 100 as an example, the terminal 400 obtains an image to be reflected, wherein the image to be reflected includes a virtual object 101 and multiple reflection planes, and the virtual object includes multiple reflection sources; each reflection source is projected based on the multiple reflection planes to obtain multiple reflection points corresponding to each reflection source; from the multiple reflection points corresponding to each reflection source, the target reflection point of each reflection source is determined; based on each reflection source and the target reflection point of each reflection source, the reflection map of the image to be reflected is determined; based on the reflection map of the image to be reflected, the image to be reflected is rendered to obtain a reflection image corresponding to the image to be reflected, that is, a rendered image including the virtual scene 100, the virtual scene includes the virtual object 101 and the reflection object 102 of the virtual object 101, and the rendered image including the virtual scene 100 is sent to the terminal 400, so that the rendered image including the virtual scene 100 is displayed on the client 410.

[0093] In some embodiments, the terminal 400 can implement the image rendering method provided by the embodiment of the present application by running a computer program. For example, the computer program can be a native program or software module in the operating system; it can be a native application (APP, APPlication), that is, a program that needs to be installed in the operating system to run, such as a dress-up game APP (that is, the above-mentioned client 410); it can also be a small program, that is, a program that can be run only by downloading it to a browser environment; it can also be a game small program that can be embedded in any APP. In short, the above-mentioned computer program can be an application, module or plug-in in any form.

[0094] Taking the computer program as an application program as an example, in actual implementation, the terminal 400 installs and runs an application program that supports image rendering. The application program can be an image application such as various games, video players, etc.

[0095] In some embodiments, the embodiments of the present application can also be implemented with the aid of cloud technology. Cloud technology refers to a hosting technology that unifies a series of resources such as hardware, software, and networks within a wide area network or a local area network to achieve data calculation, storage, processing, and sharing.

[0096] For example, Figure 1B The server 200 in the example may be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. The terminal 400 may be a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart watch, etc., but is not limited thereto. The terminal 400 and the server 200 may be directly or indirectly connected via wired or wireless communication, which is not limited in the embodiments of the present application.

[0097] In some embodiments, multiple servers may form a blockchain, and server 200 is a node on the blockchain. Information connections may exist between each node in the blockchain, and information may be transmitted between nodes through the above information connections. Among them, data related to the image rendering method provided in the embodiment of the present application (such as image rendering logic, rendered image) may be stored on the blockchain.

[0098] The structure of the electronic device for image rendering provided by the embodiment of the present application is described below. Figure 2 , Figure 2 1 is a schematic diagram of the structure of an electronic device 500 for image rendering provided in an embodiment of the present application. Taking the electronic device 500 as a terminal as an example, Figure 2 The electronic device 500 for image rendering shown includes: at least one processor 510, a memory 550, at least one network interface 520 and a user interface 530. The various components in the electronic device 500 are coupled together via a bus system 540. It is understood that the bus system 540 is used to achieve connection and communication between these components. In addition to the data bus, the bus system 540 also includes a power bus, a control bus and a status signal bus. However, for the sake of clarity, the bus system 540 is not described in detail. Figure 2 Various buses are labeled as bus system 540 .

[0099] The processor 510 can be an integrated circuit chip with signal processing capabilities, such as a general-purpose processor, a digital signal processor (DSP), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc., where the general-purpose processor can be a microprocessor or any conventional processor, etc.

[0100] The memory 550 includes a volatile memory or a non-volatile memory, and may also include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), and the volatile memory may be a random access memory (RAM). The memory 550 described in the embodiment of the present application is intended to include any suitable type of memory. The memory 550 optionally includes one or more storage devices that are physically far away from the processor 510.

[0101] In some embodiments, the memory 550 can store data to support various operations, examples of which include programs, modules, and data structures, or a subset or superset thereof, as exemplarily described below.

[0102] Operating system 551, including system programs for processing various basic system services and performing hardware-related tasks, such as framework layer, core library layer, driver layer, etc., for implementing various basic services and processing hardware-based tasks;

[0103] A network communication module 552, used to reach other electronic devices via one or more (wired or wireless) network interfaces 520, exemplary network interfaces 520 include: Bluetooth, Wireless Compatibility Authentication (WiFi), and Universal Serial Bus (USB), etc.;

[0104] In some embodiments, the image rendering device provided in the embodiments of the present application can be implemented in software. The image rendering device provided in the embodiments of the present application can be provided as various software embodiments, including various forms including applications, software, software modules, scripts or codes.

[0105] Figure 2 An image rendering device 555 stored in a memory 550 is shown, which may be software in the form of a program or plug-in, and includes a series of modules, including an acquisition module 5551, a projection module 5552, a reflection module 5553, and a rendering module 5554. These modules are logical, and therefore may be arbitrarily combined or further split according to the functions implemented. The functions of each module will be described below.

[0106] As mentioned above, the image rendering method provided in the embodiment of the present application can be implemented by various types of electronic devices, such as a terminal, a server, or a combination of the two. Therefore, the execution subject of each step will not be repeatedly described below. Figure 3A , Figure 3A is a flowchart of an image rendering method provided by an embodiment of the present application, combined with Figure 3A The steps shown are explained.

[0107] In step 101, an image to be reflected is acquired, wherein the image to be reflected includes a plurality of reflection sources and a plurality of reflection planes.

[0108] It should be noted that the image to be reflected includes virtual objects in the virtual scene (i.e., objects, people, etc. that need to be reflected), each virtual object includes multiple reflection sources (i.e., pixels), and the reflection plane can be a regular plane or an irregular plane. For example, if the virtual object is a tree that needs to generate a reflection, the reflection plane is a lake surface; if the virtual object is a person that needs to generate a mirror surface, the reflection plane is a mirror.

[0109] In some embodiments, after acquiring the image to be reflected, a plurality of reflection planes may be screened to obtain a plurality of target reflection planes, and subsequent steps 102 - 105 may be performed based on the target reflection planes.

[0110] For example, the screening process can be achieved in the following ways: perform frustum culling on multiple reflection planes to obtain culled reflection planes; sort the culled reflection planes in descending order based on the sizes of the culled reflection planes; and use the culled reflection planes that are arranged in front of the sorting results as the reflection planes for projection processing (i.e., the target reflection planes).

[0111] As an example, frustum culling is performed on multiple reflection planes to screen out reflection planes within the frustum (i.e., reflection planes after culling), and then the reflection planes within the frustum are sorted from large to small according to the area (i.e., size) occupied by the reflection planes in the screen space, and the top K reflection planes are taken as target reflection planes, where K is a positive integer.

[0112] It should be noted that the purpose of sorting the reflection planes is to eliminate reflection planes with a small pixel ratio in the screen space, avoid performing related reflection calculations for reflection planes with a small pixel ratio in the screen space, and reduce performance overhead.

[0113] In step 102, projection processing based on multiple reflection planes is performed on each reflection source to obtain multiple reflection points corresponding to each reflection source.

[0114] Following the above step 101, the obtained reflection source is projected based on multiple reflection planes to obtain multiple reflection points corresponding to each reflection source, wherein the reflection point is a pixel point where the reflection source performs reflection projection on the reflection plane.

[0115] In some embodiments, each reflection source is projected based on multiple reflection planes to obtain multiple reflection points corresponding to each reflection source, including: determining the screen space coordinates of each reflection source and determining the world coordinates of each reflection plane; converting the screen space coordinates of each reflection source into a target space coordinate system to obtain a first target space coordinate of each reflection source; converting the world coordinates of each reflection plane into a target space coordinate system to obtain a second target space coordinate of each reflection plane; and performing physical projection processing on each reflection source based on the first target space coordinates of each reflection source and the second target space coordinates of each reflection plane to obtain multiple reflection points corresponding to each reflection source.

[0116] It should be noted that the embodiments of the present application are not limited to the target space coordinate system, for example, the target space coordinate system may be a camera coordinate system, a view space coordinate system, a projection space coordinate system, etc. The reflection source and the reflection plane are transformed into the same coordinate system, and then the transformed reflection source and the reflection plane are physically projected to obtain the reflection point of the reflection source.

[0117] For example, the reflection source is converted from the screen space coordinate system to the view space coordinate system to obtain the view space coordinates of the reflection source, the reflection plane is converted from the world coordinate system to the view space coordinate system to obtain the view space coordinates of the reflection plane, and then based on the view space coordinates of the reflection source and the view space coordinates of the reflection plane, the reflection source is physically projected to obtain the reflection point corresponding to the reflection source.

[0118] In some embodiments, based on the first target space coordinates of each reflection source and the second target space coordinates of each reflection plane, each reflection source is physically projected to obtain multiple reflection points corresponding to each reflection source, including: performing the following processing on any reflection plane among the multiple reflection planes: in the target space coordinate system, projection processing is performed based on the second target space coordinates of the reflection plane and the first target space coordinates of each reflection source to obtain the symmetric point (also called projection point) of each reflection source relative to the reflection plane; in the target space coordinate system, a line is constructed between the symmetric point and the camera; and the intersection of the line and the reflection plane is determined as the reflection point corresponding to each reflection source.

[0119] like Figure 4As shown, pixel point A is the reflection source in the target space coordinate system, plane 301 is the reflection plane in the target space coordinate system, and in the target space coordinate system, projection processing is performed based on the second target space coordinate of the reflection plane and the first target space coordinate of the reflection source to obtain a symmetrical point B of the reflection source relative to the reflection plane, and the intersection of the line connecting the symmetrical point and the camera 302 in the perspective space coordinate system and the reflection plane is the reflection point, that is, point A' is the reflection point of the reflection source.

[0120] In step 103, a target reflection point of each reflection source is determined from a plurality of reflection points corresponding to each reflection source.

[0121] Following the above step 102, after the reflection point is obtained, a target reflection point of each reflection source is determined from the multiple reflection points corresponding to each reflection source.

[0122] See also Figure 3B , Figure 3B is a flowchart of an image rendering method provided by an embodiment of the present application. Figure 3B Show Figure 3A Step 103 in the method can be implemented by steps 1031 and 1032: in step 1031, the distance between each reflection point and the camera is determined; in step 1032, when any reflection point among the multiple reflection points is within the range of the reflection plane and the distance between any reflection point and the camera is the smallest, any reflection point is determined as the target reflection point of each reflection source.

[0123] It should be noted that the reflection point, camera, and reflection plane are all in the same coordinate system (i.e., the target space coordinate system). In the target space coordinate system, the reflection point within the range of the reflection plane and with the smallest distance from the camera is determined as the target reflection point of the reflection source.

[0124] In some embodiments, the reflection point is determined to be within the range of the reflection plane in the following manner: determining the origin coordinates of the reflection plane and the size of the reflection plane; determining the range of the reflection plane based on the origin coordinates of the reflection plane and the size of the reflection plane; when any reflection point falls within the range of the reflection plane, determining that any reflection point among the multiple reflection points is within the range of the reflection plane.

[0125] The origin coordinates may be the center coordinates of the reflection plane, or the vertex coordinates of the reflection plane, etc. The size may be the length and width, or the area, etc. After the origin coordinates of the reflection plane and the size of the reflection plane are determined, the range of the reflection plane may be determined by mathematical calculation.

[0126] Through step 104, the embodiment of the present application can accurately determine the target reflection point that uniquely corresponds to the reflection source from the multiple reflection points corresponding to the reflection source, realize the one-to-one correspondence between the reflection source and the reflection point, and thus accurately determine the relationship between the reflection source and the multiple reflection planes, so as to accurately present the reflection image subsequently, thereby avoiding the waste of a large amount of computing resources and improving the image rendering effect.

[0127] In step 104, a reflection map of the image to be reflected is determined based on each reflection source and the target reflection point of each reflection source.

[0128] Following the above step 103, after determining the target reflection point uniquely corresponding to the reflection source, a reflection map of the image to be reflected is determined based on each reflection source and the target reflection point of each reflection source.

[0129] In some embodiments, based on each reflection source and the target reflection point of each reflection source, a reflection map of the image to be reflected is determined, including: performing the following processing for any reflection source among multiple reflection sources: determining the color value (also known as the screen color value) of the reflection source based on the correspondence between the reflection source and the target reflection point; determining the color value of the reflection source as the color value of the target reflection point; writing the color value of the target reflection point into the rendering target to obtain the reflection map of the image to be reflected.

[0130] For example, since the reflection source and the target reflection point are in a one-to-one correspondence, the color value of the reflection source and the color value of the reflection point should be the same. Therefore, the color value of the reflection source is determined as the color value of the target reflection point, and the color value of the target reflection point is written into the rendering target to obtain a reflection buffer (Reflection Buffer). The image formed by the reflection buffer can be the reflection map of the image to be reflected.

[0131] In some embodiments, based on the correspondence between the reflection source and the target reflection point, the color value of the reflection source is determined, including: encoding the screen space coordinates of the reflection source based on a coding format to obtain the encoded coordinates of the reflection source; based on the correspondence between the reflection source and the target reflection point, writing the encoded coordinates of the reflection source into the screen space coordinates of the target reflection point of the reflection source to obtain a projection buffer; performing decoding processing based on the projection buffer to obtain the decoded coordinates of the reflection source; sampling the screen color based on the decoded coordinates of the reflection source to obtain the color value of the reflection source.

[0132] For example, the screen space coordinates of the reflection source are encoded into a coding format according to the pixel projected reflection (PPR) technology to obtain the coded coordinates of the reflection source. Then, based on the correspondence between the reflection source and the target reflection point, the InterlockedMin function (used to execute a guaranteed atomic minimum) is used to write the coded coordinates in the screen space coordinates of the corresponding reflection point in the rendering target (RT, Render Target) to obtain the projection buffer. Next, for each pixel in the screen space coordinate system, the Projection Buffer is sampled by the pixel shader (Pixel Shader) of the reflection process (Reflection Pass), and then the sampling result is reversed, that is, the decoding process is performed based on the projection buffer to restore the screen space coordinates of the reflection source (i.e., the decoded coordinates of the reflection source). Finally, the screen space coordinates of the reflection source (i.e., the decoded coordinates of the reflection source) are used to sample the screen color (SceneColor) to obtain the reflection color (i.e., the color value of the reflection source), where Scene Color represents the color buffer of the current screen space.

[0133] In some embodiments, the screen space coordinates of the reflection source include a horizontal axis coordinate value and a vertical axis coordinate value; the screen space coordinates of the reflection source are encoded to obtain the encoded coordinates of the reflection source in an encoded format, including: when the angle between the reflection plane and the horizontal plane is less than an angle threshold, the integer part of the vertical axis coordinate value of the reflection source is stored in a first encoding bit of the encoding format, the decimal part of the vertical axis coordinate value of the reflection source is stored in a second encoding bit of the encoding format, the integer part of the horizontal axis coordinate value of the reflection source is stored in a third encoding bit of the encoding format, and the decimal part of the horizontal axis coordinate value of the reflection source is stored in a fourth encoding bit of the encoding format to obtain the encoded coordinates of the reflection source.

[0134] For example, when the reflection plane is a plane that is nearly horizontal (i.e., the angle between the reflection plane and the horizontal plane is less than the set angle threshold), the encoding format is as follows: bits 0 to 11 (i.e., the first encoding bits) are used to store the integer value of the Y value (i.e., the vertical axis coordinate value) of the screen space coordinate of the reflection source, and bits 12 to 14 (i.e., the second encoding bits) are used to store the decimal value of the Y value of the screen space coordinate of the reflection source; bits 15 to 27 (i.e., the third encoding bits) are used to store the integer value of the X value (i.e., the horizontal axis coordinate value) of the screen space coordinate of the reflection source, and bits 28 to 30 (i.e., the fourth encoding bits) are used to store the decimal value of the X value of the screen space coordinate of the reflection source.

[0135] In some embodiments, the screen space coordinates of the reflection source include a horizontal axis coordinate value and a vertical axis coordinate value; the screen space coordinates of the reflection source are encoded to obtain the encoded coordinates of the reflection source, including: when the angle between the reflection plane and the vertical plane is less than an angle threshold, the integer part of the horizontal axis coordinate value of the reflection source is stored in the fifth encoding bit of the encoding format, the decimal part of the horizontal axis coordinate value of the reflection source is stored in the sixth encoding bit of the encoding format, the integer part of the vertical axis coordinate value of the reflection source is stored in the seventh encoding bit of the encoding format, and the decimal part of the vertical axis coordinate value of the reflection source is stored in the eighth encoding bit of the encoding format to obtain the encoded coordinates of the reflection source.

[0136] For example, when the reflection plane is a nearly vertical plane (i.e., the angle between the reflection plane and the vertical plane is less than the set angle threshold), the encoding format is as follows: bits 0 to 11 (i.e., the fifth encoding bit) are used to store the integer value of the X value of the screen space coordinate of the reflection source, and bits 12 to 14 (i.e., the sixth encoding bit) are used to store the decimal value of the X value of the screen space coordinate of the reflection source; bits 15 to 27 (i.e., the seventh encoding bit) are used to store the integer value of the Y value of the screen space coordinate of the reflection source, and bits 28 to 30 (i.e., the eighth encoding bit) are used to store the decimal value of the Y value of the screen space coordinate of the reflection source.

[0137] In some embodiments, writing the encoded coordinates of a reflection source into the screen space coordinates of a target reflection point of the reflection source includes: when the screen space coordinates of the target reflection point of the reflection source have been written into the encoded coordinates of other reflection sources, performing a comparison process on the encoded coordinates of the reflection source and the encoded coordinates of the other reflection sources; when the encoded coordinates of the reflection source located at the target encoding position of the encoding format are smaller than the encoded coordinates of other reflection sources, writing the encoded coordinates of the reflection source into the screen space coordinates of the target reflection point of the reflection source.

[0138] For example, the embodiment of the present application can use the InterlockedMin function to write the coded coordinates of the reflection source in the screen space coordinates of the corresponding reflection point in the rendering target. When the InterlockedMin function is used for the write operation, it is first determined whether the screen space coordinates of the target reflection point of the reflection source (i.e., the reflection point that only corresponds to the reflection source) have been written into the coded coordinates of other reflection sources. When the screen space coordinates of the target reflection point of the reflection source have been written into the coded coordinates of other reflection sources, the coded coordinates of the reflection source and the coded coordinates of other reflection sources are compared and processed. When the coded coordinates of the reflection source located at the target coded bit of the coding format are less than the coded coordinates of other reflection sources, the coded coordinates of the reflection source are written into the screen space coordinates of the target reflection point of the reflection source. It should be noted that when the reflection plane is a plane that is nearly horizontal, the target coded bits are the first coded bits and the second coded bits; when the reflection plane is a plane that is nearly vertical, the target coded bits are the fifth coded bits and the sixth coded bits.

[0139] Therefore, by performing a write operation through the InterlockedMin function, when multiple reflection sources simultaneously write the screen space coordinates of the reflection point, it can ensure that the reflection source closest to the reflection plane is the final reflection source, thereby avoiding write conflicts when multiple reflection sources correspond to the same reflection point.

[0140] In some embodiments, writing the encoded coordinates of the reflection source into the screen space coordinates of the target reflection point of the reflection source includes: when the screen space coordinates of the target reflection point of the reflection source are not written into the encoded coordinates of other reflection sources, writing the encoded coordinates of the reflection source into the screen space coordinates of the target reflection point of the reflection source.

[0141] In step 105, based on the reflection map of the image to be reflected, image rendering processing is performed on the image to be reflected to obtain a reflection image corresponding to the image to be reflected.

[0142] The reflected image includes a virtual object and a reflected object (ie, a virtual object obtained after reflection of the virtual object).

[0143] Following the above step 104, after obtaining the reflection map of the image to be reflected, illumination calculation is performed, that is, image rendering is performed in combination with the reflection map and the image to be reflected to render a reflection image including the virtual object and the reflection object.

[0144] The following is an explanation of an exemplary application of an embodiment of the present application in a practical application scenario.

[0145] The embodiments of the present application can be applied to various image rendering scenarios, such as game applications, drawing applications, etc.

[0146] In the related art, pixel projected reflection (PPR) technology can realize the reflection of a virtual object (i.e., an object that needs to be reflected, and the object includes multiple reflection sources) in a virtual scene to form a reflection object of the virtual object (including multiple reflection points).

[0147] It should be noted that the relevant technology can only support one reflection plane to reflect the virtual object. Once there are multiple reflection planes in the virtual scene, reflection errors will occur and the virtual object cannot be reflected correctly.

[0148] In order to solve the above problems, the embodiment of the present application provides a high-performance multi-plane reflection method based on screen space (implemented by an image rendering method), which can support reflection on multiple reflection planes of different heights. For example, after a reflection source is reflected by multiple reflection planes, multiple reflection points are obtained, and a correct reflection point is determined from the multiple reflection points, so that a reflection source has at most one corresponding reflection point, and the correct reflection relationship can be found in multiple reflection planes, thereby ensuring that the final generated reflection map will not have reflection errors.

[0149] Combine the following Figure 5 The following describes a high-performance multi-plane reflection method based on screen space provided by an embodiment of the present application:

[0150] Step 1: Filter the reflection planes and transmit the filtered reflection planes to a graphics processing unit (GPU).

[0151] For example, a central processing unit (CPU) in an electronic device performs frustum culling on multiple reflection planes to screen out reflection planes within the frustum, and then sorts the reflection planes within the frustum from large to small according to the area occupied by the reflection planes in the screen space, and then transmits relevant information of the top K reflection planes (including world space coordinates, bounding boxes of reflection planes, etc.) to a compute shader of a projection pass in a GPU to execute step 3 based on the K reflection planes, where K is a positive integer.

[0152] It should be noted that the screening process includes the frustum culling process and the sorting process. The purpose of sorting the reflection planes is to eliminate the reflection planes with a small screen space pixel ratio, avoid performing related reflection calculations for the reflection planes with a small screen space pixel ratio, and reduce performance overhead.

[0153] Step 2: Calculate the view space coordinates for each pixel in the screen space coordinate system.

[0154] For example, the following processing is performed through the Compute Shader of the Projection Pass: for each pixel in the screen space coordinate system, the world space coordinates of the pixel are first restored through the screen space coordinates of the pixel and the depth value of the pixel in the depth buffer, and then the pixel is transformed to the view space coordinate system using the inverse matrix of the product of the projection matrix and the view matrix, that is, the world space coordinates of the pixel are multiplied by the inverse matrix to obtain the view space coordinates of the pixel, so as to realize the conversion of the world space coordinates of the pixel into the view space coordinates.

[0155] It should be noted that the embodiments of the present application are not limited to converting pixels into a viewing space coordinate system, but may also be other space coordinate systems.

[0156] Step 3: Traverse the reflection plane passed into the GPU and determine the unique reflection point corresponding to each reflection source based on the reflection plane.

[0157] For example, after the Compute Shader of the Projection Pass receives multiple reflection planes, it traverses the reflection planes, converts the world space coordinates of the reflection planes into view space coordinates (converts a point on the reflection plane and the plane normal from the world coordinate system to the view space coordinate system), and finds the reflection point relative to the reflection plane through the view space coordinates of the current pixel point (ie, the reflection source). That is, through the reflection source converted to the view space coordinate system, the symmetric point relative to the reflection plane converted to the view space coordinate system is calculated, and the intersection of the symmetric point and the line connecting the camera of the view space coordinate system and the reflection plane is the reflection point.

[0158] For the reflection points obtained respectively by multiple reflection planes, the embodiment of the present application only takes the reflection point within the range of the reflection plane (the range of the reflection plane can be determined by the origin coordinates, length and width of the reflection plane) and closest to the camera as the only target reflection point of the reflection source.

[0159] like Figure 6 As shown, for the reflection source A, the reflection points A' and B' corresponding to the two reflection planes below the reflection source A are calculated, and compared with the reflection point B', the reflection point A' closer to the camera 601 is used as the target reflection point of the reflection source A. Through the above scheme, a reflection source has at most only one corresponding reflection point, so as to find the correct reflection relationship among multiple reflection planes, thereby ensuring that the reflection map finally generated will not have reflection errors.

[0160] Step 4: Encode the screen space coordinates of the reflection source into uint32 format, and write the encoded coordinates into the screen space coordinates of the corresponding reflection point to obtain a projection buffer.

[0161] For example, the screen space coordinates of the reflection source corresponding to the reflection point obtained in step 3 are encoded into uint32 format according to the pixel projected reflection (PPR) technology, and then the InterlockedMin function (used to perform a guaranteed atomic minimum) is used to write the encoded coordinates into the screen space coordinates of the corresponding reflection point in the rendering target (RT, Render Target), and the following is obtained: Figure 7 The Projection Buffer shown.

[0162] It should be noted that when the reflection plane is a plane that is nearly horizontal (the angle between the reflection plane and the horizontal plane is less than the set angle threshold), the uint32 format is as follows: bits 0 to 11 are used to store the integer value of the Y value of the screen space coordinate of the reflection source, and bits 12 to 14 are used to store the decimal value of the Y value of the screen space coordinate of the reflection source; bits 15 to 27 are used to store the integer value of the X value of the screen space coordinate of the reflection source, and bits 28 to 30 are used to store the decimal value of the X value of the screen space coordinate of the reflection source.

[0163] The reason for encoding in uint32 format is to store the Y value of the screen space coordinate in the high bit of the uint32 format, so that when the InterlockedMin function is used for writing, the Y value of the encoded coordinate written on the RT can be guaranteed to be the smallest. That is, when the screen space coordinates of the reflection point are written by multiple reflection sources at the same time, the reflection source closest to the reflection plane is guaranteed to be the final reflection source, thereby avoiding writing conflicts when multiple reflection sources correspond to the same reflection point.

[0164] Step 5: Based on the Projection Buffer, restore the screen space coordinates of the reflection source.

[0165] For example, for each pixel in the screen space coordinate system, the Projection Buffer is sampled by the pixel shader of the reflection pass, and then the sampling result is de-encoded to restore the screen space coordinates of the reflection source.

[0166] It should be noted that the specific inverse encoding method is as follows: the values ​​of bits 0 to 11 are taken as the integer value of the Y value of the screen space coordinate of the reflection source, the values ​​of bits 12 to 14 are taken as the decimal value of the Y value of the screen space coordinate of the reflection source, the values ​​of bits 15 to 27 are taken as the integer value of the X value of the screen space coordinate of the reflection source, and the values ​​of bits 28 to 30 are taken as the decimal value of the X value of the screen space coordinate of the reflection source.

[0167] Step 6: Sample the screen color based on the screen space coordinates of the reflection source to obtain the reflection color, and write the screen space coordinates of the corresponding reflection point to obtain the reflection buffer.

[0168] For example, using the screen space coordinates of the reflection source, sampling Figure 8 The screen color (Scene Color) shown in the figure is used to obtain the reflection color (i.e., the screen color value of the reflection source). Scene Color represents the color buffer of the current screen space. Then, the reflection color is written into the screen space coordinates of the corresponding reflection point to obtain the following: Fig. 9 The Reflection Buffer shown.

[0169] Step 7: When rendering objects that need reflection, sample the Reflection Buffer to get the final reflection result.

[0170] For example, when rendering an object that needs to be reflected (by adding a marker to the material ball in the engine to mark the object that needs to be reflected), traverse the pixels of the object that needs to be reflected, project the current pixel traversed to the screen space coordinate system, use the screen space coordinates of the current pixel as the sampling coordinates to sample the Reflection Buffer, obtain the reflection point and reflection color of the current pixel, and render based on the reflection point and reflection color, so as to obtain the following: Fig.10 The final reflection result is shown.

[0171] The following is a comparison of the reflection effect diagram:

[0172] Fig.11A This is a lake reflection effect diagram of the related technology. Fig. 11B This is a picture of the lake surface reflection effect of an embodiment of the present application. It can be seen that the reflection of the lake surface 1101 presented by the related technology is not real. After the embodiment of the present application applies a high-performance multi-plane reflection method based on screen space, the lake surface 1102 has a correct reflection effect, making the reflection picture more realistic.

[0173] Fig. 12A It is a reflection effect diagram of multiple reflection planes in the related art. Fig. 12B This is a reflection effect diagram of multiple reflection planes in an embodiment of the present application. It can be seen that the reflection 1201 presented by the related technology is wrong. After the embodiment of the present application applies a high-performance multi-plane reflection method based on screen space, the correct reflection relationship is found in multiple reflection planes, thereby ensuring that the final generated reflection map will not have reflection errors, that is, the presented reflection 1202 is correct, making the picture more realistic.

[0174] In summary, the high-performance multi-plane reflection method based on screen space provided in the embodiment of the present application can support reflection on multiple reflection planes of different heights, and can find the correct reflection relationship among multiple reflection planes, thereby ensuring that the final generated reflection map will not have reflection errors.

[0175] So far, the image rendering method provided by the embodiment of the present application has been described in combination with the exemplary application and implementation of the electronic device provided by the embodiment of the present application. The following will continue to describe the cooperation of various modules in the image rendering device 555 provided by the embodiment of the present application to implement the image rendering scheme.

[0176] An acquisition module 5551 is used to acquire an image to be reflected, wherein the image to be reflected includes multiple reflection sources and multiple reflection planes; a projection module 5552 is used to perform projection processing on each of the reflection sources based on the multiple reflection planes to obtain multiple reflection points corresponding to each of the reflection sources; and a target reflection point of each of the reflection sources is determined from the multiple reflection points corresponding to each of the reflection sources; a reflection module 5553 is used to determine a reflection map of the image to be reflected based on each of the reflection sources and the target reflection point of each of the reflection sources; and a rendering module 5554 is used to perform image rendering processing on the image to be reflected based on the reflection map of the image to be reflected to obtain a reflection image corresponding to the image to be reflected.

[0177] In some embodiments, the projection module 5552 is also used to determine the screen space coordinates of each of the reflection sources and the world coordinates of each of the reflection planes; convert the screen space coordinates of each of the reflection sources into a target space coordinate system to obtain a first target space coordinate of each of the reflection sources; convert the world coordinates of each of the reflection planes into the target space coordinate system to obtain a second target space coordinate of each of the reflection planes; and perform physical projection processing on each of the reflection sources based on the first target space coordinates of each of the reflection sources and the second target space coordinates of each of the reflection planes to obtain a plurality of reflection points corresponding to each of the reflection sources.

[0178] In some embodiments, the projection module 5552 is also used to perform the following processing on any of the multiple reflection planes: in the target space coordinate system, projection processing is performed based on the second target space coordinate of the reflection plane and the first target space coordinate of each of the reflection sources to obtain the symmetric point of each of the reflection sources relative to the reflection plane; in the target space coordinate system, a line is constructed between the symmetric point and the camera; and the intersection of the line and the reflection plane is determined as the reflection point corresponding to each of the reflection sources.

[0179] In some embodiments, the projection module 5552 is also used to determine the distance between each of the reflection points and the camera; when any of the multiple reflection points is within the range of the reflection plane and the distance between any of the reflection points and the camera is the smallest, any of the reflection points is determined as a target reflection point of each of the reflection sources.

[0180] In some embodiments, before determining any of the reflection points as the target reflection point of each of the reflection sources, the projection module 5552 is also used to determine the origin coordinates of the reflection plane and the size of the reflection plane; based on the origin coordinates of the reflection plane and the size of the reflection plane, determine the range of the reflection plane; when any of the reflection points falls within the range of the reflection plane, determine that any of the multiple reflection points is within the range of the reflection plane.

[0181] In some embodiments, the reflection module 5553 is also used to perform the following processing for any of the multiple reflection sources: determine the color value of the reflection source based on the correspondence between the reflection source and the target reflection point; determine the color value of the reflection source as the color value of the target reflection point; write the color value of the target reflection point into the rendering target to obtain the reflection map of the image to be reflected.

[0182] In some embodiments, the reflection module 5553 is also used to perform encoding processing on the screen space coordinates of the reflection source based on the encoding format to obtain the encoded coordinates of the reflection source; based on the correspondence between the reflection source and the target reflection point, write the encoded coordinates of the reflection source into the screen space coordinates of the target reflection point of the reflection source to obtain a projection buffer; perform decoding processing based on the projection buffer to obtain the decoded coordinates of the reflection source; sample the screen color based on the decoded coordinates of the reflection source to obtain the color value of the reflection source.

[0183] In some embodiments, the screen space coordinates of the reflection source include a horizontal axis coordinate value and a vertical axis coordinate value; the reflection module 5553 is also used to store the integer part of the vertical axis coordinate value of the reflection source in the first coding bit of the coding format, store the decimal part of the vertical axis coordinate value of the reflection source in the second coding bit of the coding format, store the integer part of the horizontal axis coordinate value of the reflection source in the third coding bit of the coding format, and store the decimal part of the horizontal axis coordinate value of the reflection source in the fourth coding bit of the coding format when the angle between the reflection plane and the horizontal plane is less than an angle threshold, so as to obtain the encoded coordinates of the reflection source.

[0184] In some embodiments, the screen space coordinates of the reflection source include a horizontal axis coordinate value and a vertical axis coordinate value; the reflection module 5553 is also used to store the integer part of the horizontal axis coordinate value of the reflection source in the fifth coding bit of the coding format, store the decimal part of the horizontal axis coordinate value of the reflection source in the sixth coding bit of the coding format, store the integer part of the vertical axis coordinate value of the reflection source in the seventh coding bit of the coding format, and store the decimal part of the vertical axis coordinate value of the reflection source in the eighth coding bit of the coding format to obtain the coded coordinates of the reflection source when the angle between the reflection plane and the vertical plane is less than an angle threshold.

[0185] In some embodiments, the reflection module 5553 is also used to compare the encoded coordinates of the reflection source and the encoded coordinates of the other reflection sources when the screen space coordinates of the target reflection point of the reflection source have been written into the encoded coordinates of other reflection sources; when the encoded coordinates of the reflection source located at the target encoding position of the encoding format are smaller than the encoded coordinates of the other reflection sources, the encoded coordinates of the reflection source are written into the screen space coordinates of the target reflection point of the reflection source; or, when the screen space coordinates of the target reflection point of the reflection source have not been written into the encoded coordinates of other reflection sources, the encoded coordinates of the reflection source are written into the screen space coordinates of the target reflection point of the reflection source.

[0186] In some embodiments, before performing projection processing based on the multiple reflection planes on each of the reflection sources, the acquisition module 5551 is also used to perform a frustum culling process on the multiple reflection planes to obtain the culled reflection planes; based on the sizes of the culled reflection planes, the culled reflection planes are sorted in descending order; and the culled reflection planes that are arranged in front of the sorting result are used as the reflection planes for projection processing.

[0187] The embodiment of the present application provides a computer program product, which includes a computer program or a computer executable instruction, and the computer program or the computer executable instruction is stored in a computer-readable storage medium. The processor of the electronic device reads the computer program or the computer executable instruction from the computer-readable storage medium, and the processor executes the computer program or the computer executable instruction, so that the electronic device performs the image rendering method described in the embodiment of the present application.

[0188] The present application embodiment provides a computer-readable storage medium storing computer-executable instructions, wherein the computer-executable instructions or computer programs are stored. When the computer-executable instructions or computer programs are executed by a processor, the processor will be caused to execute the image rendering method provided by the present application embodiment, for example, Figure 3A-3B An image rendering method is shown.

[0189] In some embodiments, the computer-readable storage medium may be a memory such as FRAM, ROM, PROM, EPROM, EEPROM, flash memory, magnetic surface storage, optical disk, or CD-ROM; or it may be various devices including one or any combination of the above memories.

[0190] In some embodiments, computer executable instructions may be in the form of a program, software, software module, script or code, written in any form of programming language (including compiled or interpreted languages, or declarative or procedural languages), and may be deployed in any form, including as a stand-alone program or as a module, component, subroutine or other unit suitable for use in a computing environment.

[0191] As an example, computer-executable instructions may, but need not, correspond to a file in a file system, may be stored as part of a file storing other programs or data, such as in one or more scripts in a HyperText Markup Language (HTML) document, in a single file dedicated to the program in question, or in multiple coordinated files (e.g., files storing one or more modules, subroutines, or code portions).

[0192] As an example, computer executable instructions may be deployed to be executed on one electronic device, or on multiple electronic devices located at one site, or on multiple electronic devices distributed at multiple sites and interconnected by a communication network.

[0193] It is understandable that in the embodiments of the present application, related data such as user information is involved. When the embodiments of the present application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of relevant data need to comply with relevant laws, regulations and standards of relevant countries and regions.

[0194] The above is only an embodiment of the present application and is not intended to limit the protection scope of the present application. Any modifications, equivalent substitutions and improvements made within the spirit and scope of the present application are included in the protection scope of the present application.

Claims

1. An image rendering method, characterized in that: The method comprises: Acquire an image to be reflected, wherein the image to be reflected includes a plurality of reflection sources and a plurality of reflection planes; Performing projection processing on each of the reflection sources based on the multiple reflection planes to obtain multiple reflection points corresponding to each of the reflection sources; Determining a target reflection point of each reflection source from a plurality of reflection points corresponding to each reflection source; Determine a reflection map of the image to be reflected based on each of the reflection sources and a target reflection point of each of the reflection sources; Based on the reflection map of the image to be reflected, image rendering processing is performed on the image to be reflected to obtain a reflection image corresponding to the image to be reflected.

2. The method according to claim 1, characterized in that: The performing projection processing on each of the reflection sources based on the multiple reflection planes to obtain multiple reflection points corresponding to each of the reflection sources includes: Determine the screen space coordinates of each of the reflection sources, and determine the world coordinates of each of the reflection planes; Convert the screen space coordinates of each of the reflection sources into a target space coordinate system to obtain a first target space coordinate of each of the reflection sources; Convert the world coordinates of each of the reflection planes into the target space coordinate system to obtain the second target space coordinates of each of the reflection planes; Based on the first target space coordinates of each of the reflection sources and the second target space coordinates of each of the reflection planes, physical projection processing is performed on each of the reflection sources to obtain a plurality of reflection points corresponding to each of the reflection sources.

3. The method according to claim 2, characterized in that The method of performing physical projection processing on each of the reflection sources based on the first target space coordinates of each of the reflection sources and the second target space coordinates of each of the reflection planes to obtain a plurality of reflection points corresponding to each of the reflection sources includes: The following processing is performed for any of the plurality of reflection planes: In the target space coordinate system, projection processing is performed based on the second target space coordinates of the reflection plane and the first target space coordinates of each of the reflection sources to obtain a symmetric point of each of the reflection sources relative to the reflection plane; In the target space coordinate system, constructing a line connecting the symmetric point and the camera; The intersection point of the connecting line and the reflecting plane is determined as the reflection point corresponding to each of the reflecting sources.

4. The method according to claim 1, characterized in that: Determining a target reflection point of each reflection source from a plurality of reflection points corresponding to each reflection source comprises: Determining the distance between each of the reflection points and the camera; When any one of the multiple reflection points is within the range of the reflection plane and the distance between any one of the reflection points and the camera is the smallest, any one of the reflection points is determined as a target reflection point of each of the reflection sources.

5. The method according to claim 4, characterized in that Before determining any of the reflection points as a target reflection point of each of the reflection sources, the method further comprises: Determine the origin coordinates of the reflection plane and the size of the reflection plane; Determine the range of the reflection plane based on the origin coordinates of the reflection plane and the size of the reflection plane; When any of the reflection points falls within the range of the reflection plane, it is determined that any of the multiple reflection points is within the range of the reflection plane.

6. The method according to claim 1, characterized in that The step of determining the reflection map of the image to be reflected based on each of the reflection sources and the target reflection point of each of the reflection sources comprises: The following processing is performed for any of the plurality of reflection sources: Determining a color value of the reflection source based on a correspondence between the reflection source and the target reflection point; Determine the color value of the reflection source as the color value of the target reflection point; The color value of the target reflection point is written into the rendering target to obtain the reflection map of the image to be reflected.

7. The method according to claim 6, characterized in that The determining the color value of the reflection source based on the correspondence between the reflection source and the target reflection point includes: Performing encoding processing based on an encoding format on the screen space coordinates of the reflection source to obtain the encoded coordinates of the reflection source; Based on the correspondence between the reflection source and the target reflection point, the encoded coordinates of the reflection source are written into the screen space coordinates of the target reflection point of the reflection source to obtain a projection buffer; Performing decoding processing based on the projection buffer to obtain the decoded coordinates of the reflection source; The screen color is sampled based on the decoded coordinates of the reflection source to obtain the color value of the reflection source.

8. The method according to claim 7, characterized in that The screen space coordinates of the reflection source include a horizontal axis coordinate value and a vertical axis coordinate value; The encoding process of the screen space coordinates of the reflection source to obtain the encoded coordinates of the reflection source in an encoded format includes: When the angle between the reflection plane and the horizontal plane is less than the angle threshold, the integer part of the longitudinal axis coordinate value of the reflection source is stored in the first coding bit of the coding format, the decimal part of the longitudinal axis coordinate value of the reflection source is stored in the second coding bit of the coding format, the integer part of the transverse axis coordinate value of the reflection source is stored in the third coding bit of the coding format, and the decimal part of the transverse axis coordinate value of the reflection source is stored in the fourth coding bit of the coding format to obtain the coded coordinates of the reflection source.

9. The method according to claim 7, characterized in that: The screen space coordinates of the reflection source include a horizontal axis coordinate value and a vertical axis coordinate value; The encoding process of the screen space coordinates of the reflection source to obtain the encoded coordinates of the reflection source includes: When the angle between the reflection plane and the vertical plane is less than the angle threshold, the integer part of the horizontal axis coordinate value of the reflection source is stored in the fifth coding bit of the coding format, the decimal part of the horizontal axis coordinate value of the reflection source is stored in the sixth coding bit of the coding format, the integer part of the vertical axis coordinate value of the reflection source is stored in the seventh coding bit of the coding format, and the decimal part of the vertical axis coordinate value of the reflection source is stored in the eighth coding bit of the coding format to obtain the coded coordinates of the reflection source.

10. The method according to claim 7, characterized in that The step of writing the encoded coordinates of the reflection source into the screen space coordinates of the target reflection point of the reflection source comprises: When the screen space coordinates of the target reflection point of the reflection source have been written into the coded coordinates of other reflection sources, the coded coordinates of the reflection source and the coded coordinates of the other reflection sources are compared. When the encoding coordinates of the reflection source at the target encoding position of the encoding format are smaller than the encoding coordinates of the other reflection sources, writing the encoding coordinates of the reflection source into the screen space coordinates of the target reflection point of the reflection source; or When the screen space coordinates of the target reflection point of the reflection source are not written into the coded coordinates of other reflection sources, the coded coordinates of the reflection source are written into the screen space coordinates of the target reflection point of the reflection source.

11. The method according to claim 1, characterized in that: Before performing the projection processing based on the multiple reflection planes on each of the reflection sources, the method further includes: Performing frustum culling processing on the multiple reflection planes to obtain the culled reflection planes; Based on the sizes of the removed reflection planes, the removed reflection planes are sorted in descending order; The reflection plane after removing the part arranged in front in the sorting result is used as the reflection plane for projection processing.

12. An image rendering device, characterized in that: The device comprises: An acquisition module, used for acquiring an image to be reflected, wherein the image to be reflected includes a plurality of reflection sources and a plurality of reflection planes; A projection module, used for performing projection processing on each of the reflection sources based on the multiple reflection planes to obtain multiple reflection points corresponding to each of the reflection sources; Determining a target reflection point of each reflection source from a plurality of reflection points corresponding to each reflection source; A reflection module, used to determine a reflection map of the image to be reflected based on each of the reflection sources and a target reflection point of each of the reflection sources; A rendering module is used to perform image rendering processing on the image to be reflected based on the reflection map of the image to be reflected, so as to obtain a reflection image corresponding to the image to be reflected.

13. An electronic device, characterized in that: The electronic device comprises: Memory for storing computer programs or computer executable instructions; A processor, configured to implement the image rendering method according to any one of claims 1 to 11 when executing the computer program or computer executable instructions stored in the memory.

14. A computer-readable storage medium, characterized in that: A computer program or a computer executable instruction is stored, and when the computer program or the computer executable instruction is executed by a processor, the image rendering method according to any one of claims 1 to 11 is implemented.

15. A computer program product comprising a computer program or computer executable instructions, characterized in that: When the computer program or computer executable instructions are executed by a processor, the image rendering method according to any one of claims 1 to 11 is implemented.

Citation Information

Cited By

  • Image rendering method and device, storage medium and program product

    CN119762655A