Image rendering method, device, computer equipment and storage medium

Calculate and transfer physical texture coordinates through the vertex shader, and directly sample texture pixels in the pixel shader, solving the problem of complex texture map sampling calculations and improving image rendering efficiency.

CN112884875BActive Publication Date: 2024-09-27TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202110295463.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-03-19
Publication Date
2024-09-27
Estimated Expiration
2041-03-19

AI Technical Summary

Technical Problem

In the existing technology, the sampling calculation of texture maps during the image rendering process is complex, resulting in high resource consumption and low efficiency for low-performance terminals.

Method used

Determine the vertex coordinates of the virtual texture block through the vertex shader, load the physical texture into the texture cache, calculate the physical texture coordinates of the rendering sub-block, and pass it to the pixel shader to directly sample texture pixels, reducing the calculation amount of the pixel shader.

Benefits of technology

It effectively reduces resource consumption in the image rendering process, improves rendering efficiency, and makes the image rendering efficiency of low-performance terminals close to that of high-performance terminals.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112884875B
    Figure CN112884875B
Patent Text Reader

Abstract

The present application relates to an image rendering method, device, computer equipment and storage medium. The method comprises: determining the vertex coordinates of the corresponding virtual map block in the virtual map of the image to be rendered; loading the physical map corresponding to the vertex coordinates into the map cache through the vertex shader; determining the physical texture coordinates corresponding to each rendering sub-block in the virtual map block corresponding to the vertex coordinates in the map cache; passing the physical texture coordinates into the pixel shader; sampling the texture pixels matching the physical texture coordinates from the physical map in the map cache through the pixel shader, and rendering the image to be rendered based on the texture pixels. The use of this method can effectively reduce the resource consumption in the image rendering process, so as to effectively improve the image rendering efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of image processing technology, and in particular to an image rendering method, apparatus, computer equipment and storage medium. Background Art

[0002] Texture in computer graphics is one or more two-dimensional images that represent the details of an object's surface. It is also called a texture map. You can apply any type of texture map to one or more faces of a three-dimensional model, such as patterns of bricks, leaves, and ground. Texture maps increase the realism of the scene.

[0003] In the related art, virtual mapping technology is usually used, which divides a large texture map into multiple small blocks and generates an indirect texture, so that the position of the real map corresponding to each page block position in each virtual map can be obtained from the indirect texture during rendering. However, the sampling and calculation process of texture mapping in this way is relatively complicated, and the resource consumption on some low-performance terminals is high, resulting in low efficiency of image rendering. Summary of the invention

[0004] Based on this, it is necessary to provide an image rendering method, apparatus, computer equipment and storage medium that can effectively reduce resource consumption in the image rendering process to effectively improve image rendering efficiency in response to the above technical problems.

[0005] An image rendering method, the method comprising:

[0006] Determine the vertex coordinates of the corresponding virtual texture block of the image to be rendered in the virtual texture;

[0007] Loading the physical texture corresponding to the vertex coordinates into a texture cache through a vertex shader;

[0008] For each rendering sub-block in the virtual texture block corresponding to the vertex coordinates, determining the physical texture coordinates corresponding to each rendering sub-block in the texture cache;

[0009] Passing the physical texture coordinates into a pixel shader;

[0010] The pixel shader samples texture pixels matching the physical texture coordinates from the physical texture in the texture cache, and renders the image to be rendered based on the texture pixels.

[0011] An image rendering device, the device comprising:

[0012] A data acquisition module, used to determine the vertex coordinates of the corresponding virtual map block of the image to be rendered in the virtual map;

[0013] A texture acquisition module, used for loading the physical texture corresponding to the vertex coordinates into a texture cache through a vertex shader;

[0014] A physical texture coordinate determination module, used for determining the physical texture coordinates corresponding to each rendering sub-block in the virtual texture block corresponding to the vertex coordinates in the texture cache;

[0015] A data transmission module, used for transmitting the physical texture coordinates into a pixel shader;

[0016] The image rendering module is used to sample texture pixels matching the physical texture coordinates from the physical texture in the texture cache through a pixel shader, and render the image to be rendered based on the texture pixels.

[0017] In one embodiment, the texture acquisition module is also used to determine the virtual texture coordinates of the virtual texture block corresponding to the vertex coordinates in the virtual texture coordinate system through a vertex shader; obtain a virtual texture page table; the virtual texture page table stores a mapping relationship between virtual texture coordinates and physical texture coordinates; the physical texture coordinates are the coordinates of the physical texture in the physical texture coordinate system; according to the corresponding physical texture coordinates of the virtual texture coordinates in the virtual texture page table, obtain the physical texture corresponding to each of the virtual texture blocks; and load the obtained physical texture into the texture cache.

[0018] In one embodiment, the texture acquisition module is further used to determine the world coordinates of the virtual texture block corresponding to the vertex coordinates; and determine the virtual texture coordinates of the virtual texture block in a virtual texture coordinate system according to the world coordinates of the virtual texture block.

[0019] In one embodiment, the texture acquisition module is also used to determine the physical texture coordinates of the physical texture corresponding to each virtual texture block in the virtual texture page table based on the virtual texture coordinates and the virtual texture size of the virtual texture; and acquire the physical texture corresponding to each virtual texture block based on the physical texture coordinates.

[0020] In one embodiment, the physical texture coordinate determination module is further used to perform scaling transformation processing on the vertex coordinates of each rendering sub-block in the virtual map block according to the scaling transformation matrix to obtain the local virtual texture coordinates of each rendering sub-block after the scaling transformation; determine the starting physical texture coordinates corresponding to the physical map according to the world coordinates corresponding to the virtual map block and the virtual texture coordinates corresponding to the virtual map block in the virtual texture page table; determine the physical texture coordinates corresponding to each rendering sub-block in the map cache according to the local virtual texture coordinates of each rendering sub-block and the starting physical texture coordinates corresponding to the physical map.

[0021] In one embodiment, the physical texture coordinate determination module is further used to align each virtual texture block with a matching physical texture according to the starting virtual texture coordinates of each virtual texture block and the starting physical texture coordinates corresponding to each physical texture; determine the offset of each rendering sub-block in the virtual texture block according to the starting virtual texture coordinates of the virtual texture block and the local virtual texture coordinates of each rendering sub-block; and determine the physical texture coordinates corresponding to each rendering sub-block in the texture cache according to the starting physical texture coordinates corresponding to the physical texture and the offset.

[0022] In one embodiment, the physical texture coordinate determination module is also used to determine the physical texture coordinates corresponding to each rendering sub-block in the texture cache through the sampling nodes in the vertex shader, for each rendering sub-block in the virtual texture block corresponding to the vertex coordinates; the data transmission module is also used to transfer the physical texture coordinates to the pixel shader through the sampling nodes in the vertex shader.

[0023] In one embodiment, the data transmission module is also used to interpolate the vertex attributes corresponding to the physical texture coordinates through the sampling nodes in the vertex shader to obtain the physical texture coordinates of the pixel attributes; and pass the physical texture coordinates of the pixel attributes into the pixel shader.

[0024] In one embodiment, the above-mentioned image rendering device also includes a parameter determination module, which is used to determine the texture request parameters corresponding to each virtual texture block through the vertex shader according to the virtual texture coordinates corresponding to each virtual texture block; through the vertex shader, the physical texture coordinates and the texture request parameters are passed into the pixel shader; the image rendering module is also used to sample texture pixels matching the physical texture coordinates from the physical texture in the texture cache based on the texture request parameters through the pixel shader.

[0025] In one embodiment, the parameter determination module is also used to correct the virtual texture coordinates corresponding to each virtual texture block according to the size of the virtual texture page in the virtual texture page table to obtain the corrected virtual texture coordinates; and generate the texture request parameters corresponding to each virtual texture block according to the corrected virtual texture coordinates.

[0026] In one embodiment, the parameter determination module is also used to determine the texture level corresponding to the virtual texture page according to the corrected virtual texture coordinates; determine the pixel coordinates of the virtual texture page corresponding to each virtual map block according to the corrected virtual texture coordinates and the texture level; and generate texture request parameters corresponding to each virtual map block according to the pixel coordinates.

[0027] In one embodiment, the data acquisition module is also used to determine the vertex coordinates of the corresponding virtual texture block of the terrain scene area in the virtual map when the image to be rendered includes a terrain scene area; the image rendering module is also used to sample texture pixels matching the physical texture coordinates from the physical texture in the texture cache through the pixel shader, and render the terrain scene area in the image to be rendered based on the texture pixels.

[0028] A computer device comprises a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:

[0029] Determine the vertex coordinates of the corresponding virtual texture block of the image to be rendered in the virtual texture;

[0030] Loading the physical texture corresponding to the vertex coordinates into a texture cache through a vertex shader;

[0031] For each rendering sub-block in the virtual texture block corresponding to the vertex coordinates, determining the physical texture coordinates corresponding to each rendering sub-block in the texture cache;

[0032] Passing the physical texture coordinates into a pixel shader;

[0033] The pixel shader samples texture pixels matching the physical texture coordinates from the physical texture in the texture cache, and renders the image to be rendered based on the texture pixels.

[0034] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the following steps:

[0035] Determine the vertex coordinates of the corresponding virtual texture block of the image to be rendered in the virtual texture;

[0036] Loading the physical texture corresponding to the vertex coordinates into a texture cache through a vertex shader;

[0037] For each rendering sub-block in the virtual texture block corresponding to the vertex coordinates, determining the physical texture coordinates corresponding to each rendering sub-block in the texture cache;

[0038] Passing the physical texture coordinates into a pixel shader;

[0039] The pixel shader samples texture pixels that match the physical texture coordinates from the physical texture in the texture cache, and renders the image to be rendered based on the texture pixels.

[0040] A computer program product or a computer program, wherein the computer program product or the computer program comprises computer instructions, wherein the computer instructions are stored in a computer-readable storage medium; a processor of the computer device reads the computer instructions from the computer-readable storage medium, and when the processor executes the computer instructions, the following steps are implemented:

[0041] Determine the vertex coordinates of the corresponding virtual texture block of the image to be rendered in the virtual texture;

[0042] Loading the physical texture corresponding to the vertex coordinates into a texture cache through a vertex shader;

[0043] For each rendering sub-block in the virtual texture block corresponding to the vertex coordinates, determining the physical texture coordinates corresponding to each rendering sub-block in the texture cache;

[0044] Passing the physical texture coordinates into a pixel shader;

[0045] The pixel shader samples texture pixels matching the physical texture coordinates from the physical texture in the texture cache, and renders the image to be rendered based on the texture pixels.

