Texture rendering method, device, equipment and program product

By rendering small texture images using index information and shaders on devices with lower computing performance, the problem of low texture rendering efficiency is solved, and efficient texture rendering effect is achieved.

CN119919556BActive Publication Date: 2026-05-08ZHEJIANG GEELY HLDG GRP CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
ZHEJIANG GEELY HLDG GRP CO LTD
Filing Date
2025-01-06
Publication Date
2026-05-08

AI Technical Summary

Technical Problem

Existing technologies are inefficient for texture rendering on devices with low computing performance, especially in multi-object rendering where high device performance is required, making them unsuitable for effective application.

Method used

By acquiring vertex data from small texture images and adding index information, and then using vertex and fragment shaders for rendering, multiple small texture images can be rendered simultaneously, reducing computational performance requirements.

Benefits of technology

It improves texture rendering efficiency, reduces the number of rendering function calls, reduces the pressure on device computing performance, and enhances rendering efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119919556B_ABST
    Figure CN119919556B_ABST
Patent Text Reader

Abstract

The application relates to the rendering technical field, in particular to a texture rendering method, device, equipment and program product. The method comprises the following steps: acquiring vertex data of N small texture images, wherein N is a positive integer, and the vertex data comprises index information corresponding to each small texture image; inputting the vertex data of the N small texture images into a shader; and calling the shader to render each small texture image based on the index information. The application can improve the rendering efficiency of texture rendering on a device with low computing performance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of rendering technology, specifically to a texture rendering method, apparatus, device, and program product. Background Technology

[0002] With technological advancements, texture rendering technology is increasingly being applied in people's lives, such as in automotive dashboards, in-vehicle infotainment systems, and smart home devices, providing users with richer and more detailed visuals. However, there are currently two main texture rendering methods: immediate rendering and multi-objective rendering. Immediate rendering renders each texture individually. This method is efficient when the number of textures is small, but frequent calls to the rendering function reduce efficiency when rendering a large number of textures. Multi-objective rendering, on the other hand, can generate rendering results for multiple textures with a single call to the rendering function. However, multi-objective rendering places higher demands on device performance and cannot be applied to devices with lower computing power, such as automotive dashboards. Summary of the Invention

[0003] Based on the defects and shortcomings of the prior art, this application proposes a texture rendering method, apparatus, device and program product, which can improve the rendering efficiency of texture rendering on devices with low computing performance.

[0004] According to a first aspect of this application, a texture rendering method is provided, comprising: acquiring vertex data of N small texture images, wherein N is a positive integer, and the vertex data includes index information corresponding to each of the small texture images; inputting the vertex data of the N small texture images into a shader; and invoking the shader to render each of the small texture images based on the index information.

[0005] According to the texture rendering method provided in the first aspect of this application, the step of obtaining vertex data of N small texture images includes: creating a data list based on the number M of texture units in the rendering device, wherein M is a positive integer greater than or equal to N, and the data list is used to store vertex data of up to M small texture images; storing the vertex data of the N small texture images into the data list; and the step of inputting the vertex data of the N small texture images into the shader includes: inputting the data list into the shader.

[0006] According to the texture rendering method provided in the first aspect of this application, the shader includes a vertex shader and a fragment shader; the step of calling the shader to render each of the small texture images based on the index information includes: calling the vertex shader to receive vertex data and transmit the vertex data to the fragment shader; and calling the fragment shader to render each of the small texture images based on the index information.

[0007] According to the texture rendering method provided in the first aspect of this application, the index information received by the vertex shader includes floating-point type index data; before calling the shader to render each of the small texture images based on the index information, the method further includes: converting the index information from the floating-point type to the integer type through the fragment shader.

[0008] According to the texture rendering method provided in the first aspect of this application, obtaining the vertex data of N small texture images includes: loading the large texture image into graphics memory based on the first texture identifier of the large texture image, wherein the large texture image includes P small texture images, the second texture identifier of each small texture image in the large texture image is the same as the first texture identifier, and P is an integer greater than or equal to N; traversing the small texture images in the large texture image to determine N small texture images and obtaining the vertex data of the N small texture images.

[0009] According to the texture rendering method provided in the first aspect of this application, after calling the shader and rendering each of the small texture images based on the index information, the method further includes: determining whether the small texture images in the large texture image have been completely traversed; if not, re-determining N unrendered small texture images in the large texture image and obtaining the vertex data of the re-determined N small texture images, until the small texture images in the large texture image have been completely traversed.

