Texture rendering method and device based on UV space and computer equipment
Through the UV spatial texture rendering method based on camera position information, the problem of high resource consumption of traditional three-dimensional model rendering methods is solved, and efficient texture rendering and fast three-dimensional scene restoration are achieved.
Patent Information
- Application Number
- CN202411478919.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-22
- Publication Date
- 2025-02-28
AI Technical Summary
Traditional three-dimensional model rendering methods consume a lot of resources during texture mapping, resulting in slowing rendering speed and high hardware resource usage, especially in real-time rendering scenarios.
By generating a camera matrix based on camera position information, calculating the camera space vector, generating a perspective matrix, performing perspective transformation and perspective division on the three-dimensional spatial model, obtaining the model coordinates in UV space, and using these coordinates for texture sampling to generate the final texture rendering diagram.
It effectively reduces resource consumption during the three-dimensional model rendering process, improves rendering speed and scene restoration effect, especially in real-time rendering applications, which significantly improves performance.
Smart Images

Figure CN119540432A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing, and in particular to a texture rendering method, device and computer equipment based on UV space. Background Art
[0002] With the development of computer graphics, 3D model rendering technology is widely used in movies, games, virtual reality, augmented reality and other fields. In order to present high-quality 3D scenes, it is usually necessary to map textures to the surface of 3D models to give the models a sense of reality. This texture mapping process often relies on converting the object coordinates in 3D space into UV coordinate space so that the texture can be accurately applied to the surface of the object. Traditional 3D model rendering methods usually require a lot of computing resources when performing texture mapping. As the complexity of the scene increases, the complexity of the calculation also rises sharply. This not only slows down the rendering speed, but also greatly occupies hardware resources, especially in real-time rendering (such as games or virtual reality).
[0003] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention
[0004] The embodiments of the present invention provide a UV space-based texture rendering method, device and computer equipment to at least solve the technical problem that rendering a three-dimensional model consumes a lot of resources.
[0005] According to one aspect of an embodiment of the present invention, a texture rendering method based on UV space is provided, including: obtaining a camera matrix based on position information of a camera, and performing calculations based on the camera matrix to obtain a spatial vector of the camera; generating a perspective matrix based on the spatial vector of the camera, and using the perspective matrix to restore a target object in a perspective clipping space to obtain a three-dimensional space model after perspective transformation; performing perspective division on the three-dimensional space model to obtain model coordinates in UV space, and using the model coordinates in UV space to perform texture sampling on the target object to generate a final texture rendering image.
[0006] According to another aspect of an embodiment of the present invention, a texture rendering device based on UV space is also provided, including: a calculation module, configured to obtain a camera matrix based on the position information of the camera, and perform calculations based on the camera matrix to obtain the space vector of the camera; a perspective module, configured to generate a perspective matrix based on the space vector of the camera, and use the perspective matrix to restore the target object in the perspective clipping space to obtain a three-dimensional space model after perspective transformation; a mapping module, configured to perform perspective division on the three-dimensional space model to obtain model coordinates in the UV space, and use the model coordinates in the UV space to perform texture sampling on the target object to generate a final texture rendering image.
[0007] In the embodiment of the present invention, a camera matrix is obtained based on the position information of the camera, and a calculation is performed based on the camera matrix to obtain the spatial vector of the camera; a perspective matrix is generated based on the spatial vector of the camera, and the perspective matrix is used to restore the target object in the perspective clipping space to obtain a three-dimensional space model after perspective transformation; perspective division is performed on the three-dimensional space model to obtain the model coordinates in the UV space, and the model coordinates in the UV space are used to perform texture sampling on the target object to generate the final texture rendering. Through the above solution, the technical problem of consuming a lot of resources in rendering three-dimensional models is solved. BRIEF DESCRIPTION OF THE DRAWINGS
[0008] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:
[0009] Figure 1 is a flow chart of a texture rendering method based on UV space according to an embodiment of the present invention;
[0010] Figure 2 is a flowchart of another UV space-based texture rendering method according to an embodiment of the present invention;
[0011] Figure 3 is a flowchart of a method for generating a camera matrix according to an embodiment of the present invention;
[0012] Figure 4 is a flowchart of a method for calculating a spatial vector of a camera according to an embodiment of the present invention;
[0013] Figure 5 is a flow chart of a method for generating a perspective matrix according to an embodiment of the present invention;
[0014] Figure 6 is a flow chart of a method for performing perspective transformation and depth testing according to an embodiment of the present invention;
[0015] Figure 7 is a structural schematic diagram of a texture rendering device based on UV space according to an embodiment of the present invention;
[0016] Figure 8 A schematic diagram of the structure of an electronic device suitable for implementing the embodiments of the present disclosure is shown. DETAILED DESCRIPTION
[0017] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0018] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0019] According to an embodiment of the present invention, a method embodiment of a texture rendering method based on UV space is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0020] Figure 1 is a texture rendering method based on UV space according to an embodiment of the present invention, such as Figure 1 As shown, the method comprises the following steps:
[0021] Step S102, obtaining a camera matrix based on the position information of the camera, and performing calculation based on the camera matrix to obtain a space vector of the camera.
[0022] First, a camera matrix is obtained based on the position information of the camera. For example, the position information of the camera is obtained, and based on the position information of the camera and the coordinates of the center point of the target object, the distance vector from the camera to the target object is calculated; based on the distance vector, in combination with the viewing direction and the upward vector of the camera, the rotation matrix of the camera is constructed, wherein the rotation matrix is used to describe the posture information of the camera; by calculating the offset of the camera in three-dimensional space, the displacement matrix of the camera is generated, wherein the displacement matrix is used to describe the translation information of the camera relative to the world coordinate system; based on the rotation matrix and the displacement matrix, the camera matrix is generated. Through the above method, the present invention significantly improves the accuracy of three-dimensional rendering and the effect of scene restoration.
[0023] Next, calculations are performed based on the camera matrix to obtain the spatial vector of the camera. For example, the forward vector of the camera is obtained by subtracting the position coordinates corresponding to the position information of the camera from the coordinates of the center point of the target object; the right vector is obtained by performing a cross product calculation on the forward vector and the global up vector, wherein the right vector is used to describe the horizontal direction of the camera in the world coordinate system, and the global up vector is a fixed upward direction used to provide an upward standard; the up vector is obtained by performing a cross product calculation on the right vector and the forward vector, wherein the up vector is used to describe the vertical direction of the camera in the world coordinate system; wherein the spatial vector of the camera includes the forward vector, the right vector, and the up vector.
[0024] Step S104, generating a perspective matrix based on the spatial vector of the camera, and using the perspective matrix to restore the target object in the perspective clipping space to obtain a three-dimensional space model after perspective transformation.
[0025] First, generate a perspective matrix. For example, based on the forward vector, the right vector and the upward vector, and in combination with the field of view angle parameters and aspect ratio parameters of the camera, calculate the projection range of the cone; use the projection range of the cone to calculate the projection parameters of the perspective projection matrix, wherein the projection parameters of the perspective projection matrix include the cone angle range in the horizontal direction and the cone angle range in the vertical direction; based on the projection parameters of the perspective projection matrix, in combination with the distances of the near clipping plane and the far clipping plane of the camera, generate a perspective transformation matrix; use the perspective transformation matrix to map the coordinates in the three-dimensional space to the two-dimensional screen coordinates, and perform normalization processing to obtain the perspective matrix.
[0026] Then, restoration is performed. For example, the three-dimensional coordinate data of the target object is perspective transformed based on the perspective matrix, and the local coordinates of the target object are mapped to the perspective clipping space coordinate system; the perspective coordinate value of each vertex of the target object in the perspective clipping space coordinate system is calculated, and the perspective coordinate value of each vertex is normalized to the screen space coordinate system to obtain normalized screen space coordinates; based on the normalized screen space coordinates, the perspective coordinate value of each vertex of the target object is depth tested to determine the depth relationship of the perspective coordinate value of each vertex of the target object in the perspective space, and the three-dimensional space model after perspective transformation is obtained based on the depth relationship.
[0027] Step S106, performing perspective division on the three-dimensional space model to obtain model coordinates in UV space, and using the model coordinates in UV space to perform texture sampling on the target object to generate a final texture rendering image.
[0028] First, generate model coordinates in UV space. For example, by dividing the perspective coordinate value of each vertex of the target object by the depth component in the homogeneous coordinates, the perspective coordinate value of each vertex of the target object is converted into a normalized two-dimensional coordinate; based on the normalized two-dimensional coordinate, the three-dimensional coordinate is mapped into a two-dimensional UV space coordinate system so that each vertex of the target object corresponds to a texture coordinate of the UV space; based on the geometric shape and surface features of the target object, the distribution of the texture coordinates of the UV space is adjusted to obtain the model coordinates in the UV space.
[0029] Next, a final texture rendering is generated. For example, based on the model coordinates in the UV space, texture data corresponding to the model coordinates are extracted from a pre-generated texture map to obtain a preliminary texture sampling result; the preliminary texture sampling result is mapped pixel by pixel, and the extracted texture data is applied to the surface of the target object to generate a preliminary texture mapping map; based on the preliminary texture mapping map, a bilinear interpolation algorithm is performed on each UV coordinate point in the preliminary texture mapping map to smooth the texture data of adjacent pixels to obtain interpolated texture data, and a final texture rendering is generated based on the interpolated texture data.
[0030] The embodiment of the present invention provides another texture rendering method based on UV space, which can effectively solve the problems of distortion, detail loss and inaccurate occlusion relationship in the traditional texture mapping process. Figure 2 As shown, the following steps are included:
[0031] Step S202, generating a camera matrix.
[0032] like Figure 3 As shown, the method for generating a camera matrix includes the following steps:
[0033] Step S2022, obtaining the camera's location information.
[0034] The camera position information is obtained through sensors or set camera parameters, including the camera's three-dimensional coordinates (X, Y, Z) and the observation direction vector. These parameters describe the specific position and orientation of the camera in the three-dimensional world coordinate system. The camera's viewing direction is determined by the position of the target object. By adjusting the rotation and displacement of the camera, the best observation of the scene can be achieved.
[0035] Step S2024, calculate the rotation matrix of the camera.
[0036] After the camera position information is determined, the camera's rotation matrix is calculated. The camera's rotation matrix is used to describe the camera's rotation changes in three-dimensional space. First, the camera's right vector (i.e., horizontal vector) is calculated based on the camera's forward vector and the global up vector (usually the Y axis in the world coordinate system), and then the new up vector is obtained by cross-producting the forward vector and the right vector. The resulting rotation matrix represents the change in the camera's orientation.
[0037] Step S2026, generating the camera displacement matrix.
[0038] Calculate the displacement matrix based on the spatial coordinates of the camera. Generate a displacement matrix describing its relative position to the world coordinate system from the camera's 3D spatial position. This matrix will be used to move the camera from its initial position in the world coordinate system to the observation position of the target object.
[0039] Step S2028, combining and generating a camera matrix.
[0040] The rotation matrix and translation matrix of the camera are combined to generate a complete camera matrix. The camera matrix represents the position and orientation of the camera relative to the world coordinate system and is used to transform the coordinates in the 3D scene into the camera's observation coordinate system.
[0041] Step S204, calculating the space vector of the camera.
[0042] After the camera matrix is generated, the camera's space vector is calculated. The space vector includes the camera's forward vector, right vector, and up vector, which are used to describe the direction relationship of the camera in three-dimensional space and provide a basis for subsequent projection transformation. Specifically, Figure 4 As shown, the method for calculating the space vector of the camera includes the following steps:
[0043] Step S2042, calculate the forward vector.
[0044] The forward vector represents the viewing direction of the camera and is calculated by the vector difference between the camera's position and the center point of the target object. This vector is used to determine the specific direction the camera is facing in three-dimensional space and is normalized to a unit vector for subsequent calculations.
[0045] Step S2044, calculate the right vector.
[0046] The right vector is obtained by cross-producting the forward vector and the global up vector. The right vector is used to describe the orientation of the camera on the horizontal axis and is orthogonal to the forward vector and the up vector to form a spatial coordinate system.
[0047] Step S2046, calculate the upward vector.
[0048] The up vector is generated by cross-producting the right vector and the forward vector again. The up vector describes the direction of the camera on the vertical axis, ensuring that the camera's perspective in space is correct.
[0049] Step S2048, generate a camera space vector.
[0050] By calculating the forward, right, and upward vectors, the camera's space vectors are formed. These vectors will be used in the subsequent projection transformation process to ensure that the three-dimensional coordinates can be correctly mapped to the screen coordinates.
[0051] Step S206, generating a perspective matrix.
[0052] The perspective matrix projects the vertex coordinates in the three-dimensional scene onto the two-dimensional screen. Through perspective transformation, a true sense of depth and distance can be achieved. Figure 5 As shown, the method for generating a perspective matrix includes the following steps:
[0053] Step S2062, calculating the field of view angle parameters.
[0054] The field of view (FOV) is used to indicate the horizontal and vertical range that the camera can observe. The field of view and the aspect ratio of the camera determine the parameters of the perspective matrix. A larger field of view will result in more obvious perspective distortion, while a smaller field of view will provide a more flat view.
[0055] Step S2064, generating a perspective transformation matrix.
[0056] The perspective projection matrix is generated by the camera's near clipping plane, far clipping plane, field of view angle, and aspect ratio parameters. The perspective matrix converts the three-dimensional coordinates into homogeneous coordinates in the perspective clipping coordinate system, so that objects farther away appear smaller on the screen and objects closer appear larger, simulating the visual effect of the human eye. Then, based on the projection parameters of the perspective projection matrix, combined with the distances of the camera's near clipping plane and far clipping plane, a perspective transformation matrix is generated.
[0057] Step S2066, generating a perspective matrix.
[0058] The perspective transformation matrix is used to map the coordinates in the three-dimensional space to the two-dimensional screen coordinates, and normalized to obtain the perspective matrix.
[0059] Step S208, performing perspective transformation and depth testing.
[0060] like Figure 6 As shown, the method for performing perspective transformation and depth testing includes the following steps:
[0061] Step S2082, perspective transformation.
[0062] The vertex coordinates in the 3D scene are converted to coordinates in the perspective clipping coordinate system through the perspective matrix. This transformation produces a homogeneous coordinate that contains depth information, which is used to represent the distance relationship of objects in 3D space.
[0063] Step S2084, normalization processing.
[0064] The vertex coordinates in perspective clip coordinates need to be normalized, that is, converted to standard screen space coordinates. This is done by dividing by the w component of the homogeneous coordinates, thus transforming the 3D coordinates into 2D coordinates on the screen.
[0065] Step S2086, depth test.
[0066] Depth testing is used to ensure that objects in the scene can correctly occlude each other. By comparing the depth value of each vertex, the rendering engine can decide which objects should be displayed in front and which objects are occluded in the back. The results of the depth test ensure that the occlusion relationship and the distance relationship in the scene are correctly presented.
[0067] Step S210, generating model coordinates in UV space.
[0068] After the vertices in the 3D scene are converted to 2D screen coordinates, the texture coordinates in UV space are generated next. UV space is a 2D coordinate system used to map textures on the surface of a 3D model.
[0069] The homogeneous coordinates after perspective transformation need to be converted into actual two-dimensional coordinates through perspective division. The process of perspective division is to divide each component in the homogeneous coordinates by its w component to generate standard normalized coordinates for subsequent UV space texture mapping.
[0070] UV coordinates are generated by mapping normalized 2D coordinates onto the surface of the model. In the process of generating UV coordinates, the 3D coordinates of the vertex are mapped onto the UV plane to determine the texture position of each vertex. UV coordinates are used to describe the distribution of textures on the surface of the model to ensure that the texture can accurately cover the entire surface of the model.
[0071] In order to avoid distortion or stretching of the texture on the model surface, it is usually necessary to adjust the UV coordinates. The adjustment methods include evenly distributing the texture coordinates, or performing local optimization according to the normal direction and curvature of the model surface. Through these adjustments, it can ensure that the texture on the model surface is presented more naturally and realistically.
[0072] Step S212: texture mapping and interpolation processing.
[0073] After generating the model coordinates in UV space, the next step is to carry out the texture mapping process.
[0074] First, load the texture image for mapping. The texture image saves various details of the model surface, such as color, bumps, material, etc. Texture images can be in a variety of formats, such as JPEG, PNG or TGA. After loading the texture image, you may need to perform some preprocessing operations on it, such as scaling, rotating or filtering the image, to ensure that the texture can remain clear and correct during the mapping process.
[0075] Next, the texture mapping operation is performed according to the UV coordinates generated previously. Each vertex of the 3D model corresponds to a UV coordinate. By mapping the UV coordinate to the coordinate system of the texture image, the pixel position of each vertex on the texture image can be found. The texture coordinates can transition the texture colors between vertices through linear interpolation to ensure the smoothness of the model surface when the texture is displayed.
[0076] In order to improve the effect of texture mapping and avoid problems such as aliasing and distortion, in some embodiments, the texture image can be filtered. For example, the color value of the target pixel is calculated by interpolating four adjacent texture pixels. Bilinear filtering can make the texture surface smoother and reduce the graininess. When the viewing angle becomes extremely tilted, traditional bilinear or trilinear filtering may not be able to effectively solve the texture distortion problem. Therefore, anisotropic filtering methods can also be used to greatly reduce the blurring phenomenon under oblique viewing angles by sampling texture pixels in multiple directions, which is particularly suitable for scenes with dense textures.
[0077] In many cases, in order to enhance the expressiveness of the model, a single texture often cannot meet the needs. For example, in addition to the basic color texture, the model may also require multiple textures such as normal maps and bump maps to express different levels of the material. Therefore, when performing texture mapping, the system will also overlay multiple textures. For example, the normal map is used to increase surface details so that the model shows a richer sense of bumps and bumps under lighting. According to the normal information of each vertex, the reflection direction of the light in the area is adjusted to make the effect of light exposure more realistic.
[0078] In some embodiments, the UV coordinates are further optimized. When the UV coordinates are outside the range of [0,1], the texture can be repeated or tiled to ensure that the entire model surface is covered by the texture. In some cases, the texture can also be rotated or flipped so that the texture direction is consistent with the model surface structure.
[0079] After the texture mapping is completed, the model can also be subjected to illumination calculation and shading. When performing illumination calculation, an illumination model is used to simulate the effects of light reflection, refraction, and surface shadows. This embodiment adopts the Phong illumination model, which is a prior art and will not be described in detail here. After the illumination calculation is completed, the model surface will be shaded according to the properties of the material and the type of light source. By calculating the illumination value at each vertex and then interpolating between adjacent vertices, the color value of the entire model surface is obtained. Alternatively, illumination calculation can be performed on each pixel on the model surface, which can more accurately represent the details and illumination changes of the model. When the texture mapping and illumination calculation are completed, the two are fused to generate the final rendering result. In this process, the color information of the texture is multiplied by the result of the illumination calculation to generate a texture surface with light and shadow effects.
[0080] Texture mapping provides color information on the model surface, while lighting calculation provides light and shadow changes on the surface. During the rendering process, the final color value is generated by mixing the two. Specifically, the color value of each texture pixel is multiplied by the lighting value at the corresponding position to realize the influence of lighting on the texture surface.
[0081] In some embodiments, when using bump mapping, the reflection direction of the light is dynamically adjusted according to the change of the surface normal. By combining with the lighting model, bump mapping can make the surface present richer details under lighting, increasing the visual realism.
[0082] After the fusion of texture and lighting is completed, the final image is anti-aliased to ensure that the output rendering result has smooth edges and high-quality image effects. For example, by calculating the color value at multiple sampling points of each pixel, MSAA can effectively reduce the jagged phenomenon of the edge. After anti-aliasing, the final image generated will be output and stored. The final image can be saved in different resolutions and formats according to the application scenario, so as to facilitate display or use on different platforms.
[0083] Through the above steps, the present invention realizes a texture rendering method based on UV space, which can efficiently apply two-dimensional textures to the surface of three-dimensional models, and ensures high-quality performance of the final rendering results through lighting calculation and anti-aliasing processing.
[0084] The present application also provides a texture rendering device based on UV space, such as Figure 7 As shown, it includes: a calculation module 72, which is configured to obtain a camera matrix based on the position information of the camera, and to perform calculations based on the camera matrix to obtain the spatial vector of the camera; a perspective module 74, which is configured to generate a perspective matrix based on the spatial vector of the camera, and to restore the target object in the perspective clipping space using the perspective matrix to obtain a three-dimensional space model after perspective transformation; a mapping module 76, which is configured to perform perspective division on the three-dimensional space model to obtain the model coordinates in the UV space, and to perform texture sampling on the target object using the model coordinates in the UV space to generate a final texture rendering.
[0085] It should be noted that: the texture rendering device based on UV space provided in the above embodiment is only illustrated by the division of the above functional modules. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the texture rendering device based on UV space provided in the above embodiment and the texture rendering method embodiment based on UV space belong to the same concept. The specific implementation process is detailed in the method embodiment and will not be repeated here.
[0086] Figure 8 FIG. 1 shows a schematic diagram of the structure of an electronic device suitable for implementing the embodiment of the present disclosure. It should be noted that: Figure 8 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0087] like Figure 8As shown, the electronic device includes a central processing unit (CPU) 1001, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1002 or a program loaded from a storage part 1008 into a random access memory (RAM) 1003. In the RAM 1003, various programs and data required for system operation are also stored. The CPU 1001, the ROM 1002, and the RAM 1003 are connected to each other via a bus 1004. An input / output (I / O) interface 1005 is also connected to the bus 1004.
[0088] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A texture rendering method based on UV space, characterized in that: include: Obtaining a camera matrix based on the position information of the camera, and performing calculation based on the camera matrix to obtain a spatial vector of the camera; Generate a perspective matrix based on the spatial vector of the camera, and use the perspective matrix to restore the target object in the perspective clipping space to obtain a three-dimensional space model after perspective transformation; Perspective division is performed on the three-dimensional space model to obtain model coordinates in UV space, and texture sampling is performed on the target object using the model coordinates in UV space to generate a final texture rendering image.
2. The method according to claim 1, characterized in that The camera matrix is obtained based on the camera's position information, including: Acquire the position information of the camera, and calculate the distance vector from the camera to the target object based on the position information of the camera and the center point coordinates of the target object; Based on the distance vector, combined with the viewing direction and the upward vector of the camera, a rotation matrix of the camera is constructed, wherein the rotation matrix is used to describe the posture information of the camera; Generate a displacement matrix of the camera by calculating the offset of the camera in the three-dimensional space, wherein the displacement matrix is used to describe the translation information of the camera relative to the world coordinate system; The camera matrix is generated based on the rotation matrix and the translation matrix.
3. The method according to claim 1, characterized in that Calculating based on the camera matrix to obtain the space vector of the camera includes: Obtaining a forward vector of the camera by subtracting a position coordinate corresponding to the position information of the camera from the center point coordinate of the target object; A right vector is obtained by performing a cross product calculation on the forward vector and the global up vector, wherein the right vector is used to describe the horizontal direction of the camera in the world coordinate system, and the global up vector is a fixed upward direction and is used to provide an upward standard; An upward vector is obtained by performing a cross product calculation on the right vector and the forward vector, wherein the upward vector is used to describe the vertical direction of the camera in the world coordinate system; The spatial vectors of the camera include the forward vector, the right vector and the upward vector.
4. The method according to claim 3, characterized in that: Generate a perspective matrix based on the space vector of the camera, including: Calculate the projection range of the viewing cone based on the forward vector, the right vector and the upward vector, and in combination with the field of view angle parameter and the aspect ratio parameter of the camera; Calculating projection parameters of a perspective projection matrix using the projection range of the viewing cone, wherein the projection parameters of the perspective projection matrix include a viewing cone angle range in a horizontal direction and a viewing cone angle range in a vertical direction; Generate a perspective transformation matrix based on the projection parameters of the perspective projection matrix and in combination with the distances of the near clipping plane and the far clipping plane of the camera; The perspective transformation matrix is used to map the coordinates in the three-dimensional space to the two-dimensional screen coordinates, and normalized to obtain the perspective matrix.
5. The method according to claim 1, characterized in that The target object in the perspective clipping space is restored by using the perspective matrix to obtain a three-dimensional space model after perspective transformation, including: Performing perspective transformation on the three-dimensional coordinate data of the target object based on the perspective matrix, mapping the local coordinates of the target object to a perspective clipping space coordinate system; Calculating the perspective coordinate value of each vertex of the target object in the perspective clipping space coordinate system, and normalizing the perspective coordinate value of each vertex into the screen space coordinate system to obtain normalized screen space coordinates; Based on the normalized screen space coordinates, a depth test is performed on the perspective coordinate value of each vertex of the target object to determine the depth relationship of the perspective coordinate value of each vertex of the target object in the perspective space, and based on the depth relationship, the three-dimensional space model after perspective transformation is obtained.
6. The method according to claim 5, characterized in that Perform perspective division on the three-dimensional space model to obtain model coordinates in UV space, including: Converting the perspective coordinate value of each vertex of the target object into a normalized two-dimensional coordinate by dividing the perspective coordinate value of each vertex of the target object by a depth component in the homogeneous coordinate; Based on the normalized two-dimensional coordinates, mapping the three-dimensional coordinates into a two-dimensional UV space coordinate system so that each vertex of the target object corresponds to a texture coordinate of the UV space; Based on the geometric shape and surface features of the target object, the distribution of texture coordinates in the UV space is adjusted to obtain model coordinates in the UV space.
7. The method according to claim 1, characterized in that The target object is texture sampled using the model coordinates in the UV space to generate a final texture rendering image, including: Based on the model coordinates in the UV space, extracting texture data corresponding to the model coordinates from a pre-generated texture map to obtain a preliminary texture sampling result; Performing pixel-by-pixel mapping on the preliminary texture sampling result, applying the extracted texture data to the surface of the target object, and generating a preliminary texture mapping image; Based on the preliminary texture mapping image, a bilinear interpolation algorithm is performed on each UV coordinate point in the preliminary texture mapping image to smooth the texture data of adjacent pixels to obtain interpolated texture data, and based on the interpolated texture data, a final texture rendering image is generated.
8. A texture rendering device based on UV space, characterized in that: include: A calculation module is configured to obtain a camera matrix based on the position information of the camera, and to perform calculation based on the camera matrix to obtain a space vector of the camera; A perspective module is configured to generate a perspective matrix based on the spatial vector of the camera, and use the perspective matrix to restore the target object in the perspective clipping space to obtain a three-dimensional space model after perspective transformation; The mapping module is configured to perform perspective division on the three-dimensional space model to obtain model coordinates in UV space, and use the model coordinates in UV space to perform texture sampling on the target object to generate a final texture rendering image.
9. A computer device, characterized in that: include: Memory and processor, The memory stores a computer program; The processor is used to execute the computer program stored in the memory, and when the computer program is run, the processor is enabled to execute the method according to any one of claims 1 to 7.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.