[0046] The above-mentioned image rendering method, device, computer equipment and storage medium, after determining the vertex coordinates of the corresponding virtual map block in the virtual map of the image to be rendered, load the physical map corresponding to the vertex coordinates into the map cache through the vertex shader; for each rendering sub-block in the virtual map block corresponding to the vertex coordinate, determine the physical texture coordinates corresponding to each rendering sub-block in the map cache, thereby accurately calculating the physical texture coordinates of each rendering sub-block. Then, the physical texture coordinates are passed to the pixel shader. Since the amount of calculation of the vertex shader during the rendering process is much less than that of the pixel shader, by calculating the physical texture coordinates in the vertex shader, the pixel shader does not need to calculate the physical texture coordinates again. The pixel shader then directly samples the texture pixels matching the physical texture coordinates from the physical map in the map cache according to the physical texture coordinates passed in by the vertex shader, and renders the image to be rendered based on the texture pixels. In this way, the amount of calculation of the pixel shader can be effectively reduced, thereby effectively reducing the resource consumption in the image rendering process, and thus effectively improving the rendering efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] Figure 1 A diagram showing an application environment of an image rendering method in an embodiment;

[0048] Figure 2 is a schematic diagram of a flow chart of an image rendering method in an embodiment;

[0049] Figure 3 A schematic diagram of coordinates of a virtual map in one embodiment;

[0050] Figure 4 is a schematic diagram of a virtual map and a physical map in one embodiment;

[0051] Figure 5 is a schematic diagram of a virtual map and a virtual texture page table in one embodiment;

[0052] Figure 6 A schematic diagram of coordinates of a rendering sub-block in a virtual map block in one embodiment;

[0053] Figure 7 is a flowchart of an image rendering method in another embodiment;

[0054] Figure 8 is a flowchart of an image rendering method in yet another embodiment;

[0055] Fig. 9 A flowchart of drawing a terrain virtual map in one embodiment;

[0056] Fig.10 is a structural block diagram of an image rendering device in one embodiment;

[0057] Fig.11 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0058] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0059] The image rendering method provided in this application can be applied to Figure 1 In the application environment shown. Among them, the terminal 102 communicates with the server 104 through the network. Specifically, the terminal 102 can obtain the virtual texture and vertex data in the three-dimensional scene from the server 104. The terminal 102 then determines the vertex coordinates of the virtual texture block corresponding to the image to be rendered in the virtual texture, and loads the physical texture corresponding to the vertex coordinates into the texture cache through the vertex shader; for each rendering sub-block in the virtual texture block corresponding to the vertex coordinate, the physical texture coordinates corresponding to each rendering sub-block in the texture cache are determined; the physical texture coordinates are passed into the pixel shader; through the pixel shader, the texture pixels matching the physical texture coordinates are sampled from the physical texture in the texture cache, and the image to be rendered is rendered based on the texture pixels.

[0060] Among them, the terminal 102 can be, but is not limited to, various personal computers, laptops, smart phones, tablet computers and portable wearable devices, and the server 104 can be implemented by an independent server or a server cluster composed of multiple servers. The server can 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 can be a smart phone, tablet computer, laptop computer, desktop computer, smart speaker, smart watch, etc., but is not limited to this. The terminal and the server can be directly or indirectly connected via wired or wireless communication, and this application is not limited here.

[0061] Cloud technology refers to a hosting technology that unifies hardware, software, network and other resources in a wide area network or local area network to achieve data computing, storage, processing and sharing. Cloud technology is a general term for network technology, information technology, integration technology, management platform technology, application technology, etc. based on the cloud computing business model. It can form a resource pool that can be used on demand and is flexible and convenient. Cloud computing technology will become an important support. The background services of technical network systems require a large amount of computing and storage resources, such as video websites, picture websites and more portal websites. With the high development and application of the Internet industry, in the future, each item may have its own identification mark, and all need to be transmitted to the background system for logical processing. Data of different levels will be processed separately. All kinds of industry data require strong system backing support, which can only be achieved through cloud computing.

[0062] Computer Vision Technology (Computer Vision, CV) Computer vision is a science that studies how to make machines "see". To put it more concretely, it refers to the use of cameras and computers to replace human eyes to identify, follow and measure targets, and further perform graphics processing to make computer processing into images that are more suitable for human eye observation or transmission to instrument detection. As a scientific discipline, computer vision studies related theories and technologies, and attempts to establish an artificial intelligence system that can obtain information from images or multidimensional data. Computer vision technology generally includes image processing, image recognition, image semantic understanding, image retrieval, OCR, video processing, video semantic understanding, video content / behavior recognition, three-dimensional object reconstruction, 3D technology, virtual reality, augmented reality, synchronous positioning and map construction, and other technologies, as well as common biometric recognition technologies such as face recognition and fingerprint recognition. It can be understood that the image rendering method in this application is based on computer vision technology, and the rendering image is rendered, which can effectively improve the efficiency of scene rendering.

[0063] In one embodiment, Figure 2 As shown, an image rendering method is provided, which is applied to Figure 1 The terminal in is used as an example to illustrate, including the following steps:

[0064] S202, determining vertex coordinates of a virtual texture block corresponding to the image to be rendered in the virtual texture.

[0065] In computer graphics, rendering refers to the process of projecting the object model in a three-dimensional scene into a digital image in two dimensions according to the set environment, material, lighting and rendering parameters. It is also the process of converting the three-dimensional light energy transfer process into a two-dimensional image. The scenes and entities are represented in three-dimensional form, which is closer to the real world and easier to manipulate and transform.

[0066] It can be understood that the image to be rendered can be a scene picture to be displayed in a three-dimensional scene, for example, the three-dimensional scene can be specifically a three-dimensional virtual scene. It can be understood that in a three-dimensional scene, the position and perspective of the observation point are different, and the corresponding scene pictures displayed are also different. By displaying the image frames corresponding to the continuous scene pictures, a dynamic three-dimensional scene or a three-dimensional scene video can be displayed. Among them, the image to be rendered can represent the image frame that currently needs to be rendered in the process of displaying the three-dimensional scene.

[0067] Among them, texture represents one or several two-dimensional graphics of the surface details of an object, also known as texture image or texture map. It can be understood that texture is actually a two-dimensional array, and the elements in the two-dimensional array are some color values. When the texture is mapped to the surface of an object in a specific way, it can make the object look more realistic. Texture can be used to reflect the content of the object that needs to be rendered into the display image or video frame.

[0068] Texture maps can store a lot of information. For example, each pixel can record at least one of the following information: color, vertex data, normal vector, material, background light, scattering, highlight, transparency, geometric height, geometric displacement, etc. This information can be used to depict the details of the surface of an object. A texture map can be a pre-drawn texture image. The texture image can include information such as the color corresponding to one or more graphic objects. For example, a graphic object can include at least one of terrain, houses, trees, and people in a three-dimensional scene.

[0069] Among them, virtual mapping, also known as virtual texture mapping (VT, Virtual Textures), is suitable for high resolution. The concept of virtual texture mapping is similar to virtual memory. Instead of loading all the data of a large texture into the memory, only the required part of the large texture is loaded into the memory according to the implementation needs of the 3D scene application at runtime.

[0070] It is understood that a physical map, i.e., a physical texture map, refers to a texture image that actually exists in the memory. That is, a texture map in actual texture data loaded into the memory is a physical texture map. The texture block data may specifically be texture block data corresponding to each virtual map block.

[0071] In addition, unlike virtual memory, virtual texture mapping will not cause blocking during operation. When data cannot be read from the hard disk in time, the corresponding Mipmap (multi-level progressively distant texture) in the memory can be used to temporarily replace the display. For example, the map texture can be divided into hierarchical textures of different resolutions, and each can be divided into multiple blocks. When rendering, the closer the blocks are, the higher the resolution will be. Then, through the pre-defined mapping relationship, it is mapped to a physical texture map in the memory. When the displayed field of view changes, part of the physical map will be replaced and part of the physical map will be loaded.

[0072] The virtual texture blocks in the virtual texture may be multiple virtual texture blocks obtained by dividing the virtual texture corresponding to the entire scene. It is understood that multiple means at least two or more.

[0073] It can be understood that the terminal is deployed with an application based on a three-dimensional scene application, and a rendering engine is deployed in the application. The rendering engine is a core component or system that can realize image rendering. By using the rendering engine, the required image rendering function can be quickly realized, and all effects such as models, animations, light and shadow, special effects, etc. can be calculated in real time, and the rendering effect can be displayed on the terminal's display screen. For example, the rendering engine in the game application can include Unreal Engine, Unity Engine, etc.

[0074] The rendering engine includes shaders, which are algorithmic programs interspersed in the rendering pipeline for image rendering. They are responsible for combining the input vertex data with the input texture or color in a specified way and then outputting it. Usually, the graphics processor reads the corresponding input texture through the shader and renders the image to be rendered through the graphics processor's rendering pipeline.

[0075] It can be understood that the three-dimensional scene includes pre-set vertices, such as terrain vertices in the terrain of the three-dimensional scene. The vertex coordinates may be coordinates corresponding to each vertex in the three-dimensional scene. The coordinates corresponding to each vertex in the three-dimensional scene include not only three-dimensional world space coordinates, but also two-dimensional texture coordinates.

[0076] The vertex coordinates in the virtual map can be the texture coordinates corresponding to each vertex in the virtual map, specifically UV texture coordinates. UV coordinates, UV refers to the abbreviation of (u, v) texture coordinates, that is, UVW coordinates, which are similar to the X, Y, and Z axes of the space model. U represents the coordinate of the image in the horizontal direction, V represents the coordinate of the image in the vertical direction, and the direction of W is perpendicular to the display surface, which is generally used for program mapping or some three-dimensional scene mapping technology.

[0077] It can be understood that UV coordinates are the basis for mapping the texture to the surface of the model, and define the position of each point in the image. These points are interconnected with the model in the three-dimensional scene and are used to locate the position of the texture map surface, that is, to accurately correspond each point on the image to the surface of the model object. Through the UV coordinate system of the two-dimensional plane, any pixel point on the image can be located.

[0078] Specifically, the virtual texture includes a plurality of virtual body blocks, and each virtual texture block may be divided according to a preset size or number. The terminal may determine the vertex coordinates of each virtual texture block according to the vertex coordinates of each vertex in the virtual texture.

[0079] In one embodiment, the three-dimensional scene includes an overall virtual texture, and multiple virtual textures in the three-dimensional scene are obtained by dividing the overall virtual texture. Each virtual texture also includes multiple virtual texture blocks. When the terminal processes the image to be rendered, it first determines the virtual texture corresponding to the image to be rendered, and then determines the vertex coordinates of the corresponding virtual texture block of the image to be rendered in the virtual texture.