[0010] According to the texture rendering method provided in the first aspect of this application, the vertex data includes custom texture coordinates; the custom texture coordinates include the index information.

[0011] According to a second aspect of this application, a texture rendering apparatus is provided, comprising: an acquisition module for acquiring vertex data of N small texture images, wherein N is a positive integer, and the vertex data includes index information corresponding to each of the small texture images; an input module for inputting the vertex data of the N small texture images into a shader; and a rendering module for invoking the shader to render each of the small texture images based on the index information.

[0012] According to a third aspect of this application, an electronic device is provided, comprising: a memory and a processor; the memory is connected to the processor and is used to store a program; the processor is used to implement the texture rendering method as described in the first aspect by running the program in the memory.

[0013] According to a fourth aspect of this application, a computer program product is provided, including computer program instructions; said computer program instructions, when executed by a processor, cause the processor to perform the texture rendering method as described in the first aspect.

[0014] In this application, vertex data of N small texture images are obtained, where N is a positive integer, and the vertex data includes index information corresponding to each small texture image. The vertex data of the N small texture images are input into the shader. The shader is then invoked to render each small texture image based on the index information. To address the excessive computational pressure caused by repeatedly switching texture identifiers in ordinary multi-object rendering, the above process uses index information to achieve simultaneous rendering of multiple small texture images, reducing the computational performance requirements of the device. Furthermore, by using the index information in the vertex data, N small texture images can be rendered simultaneously with a single shader call, thereby improving rendering efficiency. Attached Figure Description

[0015] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of this application. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.

[0016] Figure 1 A flowchart illustrating a texture rendering method provided in an embodiment of this application;

[0017] Figure 2 A schematic diagram of a rendering loop based on a large texture image provided for an embodiment of this application;

[0018] Figure 3 A block diagram of a texture rendering apparatus provided in an embodiment of this application;

[0019] Figure 4 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0020] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0021] Exemplary methods

[0022] To address the problems existing in the prior art, this application provides a texture rendering method. This method is implemented in software, and the software implementing this method runs on a device with data processing capabilities, such as an in-vehicle processor, a remote server, or a smart mobile device. Optionally, the software corresponding to this method runs on a graphics processing unit (GPU) in an embedded device.

[0023] In one embodiment, such as Figure 1 As shown, the process steps for implementing the texture rendering method include:

[0024] Step 101: Obtain the vertex data of N small texture images, where N is a positive integer, and the vertex data includes the index information corresponding to each small texture image.

[0025] In this embodiment, texture rendering refers to the process of mapping a two-dimensional image onto the surface of a three-dimensional model in computer graphics. The texture rendering process includes steps such as vertex data preparation, vertex shader processing, rasterization, fragment shader processing, and frame buffer writing. Small texture images refer to image data processed as basic units during the texture rendering process. In a single texture rendering process, multiple small texture images typically need to be rendered separately to obtain the final rendering result.

[0026] In this embodiment, N small texture images are rendered simultaneously. To ensure the correct rendering logic of each small texture image, corresponding index information is configured for each small texture image. This ensures that the texture data corresponding to each small texture image can be correctly obtained when rendering the N small texture images. Index information is a data structure used for fast data lookup and access, which can significantly improve the speed and efficiency of data retrieval. Vertex data is a crucial component in computer graphics and 3D modeling. It describes the geometric structure of the 3D model, such as the position, normals, and colors of vertices. Vertex data includes the screen coordinates (also known as xy coordinates) of the vertices contained in each small texture image, and the texture coordinates (also known as UV coordinates) of the vertices contained in each small texture image in the large texture image. The large texture image includes multiple small texture images. The index information is custom-added to the vertex data of each small texture image. Optionally, the index information is based on a numerical format.

[0027] In one embodiment, the vertex data includes custom texture coordinates; the custom texture coordinates include index information.

[0028] In this embodiment, the texture rendering process is completed by the GPU. The vertex shader configured in the GPU is responsible for receiving vertex data and passing it to the fragment shader. In the vertex data passed from the vertex shader to the fragment shader, the texture coordinates of the smaller texture image are the same as those of the larger texture image before and after the transfer. However, to ensure the consistency of the index information before and after the transfer, the original texture coordinates are modified, and the index information is customized into the texture coordinates to generate custom texture coordinates. The custom texture coordinates include both the original texture coordinates and the index information.

[0029] Step 102: Input the vertex data of N small texture images into the shader.

