Texture address rewinding method and device and storage medium
By converting the texture coordinates in the form of floating point numbers into fixed-point decimals and performing the back-back mode operation in the fixed-point number domain, the problem of low texture sampling efficiency caused by floating point operations in the existing technology is solved, and more efficient texture sampling is achieved .
Patent Information
- Application Number
- CN202311040846.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-17
- Publication Date
- 2025-02-21
AI Technical Summary
In the prior art, the calculation of texture coordinates in the form of floating point numbers in the wrapping mode requires a large number of floating point operations, resulting in low efficiency of texture sampling.
By pre-processing the normalized texture coordinates of the figure, the floating point form is converted into fixed-point decimal form, and then the winding mode is calculated in the fixed-point number domain, and multiple intervals are divided to determine the sampling point.
Reduces complex floating-point operations, reduces computational volume and delay, and improves the efficiency of texture sampling.
Smart Images

Figure CN119494864A_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present application relate to the field of data processing technology, and in particular, to a texture address wrap method, device, and storage medium. Background Art
[0002] Today's graphics processors implement most of the functions of the rendering pipeline, including programmable vertex shaders and fragment shaders as well as non-programmable rasterization. Texture sampling is also one of the important functions provided by graphics processors. Texture sampling can obtain a large amount of information from a preset image at a low cost. The texture unit samples the texture image according to texture coordinates and certain rules to obtain texture values, which are used as color, transparency or other purposes.
[0003] When the texture coordinates exceed the range of the texture image, it is necessary to obtain the appropriate sampling points according to specific rules. These rules are called wrap modes. For example, the texture coordinate formula after wrapping given by OpenGL Spec is used for calculation directly. However, for the texture coordinates represented by floating-point numbers, when calculating according to the wrapping formula, it is actually a large number of floating-point operations such as multiplication, addition, and rounding of floating-point numbers. The calculation of floating-point numbers, especially the multiplication and division calculations, requires a large implementation cost. Not only is the calculation area large, but the calculation delay is also long, which leads to low efficiency of texture sampling. Summary of the invention
[0004] The embodiments of the present application provide a texture address wrap method, device, and storage medium, aiming to improve the efficiency of texture sampling.
[0005] In a first aspect, an embodiment of the present application provides a texture address wrapping method, the method comprising:
[0006] By preprocessing the normalized texture coordinates of the graphics, the normalized texture coordinates in floating point form are converted into texture coordinates in fixed point decimal form;
[0007] Determining current texture coordinates according to the texture coordinates in fixed-point decimal form;
[0008] In a plurality of intervals pre-divided by any wrap mode, the interval in which the current texture coordinates are located and the sampling points in the interval are determined, and texture sampling is performed according to the sampling points in the interval.
[0009] Optionally, preprocessing the normalized texture coordinates of the graphics to convert the normalized texture coordinates in floating point form into texture coordinates in fixed point decimal form includes:
[0010] The normalized texture coordinates of the graphic are converted into texture coordinates in the form of fixed-point decimals by any one of clamp, mod1 and mod2 operations.
[0011] Optionally, determining the current texture coordinates according to the texture coordinates in the fixed-point decimal form includes:
[0012] The product of the texture coordinate in fixed-point decimal form and the size of the texture image on any coordinate axis is used as the current texture coordinate.
[0013] Optionally, before determining the interval in which the current texture coordinates are located and the sampling points in the interval among the multiple intervals pre-divided by any wrap mode, the method further includes:
[0014] According to the wrapping formula specified by any wrapping pattern, the number of intervals and segmentation points of the wrapping pattern on any coordinate axis are calculated, and two sampling points in each interval of the wrapping pattern are determined.
[0015] Optionally, determining the interval in which the current texture coordinates are located and the sampling points in the interval among the multiple intervals pre-divided in any wrap mode, and performing texture sampling according to the sampling points in the interval includes:
[0016] Compare the current texture coordinates with a segmentation point predetermined by any wrap mode to determine the interval in which the current texture coordinates are located in the wrap mode;
[0017] According to two sampling points in the interval where the current texture coordinates are located in the wrap mode, a linear difference between the two sampling points is calculated, and texture sampling is performed according to the linear difference.
[0018] In a second aspect, an embodiment of the present application provides a texture address wrapping device, the device comprising:
[0019] A conversion module, configured to convert the normalized texture coordinates in floating point form into texture coordinates in fixed point decimal form by preprocessing the normalized texture coordinates of the graphics;
[0020] A coordinate determination module, used for determining the current texture coordinates according to the texture coordinates in the fixed-point decimal form;
[0021] The sampling module is used to determine the interval where the current texture coordinates are located and the sampling points in the interval among the multiple intervals pre-divided by any wrap mode, and perform texture sampling according to the sampling points in the interval.
[0022] Optionally, the conversion module includes:
[0023] The conversion calculation unit is used to convert the normalized texture coordinates of the graphics in floating point form into texture coordinates in fixed point decimal form through any one of clamp, mod1 and mod2 operations.
[0024] Optionally, the coordinate determination module includes:
[0025] The coordinate determination unit is used to take the product of the texture coordinate in the fixed-point decimal form and the size of the texture image on any coordinate axis as the current texture coordinate.
[0026] Optionally, the device further comprises:
[0027] The segmentation module is used to calculate the number of intervals and segmentation points of any wrapping pattern on any coordinate axis according to the wrapping formula specified by the wrapping pattern, and determine two sampling points in each interval of the wrapping pattern.
[0028] Optionally, the sampling module includes:
[0029] An interval determination unit, used for comparing the current texture coordinates with a segmentation point predetermined by any wrap mode, and determining the interval in which the current texture coordinates are located in the wrap mode;
[0030] The sampling unit is used to calculate the linear difference between two sampling points according to the two sampling points in the interval where the current texture coordinates are located in the wrap mode, and perform texture sampling according to the linear difference.
[0031] In a third aspect, an embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the texture address wrapping method described in the first aspect of the embodiment is implemented.
[0032] Beneficial effects:
[0033] By preprocessing the normalized texture coordinates of the graphics, the normalized texture coordinates in floating point form are converted into texture coordinates in fixed point decimal form; the current texture coordinates are determined based on the texture coordinates in fixed point decimal form; in a plurality of intervals pre-divided by any wrap mode, the interval in which the current texture coordinates are located and the sampling points in the interval are determined, and texture sampling is performed based on the sampling points in the interval.
[0034] The method converts normalized texture coordinates in floating-point form into fixed-point decimal form, so that multiple wrapping modes are performed in the fixed-point domain, and each wrapping mode is segmented, and corresponding sampling points are given in each segment of each wrapping model. The current texture coordinates are determined according to the texture coordinates converted into fixed-point decimal form, and the sampling points are determined according to the segment interval where the current texture coordinates are located in any mode. Compared with the wrapping mode in the prior art that requires complex floating-point operations on texture coordinates in floating-point form, the method can effectively reduce the amount of calculation and the delay in calculation when the texture coordinates are wrapped, so that the implementation cost of texture coordinate wrapping becomes smaller, and the efficiency of texture sampling can be improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the description of the embodiments of the present application will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0036] Figure 1 is a flowchart of the steps of a texture address wrapping method proposed in one embodiment of the present application;
[0037] Figure 2 It is a functional module diagram of a texture address wrapping device proposed in one embodiment of the present application. DETAILED DESCRIPTION
[0038] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0039] Today's graphics processors implement most of the functions of the rendering pipeline, including programmable vertex shaders and fragment shaders as well as non-programmable rasterization functions. For example, graphics application programming interfaces (Application Programming Interface, API) such as OpenGL specify the rendering pipeline and describe the process of converting image program data into the final image, including the image's vertex data being converted and calculated by the vertex shader, entering the primitive assembly module to become primitives, and then passing through the rasterization module to become fragment data, that is, pixels on the screen. Finally, the fragment shader processes the fragment data to obtain the final pixel color.
[0040] Today's image processors also have an important function, namely texture sampling, which can obtain a large amount of information from a preset picture at a lower cost. When performing texture sampling, the texture unit usually samples the texture image (i.e., map) according to the texture coordinates of the graphic and certain rules to obtain the texture value for use as color, transparency or other purposes.
[0041] However, when the texture coordinates of the graphics exceed the range of the texture image, it is necessary to obtain the corresponding sampling points according to specific rules. The specific rules refer to the wrap mode. For example, the wrap formula of the wrap mode specified by OpenGL is as shown in Table 1, where coord represents the texture coordinates and size represents the size of the texture image on any coordinate axis (such as length or width):
[0042] Table 1: Wrap formulas for wrap modes specified by OpenGL
[0043] Wrap Mode The texture coordinates after wrapping are wrap(coord) CLAMP_TO_EDGE clamp(coord,0,size-1) CLAMP_TO_BORDER clamp(coord,-1,size) REPEAT coord mod size MIRRORED_REPEAT (size-1)-mirror((coord mod(2*size))-size) MIRROR_CLAMP_TO_EDGE clamp(mirror(coord),0,size-1)
[0044] Where, clamp(a,min,max)=(a<min?min:a> max? max:a); mod is the modulus operator, and the modulus operation is similar to the remainder operation rem, for example, a mod b=c, indicating that the remainder of a divided by b is c; mirror(a)=(a>=0? a:-(1+a)).
[0045] Since the calculation methods of texture coordinates in different wrapping modes are different, the final texture mapping effects are different in different wrapping modes; in particular, when a rectangular texture is not used, the texture coordinates are generally represented by normalization, that is, floating point numbers are used, and the floating point number range of 0 to 1 is used to represent 0 to size, that is: coord = coord_normalized*size.
[0046] However, since the normalized texture coordinates are floating-point numbers, when calculating the wrapped texture coordinates according to the calculation formulas of different wrap modes, it is actually a large number of floating-point operations such as multiplication, addition, and rounding of floating-point numbers. The calculation of floating-point numbers, especially the calculation of multiplication and division, requires a large implementation cost. When performing calculations on floating-point numbers, not only the calculation area is large, but the calculation delay is also long. Therefore, when implementing texture sampling based on floating-point numbers, the calculation cost is large and the efficiency is low.
[0047] Based on this, an embodiment of the present application provides a texture address wrapping method, which can improve the efficiency of texture sampling under different wrapping modes.
[0048] Reference Figure 1, shows a flowchart of the steps of a texture address wrapping method provided by an embodiment of the present application, such as Figure 1 , the method specifically comprises the following steps:
[0049] S101: preprocessing the normalized texture coordinates of the graphics to convert the normalized texture coordinates in floating point form into texture coordinates in fixed point decimal form.
[0050] Texture coordinates refer to coordinates in UV space, where U and V refer to the horizontal and vertical axes of the two-dimensional space. Texture coordinates can reflect the mapping relationship between texture images and graphics. For example, each vertex in a graphic is associated with a texture coordinate, indicating that the vertex needs to read the texture image data from that position. Generally, the value range of texture coordinates is [0,1]. However, if the texture coordinates actually exceed [0,1], it is necessary to find the address of the texture coordinates, that is, to use wraparound mode for addressing.
[0051] When a rectangular texture image is not used, a normalized representation is generally used for the texture coordinates of the graphic. This embodiment first converts the normalized texture coordinates coord_normalized in floating point form into texture coordinates in fixed point decimal form, so that operations in all wrap modes are performed in the fixed point domain.
[0052] Through continuous observation and analysis, the inventor discovered the following phenomena:
[0053] a. The result of coord mod size is the same as (coord_normalized mod 1)*size, so the value range of coord_normalized can be converted to between -1 and 1;
[0054] b. The result of coord mod (2*size) is the same as (coord_normalized mod 2)*size. Therefore, the value range of coord_normalized can be converted to between -2 and 2.
[0055] c. The valid value range of coord in clamp(coord,0,size-1), clamp(coord,-1,size), and clamp(mirror(coord),0,size-1) corresponds to the range between -1 and 1 after coord_normalized;
[0056] According to the above phenomenon and the calculation formulas of different wrap modes shown in Table 1, a rule is summarized: for different wrap modes, the value range of the normalized texture coordinate coord_normalized can always be limited to between -2 and 2 by means of clamp, mod 1, and mod 2. In other words, an unrestricted floating-point number can be converted into a range with a limited point domain, that is, the floating-point number is converted into a s1i1f23 (i.e., 1-bit sign bit, 1-bit integer, 23-bit decimal) format, and the conversion loss of precision is very small.
[0057] For example, when converting normalized texture coordinates in floating-point form into texture coordinates in fixed-point decimal form, the normalized texture coordinates of the graphic can be subjected to any one of clamp, mod1 and mod2 operations. For example, the clamp method is to compare with 2 and -2. If it is between -2 and 2, it is simply converted to the s1i1f23 format, otherwise it becomes the maximum or minimum number that can be represented by the s1i1f23 format; a calculation method for mod1 and mod2 is: shift the floating-point number according to the exponent, take the part less than 1 or less than 2, and quickly convert it to the s1i1f23 format according to the decimal point position.
[0058] In other implementations, other calculation methods may be used for format conversion, or the calculation method or the s1i1f23 format may be reasonably modified, which is not limited in this embodiment.
[0059] S102: Determine current texture coordinates according to the texture coordinates in fixed-point decimal form.
[0060] After the normalized texture coordinates in floating-point form are preprocessed to obtain fixed-point decimal representation, the normalized texture coordinates are mapped to the range of 0 to size, that is, the current texture coordinate coord in the wrap mode is the product of the normalized texture coordinate coord_normalized and the size size of the texture image on any coordinate axis, which is expressed as coord = coord_normalized*size.
[0061] For texture coordinates in fixed-point decimal form, they are also represented in the fixed-point number domain after multiplying by size. The format of the calculated result only needs to expand the number of bits of the integer part; for example, if size is a 13-bit integer, the calculated coord is represented in the format of s1i14f23, and the result of coord-0.5 is also represented in the format of s1i14f23.
[0062] S103: Determine the interval where the current texture coordinates are located and the sampling points in the interval among the multiple intervals pre-divided by any wrap mode, and perform texture sampling according to the sampling points in the interval.
[0063] In order to reduce a large number of complex calculations based on formulas in the wrap mode, any coordinate axis in each wrap mode is divided into multiple intervals in advance, and the sampling points in each interval are determined. Appropriate sampling points can be selected according to the interval where the current texture coordinates are located. Compared with a large number of calculations based on the texture coordinates, the amount of calculation can be greatly reduced, the calculation delay can be slowed down, and the efficiency of texture sampling can be improved.
[0064] For example, when dividing the intervals, the number of intervals and segmentation points of the wrap mode on any coordinate axis are calculated according to the wrap formula specified by each wrap mode specified by OpenGL, and two sampling points in each interval of the wrap mode are determined.
[0065] The number of intervals, segmentation points, and sampling point information in each interval for different wrap modes are as follows:
[0066] Table 2: Number of intervals and segmentation points for different wrap modes
[0067]
[0068]
[0069] Table 3: Values of two sampling points in each interval of the wrap mode CLAMP_TO_EDGE
[0070] Segmentation The values of the two sampling points 0.5 ≥ coord i0=0;i1=0 size-0.5>coord>0.5 i0=dw(coord-0.5); i1=i0+1 coord≥size-0.5 i0=size-1;i1=size-1
[0071] Table 4: Values of two sampling points in each interval of the wrap mode CLAMP_TO_BORDER
[0072] Segmentation The values of the two sampling points -0.5 ≥ coord i0=border color; i1=border color 0.5>coord>-0.5 i0 = border color; i1 = 0 size-0.5>coord≥0.5 i0=dw(coord-0.5); i1=i0+1 size+0.5>coord≥size-0.5 i0=size-1;i1=border color coord≥size+0.5 i0=border color; i1=border color
[0073] Table 5: Values of two sampling points in each interval of the wrap mode REPEAT
[0074] Segmentation The values of the two sampling points coord<0.5 i0=size-1;i1=0 size-0.5>coord≥0.5 i0=dw(coord-0.5); i1=i0+1 coord≥size-0.5 i0=size-1;i1=0
[0075] Table 6: Values of two sampling points in each interval of the wrap mode MIRRORED_REPEAT
[0076] Segmentation The values of the two sampling points coord≤0.5 i0=0;i1=0 size-0.5>coord>0.5 i0=dw(coord-0.5); i1=i0+1 size+0.5≥coord≥size-0.5 i0=size-1;i1=size-1 2*size-0.5>coord>size+0.5 i0=uw(2*size-0.5-coord); i1=i0-1 coord≥2*size-0.5 i0=0;i1=0
[0077] Table 7: Values of two sampling points in each interval of the wrap mode MIRRORED_CLAMP_TO_EDGE
[0078] Segmentation The values of the two sampling points coord≤-size+0.5 i0=size-1;i1=size-1 -0.5>coord>-size+0.5 i0=uw(-coord-0.5); i1=i0-1 0.5 ≥ coord ≥ -0.5 i0=0;i1=0 size-0.5>coord>0.5 i0=dw(coord-0.5); i1=i0+1 coord≥size-0.5 i0=size-1;i1=size-1
[0079] The same process can be used to segment other wrap modes. Wrap modes such as REPEAT and MIRRORED_REPEAT are essentially cyclic in nature, but because the normalized texture coordinates have been mod'd during preprocessing, a smaller number of segments can be obtained.
[0080] After predetermining the interval of each wrap mode and the sampling points within each interval, during texture sampling, the current texture coordinates are compared with the segmentation points predetermined by any wrap mode to determine the interval in which the texture coordinates are located in the wrap mode; based on the two sampling points in the interval in which the current texture coordinates are located in the wrap mode, the linear difference between the two sampling points is calculated, and the pixel value is obtained based on the calculated linear difference, thereby completing the texture sampling.
[0081] This method has at least the following beneficial effects:
[0082] 1. Convert the normalized texture coordinates in floating-point form into fixed-point decimal form, so that various wrapping modes are performed in the fixed-point domain, thereby reducing complex floating-point operations.
[0083] 2. Convert the mirror / clamp and other operations of the wrap mode into segments of any coordinate axis into multiple intervals and determine the sampling points of each interval, providing a simpler calculation method or fixed value in the sampling process. For example, two sampling points in an interval of some wrap modes are the same, which essentially gives a fixed value for sampling. Compared with the prior art, the wrap mode requires complex floating-point operations on texture coordinates in floating-point form according to the wrap. This method compares the interval where the current texture coordinates are located in any wrap mode, selects appropriate sampling points to calculate the difference, which can greatly reduce the amount of calculation, slow down the calculation delay, and thus improve the efficiency of texture sampling.
[0084] Reference Figure 2 , shows a functional module diagram of a texture address wrapping device provided in an embodiment of the present application, the device comprising:
[0085] The conversion module 100 is used to convert the normalized texture coordinates in floating point form into texture coordinates in fixed point decimal form by preprocessing the normalized texture coordinates of the graphics;
[0086] A coordinate determination module 200, for determining current texture coordinates according to the texture coordinates in the fixed-point decimal form;
[0087] The sampling module 300 is used to determine the interval where the current texture coordinates are located and the sampling points in the interval among the multiple intervals pre-divided by any wrap mode, and perform texture sampling according to the sampling points in the interval.
[0088] Optionally, the conversion module includes:
[0089] The conversion calculation unit is used to convert the normalized texture coordinates of the graphics in floating point form into texture coordinates in fixed point decimal form through any one of clamp, mod1 and mod2 operations.
[0090] Optionally, the coordinate determination module includes:
[0091] The coordinate determination unit is used to take the product of the texture coordinate in the fixed-point decimal form and the size of the texture image on any coordinate axis as the current texture coordinate.
[0092] Optionally, the device further comprises:
[0093] The segmentation module is used to calculate the number of intervals and segmentation points of any wrapping pattern on any coordinate axis according to the wrapping formula specified by the wrapping pattern, and determine two sampling points in each interval of the wrapping pattern.
[0094] Optionally, the sampling module includes:
[0095] An interval determination unit, used for comparing the current texture coordinates with a segmentation point predetermined by any wrap mode, and determining the interval in which the current texture coordinates are located in the wrap mode;
[0096] The sampling unit is used to calculate the linear difference between two sampling points according to the two sampling points in the interval where the current texture coordinates are located in the wrap mode, and perform texture sampling according to the linear difference.
[0097] An embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the texture address wrapping method described in the embodiment is implemented.
[0098] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0099] Those skilled in the art will appreciate that the embodiments of the present application can be provided as methods, devices, or computer program products. Therefore, the present application can adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application can adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0100] The embodiments of the present application are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0101] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0102] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0103] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present application.
[0104] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the elements.
[0105] Specific examples are used herein to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for those skilled in the art, according to the idea of the present application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A texture address wrapping method, characterized in that: The method comprises: By preprocessing the normalized texture coordinates of the graphics, the normalized texture coordinates in floating point form are converted into texture coordinates in fixed point decimal form; Determining current texture coordinates according to the texture coordinates in fixed-point decimal form; In a plurality of intervals pre-divided by any wrap mode, the interval in which the current texture coordinates are located and the sampling points in the interval are determined, and texture sampling is performed according to the sampling points in the interval.
2. The method according to claim 1, characterized in that The preprocessing of the normalized texture coordinates of the graphics to convert the normalized texture coordinates in floating point form into texture coordinates in fixed point decimal form includes: The normalized texture coordinates of the graphic are converted into texture coordinates in the form of fixed-point decimals by any one of clamp, mod1 and mod2 operations.
3. The method according to claim 1, characterized in that The step of determining the current texture coordinates according to the texture coordinates in the fixed-point decimal form includes: The product of the texture coordinate in fixed-point decimal form and the size of the texture image on any coordinate axis is used as the current texture coordinate.
4. The method according to claim 1, characterized in that: Before determining the interval in which the current texture coordinates are located and the sampling points in the interval in any of the multiple intervals pre-divided by the wrapping mode, the method further includes: According to the wrapping formula specified by any wrapping pattern, the number of intervals and segmentation points of the wrapping pattern on any coordinate axis are calculated, and two sampling points in each interval of the wrapping pattern are determined.
5. The method according to claim 4, characterized in that The step of determining the interval in which the current texture coordinates are located and the sampling points in the interval among the multiple intervals pre-divided by any wraparound mode, and performing texture sampling according to the sampling points in the interval, comprises: Compare the current texture coordinates with a segmentation point predetermined by any wrap mode to determine the interval in which the current texture coordinates are located in the wrap mode; According to two sampling points in the interval where the current texture coordinates are located in the wrap mode, a linear difference between the two sampling points is calculated, and texture sampling is performed according to the linear difference.
6. A texture address wrapping device, characterized in that: The device comprises: A conversion module, configured to convert the normalized texture coordinates in floating point form into texture coordinates in fixed point decimal form by preprocessing the normalized texture coordinates of the graphics; A coordinate determination module, used for determining the current texture coordinates according to the texture coordinates in the fixed-point decimal form; The sampling module is used to determine the interval where the current texture coordinates are located and the sampling points in the interval among the multiple intervals pre-divided by any wrap mode, and perform texture sampling according to the sampling points in the interval.
7. The device according to claim 6, characterized in that The conversion module comprises: The conversion calculation unit is used to convert the normalized texture coordinates of the graphics in floating point form into texture coordinates in fixed point decimal form through any one of clamp, mod1 and mod2 operations.
8. The device according to claim 6, characterized in that The coordinate determination module comprises: The coordinate determination unit is used to take the product of the texture coordinate in the fixed-point decimal form and the size of the texture image on any coordinate axis as the current texture coordinate.
9. The device according to claim 6, characterized in that The device also includes: The segmentation module is used to calculate the number of intervals and segmentation points of any wrapping pattern on any coordinate axis according to the wrapping formula specified by the wrapping pattern, and determine two sampling points in each interval of the wrapping pattern.
10. The device according to claim 9, characterized in that The sampling module comprises: An interval determination unit, used for comparing the current texture coordinates with a segmentation point predetermined by any wrap mode, and determining the interval in which the current texture coordinates are located in the wrap mode; The sampling unit is used to calculate the linear difference between two sampling points according to the two sampling points in the interval where the current texture coordinates are located in the wrap mode, and perform texture sampling according to the linear difference.
11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the texture address wrapping method according to any one of claims 1 to 5 is implemented.
Citation Information
Cited By
Texture coordinate processing method and device, electronic equipment and storage medium
CN120510266A
Texture coordinate processing method and device, electronic equipment and storage medium
CN120510266B