[0080] like Figure 3 , which is a schematic diagram of coordinates of a virtual texture in an embodiment. The virtual texture 32 includes a plurality of virtual texture blocks 32a, and each virtual texture block 32a includes a plurality of rendering sub-blocks 32a1. Figure 3, the origin coordinates of the virtual texture 32 can be the coordinates (0,0) corresponding to the vertex in the upper left corner. The coordinates of the first virtual texture block in the upper left corner of the virtual texture 32 can be the vertex coordinates corresponding to the vertex in the upper left corner, that is, (0,0); the coordinates of the virtual texture block in the lower left corner are the vertex coordinates (0,7) corresponding to the vertex in the upper left corner; the coordinates of the virtual texture block in the upper right corner are the vertex coordinates (7,0) corresponding to the vertex in the upper left corner; the coordinates of the virtual texture block in the upper right corner are the vertex coordinates (7,7) corresponding to the vertex in the upper left corner. The coordinates of each rendering sub-block in the virtual texture block can also be the vertex coordinates corresponding to the vertex in the upper left corner of each rendering sub-block. For example, the fourth virtual texture block in the first row includes 4x4 rendering sub-blocks. The coordinates of the first rendering sub-block in the upper left corner of the virtual texture block in the virtual texture block are (0,0), and the coordinates of the last rendering sub-block in the lower right corner in the virtual texture block are (3,3).

[0081] S204, loading the physical texture corresponding to the vertex coordinates into the texture cache through the vertex shader.

[0082] It can be understood that the shader includes a vertex shader and a pixel shader, wherein the vertex shader is mainly responsible for the calculation and processing of the geometric relationship of vertices, etc., and the pixel shader is mainly responsible for the calculation and processing of the color of the fragment, etc.

[0083] Among them, the vertex shader is also called the vertex shading engine or vertex shader. The vertex shader is a processing unit used to add various special effects to a three-dimensional scene. The programmable nature of the vertex shader allows developers to adjust various special effects by loading new software instructions. Each vertex can be clearly defined by various data variables, including at least the x, y, and z coordinates of each vertex. For example, each vertex can include at least one of the data of color, initial path, material, light characteristics, etc.

[0084] Among them, the texture cache, that is, the virtual texture cache (Physical Texture), is also called the texture cache (TextureCache). It can be understood that the texture cache is actually a cache space used to store physical textures, so as to directly read the texture map data therein during the rendering process. Since virtual textures are large, the terminal hardware usually cannot directly cache virtual textures that are too large. Therefore, by caching only the physical textures corresponding to the most recently used virtual texture blocks into the texture cache, block rendering is performed based on the virtual texture during the rendering process to improve the rendering efficiency at runtime.

[0085] It is understandable that there is a mapping relationship between the virtual texture and the physical texture. For example, the corresponding relationship between the virtual texture block in the virtual texture and the corresponding physical texture can be established through coordinates in different coordinate systems.

[0086] After the terminal obtains the vertex coordinates of the virtual texture corresponding to the image to be rendered in the virtual texture, it inputs the obtained vertex coordinates into the vertex shader so that the vertex shader transforms the vertex coordinates. The vertex shader determines the physical texture corresponding to the virtual texture block according to the vertex coordinates of each virtual texture block, so as to load the physical texture into the texture cache.

[0087] Specifically, the terminal may perform coordinate conversion on the vertex coordinates of each virtual texture block through a vertex shader, so as to obtain a physical texture corresponding to each virtual texture block according to the converted coordinates. For example, the vertex shader may perform world coordinate conversion on the vertex coordinates of each virtual texture block to obtain the world coordinates corresponding to the vertices of each virtual texture block. The terminal then obtains the physical texture corresponding to each virtual texture block according to the world coordinates.

[0088] like Figure 4 FIG. 1 is a schematic diagram of a virtual texture and a physical texture in one embodiment. Figure 4 , the VirtualTexture virtual texture is divided into multiple virtual texture blocks. Take the virtual texture sample 42a in the virtual texture as an example for explanation. The grid coordinate schematic diagram 42b corresponding to the virtual texture sample 42a, the grid coordinate schematic diagram 42b is divided into multiple blocks 42b1, each block corresponds to the virtual texture block in the virtual texture sample 42a. Block 42b1 also includes multiple rendering sub-blocks 42b2, and each virtual texture block also includes multiple rendering sub-blocks. Among them, the rendering sub-block can be the grid unit of the smallest unit of image drawing. After the terminal determines the physical texture corresponding to each block 42b1 according to the vertex coordinates through the vertex shader, the physical texture is loaded into the Physical Texture cache 42c, and the texture cache 42c includes the physical texture 42c1 corresponding to each block 42b1.

[0089] S206 , determining, for each rendering sub-block in the virtual texture block corresponding to the vertex coordinate, the physical texture coordinates corresponding to each rendering sub-block in the texture cache.

[0090] It can be understood that the rendering sub-block refers to a plurality of rendering sub-blocks included in the virtual map block. Specifically, the rendering sub-block may be a texture unit for performing texture sampling and rendering processing, for example, a pixel unit.

[0091] Among them, physical texture coordinates, namely sampling coordinates or physical coordinates (Physical UV), in virtual mapping, physical texture coordinates represent the coordinates for texture sampling in the texture cache, that is, the texture sampling coordinates used to find the texture color value. Physical texture coordinates reflect the actual address of each rendering sub-block in the physical map.

[0092] The terminal loads the physical texture corresponding to the required virtual texture block in the image to be rendered into the texture cache according to the vertex coordinates, and then calculates the corresponding physical texture coordinates in the texture cache through the vertex shader.

[0093] Specifically, each virtual texture block includes corresponding vertex coordinates, and each rendering sub-block in the virtual texture block also has corresponding local vertex coordinates. The local vertex coordinates may refer to the relative position coordinates of the vertices of each rendering sub-block in the corresponding virtual texture block, for example, the vertex coordinates of the upper left corner vertex of each rendering sub-block in the virtual texture block. Specifically, the local vertex coordinates of the rendering sub-block are local virtual texture coordinates.

[0094] The terminal determines the offset of each rendering sub-block in the corresponding physical map based on the position of each rendering sub-block in each virtual map block and the starting position of the corresponding physical map, thereby calculating the physical texture coordinates of each rendering sub-block in the corresponding physical map in the map cache.

[0095] S208, passing the physical texture coordinates into the pixel shader.

[0096] The pixel shader is a set of instructions that are executed when a pixel is rendered. At each execution time, many pixels are rendered. The number of pixels depends on the resolution of the screen.

[0097] The terminal calculates the corresponding physical texture coordinates of each rendering sub-block in the virtual map block through the vertex shader, and then transfers the physical texture coordinates corresponding to each rendering sub-block from the vertex shader to the pixel shader after the corresponding physical texture coordinates are in the map cache.

[0098] For example, the terminal can pass the physical texture coordinates from the vertex shader to the pixel shader by means of attribute interpolation. It can be understood that in three-dimensional image rendering, triangles are generally used as the smallest unit for drawing. In the process of rasterization, vertex attributes need to be processed by attribute interpolation to obtain pixel attributes, and interpolation is used to fill the gaps between pixels during image transformation.

[0099] Specifically, when the terminal passes the physical texture coordinates from the vertex shader to the pixel shader, the terminal also interpolates the physical texture coordinates of the vertex attributes through the vertex shader, through the attribute interpolation transformation processing, to obtain the physical texture coordinates of the pixel attributes, and then passes the physical texture coordinates of the pixel attributes to the pixel shader.

[0100] S210, sampling texture pixels matching the physical texture coordinates from the physical texture in the texture cache through a pixel shader, and rendering the image to be rendered based on the texture pixels.

[0101] The texture pixel refers to the texture pixel value in the texture map, for example, it can be a texture color value.

[0102] It can be understood that sampling refers to the process of extracting individuals or samples from a population. Among them, sampling texture pixels can refer to the sampling coordinates obtained by mapping vertex coordinates with texture coordinates, and reading the color value at the sampling coordinates from the physical map. This process is texture sampling.

[0103] After the terminal obtains the physical texture coordinates through the pixel shader, it samples the texture pixels that match the physical texture coordinates from the physical texture in the texture cache through the pixel shader. The pixel shader then calculates the final pixel value of each pixel in the image to be rendered based on the sampled texture pixels, thereby rendering the image to be rendered.

[0104] In the traditional way, for runtime virtual mapping, the physical texture sampling coordinates for texture sampling are usually calculated in the pixel shader. However, due to the large number of texture maps required in larger scenes, streaming loading requires a large number of maps. For low-performance terminals, the speed of sampling runtime virtual mapping is slow and cannot be rendered efficiently.

[0105] In this embodiment, by calculating the physical texture coordinates in the vertex shader, the pixel shader no longer needs to calculate the physical texture coordinates. The pixel shader then directly samples the texture pixels that match the physical texture coordinates from the physical map in the map cache according to the physical texture coordinates passed in by the vertex shader. The amount of calculation of the pixel shader is effectively reduced, thereby effectively improving the rendering efficiency. Therefore, even if the rendering process is performed on a terminal or mobile device with lower performance, the image rendering method of this embodiment can make the image rendering efficiency on the terminal or mobile device with lower performance close to the rendering processing efficiency of a high-performance terminal, thereby enabling efficient image rendering processing.

[0106] In the above-mentioned image rendering method, after the terminal determines the vertex coordinates of the corresponding virtual texture block in the virtual texture of the image to be rendered, the physical texture corresponding to the vertex coordinates is loaded into the texture cache through the vertex shader; for each rendering sub-block in the virtual texture block corresponding to the vertex coordinate, the physical texture coordinates corresponding to each rendering sub-block in the texture cache are determined, thereby accurately calculating the physical texture coordinates of each rendering sub-block. The terminal then passes the physical texture coordinates to the pixel shader. Since the amount of calculation of the vertex shader during the rendering process is much less than that of the pixel shader, by calculating the physical texture coordinates in the vertex shader, the pixel shader does not need to calculate the physical texture coordinates. The pixel shader then directly samples the texture pixels matching the physical texture coordinates from the physical texture in the texture cache according to the physical texture coordinates passed in by the vertex shader, and renders the image to be rendered based on the texture pixels. This can effectively reduce the amount of calculation of the pixel shader, thereby effectively reducing the resource consumption in the image rendering process, and thus effectively improving the rendering efficiency.