[0030] In this embodiment, vertex data carrying index information is input into the shader required for texture rendering, thereby ensuring that the index information plays a role in the texture rendering process and ensuring the correct rendering logic of N small texture images.

[0031] Step 103: Invoke the shader and render each small texture image based on the index information.

[0032] In this embodiment, rendering N small texture images requires calling the shaders configured in the GPU. When calling the shaders, in addition to processing data such as texture identifiers (IDs), screen coordinates, and texture coordinates, index information also needs to be processed to ensure that the corresponding texture data is correctly called when rendering each small texture image, avoiding data mixing between different small texture images. Furthermore, when rendering N small texture images simultaneously, calling the shaders only calls the rendering function once, rendering each small texture image simultaneously based on the index information. The rendering process of N small texture images only requires calling the rendering function once, avoiding the computational pressure caused by repeated calls to the rendering function, thereby improving the rendering efficiency of N small texture images and reducing the performance requirements of the device on which this method runs.

[0033] In one embodiment, obtaining vertex data of N small texture images includes: creating a data list based on the number M of texture units in the rendering device, where M is a positive integer greater than or equal to N, and the data list is used to store vertex data of up to M small texture images; storing the vertex data of the N small texture images into the data list. Inputting the vertex data of the N small texture images into the shader includes: inputting the data list into the shader.

[0034] In this embodiment, the device on which this method operates includes multiple texture units. Each texture unit is a logical resource manager used to bind and process texture data. During the texture rendering process, each texture unit is bound to a small texture image for managing and applying the texture data of the bound small texture image. Texture data is image data describing the details of an object's surface and may include information such as color, brightness, transparency, and normals.

[0035] In this embodiment, for the device on which this method operates, especially when the device is an embedded device, the number of texture units is limited, and therefore the number of small texture images that can be managed simultaneously is also limited. Therefore, a data list can be created to manage the number of small texture images processed at once. The data list can store vertex data for up to M small texture images, allowing the vertex data corresponding to N small texture images to be stored in the data list at once. Then, the vertex data of the N small texture images is input into the shader through the data list, and the rendering process of the N small texture images is completed by calling the rendering function once. Optionally, index information is pre-defined, and this index information corresponds one-to-one with the texture units. The index information corresponding to the M texture units can be assigned to the N small texture images, and the index information assigned to any two small texture images is different. After a batch of N small texture images has been rendered, the index information corresponding to the M texture units can be reassigned to the next batch of N small texture images waiting to be rendered.

[0036] In this embodiment, the number of texture units configured in the device can be obtained by calling the function glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS,&maxNums), which is the maximum number of texture units supported by the device, thus determining the number M.

[0037] In one embodiment, the shader includes a vertex shader and a fragment shader. Invoking the shader to render each small texture image based on index information includes: invoking the vertex shader to receive vertex data and transmit the vertex data to the fragment shader; and invoking the fragment shader to render each small texture image based on the index information.

[0038] In this embodiment, the shaders used in the texture rendering process include vertex shaders and fragment shaders. The vertex shader processes vertex data, including position transformations, lighting calculations, and transmitting vertex data to the fragment shader, specifically passing the texture coordinates of each vertex to the fragment shader. The fragment shader samples the corresponding pixel values ​​from the texture data based on the texture coordinates passed from the vertices and calculates the final color output, taking into account factors such as lighting and material properties.

[0039] In this embodiment, index information is added to the vertex data to ensure that the index information can be passed from the vertex shader to the fragment shader. Optionally, the texture coordinates passed from the vertex shader to the fragment shader are the same; therefore, the index information is added to the original texture coordinates to form custom texture coordinates. To ensure that the vertex shader can receive vertex data containing index information, the vertex shader is pre-customized. For example, the program corresponding to the customized vertex shader is as follows:

[0040] Attribute vec2 vertexPosition;

[0041] attribute vec3 vertexUV;

[0042] varying vec3 UV;

[0043] void main()

[0044] {

[0045] gl_Position=vec4(vertexPosition.xy,0.0,1.0);

[0046] UV = vertexUV;

[0047] }

[0048] In this vertex shader, the received two-dimensional data vertexPosition is defined, representing the screen coordinates based on the screen when rendering a small texture image; the received three-dimensional data vertexUV is also defined, where the first two digits of vertexUV represent the texture coordinates of the small texture image based on the large texture image, and the third digit represents the index information v; the three-dimensional data UV is consistent with the received vertexUV and is used to pass it to the fragment shader; in the main function, gl_Position is a four-dimensional built-in variable of the vertex shader, the first three digits represent the xyz coordinates in the spatial coordinate system, the xy coordinates are the received screen coordinates vertexPosition, the z coordinate is defined as 0.0, and the fourth digit represents the homogeneous coordinate w, which is generally taken as 1.0.

[0049] By customizing the vertex shader, it is possible to ensure that the vertex shader accurately receives index information and passes the index information to the fragment shader.

[0050] In one embodiment, the index information received by the vertex shader includes floating-point index data. Before invoking the shader to render each small texture image based on the index information, the method further includes: converting the index information from floating-point to integer type through the fragment shader.

[0051] In this embodiment, based on actual operational conditions, the data input to the vertex shader is typically of floating-point (float) type. However, when the fragment shader calls the index information to query the texture data of the corresponding small texture image, using integer (int) type is more convenient for data processing. Therefore, the index information can be converted from floating-point type to integer type through the fragment shader.

[0052] In this embodiment, to ensure that the fragment shader accurately receives the index information and performs data type conversion on the index information, the fragment shader is pre-modified. For example, the program corresponding to the customized fragment shader is as follows:

[0053] The procedure for the fragment shader is as follows:

[0054] varying vec3 UV;

[0055] uniform sampler2D renderTexture[M];

[0056] void main()

[0057] {

[0058] int idx = int(UV.v – 0.5);

[0059] gl_FragColor=texture2D(renderTexture[idx],UV.uv);

[0060] }

[0061] The fragment shader receives 3D data (UV) from the vertex shader (i.e., custom texture coordinates) and second texture identifiers for n sampler2D variables of small texture images. sampler2D is a special data type specifically used to represent 2D textures, and M is determined by the maximum number of texture units supported by the device. In the main function, the type-converted index information idx is first obtained based on the input vertex data. Since the vertex data input to the vertex shader is of type float, while the index information required by the fragment shader is of type int, type conversion is necessary. The conversion formula is:

[0062] idx = int(UV.v – 0.5)

[0063] Where UV.v represents the index information of type float, int represents the rounding operation, and idx represents the index information of type int. Based on the above formula, for example, when v equals (float) 3.0, the corresponding idx is (int) 2.

[0064] gl_FragColor is a built-in variable of the fragment shader used to store the final color of a fragment (or pixel). The final color of the fragment is the result of the built-in function texture2D, which reads the color value at the corresponding position from the texture data pointed to by renderTexture[idx] based on the texture coordinates UV.uv.

[0065] By customizing the vertex shader, it can be ensured that the fragment shader accurately receives the index information and uses it correctly.

[0066] In one embodiment, obtaining vertex data of N small texture images includes: loading a large texture image into graphics memory based on a first texture identifier of a large texture image, wherein the large texture image includes P small texture images, and the second texture identifier of each small texture image in the large texture image is the same as the first texture identifier, where P is an integer greater than or equal to N; traversing the small texture images in the large texture image to determine N small texture images and obtaining vertex data of the N small texture images.

[0067] In this embodiment, during actual operation, when rendering multiple small texture images, if a large number of small texture images are loaded into the graphics memory during initialization, frequent loading and unloading of texture images will lead to a long loading process, and frequent switching of texture identifiers during rendering will also reduce rendering efficiency. Therefore, multiple small texture images can be preprocessed to combine P small texture images into one large texture image, and the second texture identifier of each small texture image in the large texture image can be updated to the first texture identifier of the large texture image, that is, the second texture identifier of each small texture image in the large texture image is the same.

[0068] In this embodiment, after synthesizing a large texture image, N small texture images are determined from the large texture image based on the limitations of texture units. Processing is then performed based on the vertex data of these N small texture images and the index information within the vertex data. During initialization, the large texture image is loaded into the graphics memory, thus completing the preprocessing loading of P small texture images without frequently switching texture identifiers, improving initialization loading efficiency. Furthermore, the second texture identifiers of the N small texture images processed simultaneously are identical. Therefore, when rendering the N small texture images simultaneously based on the index information, frequent switching of texture identifiers is also unnecessary, improving texture rendering efficiency.

[0069] In this embodiment, if two different first large texture images and second large texture images are generated according to actual needs in a rendering project, then the first texture identifiers of the first large texture image and the second large texture image are different. The second texture identifier of the first small texture image in the first large texture image is the same as the first texture identifier of the first large texture image, and the second texture identifier of the second small texture image in the second large texture image is the same as the first texture identifier of the second large texture image.