[0107] In one embodiment, a physical map corresponding to a vertex coordinate is loaded into a map cache through a vertex shader, including: determining, through a vertex shader, virtual texture coordinates of a virtual map block corresponding to the vertex coordinates in a virtual texture coordinate system; obtaining a virtual texture page table; storing a mapping relationship between virtual texture coordinates and physical texture coordinates in the virtual texture page table; physical texture coordinates are coordinates of a physical map in a physical texture coordinate system; obtaining a physical map corresponding to each virtual map block according to the corresponding physical texture coordinates of the virtual texture coordinates in the virtual texture page table; and loading the obtained physical map into the map cache.

[0108] It is understandable that each 3D vertex in a 3D scene has a corresponding 2D texture point, that is, a correspondence is pre-established between the 3D vertex and the 2D vertex. By setting the texture coordinates of each vertex, the required part of the texture map can be mapped to the geometric body in the 3D scene. The texture coordinates determine which part of the texture map is mapped to the triangle.

[0109] It can be understood that the coordinate systems in graphics are relative to each other. For example, the coordinate system can include the world coordinate system, the texture coordinate system, the screen coordinate system, etc. Among them, the texture coordinate system consists of the U axis representing the horizontal direction of the image and the V axis representing the vertical direction of the image. The coordinate (u, v) specifies an element on the texture map.

[0110] The virtual texture coordinate system refers to the two-dimensional texture coordinate system corresponding to the virtual texture map, which is used to locate the position of each element in the virtual texture map. The physical texture coordinate system refers to the two-dimensional texture coordinate system corresponding to the physical texture map, which is used to locate the position of each element in the physical texture map.

[0111] Among them, the virtual texture page table, namely Page Table, is also called indirect texture (Indirection Table). The virtual texture page table stores the mapping relationship between virtual texture coordinates and physical texture coordinates. Specifically, the virtual texture page table stores the mapping relationship between the virtual texture coordinates corresponding to the vertices of each virtual body tile and the physical texture coordinates of the starting position of the corresponding physical tile.

[0112] After the terminal determines the vertex coordinates of the corresponding virtual texture block in the virtual texture of the image to be rendered, the vertex coordinates are input into the vertex shader, and the vertex coordinates are converted by the vertex shader. Specifically, the vertex shader first determines the virtual texture coordinates of the virtual texture block corresponding to the vertex coordinates in the virtual texture coordinate system.

[0113] Then, the terminal obtains the virtual texture page table through the vertex shader, and searches for the corresponding physical texture coordinates in the virtual texture page table according to the virtual texture coordinates. The terminal then obtains the physical texture corresponding to each virtual texture block according to the corresponding physical texture coordinates found in the virtual texture page table by the virtual texture coordinates. Specifically, the terminal can obtain the texture data corresponding to the three-dimensional scene and store the texture data on the disk. After the terminal calculates the required physical texture, it reads the required physical texture from the texture data on the disk and loads the obtained physical texture into the texture cache.

[0114] like Figure 5 As shown in the figure, in one embodiment, the left figure is a virtual texture, and the virtual texture is divided into multiple virtual texture blocks, such as virtual texture block 5a. PageTable is a virtual texture page table, and the virtual texture page table stores a mapping relationship between a virtual texture block and a physical texture block, that is, the physical texture corresponding to each virtual texture block can be found from the virtual texture page table. For example, virtual texture block 5a can find the corresponding physical texture block 5b in the virtual texture page table. And other virtual texture blocks can find the corresponding physical texture blocks in the virtual texture page table.

[0115] In this embodiment, since the virtual texture page table stores the mapping relationship between the virtual texture coordinates and the physical texture coordinates, the physical texture corresponding to the virtual texture block can be accurately determined by searching the corresponding physical texture coordinates in the virtual texture page table according to the virtual texture coordinates.

[0116] In one embodiment, in a virtual texture coordinate system, determining the virtual texture coordinates of a virtual map block corresponding to the vertex coordinates includes: determining the world coordinates of the virtual map block corresponding to the vertex coordinates; and determining the virtual texture coordinates of the virtual map block in the virtual texture coordinate system based on the world coordinates of the virtual map block.

[0117] It is understood that the world coordinates refer to the coordinates in the world space coordinate system in the three-dimensional scene. Among them, the world coordinates of each vertex in the three-dimensional scene are fixed. Therefore, the coordinates of each vertex can be converted by taking the world coordinates as a reference.

[0118] When calculating the virtual texture coordinates of each virtual tile, the terminal can determine the virtual texture coordinates of each virtual tile based on the world coordinates corresponding to the vertex coordinates of each virtual tile. Specifically, the terminal first obtains the vertex coordinates of each virtual tile, and then calculates the world coordinates of the virtual tile corresponding to the vertex coordinates according to the world coordinate transformation matrix.

[0119] The terminal then calculates the virtual texture coordinates of each virtual texture block in the virtual texture coordinate system according to the world coordinates corresponding to each virtual texture block, the world origin in the virtual texture, and the size covered by the virtual texture in the world space coordinate system.

[0120] For example, the terminal can subtract the world origin in the virtual texture from the world coordinates corresponding to each virtual texture block to obtain the offset between the world coordinates corresponding to each virtual texture block and the world origin. Then, based on the ratio of the obtained offset to the size covered by the virtual texture in the world space coordinate system, the virtual texture coordinates of each virtual texture block in the virtual texture coordinate system can be accurately calculated.

[0121] In one embodiment, a physical texture corresponding to each virtual texture block is obtained according to the physical texture coordinates corresponding to the virtual texture coordinates in the virtual texture page table, including: determining the physical texture coordinates of the physical texture corresponding to each virtual texture block in the virtual texture page table according to the virtual texture coordinates and the virtual texture size of the virtual texture; and obtaining the physical texture corresponding to each virtual texture block according to the physical texture coordinates.

[0122] The virtual texture size of the virtual texture refers to the size of a single virtual texture block in the virtual texture coordinate system.

[0123] When determining the physical texture corresponding to each virtual texture block, the terminal can calculate the physical texture coordinates of the physical texture corresponding to each virtual texture block based on the virtual texture coordinates of each virtual texture block in the virtual texture coordinate system, the virtual texture size of each virtual texture block in the virtual texture coordinate system, and the size of each virtual texture block in the world space coordinate system.

[0124] Specifically, the terminal first determines the integer coordinates of the corresponding virtual texture page table according to the virtual texture coordinates of each virtual texture block in the virtual texture coordinate system and the virtual texture size of each virtual texture block in the virtual texture coordinate system. Then, according to the integer coordinates of the virtual texture page table and the size of each virtual texture block in the world space coordinate system, the physical texture coordinates of the physical texture corresponding to each virtual texture block in the virtual texture page table are calculated. The terminal then reads the physical texture corresponding to each virtual texture block from the texture data on the disk according to the physical texture coordinates, and loads the obtained physical texture into the texture cache.

[0125] In this embodiment, the physical texture coordinates corresponding to the virtual texture block are searched in the virtual texture page table according to the virtual texture coordinates, so that the physical texture corresponding to the virtual texture block can be accurately determined. And by loading the physical texture into the texture cache, the pixel shader can accurately perform texture sampling from the texture cache.

[0126] In one embodiment, for each rendering sub-block in a virtual texture block corresponding to the vertex coordinates, determining the physical texture coordinates corresponding to each rendering sub-block in the texture cache includes: performing scaling transformation processing on the vertex coordinates of each rendering sub-block in the virtual texture block according to a scaling transformation matrix to obtain local virtual texture coordinates of each rendering sub-block after the scaling transformation; determining the starting physical texture coordinates corresponding to the physical texture according to the world coordinates corresponding to the virtual texture block and the virtual texture coordinates corresponding to the virtual texture block in the virtual texture page table; determining the physical texture coordinates corresponding to each rendering sub-block in the texture cache according to the local virtual texture coordinates of each rendering sub-block and the starting physical texture coordinates corresponding to the physical texture.

[0127] It can be understood that coordinate transformation is mapping from one coordinate system to another coordinate system. In a three-dimensional coordinate system, the model is first converted from the vertices in the model space to the world space by performing a world space transformation on the vertices.

[0128] In 3D graphics, geometric transformations include translation, scaling, rotation, etc. Scaling refers to enlarging or reducing the model, that is, enlarging or reducing each vertex on the model, so that the vertex coordinate value becomes larger or smaller.

[0129] Vertex processing refers to all calculations on each vertex of each element being rendered. The transformation matrix of the vertex is generally a floating-point matrix, which generally only performs translation, rotation or scaling. Matrix transformation can also be used to implement the hierarchy of the scene. The hierarchy of the scene can be used to draw connected character structures or relatively positioned models. Vertex processing includes: world transformation, texture coordinate calculation, texture transformation, visual transformation, vertex fogging, view frustum clipping and viewport mapping. The results of vertex processing can include screen space position, color, texture coordinates and other result data.

[0130] The scaling transformation matrix refers to the matrix corresponding to the virtual texture for scaling transformation processing. The starting physical texture coordinates of the physical texture may refer to the starting coordinate addresses of each physical texture, that is, the coordinates of the starting origin of a single physical texture.

[0131] The terminal determines the physical map corresponding to each vertex coordinate through the vertex shader, and after loading the corresponding physical map into the map cache, further calculates the physical texture coordinates corresponding to each vertex coordinate based on the vertex coordinates.

[0132] Specifically, the terminal first performs scaling transformation processing on the vertex coordinates of each rendering sub-block in the virtual map block according to a preset scaling transformation matrix through a vertex shader, thereby effectively obtaining the local virtual texture coordinates of each rendering sub-block after the scaling transformation. For example, the terminal can directly multiply the vertex coordinates of each rendering sub-block by the scaling transformation matrix to obtain the local virtual texture coordinates of each rendering sub-block after the scaling transformation.

[0133] The terminal then determines the starting physical texture coordinates corresponding to the physical map based on the world coordinates corresponding to the virtual map block and the virtual texture coordinates corresponding to the virtual map block in the virtual texture page table. Specifically, the terminal can first determine the integer coordinates of the corresponding virtual texture page table based on the virtual texture coordinates of each virtual map block in the virtual texture coordinate system and the virtual map size of each virtual map block in the virtual texture coordinate system. Then, based on the integer coordinates of the virtual texture page table and the size of each virtual map block in the world space coordinate system, the starting physical texture coordinates of the physical map corresponding to each virtual map block in the virtual texture page table are calculated.

[0134] The terminal further calculates the physical texture coordinates corresponding to each rendering sub-block in the texture cache through a vertex shader based on the starting physical texture coordinates corresponding to the physical map and the difference between the local virtual texture coordinates of each rendering sub-block and the starting physical texture coordinates, thereby being able to accurately calculate the physical texture coordinates corresponding to each rendering sub-block.