[0070] In one embodiment, after calling the shader and rendering each small texture image based on the index information, the method further includes: determining whether the small texture images in the large texture image have been completely traversed; if not, re-determining N unrendered small texture images in the large texture image and obtaining the vertex data of the re-determined N small texture images, until the small texture images in the large texture image have been completely traversed.

[0071] In this embodiment, the number of small texture images contained in a large texture image is determined based on the project requirements. Therefore, the number of small texture images contained in a large texture image may be much greater than the number of texture units configured in the device. Based on the above, the small texture images in the large texture image can be traversed to achieve automatic loop rendering of the small texture images in the large texture image, thereby completing the rendering of the large texture image.

[0072] In a specific embodiment, such as Figure 2As shown, the rendering loop for small texture images within a large texture image includes:

[0073] Step 201: Create a data list that can store M sets of vertex data, and a counter variable count, which is initialized to 1;

[0074] Step 202: Traverse the small texture objects in the large texture image, store the vertex data of the next small texture object into the data list, and pass the index information v in the custom texture coordinates into the renderTexture array of the fragment shader;

[0075] Based on the above embodiments, the fragment shader performs data type conversion on the index information v to obtain the index information idx. The conversion relationship is as follows:

[0076] int idx = int((UV.v – 0.5);

[0077] Step 203: Determine if the current count is equal to M. If not, proceed to step 204. If yes, proceed to step 205.

[0078] Step 204, count +1, then proceed to step 202;

[0079] Step 205: Pass the data list to the shader, clear the data list, call the rendering function once to render each small texture image stored in the data list, and reset count = 0;

[0080] Step 206: Determine whether all the small texture images in the large texture image have been traversed. If not, proceed to step 202; if yes, proceed to step 207.

[0081] Step 207: If the data list is not empty, call the rendering function once to render each small texture image stored in the data list, and end the rendering loop for the large texture image.

[0082] In one specific embodiment, multiple small texture images are preprocessed by merging. Specifically, 144 small texture images are pre-created, each a 160*90 resolution PNG image texture. The 144 small texture images are then combined into a single large image texture using the open-source software FreeTexture Packer, generating a JSON file that records the texture coordinates of each small image texture within the large image texture. Optionally, the large image texture is packed using OptimalPacker with an inner margin of 1 to ensure a tighter arrangement of the small textures within the large image texture and to minimize the resolution of the large image texture. Optionally, the resolution of the large image texture is 894*868.

[0083] In this embodiment, the maximum number of texture units supported by the device is obtained, and the shader code and rendering loop logic are modified accordingly. Specifically, the maximum number of texture units supported by the current device, i.e., the value of maxNums, is obtained by calling the function glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS,&maxNums). In this embodiment, the device is an embedded device, and the value of maxNums for the embedded device is 16. Therefore, the data list can store texture data of up to 16 small texture units. The array size of the sampler2D variable is defined as 16 in the fragment shader, so that 16 texture units can be selected for each call to the rendering function. Optionally, the rendering function is glDraw*, where glDraw* is a collective term for a series of functions used to draw geometric primitives.

[0084] In this embodiment, the rendering loop logic uses a loop to process large texture images as follows: Figure 2 The rendering loop shown can be divided into 9 batches of 144 small texture images. Each batch loads the vertex arrays and texture data of 16 small texture images into the shader. The rendering function is called once for each batch of 16 small texture images. The above operation is repeated until the rendering of all 144 small texture images is completed. This is equivalent to reducing the number of times the rendering function is called from 144 to 9.

[0085] In this embodiment, the large image texture is loaded during initialization. Specifically, during the program initialization phase, the large image texture is read into the graphics memory, and a corresponding first texture identifier is generated. Then, in the generated JSON file, the custom texture coordinates of each small image texture within the large image texture are obtained. Based on these custom texture coordinates, the corresponding vertex data is calculated. The vertex data includes the screen coordinates of the small texture relative to the screen, the texture coordinates of the small texture image within the large texture image, and index information from 1 to 16. This ensures that the vertex data of the small texture image in the fragment shader during rendering corresponds one-to-one with the small texture image. The second texture identifier of the small texture image is the same as the first texture identifier of the large texture image. In this embodiment, only one large texture image is generated; therefore, the second texture identifiers of all small texture images are the same as the first texture identifier of the large texture image. Finally, 144 small texture images with vertex data and second texture identifiers are obtained.