[0135] In one embodiment, the physical texture coordinates corresponding to each rendering sub-block in the texture cache are determined according to the local virtual texture coordinates of each rendering sub-block and the starting physical texture coordinates corresponding to the physical texture, including: aligning each virtual texture block with the matching physical texture according to the starting virtual texture coordinates of each virtual texture block and the starting physical texture coordinates corresponding to each physical texture; determining the offset of each rendering sub-block in the virtual texture block according to the starting virtual texture coordinates of the virtual texture block and the local virtual texture coordinates of each rendering sub-block; determining the physical texture coordinates corresponding to each rendering sub-block in the texture cache according to the starting physical texture coordinates and the offset corresponding to the physical texture.

[0136] It can be understood that the offset refers to the distance between the actual address of the storage unit and the segment address of the segment where it is located, also known as the intra-segment offset or effective address. The offset of each rendering sub-block in the virtual texture block represents the distance between the local virtual texture coordinates of each rendering sub-block and the starting virtual texture coordinates of the virtual texture block.

[0137] The rendering sub-block may be the smallest unit for performing drawing processing during the rendering process, for example, it may be a pixel grid or a pixel grid corresponding to a pixel point.

[0138] Each virtual texture block includes a corresponding starting virtual texture coordinate, that is, the starting point coordinate of each virtual texture block itself. It can be understood that the initial virtual texture has a corresponding starting point coordinate, and the virtual texture block has a corresponding position in the virtual texture, that is, the position coordinates of each virtual texture block in the virtual texture can be determined according to the vertex coordinates corresponding to the vertices of each virtual texture block.

[0139] The terminal determines the physical texture corresponding to each virtual texture block according to the vertex coordinates of the virtual texture block, and loads the physical texture into the texture cache.

[0140] The terminal then performs scaling transformation processing on the vertex coordinates of each rendering sub-block in the virtual map block according to the preset scaling transformation matrix to obtain the local virtual texture coordinates of each rendering sub-block after scaling transformation. Then the terminal determines the starting physical texture coordinates corresponding to the physical map according to the world coordinates corresponding to the virtual map block and the virtual texture coordinates corresponding to the virtual map block in the virtual texture page table.

[0141] like Figure 6As shown, a virtual texture in an embodiment, the virtual texture 62 includes multiple virtual texture blocks, each virtual texture block includes multiple rendering sub-blocks, and the local virtual texture coordinates of each rendering sub-block can be the vertex coordinates of the upper left corner vertex of each rendering sub-block in the corresponding virtual texture block. Taking the virtual texture block 6a as an example, the vertex coordinates of the virtual texture block 6a are the vertex coordinates of the upper left corner vertex in the corresponding virtual texture, that is, (0,3). The coordinates of the rendering sub-block 6a1 in the virtual texture block 6a are (3,3).

[0142] The terminal further aligns each virtual texture block with the corresponding physical texture according to the starting virtual texture coordinates of each virtual texture block and the starting physical texture coordinates of the corresponding physical texture. Since the texture range of each virtual texture block is consistent with that of the corresponding physical texture, the terminal can then determine the corresponding physical texture coordinates of each rendering sub-block in the texture cache according to the offset of each rendering sub-block in the virtual texture block.

[0143] Specifically, the terminal determines the offset of each rendering sub-block in the virtual texture block according to the starting virtual texture coordinates of the virtual texture block and the local virtual texture coordinates of each rendering sub-block. For example, the terminal can obtain the offset of each rendering sub-block in the virtual texture block according to the ratio of the local virtual texture coordinates of each rendering sub-block after scaling transformation and the size of a single virtual texture block in the virtual texture in the world space.

[0144] The terminal then determines the physical texture coordinates corresponding to each rendering sub-block in the texture cache according to the starting physical texture coordinates and offset corresponding to the physical texture. Specifically, the physical texture coordinates are calculated using the following formula:

[0145] LPInC = LP*LS;

[0146] Among them, LP represents the local vertex coordinates of each rendering sub-block in the virtual map block; LS represents the scaling transformation matrix; LPInC represents the local virtual texture coordinates after scaling transformation.

[0147] BSWP = SP * WM;

[0148] Among them, SP represents the vertex coordinates of each virtual texture block; WM represents the world transformation matrix; BSWP represents the world coordinates corresponding to each virtual texture block.

[0149] VTUV=(BSWP-VTOrg) / VTSize;

[0150] Among them, VTOrg represents the world origin coordinates of the virtual map, that is, the coordinates of the upper left vertex; VTSize represents the size covered by the virtual map in the world coordinate system; VTUV represents the virtual texture coordinates of each virtual map block.

[0151] VTPageCoord=floorToInt(VTUV / VTUVTileSize);

[0152] Among them, VTUVTileSize represents the size of a single virtual map block in the virtual texture space; VTPageCoord represents the corresponding integer coordinates in PageTable.

[0153] PhysicalStartUV=PageTableTexture.Load(VTPageCoord);

[0154] Among them, PageTableTexture represents the physical map data in PageTable; PhysicalStartUV represents the starting physical texture coordinate address corresponding to the physical map.

[0155] PhysicalUV=PhysicalStartUV+(LPInC / VTWorldTileSize);

[0156] Among them, PhysicalUV is the physical texture coordinates corresponding to each rendering sub-block in the texture cache that is finally calculated.

[0157] The terminal can accurately calculate the corresponding physical texture coordinates of each rendering sub-block in the physical texture in the texture cache by adding the starting physical texture coordinates of the physical texture to the offset of each rendering sub-block in the virtual texture block.

[0158] In one embodiment, for each rendering sub-block in the virtual texture block corresponding to the vertex coordinate, determining the physical texture coordinates corresponding to each rendering sub-block in the texture cache includes: determining the physical texture coordinates corresponding to each rendering sub-block in the texture cache for each rendering sub-block in the virtual texture block corresponding to the vertex coordinate through a sampling node in a vertex shader. Passing the physical texture coordinates into the pixel shader includes: passing the physical texture coordinates into the pixel shader through a sampling node in the vertex shader.

[0159] The sampling node refers to a processing node deployed in the vertex shader for calculating the physical texture coordinates, so that after the vertex shader obtains the vertex coordinates, the physical texture coordinates can be directly calculated in the vertex shader.

[0160] It can be understood that the vertex shader includes a vertex factory function, for example, the vertex shader in the Unreal Engine engine includes a Vertex Factory function, which is mainly responsible for transferring vertex data of a specific mesh type from the CPU (Central Processing Unit) to the GPU (Graphics Processing Unit). Then, in the pixel shader, rendering is performed based on the incoming vertex data. Among them, the sampling node can be one of the vertex factory functions in the vertex factory function.

[0161] For example, in Unreal Engine, the vertex factory function corresponding to the sampling node may be specifically FVertexFactoryInterpolantsVSToPS, which is used to transfer vertex-related data from the vertex shader to the vertex factory data of the pixel shader.

[0162] After the terminal obtains the vertex coordinates of each virtual map block, it inputs the vertex coordinates into the vertex shader, and performs coordinate transformation on the vertex coordinates through the sampling nodes in the vertex shader to calculate the physical texture coordinates corresponding to each rendering sub-block in the map cache. The terminal then writes the calculated physical texture coordinates into the preset structure in the sampling node of the vertex shader. The terminal then passes the physical texture coordinates from the vertex shader to the pixel shader according to the preset structure, thereby being able to accurately and effectively transmit the physical texture coordinates to the pixel shader.

[0163] In one embodiment, the physical texture coordinates are passed into the pixel shader via the sampling nodes in the vertex shader, including: interpolating the vertex attributes corresponding to the physical texture coordinates via the sampling nodes in the vertex shader to obtain the physical texture coordinates of the pixel attributes; and passing the physical texture coordinates of the pixel attributes into the pixel shader.

[0164] Among them, interpolation is a process or method of inferring new data points within a range through known, discrete data points. Interpolation is an important method for approximating discrete functions. It can estimate the approximate value of a function at other points by the value of the function at a finite number of points.

[0165] It can be understood that in the vertex processing stage, the input data usually only has vertex information. In the process of rasterization, the vertex attributes need to be processed by attribute interpolation to obtain pixel attributes. Specifically, by scanning and transforming part of the vertex information of the triangle inside the triangle, the attribute information of each pixel inside the triangle is interpolated, so that each pixel has attribute information such as position, color, texture coordinates, etc., which can effectively fill the gaps between pixels during image transformation.

[0166] Among them, the sampling node in the vertex shader can include a corresponding preset structure. It can be understood that the structure refers to a data structure constructed using a predefined data type and a preset data organization method, which is usually used to encapsulate some attributes to form a new type to simplify operations and data reading. The preset structure in this embodiment can be a data structure used to support reading physical texture coordinates.

[0167] The preset structure may include a texture sampling coordinate attribute. The texture sampling coordinate attribute is used to indicate that the physical texture coordinates in the preset structure need to be interpolated.

[0168] When the terminal passes the physical texture coordinates from the vertex shader to the pixel shader, it needs to go through attribute interpolation processing to pass the physical texture coordinates into the pixel shader.

[0169] Specifically, the terminal calculates the physical texture coordinates corresponding to each rendering sub-block in the texture cache through the vertex shader, and the coordinate attributes of the physical texture coordinates at this time are vertex attributes. After the terminal writes the calculated physical texture coordinates into the preset structure in the sampling node of the vertex shader, it interpolates the vertex attributes corresponding to the physical texture coordinates according to the texture sampling coordinate attributes in the preset structure, so as to interpolate the physical texture coordinates of the vertex attributes and obtain the physical texture coordinates of the pixel attributes. Then the terminal passes the physical texture coordinates from the vertex shader to the pixel shader, so that the pixel shader can directly process the physical texture coordinates of the pixel attributes, and further sample the texture pixels matching the physical texture coordinates from the physical map in the texture cache according to the physical texture coordinates of the pixel attributes, and render the image to be rendered based on the sampled texture pixels.

[0170] In this embodiment, by deploying the texture sampling coordinate attribute in the preset structure corresponding to the sampling node, the physical texture coordinates in the preset structure can be effectively interpolated, and then the physical texture coordinates can be passed into the pixel shader.

[0171] In one embodiment, Figure 7 As shown, another image rendering method is provided, which specifically includes the following steps:

[0172] S702, determining vertex coordinates of a virtual texture block corresponding to the image to be rendered in the virtual texture.

[0173] S704, loading the physical texture corresponding to the vertex coordinates into the texture cache through the vertex shader.

[0174] S706 , for each rendering sub-block in the virtual texture block corresponding to the vertex coordinate, determine the physical texture coordinates corresponding to each rendering sub-block in the texture cache.

[0175] S708 , determining texture request parameters corresponding to each virtual texture block according to virtual texture coordinates corresponding to each virtual texture block through a vertex shader.

[0176] S710, passing the physical texture coordinates and texture request parameters to the pixel shader through the vertex shader.

[0177] S712, sampling, through a pixel shader, texture pixels matching the physical texture coordinates from the physical texture in the texture cache according to the texture request parameters.

[0178] The texture request parameter is request parameter information indicating the virtual map data that needs to be requested for the current image to be rendered, and can be used to update the required virtual texture data.

[0179] After the terminal obtains the vertex coordinates of the corresponding virtual texture block in the virtual texture of the image to be rendered, it transforms the vertex coordinates through the vertex shader. The vertex shader determines the physical texture corresponding to the virtual texture block according to the vertex coordinates of each virtual texture block, so as to load the physical texture into the texture cache.

[0180] The terminal then determines the physical texture coordinates corresponding to each rendering sub-block in the virtual texture block corresponding to the vertex coordinate through the vertex shader. In addition, the terminal also determines the texture request parameters corresponding to each virtual texture block according to the virtual texture coordinates corresponding to each virtual texture block through the vertex shader.

[0181] The virtual texture coordinates corresponding to the virtual map block may specifically be the vertices of the virtual map block, and the virtual texture coordinates in the virtual map under the virtual texture coordinate system.

[0182] Specifically, the terminal may first determine the integer coordinates of the corresponding virtual texture page table according to the virtual texture coordinates of each virtual texture block in the virtual texture coordinate system and the virtual texture size of each virtual texture block in the virtual texture coordinate system, and then obtain the texture request parameters corresponding to each virtual texture block according to the integer coordinates of the virtual texture page table.

[0183] After the terminal calculates the required physical texture coordinates and texture request parameters through the vertex shader, the physical texture coordinates and texture request parameters are passed into the pixel shader. Specifically, the vertex shader of the terminal can write the physical texture coordinates and texture request parameters into a preset structure. The preset structure includes texture sampling coordinate attributes and texture request parameter attributes. Among them, the texture sampling coordinate attribute is used to indicate that the physical texture coordinates in the preset structure need to be interpolated. The texture request parameter attribute is used to pass the texture request parameters into the pixel shader.

[0184] After the pixel shader obtains the physical texture coordinates and texture request parameters input by the vertex shader, it samples the texture pixels that match the physical texture coordinates from the physical texture in the texture cache according to the texture request parameters. When the level of the required virtual texture data changes, the corresponding virtual texture block is updated according to the texture request parameters to further sample the required texture pixels according to the calculated physical texture coordinates, so that the image to be rendered can be rendered accurately and efficiently.

[0185] In one embodiment, texture request parameters corresponding to each virtual texture block are determined based on virtual texture coordinates corresponding to each virtual texture block, including: correcting the virtual texture coordinates corresponding to each virtual texture block according to the size of the virtual texture page in the virtual texture page table to obtain corrected virtual texture coordinates; and generating texture request parameters corresponding to each virtual texture block based on the corrected virtual texture coordinates.

[0186] It can be understood that the virtual texture page table includes multiple virtual texture pages, each of which includes a corresponding size. The virtual texture page in the virtual texture page table corresponds to the virtual texture block in the virtual map. According to the size of the virtual texture page, the texture request parameter corresponding to the virtual texture block of the corresponding texture level can be determined.

[0187] For example, when the image to be rendered is a continuous image frame, it is necessary to continuously update the texture map corresponding to the required texture level according to the change of the viewing angle in the three-dimensional scene.

[0188] Specifically, the terminal can correct the virtual texture coordinates corresponding to each virtual texture block according to the virtual texture coordinates corresponding to each virtual texture block and the size of the virtual texture page in the current virtual texture page table to obtain the corrected virtual texture coordinates. For example, the terminal can correct the virtual texture coordinates according to the addressing mode of the virtual texture coordinates and the size of the virtual texture page in the virtual texture page table. Then the terminal updates the texture request parameters corresponding to each virtual texture block according to the corrected virtual texture coordinates, so that the texture request parameters corresponding to the virtual texture block of the required texture level can be accurately generated.

[0189] In one embodiment, texture request parameters corresponding to each virtual map block are generated according to the corrected virtual texture coordinates, including: determining the texture level corresponding to the virtual texture page according to the corrected virtual texture coordinates; determining the pixel coordinates of the virtual texture page corresponding to each virtual map block according to the corrected virtual texture coordinates and the texture level; and generating texture request parameters corresponding to each virtual map block according to the pixel coordinates.

[0190] It is understood that the virtual map may include texture map data corresponding to multiple texture levels, for example, may include texture map data corresponding to multiple texture levels generated based on Mipmap (multi-level mipmap), wherein the precision of the texture map data corresponding to each texture level is different.

[0191] For example, Mip Level 0 is the highest precision level; Mip Level 1 is half the width and height of the image at level 0; Mip Level n is half the width and height of the image at the previous level. By determining the correct texture level, the correct texture request parameters can be determined, so that the required texture pixels can be sampled accurately.

[0192] Specifically, the terminal obtains the corrected virtual texture coordinates according to the virtual texture coordinates corresponding to each virtual map block and the size of the virtual texture page in the current virtual texture page table. Then, according to the corrected virtual texture coordinates, the texture level corresponding to the required virtual texture page is determined. Specifically, the terminal can determine the texture level corresponding to the virtual texture page according to the corrected virtual texture coordinates.

[0193] The terminal then determines the pixel coordinates of each virtual map block corresponding to the virtual texture page based on the corrected virtual texture coordinates and texture level, and generates texture request parameters corresponding to each virtual map block based on the texture level and pixel coordinates, thereby being able to accurately generate texture request parameters corresponding to the virtual map block of the required texture level.

[0194] For example, the terminal may correct the virtual texture coordinates according to the addressing mode of the virtual texture coordinates, and then calculate the pixel coordinates corresponding to the virtual texture coordinates in the virtual texture page according to the number and size of the virtual texture pages in the current virtual map and the calculated virtual texture coordinates.

[0195] In one embodiment, Figure 8 As shown, another image rendering method is provided, which specifically includes the following steps:

[0196] S802: When the image to be rendered includes a terrain scene area, determine vertex coordinates of a corresponding virtual map block of the terrain scene area in the virtual map.

[0197] S804, loading the physical texture corresponding to the vertex coordinates into the texture cache through the vertex shader.

[0198] S806 , for each rendering sub-block in the virtual texture block corresponding to the vertex coordinate, determine the physical texture coordinates corresponding to each rendering sub-block in the texture cache.

[0199] S808, passing the physical texture coordinates to the pixel shader through the vertex shader.

[0200] S810, sampling texture pixels matching the physical texture coordinates from the physical texture in the texture cache through a pixel shader, and rendering a terrain scene area in the image to be rendered based on the texture pixels.

[0201] It can be understood that the image to be rendered includes image areas of various types of scene objects in a three-dimensional scene. For example, the scene object may include at least one of three-dimensional terrain, houses, trees, people, and the like.

[0202] The terrain scene area in the image to be rendered may be an area corresponding to the three-dimensional terrain in the three-dimensional scene to be displayed. It is understandable that the image to be rendered may include only the terrain scene area, or may include the terrain scene area and areas corresponding to other scene objects. This application does not limit this.

[0203] For a large 3D terrain, it is usually necessary to combine multiple terrain texture images to obtain a complete 3D terrain. The vertex coordinates of the virtual texture block corresponding to the terrain scene area can be the vertex coordinates corresponding to each mesh vertex generated in advance based on the mesh vertices in the terrain mesh.

[0204] When the image to be rendered includes a terrain scene area, the terminal obtains the vertex coordinates of the corresponding virtual texture block of the terrain scene area in the virtual texture, and inputs the vertex coordinates into the vertex shader. The vertex shader then determines the physical texture corresponding to the vertex coordinates and loads the physical texture into the texture cache.

[0205] The terminal determines the physical texture coordinates of each rendering sub-block in the texture cache through the vertex shader for each rendering sub-block in the virtual texture block corresponding to the vertex coordinate, and then passes the physical texture coordinates to the pixel shader through the vertex shader.

[0206] The terminal then samples texture pixels matching the physical texture coordinates from the physical texture in the texture cache through a pixel shader, and renders the terrain scene area in the image to be rendered based on the texture pixels.

[0207] In one of the embodiments, when the image to be rendered also includes areas corresponding to other scene objects, the terminal obtains the vertex coordinates of the virtual map blocks corresponding to the other scene object areas and inputs them into the vertex shader. The vertex coordinates are then transformed by the vertex shader to obtain the vertex data after the vertex transformation. The vertex data after the vertex transformation is then passed to the pixel shader through the vertex shader, so that the pixel shader determines the physical map of the other scene objects corresponding to the vertex data based on the transformed vertex data, and loads the physical map into the map cache. The pixel shader then calculates the physical texture coordinates corresponding to the other scene object areas in the physical map of the other scene objects based on the transformed vertex data.

[0208] The terminal then samples texture pixels matching other scene object areas from the physical texture in the texture cache through a pixel shader according to the physical texture coordinates. The pixel shader then renders the terrain scene area and other scene object areas in the image to be rendered based on the sampled texture pixels matching the terrain scene area and the texture pixels matching other scene object areas.

[0209] In one embodiment, the above image rendering method is applicable to a three-dimensional scene with a fixed top-down perspective. Specifically, the virtual observation point in the three-dimensional scene can be moved arbitrarily, and the field of view can be enlarged or reduced arbitrarily. As a result, texture maps with under-sampled textures will not be generated, thereby effectively ensuring the accuracy of image rendering.

[0210] In this embodiment, by separating the terrain scene areas, the calculation process of the physical texture coordinates of the terrain scene areas is implemented in the vertex shader according to the unique properties of the terrain scene areas, thereby effectively reducing the calculation amount of the pixel shader without affecting the rendering processing of other scene object areas, thereby effectively reducing the resource consumption in the image rendering process, and then effectively improving the rendering efficiency.

[0211] In a specific embodiment, Fig. 9 The figure shows a flow chart for drawing a terrain virtual map. When the terminal starts rendering, it obtains vertex data corresponding to the image to be rendered, inputs the vertex data into the vertex shader, and performs terrain vertex processing through the vertex shader. Specifically, the terminal uses the vertex shader to transform the vertex coordinates of the virtual map block in the virtual map corresponding to the image to be rendered in the vertex data based on the world coordinates of each vertex, and then determines the physical map corresponding to each virtual map block based on the transformed vertex coordinates, so as to load the physical map into the map cache.