[0086] In this embodiment, a rendering loop is initiated to achieve multi-texture rendering. Specifically, the 144 small texture images generated above are traversed and rendered in a loop. Since the second texture identifier of all small texture images uses the first texture identifier of the large texture image, the rendering function is called only 9 times when rendering the large texture image in a single frame.

[0087] In one embodiment, different rendering methods were used to conduct rendering experiments on 144 small texture images.

[0088] Experimental Group 1

[0089] No merging operation was performed on the small texture images. 144 small texture images were loaded separately during initialization. No index information was added. The rendering function was called 144 times to complete the rendering of the 144 small texture images.

[0090] Experimental Group 2

[0091] The 144 small texture images are merged into one large texture image. The large texture image is loaded during initialization; however, no index information is added to the small texture images. The rendering function is called 144 times to complete the rendering of the 144 small texture images.

[0092] Experimental Group 3

[0093] The 144 small texture images are merged into one large texture image. The large texture image is loaded separately during initialization. Index information is added to the small texture images, and the rendering function is called 9 times to complete the rendering of the 144 small texture images.

[0094] Rendering tests were conducted on the three experimental groups using the same embedded hardware, which included 16 texture units. Initialization was performed using Experimental Group 1, Experimental Group 2, and Experimental Group 3, with times of 62ms, 25ms, and 25ms respectively. Rendering of 144 small texture images was then performed using Experimental Group 1, Experimental Group 2, and Experimental Group 3, with average frame rates of 3081fps, 3207fps, and 3675fps respectively. This demonstrates that the texture rendering method provided in this application can reduce initialization time by approximately 60% and increase the frame rate by approximately 20%.

[0095] In this application, vertex data of N small texture images are obtained, where N is a positive integer, and the vertex data includes index information corresponding to each small texture image. The vertex data of the N small texture images are input into the shader. The shader is then invoked to render each small texture image based on the index information. To address the excessive computational pressure caused by repeatedly switching texture identifiers in ordinary multi-object rendering, the above process uses index information to achieve simultaneous rendering of multiple small texture images, reducing the computational performance requirements of the device. Furthermore, by using the index information in the vertex data, N small texture images can be rendered simultaneously with a single shader call, thereby improving rendering efficiency.

[0096] Furthermore, merging the small texture images to be rendered into a single large texture image can improve rendering efficiency to some extent. Based on the maximum number of texture units supported by the device, a maximum number of sampler2D variables are defined in the fragment shader, and the index information configured for each small texture image is received in the vertex shader. During loop rendering, the index information is added to the vertex data so that the vertex data corresponds one-to-one with the small texture images during drawing. In one rendering loop, when the number of small texture images bound to each texture unit reaches the maximum number defined in the fragment shader, the rendering function is called once. This significantly reduces the number of rendering function calls, improving rendering efficiency. Because the number of rendering function calls is reduced, the pressure on the device's computing performance is decreased, allowing the proposed solution to maintain high rendering efficiency even when applied to embedded devices or other devices with lower computing performance.

[0097] Exemplary device

[0098] Accordingly, embodiments of this application also provide a texture rendering apparatus, such as... Figure 3 As shown, the device may include:

[0099] The acquisition module 301 is used to acquire vertex data of N small texture images, where N is a positive integer, and the vertex data includes the index information corresponding to each small texture image.

[0100] Input module 302 is used to input vertex data of N small texture images into the shader;

[0101] The rendering module 303 is used to call the shader and render each small texture image based on the index information.

[0102] In one embodiment, the acquisition module 301 is configured to create a data list based on the number M of texture units in the rendering device, wherein M is a positive integer greater than or equal to N, and the data list is used to store vertex data of up to M small texture images; store the vertex data of N small texture images into the data list; and input the vertex data of N small texture images into the shader, including: inputting the data list into the shader.

[0103] In one embodiment, the shader includes a vertex shader and a fragment shader;

[0104] The rendering module 303 is used to call the vertex shader, receive vertex data, and transmit vertex data to the fragment shader; and call the fragment shader to render each small texture image based on the index information.

[0105] In one embodiment, the index information received by the vertex shader includes floating-point index data;

[0106] The rendering module 303 is also used to call the shader. Before rendering each small texture image based on the index information, the index information is converted from floating-point type to integer type through the fragment shader.

[0107] In one embodiment, the acquisition module 301 is used to load the large texture image into the graphics memory based on the first texture identifier of the large texture image, wherein the large texture image includes P small texture images, the second texture identifier of each small texture image in the large texture image is the same as the first texture identifier, and P is an integer greater than or equal to N; traversing the small texture images in the large texture image, determining N small texture images, and obtaining the vertex data of the N small texture images.

[0108] In one embodiment, the rendering module 303 is further configured to call the shader, render each small texture image based on the index information, determine whether the small texture images in the large texture image have been completely traversed, and if not, re-determine N unrendered small texture images in the large texture image and obtain the vertex data of the re-determined N small texture images until the small texture images in the large texture image have been completely traversed.

[0109] In one embodiment, the vertex data includes custom texture coordinates; the custom texture coordinates include index information.

[0110] The texture rendering apparatus provided in this embodiment belongs to the same concept as the texture rendering method provided in the above embodiments of this application. It can execute the texture rendering method provided in any of the above embodiments of this application and has the corresponding functional modules and beneficial effects of the method. Technical details not described in detail in this embodiment can be found in the specific processing content of the texture rendering method provided in the above embodiments of this application, and will not be repeated here.

[0111] Exemplary electronic devices

[0112] This application also provides an electronic device, such as... Figure 4 As shown, the electronic device includes a memory 400 and a processor 401.

[0113] The memory 400 is connected to the processor 401 and is used to store programs.

[0114] The processor 401 is used to implement the texture rendering method in the above embodiments by running the program stored in the memory 400.

[0115] Specifically, the aforementioned electronic device may also include: a communication interface 402, an input device 403, an output device 404, and a bus 405.

[0116] The processor 401, memory 400, communication interface 402, input device 403, and output device 404 are interconnected via a bus. Among them:

[0117] Bus 405 may include a pathway for transmitting information between various components of a computer system.

[0118] Processor 401 can be a general-purpose processor, such as a general-purpose central processing unit (CPU), a microprocessor, etc., or an application-specific integrated circuit (ASIC), or one or more integrated circuits used to control the execution of the program of the present invention. It can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), an off-the-shelf programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.

[0119] Processor 401 may include a main processor, as well as a baseband chip, modem, etc.

[0120] The memory 400 stores a program that executes the technical solution of this invention, and may also store an operating system and other key business functions. Specifically, the program may include program code, which includes computer operation instructions. More specifically, the memory 400 may include read-only memory (ROM), other types of static storage devices capable of storing static information and instructions, random access memory (RAM), other types of dynamic storage devices capable of storing information and instructions, disk storage, flash memory, etc.

[0121] Input device 403 may include a device for receiving data and information input by the user, such as a keyboard, mouse, camera, scanner, light pen, voice input device, touch screen, pedometer, or gravity sensor.

[0122] Output device 404 may include devices that allow information to be output to a user, such as a display screen, printer, speaker, etc.

[0123] The communication interface 402 may include a device that uses any transceiver to communicate with other devices or communication networks, such as Ethernet, Radio Access Network (RAN), Wireless Local Area Network (WLAN), etc.

[0124] The processor 401 executes the program stored in the memory 400 and calls other devices, which can be used to implement the various steps of the texture rendering method provided in the above embodiments of this application.

[0125] Exemplary computer program products and storage media

[0126] In addition to the methods and devices described above, embodiments of this application may also be computer program products, which include computer program instructions that, when executed by a processor, cause the processor to perform the steps in the texture rendering method described in the embodiments of this application.

[0127] The computer program product can be written in any combination of one or more programming languages ​​to perform the operations of the embodiments of this application. The programming languages ​​include object-oriented programming languages ​​such as Java and C++, as well as conventional procedural programming languages ​​such as C or similar languages. The program code can be executed entirely on the user's computing device, partially on the user's computing device, as a standalone software package, partially on the user's computing device and partially on a remote computing device, or entirely on a remote computing device or server.

[0128] Furthermore, embodiments of this application may also be storage media storing a computer program, which is executed by a processor of the steps in the texture rendering method described in the embodiments of this application.

[0129] For the foregoing method embodiments, in order to simplify the description, they are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, because according to this application, some steps can be performed in other orders or simultaneously. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily essential to this application.

[0130] It should be noted that the various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For apparatus embodiments, since they are basically similar to method embodiments, the description is relatively simple; relevant parts can be referred to the descriptions in the method embodiments.

[0131] The steps in the methods of the various embodiments of this application can be adjusted, merged, or deleted in order according to actual needs, and the technical features described in each embodiment can be replaced or combined.

[0132] The modules and sub-modules in the devices and terminals provided in the various embodiments of this application can be merged, divided, and deleted according to actual needs.