[0212] The terminal then calculates the Physical UV (physical texture coordinates) and Request (texture request parameters) through the vertex shader, and then passes the interpolated physical texture coordinates and texture request parameters to the pixel shader. The terminal pixel shader samples the texture pixels in the physical map from the map cache according to the interpolated physical texture coordinates, and then performs other pixel shading operations based on the sampled texture pixels to render the image to be rendered. Finally, the pixels of the rendered image are output to the terminal display for display.

[0213] In this embodiment, for the terrain virtual map, the required physical texture coordinates are calculated by the vertex shader and passed to the pixel shader, so that the pixel shader no longer needs to calculate the physical texture coordinates. This ensures that the physical texture coordinates used for texture sampling are accurately calculated while effectively reducing the amount of calculation of the pixel shader, thereby enabling efficient and accurate image rendering of the terrain scene.

[0214] The present application also provides an application scenario, which is an open-world three-dimensional game scene, and the game scene applies the above-mentioned image rendering method. Specifically, the open-world three-dimensional game scene includes an open-world terrain, wherein the open-world terrain is an open-world mission space, and generally includes a map with a larger area corresponding to the open-world terrain, including a pre-drawn terrain texture map corresponding to the open-world terrain. Since the open-world terrain has a large range, a large number of texture map blocks after the terrain texture map is segmented need to be loaded, so the open-world terrain has high requirements for the accuracy of the terrain texture map.

[0215] The terminal is deployed with a 3D game application corresponding to the 3D game scene, and the terminal can obtain the game texture resources generated in advance by the game editor through the 3D game application. When the terminal runs the 3D game application, it obtains the virtual texture map and corresponding vertex data corresponding to the image to be rendered, and determines the vertex coordinates of the corresponding virtual map block in the virtual map of the image to be rendered, and inputs the vertex coordinates into the vertex shader. The terminal then determines the physical map corresponding to the virtual map block according to the vertex coordinates through the vertex shader to load the physical map into the map cache.

[0216] The terminal further determines the physical texture coordinates corresponding to each rendering sub-block in the texture cache for each rendering sub-block in the virtual texture block corresponding to the vertex coordinate. The terminal then passes the calculated physical texture coordinates to the pixel shader through the vertex shader. The terminal then samples the texture pixels that match the physical texture coordinates from the physical texture in the texture cache through the pixel shader, and renders the image to be rendered based on the texture pixels.

[0217] In one embodiment, the image to be rendered includes a terrain scene area and other scene object areas, wherein the game texture resources include terrain texture map data corresponding to the open world terrain in the three-dimensional game scene, and texture map data corresponding to other scene objects in the three-dimensional game scene.

[0218] Specifically, for the terrain scene area in the image to be rendered, the terminal obtains the virtual terrain texture map data and terrain location data corresponding to the terrain scene area, and determines the terrain vertex coordinates of the corresponding virtual terrain map block in the virtual terrain map of the terrain scene area, and inputs the terrain vertex coordinates into the vertex shader. The terrain physical map corresponding to the virtual terrain map block is determined by the vertex shader, and the terrain physical map is loaded into the map cache. Then, the physical texture coordinates corresponding to the terrain scene area are calculated by the vertex shader and passed to the pixel shader.

[0219] For other scene object areas in the image to be rendered, the terminal performs vertex coordinate transformation on the vertex coordinates through the vertex shader, and the vertex shader then passes the transformed vertex data to the pixel shader, so that the pixel shader calculates the corresponding physical texture coordinates of other scene object areas in the physical map of other scene objects based on the transformed vertex data.

[0220] The terminal then uses a pixel shader to sample matching texture pixels from the corresponding physical texture in the texture cache according to the physical texture coordinates corresponding to the terrain scene area and other scene objects, and renders the image to be rendered based on the texture pixels. By separating the terrain scene area, the calculation process of the physical texture coordinates of the terrain scene area is implemented in the vertex shader according to the unique properties of the terrain scene area, which can effectively reduce the amount of calculation of the pixel shader, thereby effectively improving the efficiency of image rendering.

[0221] In one embodiment, the three-dimensional game scene is a three-dimensional game scene with a fixed viewing angle, for example, the fixed viewing angle may be a fixed top-down viewing angle. Since the fixed viewing angle does not produce too small texture sampling, when the above-mentioned image rendering method is adopted, the resource consumption in the image rendering process can be effectively reduced, and even if multi-level asymptotic texture mapping is not used, there will be no obvious noise. Therefore, even on a mobile terminal with lower performance, it is possible to efficiently render high-precision open world terrain and multi-layer mixed terrain materials, thereby effectively improving the image rendering efficiency.

[0222] The present application also provides an application scenario, which is a three-dimensional environment demonstration scene, such as a tourism environment demonstration scene, a building demonstration scene, etc. The three-dimensional environment demonstration scene applies the above-mentioned image rendering method. For the three-dimensional environment demonstration scenes in various environments, texture map data corresponding to various three-dimensional scenes can be obtained in advance.

[0223] When displaying a 3D environment demonstration scene, the terminal obtains the virtual texture map and corresponding vertex data corresponding to the image to be rendered, determines the vertex coordinates of the corresponding virtual texture block in the virtual texture of the image to be rendered, and inputs the vertex coordinates into the vertex shader. The terminal then determines the physical texture corresponding to the virtual texture block according to the vertex coordinates through the vertex shader to load the physical texture into the texture cache.

[0224] The terminal further determines the physical texture coordinates corresponding to each rendering sub-block in the texture cache for each rendering sub-block in the virtual texture block corresponding to the vertex coordinates. The terminal then passes the calculated physical texture coordinates to the pixel shader through the vertex shader. The terminal then samples the texture pixels that match the physical texture coordinates from the physical map in the texture cache through the pixel shader, and renders the image to be rendered based on the texture pixels. By calculating the required physical texture coordinates in the vertex shader and passing them to the pixel shader, the pixel shader no longer needs to calculate the physical texture coordinates, thereby effectively reducing the amount of calculation of the pixel shader, thereby effectively improving the image rendering efficiency.

[0225] It should be understood that although Figure 2 , 7 The steps in the flowchart of 8 are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 2 , 7 , at least part of the steps in 8 may include multiple steps or multiple stages. These steps or stages are not necessarily performed at the same time, but can be performed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed in turn or alternately with other steps or at least part of the steps or stages in other steps.

[0226] In one embodiment, Fig.10 As shown, an image rendering device 1000 is provided. The device can adopt a software module or a hardware module, or a combination of the two to become a part of a computer device. The device specifically includes: a data acquisition module 1002, a physical texture coordinate determination module 1004, a data transmission module 1006 and an image rendering module 1008, wherein:

[0227] The data acquisition module 1002 is used to determine the vertex coordinates of the corresponding virtual texture block of the image to be rendered in the virtual texture; and load the physical texture corresponding to the vertex coordinates into the texture cache through the vertex shader.

[0228] The physical texture coordinate determination module 1004 is used to determine the physical texture coordinates corresponding to each rendering sub-block in the texture cache for each rendering sub-block in the virtual texture block corresponding to the vertex coordinates.

[0229] The data transmission module 1006 is used to transmit the physical texture coordinates to the pixel shader.

[0230] The image rendering module 1008 is used to sample texture pixels matching the physical texture coordinates from the physical texture in the texture cache through a pixel shader, and render the image to be rendered based on the texture pixels.

[0231] In one embodiment, the data acquisition module 1002 is also used to determine the virtual texture coordinates of the virtual map block corresponding to the vertex coordinates in the virtual texture coordinate system through the vertex shader; obtain the virtual texture page table; the virtual texture page table stores the mapping relationship between the virtual texture coordinates and the physical texture coordinates; the physical texture coordinates are the coordinates of the physical map in the physical texture coordinate system; according to the corresponding physical texture coordinates of the virtual texture coordinates in the virtual texture page table, obtain the physical map corresponding to each virtual map block; load the obtained physical map into the map cache.

[0232] In one embodiment, the data acquisition module 1002 is further used to determine the world coordinates of the virtual texture block corresponding to the vertex coordinates; and determine the virtual texture coordinates of the virtual texture block in the virtual texture coordinate system according to the world coordinates of the virtual texture block.

[0233] In one embodiment, the data acquisition module 1002 is also used to determine the physical texture coordinates of the physical map corresponding to each virtual map block in the virtual texture page table according to the virtual texture coordinates and the virtual map size of the virtual map; and obtain the physical map corresponding to each virtual map block according to the physical texture coordinates.

[0234] In one embodiment, the physical texture coordinate determination module 1004 is further used to perform scaling transformation processing on the vertex coordinates of each rendering sub-block in the virtual map block according to the scaling transformation matrix to obtain the local virtual texture coordinates of each rendering sub-block after the scaling transformation; determine the starting physical texture coordinates corresponding to the physical map according to the world coordinates corresponding to the virtual map block and the virtual texture coordinates corresponding to the virtual map block in the virtual texture page table; determine the physical texture coordinates corresponding to each rendering sub-block in the map cache according to the local virtual texture coordinates of each rendering sub-block and the starting physical texture coordinates corresponding to the physical map.

[0235] In one embodiment, the physical texture coordinate determination module 1004 is further used to align each virtual texture block with a matching physical texture according to the starting virtual texture coordinates of each virtual texture block and the starting physical texture coordinates corresponding to each physical texture; determine the offset of each rendering sub-block in the virtual texture block according to the starting virtual texture coordinates of the virtual texture block and the local virtual texture coordinates of each rendering sub-block; and determine the physical texture coordinates corresponding to each rendering sub-block in the texture cache according to the starting physical texture coordinates and the offset corresponding to the physical texture.

[0236] In one embodiment, the physical texture coordinate determination module 1004 is also used to determine the physical texture coordinates corresponding to each rendering sub-block in the texture cache through the sampling nodes in the vertex shader, for each rendering sub-block in the virtual texture block corresponding to the vertex coordinates; the data transmission module 1006 is also used to transfer the physical texture coordinates to the pixel shader through the sampling nodes in the vertex shader.

[0237] In one embodiment, the data transmission module 1006 is also used to interpolate the vertex attributes corresponding to the physical texture coordinates through the sampling nodes in the vertex shader to obtain the physical texture coordinates of the pixel attributes; and pass the physical texture coordinates of the pixel attributes to the pixel shader.

[0238] In one embodiment, the above-mentioned image rendering device also includes a parameter determination module, which is used to determine the texture request parameters corresponding to each virtual texture block through a vertex shader according to the virtual texture coordinates corresponding to each virtual texture block; the physical texture coordinates and texture request parameters are passed into the pixel shader through the vertex shader; the image rendering module 1008 is also used to sample texture pixels matching the physical texture coordinates from the physical map in the map cache based on the texture request parameters through the pixel shader.

[0239] In one embodiment, the parameter determination module is also used to correct the virtual texture coordinates corresponding to each virtual texture block according to the size of the virtual texture page in the virtual texture page table to obtain the corrected virtual texture coordinates; and generate the texture request parameters corresponding to each virtual texture block according to the corrected virtual texture coordinates.

[0240] In one embodiment, the parameter determination module is also used to determine the texture level corresponding to the virtual texture page according to the corrected virtual texture coordinates; determine the pixel coordinates of the virtual texture page corresponding to each virtual map block according to the corrected virtual texture coordinates and the texture level; and generate texture request parameters corresponding to each virtual map block according to the pixel coordinates.

[0241] In one embodiment, the data acquisition module 1002 is also used to determine the vertex coordinates of the corresponding virtual texture block of the terrain scene area in the virtual map when the image to be rendered includes a terrain scene area; the image rendering module 1008 is also used to sample texture pixels matching the physical texture coordinates from the physical map in the texture cache through a pixel shader, and render the terrain scene area in the image to be rendered based on the texture pixels.

[0242] For the specific definition of the image rendering device, please refer to the definition of the image rendering method above, which will not be repeated here. Each module in the above image rendering device can be implemented in whole or in part by software, hardware and a combination thereof. The above modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.

[0243] In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Fig.11 As shown. The computer device includes a processor, a memory, a communication interface, a display screen and an input device connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be achieved through WIFI, an operator network, NFC (near field communication) or other technologies. When the computer program is executed by the processor, an image rendering method is implemented. The display screen of the computer device can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covered on the display screen, or a key, trackball or touchpad set on the computer device housing, or an external keyboard, touchpad or mouse, etc.

[0244] Those skilled in the art will understand that Fig.11 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0245] In one embodiment, a computer device is further provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above method embodiments when executing the computer program.

[0246] In one embodiment, a computer-readable storage medium is provided, storing a computer program, which implements the steps in the above method embodiments when executed by a processor.

[0247] In one embodiment, a computer program product or computer program is provided, the computer program product or computer program includes computer instructions, the computer instructions are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device performs the steps in the above-mentioned method embodiments.

[0248] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory or optical memory, etc. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM).

[0249] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0250] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.

Claims

1. An image rendering method, characterized in that: The method comprises: Determine the vertex coordinates of the corresponding virtual texture block of the image to be rendered in the virtual texture; Loading the physical texture corresponding to the vertex coordinates into a texture cache through a vertex shader; For each rendering sub-block in the virtual texture block corresponding to the vertex coordinate, determining the physical texture coordinates corresponding to each rendering sub-block in the texture cache through vertex shader calculation, where the rendering sub-block refers to a plurality of rendering sub-blocks included in the virtual texture block; The physical texture coordinates are passed into the pixel shader, including: the physical texture coordinates of the vertex attribute are interpolated by the vertex shader through attribute interpolation transformation processing to obtain the physical texture coordinates of the pixel attribute, and then the physical texture coordinates of the pixel attribute are passed into the pixel shader; The pixel shader samples texture pixels matching the physical texture coordinates from the physical texture in the texture cache, and renders the image to be rendered based on the texture pixels.

2. The method according to claim 1, characterized in that The step of loading the physical texture corresponding to the vertex coordinates into the texture cache through the vertex shader includes: Determine, by a vertex shader, in a virtual texture coordinate system, a virtual texture coordinate of a virtual map block corresponding to the vertex coordinate; Acquire a virtual texture page table; the virtual texture page table stores a mapping relationship between virtual texture coordinates and physical texture coordinates; the physical texture coordinates are coordinates of a physical map in a physical texture coordinate system; Acquire a physical texture corresponding to each virtual texture block according to the physical texture coordinates corresponding to the virtual texture coordinates in the virtual texture page table; Load the obtained physical map into the map cache.

3. The method according to claim 2, characterized in that Determining the virtual texture coordinates of the virtual map block corresponding to the vertex coordinates in the virtual texture coordinate system includes: Determining the world coordinates of the virtual texture block corresponding to the vertex coordinates; According to the world coordinates of the virtual map block, the virtual texture coordinates of the virtual map block in the virtual texture coordinate system are determined.

4. The method according to claim 2, characterized in that: The acquiring the physical texture corresponding to each virtual texture block according to the physical texture coordinates corresponding to the virtual texture coordinates in the virtual texture page table includes: Determine, according to the virtual texture coordinates and the virtual texture size of the virtual texture, the physical texture coordinates of the physical texture corresponding to each of the virtual texture blocks in the virtual texture page table; A physical texture corresponding to each of the virtual texture blocks is obtained according to the physical texture coordinates.

5. The method according to claim 1, characterized in that The step of determining, for each rendering sub-block in the virtual texture block corresponding to the vertex coordinate, a physical texture coordinate corresponding to each rendering sub-block in the texture cache includes: Performing scaling transformation processing on the vertex coordinates of each rendering sub-block in the virtual map block according to the scaling transformation matrix to obtain local virtual texture coordinates of each rendering sub-block after scaling transformation; Determine the starting physical texture coordinates corresponding to the physical texture according to the world coordinates corresponding to the virtual texture block and the virtual texture coordinates corresponding to the virtual texture block in the virtual texture page table; The physical texture coordinates corresponding to each rendering sub-block in the texture cache are determined according to the local virtual texture coordinates of each rendering sub-block and the initial physical texture coordinates corresponding to the physical texture.

6. The method according to claim 5, characterized in that Determining the physical texture coordinates corresponding to each rendering sub-block in the texture cache according to the local virtual texture coordinates of each rendering sub-block and the starting physical texture coordinates corresponding to the physical texture includes: Aligning each of the virtual texture blocks with a matching physical texture according to the starting virtual texture coordinates of each of the virtual texture blocks and the starting physical texture coordinates corresponding to each of the physical textures; Determine the offset of each rendering sub-block in the virtual texture block according to the starting virtual texture coordinates of the virtual texture block and the local virtual texture coordinates of each rendering sub-block; The physical texture coordinates corresponding to each of the rendering sub-blocks in the texture cache are determined according to the starting physical texture coordinates corresponding to the physical texture and the offset.

7. The method according to claim 1, characterized in that The step of determining, for each rendering sub-block in the virtual texture block corresponding to the vertex coordinate, a physical texture coordinate corresponding to each rendering sub-block in the texture cache includes: Determine, through a sampling node in a vertex shader, for each rendering sub-block in a virtual texture block corresponding to the vertex coordinate, the physical texture coordinates corresponding to each rendering sub-block in the texture cache; The step of passing the physical texture coordinates into a pixel shader comprises: The physical texture coordinates are passed to the pixel shader via the sampling node in the vertex shader.

8. The method according to claim 7, characterized in that The step of passing the physical texture coordinates into the pixel shader via the sampling node in the vertex shader comprises: Through the sampling nodes in the vertex shader, the vertex attributes corresponding to the physical texture coordinates are interpolated to obtain the physical texture coordinates of the pixel attributes; The physical texture coordinates of the pixel point attributes are passed into the pixel shader.

9. The method according to claim 1, characterized in that: The method further comprises: Determining, by the vertex shader, texture request parameters corresponding to each of the virtual texture blocks according to the virtual texture coordinates corresponding to each of the virtual texture blocks; Passing the physical texture coordinates and the texture request parameters into a pixel shader through the vertex shader; The step of sampling a texture pixel matching the physical texture coordinate from the physical texture in the texture cache by the pixel shader comprises: The pixel shader samples a texture pixel matching the physical texture coordinate from the physical texture in the texture cache based on the texture request parameter.

10. The method according to claim 9, characterized in that The step of determining the texture request parameters corresponding to each virtual texture block according to the virtual texture coordinates corresponding to each virtual texture block includes: Correcting the virtual texture coordinates corresponding to each virtual texture block according to the size of the virtual texture page in the virtual texture page table to obtain corrected virtual texture coordinates; According to the corrected virtual texture coordinates, texture request parameters corresponding to each virtual map block are generated.

11. The method according to claim 10, characterized in that Generating texture request parameters corresponding to each virtual map block according to the corrected virtual texture coordinates includes: Determining a texture level corresponding to the virtual texture page according to the corrected virtual texture coordinates; Determining pixel coordinates of a virtual texture page corresponding to each virtual map block according to the corrected virtual texture coordinates and the texture level; A texture request parameter corresponding to each of the virtual map blocks is generated according to the pixel coordinates.

12. The method according to any one of claims 1 to 11, characterized in that: The step of determining the vertex coordinates of the corresponding virtual map block of the image to be rendered in the virtual map comprises: When the image to be rendered includes a terrain scene area, determining vertex coordinates of a corresponding virtual map block of the terrain scene area in the virtual map; The step of sampling, by the pixel shader, texture pixels matching the physical texture coordinates from the physical texture in the texture cache, and rendering the image to be rendered based on the texture pixels comprises: The pixel shader samples texture pixels matching the physical texture coordinates from the physical texture in the texture cache, and renders the terrain scene area in the image to be rendered based on the texture pixels.

13. An image rendering device, characterized in that: The device comprises: A data acquisition module is used to determine the vertex coordinates of the corresponding virtual texture block of the image to be rendered in the virtual texture; through the vertex shader, the physical texture corresponding to the vertex coordinates is loaded into the texture cache; A physical texture coordinate determination module, for determining, by vertex shader calculation, the physical texture coordinates corresponding to each rendering sub-block in the virtual texture block corresponding to the vertex coordinates in the texture cache, wherein the rendering sub-block refers to a plurality of rendering sub-blocks included in the virtual texture block; The data transmission module is used to transfer the physical texture coordinates to the pixel shader, including: interpolating the physical texture coordinates of the vertex attribute through the vertex shader, through the attribute interpolation transformation processing, to obtain the physical texture coordinates of the pixel attribute, and then transferring the physical texture coordinates of the pixel attribute to the pixel shader; The image rendering module is used to sample texture pixels matching the physical texture coordinates from the physical texture in the texture cache through the pixel shader, and render the image to be rendered based on the texture pixels.

14. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 12 are implemented.

15. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 12 are implemented.