[0133] It should be understood that the disclosed terminals, devices, and methods can be implemented in other ways, given the several embodiments provided in this application. For example, the terminal embodiments described above are merely illustrative. For instance, the division of modules or sub-modules is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple sub-modules or modules may be combined or integrated into another module, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be indirect coupling or communication connection through some interfaces, devices, or modules, and may be electrical, mechanical, or other forms.

[0134] The modules or submodules described as separate components may or may not be physically separate. The components that constitute a module or submodule may or may not be physical modules or submodules; that is, they may be located in one place or distributed across multiple network modules or submodules. Some or all of the modules or submodules can be selected to achieve the purpose of this embodiment's solution, depending on actual needs.

[0135] Furthermore, the functional modules or sub-modules in the various embodiments of this application can be integrated into one processing module, or each module or sub-module can exist physically separately, or two or more modules or sub-modules can be integrated into one module. The integrated modules or sub-modules described above can be implemented in hardware or in the form of software functional modules or sub-modules.

[0136] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0137] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly by hardware, a software unit executed by a processor, or a combination of both. The software unit can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.

[0138] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0139] The above description of the disclosed embodiments enables those skilled in the art to make or use this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A texture rendering method, characterized in that, include: Obtain vertex data for N small texture images, where N is a positive integer. The vertex data includes the index information corresponding to each of the small texture images. The small texture images refer to image data that are processed as basic units during the texture rendering process. Input the vertex data of the N small texture images into the shader; The shader is invoked to render each of the small texture images based on the index information. The shader includes a vertex shader and a fragment shader, and the index information is passed from the vertex shader to the fragment shader.

2. The texture rendering method according to claim 1, characterized in that, The acquisition of vertex data from N small texture images includes: Based on the number M of texture units in the rendering device, a data list is created, where M is a positive integer greater than or equal to N, and the data list is used to store vertex data of up to M of the small texture images; The vertex data of the N small texture images are stored in the data list; The step of inputting the vertex data of the N small texture images into the shader includes: Input the data list into the shader.

3. The texture rendering method according to claim 1, characterized in that, The step of invoking the shader to render each of the small texture images based on the index information includes: The vertex shader is invoked to receive the vertex data and to transmit the vertex data to the fragment shader. The fragment shader is invoked to render each of the small texture images based on the index information.

4. The texture rendering method according to claim 3, characterized in that, The index information received by the vertex shader includes floating-point index data; Before invoking the shader to render each of the small texture images based on the index information, the method further includes: The fragment shader converts the index information from the floating-point type to the integer type.

5. The texture rendering method according to claim 1, characterized in that, The acquisition of vertex data from N small texture images includes: Based on the first texture identifier of the large texture image, the large texture image is loaded into the graphics memory, wherein the large texture image includes P small texture images, and the second texture identifier of each small texture image in the large texture image is the same as the first texture identifier, where P is an integer greater than or equal to N; Traverse the small texture images in the large texture image, determine N small texture images, and obtain the vertex data of the N small texture images.

6. The texture rendering method according to claim 5, characterized in that, After invoking the shader and rendering each of the small texture images based on the index information, the process further includes: Determine whether all the small texture images in the large texture image have been completely traversed. If not, re-determine N unrendered small texture images in the large texture image and obtain the vertex data of the re-determined N small texture images until all the small texture images in the large texture image have been completely traversed.

7. The texture rendering method according to any one of claims 1-6, characterized in that, The vertex data includes custom texture coordinates; The custom texture coordinates include the index information.

8. A texture rendering apparatus, characterized in that, include: The acquisition module is used to acquire vertex data of N small texture images, where N is a positive integer. The vertex data includes index information corresponding to each of the small texture images. The small texture images refer to image data that are processed as basic units in the texture rendering process. The input module is used to input the vertex data of the N small texture images into the shader; The rendering module is used to call the shader and render each of the small texture images based on the index information. The shader includes a vertex shader and a fragment shader, and the index information is passed from the vertex shader to the fragment shader.

9. An electronic device, characterized in that, include: Memory and processor; The memory is connected to the processor and is used to store programs; The processor is used to implement the texture rendering method as described in any one of claims 1-7 by running a program in the memory.

10. A computer program product, characterized in that, Includes computer program instructions; When the computer program instructions are executed by the processor, the processor causes the processor to perform the texture rendering method as described in any one of claims 1-7.

Citation Information

Patent Citations

  • Image rendering method and device, and storage medium

    CN108961382A

  • VR-based video rendering method and device, electronic equipment and storage medium

    CN111754614A