Texture rendering method and device and electronic equipment
By randomly adjusting the sampling steps and blending process of pixels, the parallax occlusion mapping method is optimized, which solves the problems of artifacts and performance consumption in parallax occlusion mapping and achieves efficient rendering results.
Patent Information
- Application Number
- CN202511216962.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-28
- Publication Date
- 2026-01-23
AI Technical Summary
Existing parallax occlusion mapping methods suffer from artifacts due to insufficient sampling steps when the parallax is large, while excessive sampling steps increase the computational load, making it impossible to balance rendering performance and quality.
By randomly adjusting the initial sampling step count of each pixel to make the target sampling step count of each pixel different, and by determining the target sampling point through parallax mapping occlusion, the rendering process is optimized by combining the current frame with the historical frame.
While eliminating artifacts, it reduced rendering performance consumption and improved rendering effects, achieving a balance between performance and quality.
Smart Images

Figure CN121392091A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present disclosure relates to the technical field of rendering, and in particular to a texture rendering method, device and electronic equipment. BACKGROUND
[0002] In the current parallax occlusion mapping method, linear sampling is performed along the direction of the observation ray at a fixed step, the intersection points of the height field and the ray are detected layer by layer, the surface texture coordinates are dynamically adjusted, and the concave-convex effect with real depth perception is generated. Since the number of sampling steps is fixed, for surfaces with large parallax, if the number of sampling steps is insufficient, the surface will appear stepped artifacts. Although increasing the number of sampling steps can solve the artifacts, it will increase the calculation amount of the shader, affect the rendering performance, and cannot balance between rendering performance and rendering quality. SUMMARY
[0003] Therefore, the purpose of the present disclosure is to provide a texture rendering method, device and electronic equipment, which randomly adjusts the initial sampling step number of each pixel, so that the target sampling step number of each pixel is different, to realize the phase staggering of adjacent pixels, and through the mixing mechanism of the current frame and the historical frame, the performance consumption is reduced while solving the artifacts, and the rendering effect is improved.
[0004] In a first aspect, an embodiment of the present disclosure provides a texture rendering method, which comprises: for each pixel of a target model surface in a current frame to be rendered, performing step number adjustment processing on the initial sampling step number of the pixel to obtain the target sampling step number of the pixel; wherein the target sampling step number of at least part of the pixels after the step number adjustment processing is different; determining the target step length of the pixel according to the target sampling step number of the pixel; wherein the target step length of at least part of the pixels is different; determining the target sampling point of each pixel according to the target step length of the pixel in a parallax mapping occlusion manner; determining the texture information corresponding to the target sampling point as the texture information of the pixel, rendering the target model surface based on the texture information of the pixel to obtain the current frame; and mixing the pixel value of the current frame with the pixel value of a historical frame to obtain a processed current frame.
[0005] In a second aspect, the embodiments of the present disclosure provide a texture rendering device, which comprises: a sampling step number adjustment module, configured to perform step number adjustment processing on an initial sampling step number of each pixel of a target model surface in a current frame to be rendered, to obtain a target sampling step number of the pixel; wherein the target sampling step numbers of at least part of the pixels after the step number adjustment processing are different; a step length determination module, configured to determine a target step length of the pixel according to the target sampling step number of the pixel; wherein the target step lengths of at least part of the pixels are different; a sampling point determination module, configured to determine a target sampling point of each pixel according to the target step length of the pixel in a manner of disparity mapping occlusion; a model rendering module, configured to determine texture information corresponding to the target sampling point as texture information of the pixel, and render the target model surface based on the texture information of the pixel to obtain the current frame; and a blending processing module, configured to perform blending processing on pixel values of the current frame and pixel values of a historical frame to obtain a processed current frame.
[0006] In a third aspect, the embodiments of the present disclosure provide an electronic device, comprising a processor and a memory, the memory storing computer executable instructions capable of being executed by the processor, and the processor executes the computer executable instructions to implement the texture rendering method of any one of the first aspect.
[0007] In a fourth aspect, the embodiments of the present disclosure provide a computer readable storage medium, which stores computer executable instructions, and the computer executable instructions, when invoked and executed by a processor, cause the processor to implement the texture rendering method of any one of the first aspect.
[0008] The embodiments of the present disclosure bring the following beneficial effects:
[0009] The present disclosure provides a texture rendering method and device and electronic device, which performs step number adjustment processing on an initial sampling step number of each pixel of a target model surface in a current frame to be rendered, to obtain a target sampling step number of the pixel; wherein the target sampling step numbers of at least part of the pixels after the step number adjustment processing are different; determines a target step length of the pixel according to the target sampling step number of the pixel; wherein the target step lengths of at least part of the pixels are different; determines a target sampling point of each pixel according to the target step length of the pixel in a manner of disparity mapping occlusion; determines texture information corresponding to the target sampling point as texture information of the pixel, and renders the target model surface based on the texture information of the pixel to obtain the current frame; and performs blending processing on pixel values of the current frame and pixel values of a historical frame to obtain a processed current frame. In this way, the initial sampling step number of each pixel is randomly adjusted, so that the target sampling step numbers of each pixel are different, to realize phase staggering of adjacent pixel sampling, and through the blending mechanism of the current frame and the historical frame, the performance consumption is reduced while the artifacts are solved, and the rendering effect is improved.
[0010] Other features and advantages of the present disclosure will be set forth in the description that follows, and in part will be apparent from the description, or can be learned by practice of the present disclosure. The purposes and other advantages of the present disclosure will be realized and attained by the structure particularly pointed out in the description, claims and drawings.
[0011] In order to make the above objectives, features and advantages of the present disclosure more apparent, the following will specifically describe preferred embodiments of the present disclosure, and make a detailed description with reference to the accompanying drawings. BRIEF DESCRIPTION OF DRAWINGS
[0012] In order to more clearly illustrate the specific embodiments of the present disclosure or the technical solutions in the prior art, the following will briefly introduce the drawings needed to be used in the specific embodiments or prior art description. Obviously, the drawings described below are some embodiments of the present disclosure, and other drawings can be obtained by those skilled in the art without creative labor on the basis of these drawings.
[0013] Figure 1 A schematic diagram of a texture rendering result provided by an embodiment of the present disclosure;
[0014] Figure 2 A flowchart of a texture rendering method provided by an embodiment of the present disclosure;
[0015] Figure 3 A schematic diagram of another texture rendering result provided by an embodiment of the present disclosure;
[0016] Figure 4 A structural schematic diagram of a texture rendering device provided by an embodiment of the present disclosure;
[0017] Figure 5 A structural schematic diagram of an electronic device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION
[0018] In order to make the objectives, technical solutions and advantages of the embodiments of the present disclosure more apparent, the technical solutions of the present disclosure will be described clearly and completely with reference to the drawings. Obviously, the described embodiments are only some of the embodiments of the present disclosure, but not all the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by those skilled in the art without creative labor fall within the protection scope of the present disclosure.
[0019] Parallax occlusion mapping (POM) is a texture mapping technique widely used in real-time rendering. Its core goal is to achieve high-precision geometric detail on the surface of low-polygon models by simulating the offset of the height field on the ray path. Traditional POM technology performs linear sampling with a fixed step size along the direction of the viewing ray, detecting the intersection of the height field and the ray layer by layer, thereby dynamically adjusting the surface texture coordinates to generate a bump effect with realistic depth. Compared to normal mapping, POM can produce more realistic parallax displacement and self-occlusion effects, and therefore is widely used in game development, virtual reality, and other fields.
[0020] However, traditional POM technology has the following significant drawbacks: when the parallax height parameter increases, insufficient sampling steps lead to exacerbated discretization errors, manifesting as step-like artifacts on the rendered surface. For example, ... Figure 1 As shown in the diagram, this phenomenon stems from the inherent characteristics of the algorithm, which involves uniformly sampling the height field at fixed intervals. Specifically, the number of sampling steps determines the number of "slices" into which the ray path is divided. A larger number of steps results in denser slices and less artifacts, but the computational load increases linearly. For example, in mobile devices or complex scenes, increasing the number of sampling steps from 16 to 32 steps can double the computational load of the pixel shader, severely impacting rendering performance.
[0021] In summary, for flat areas, excessively high sampling steps result in wasted performance; for steep parallax areas, excessively low sampling steps lead to artifact persistence. Existing technologies mitigate artifacts by globally increasing the sampling steps, but this method lacks spatial adaptability and fails to achieve a balance between performance and quality. Therefore, this disclosure provides a texture rendering method, apparatus, and electronic device, applicable to devices with rendering capabilities, particularly suitable for games or animations that require rendering virtual scenes using parallax occlusion mapping technology.
[0022] To facilitate understanding of this embodiment, a texture rendering method disclosed in this disclosure will first be described in detail, such as... Figure 2 As shown, the method includes the following steps:
[0023] Step S202: For each pixel on the surface of the target model in the current frame to be rendered, the initial sampling step number of the pixel is adjusted to obtain the target sampling step number of the pixel; wherein, at least some pixels have different target sampling steps after the step adjustment process.
[0024] The current frame can be a game animation frame or a video frame, and the target model can be a virtual ground, a virtual wall or other virtual model in a virtual scene.
[0025] In one possible way, different adjustment parameters are set for each pixel in advance, and the initial sampling step number of the pixel is multiplied by the adjustment parameter set in advance for the pixel to obtain the target sampling step number of the pixel.
[0026] In another possible way, a random value is set for each pixel based on noise, and the initial sampling step number of the pixel is multiplied by the random value set for the pixel to obtain the target sampling step number of the pixel.
[0027] For example, the surface of the target model includes three pixels, and the initial sampling step number of each pixel is a fixed sampling step number 32. The initial sampling step number 32 of the first pixel is multiplied by a first random value 0.6 to obtain a target sampling step number 19 of the first pixel. The initial sampling step number 32 of the second pixel is multiplied by a second random value 0.9 to obtain a target sampling step number 29 of the second pixel. The initial sampling step number 32 of the third pixel is multiplied by a second random value 1.1 to obtain a target sampling step number 35 of the third pixel.
[0028] In step S204, the target step length of the pixel is determined according to the target sampling step number of the pixel; wherein the target step length of at least part of the pixels is different.
[0029] Specifically, the ratio of the maximum depth value of the surface of the target model to the target sampling step number of the pixel is calculated to obtain the target step length of the pixel.
[0030] Generally, the maximum depth value of the surface of the target model is fixed. If the target sampling step number of the pixel changes, the step length of the pixel will also change accordingly. For example, the maximum depth value is 10, and the initial sampling step number of the pixel is 10. The initial step length of the pixel is 1. If the initial sampling step number of the pixel changes to 5, the target step length of the pixel changes to 2.
[0031] In step S206, for each pixel, the target sampling point of the pixel is determined according to the target step length of the pixel by means of disparity mapping and occlusion.
[0032] Specifically, for each pixel, a starting sampling point of the pixel is determined, and the starting sampling point is usually a pixel center of the pixel, then a depth value and a height value corresponding to the starting sampling point are obtained from a depth map and a height map corresponding to a surface of the target model, whether the starting sampling point hits the intersection point is determined according to the depth value and the height value, if not, a next sampling point of the pixel is determined by stepping a target step length in a stepping direction, then a depth value and a height value of the next sampling point are obtained from the depth map and the height map corresponding to the surface of the target model, until it is determined that the intersection point is hit, and a target sampling point is determined according to the sampling point corresponding to the intersection point.
[0033] The manner of determining the target sampling point is the same as that of determining the target sampling point in the conventional disparity mapping occlusion, except that the sampling step number of each pixel in the embodiment is different, and therefore, relative to the pixels with a fixed sampling step number, the sampling point positions of adjacent pixels are not uniformly distributed in the same frame.
[0034] In step S208, texture information corresponding to the target sampling point is determined as texture information of the pixel, and a surface of the target model is rendered based on the texture information of the pixel, to obtain a current frame.
[0035] Specifically, the texture information of the pixel is obtained by sampling a texture map according to the UV coordinates of the target sampling point, and then the texture information of the pixel is rendered to the pixel by a shader.
[0036] In step S210, a current pixel value of the current frame and a historical pixel value of a historical frame are mixed to obtain a processed current frame.
[0037] The historical frame can be a previous historical frame of the current frame, or previous two historical frames, etc.
[0038] Optionally, for each pixel of the current frame, a current pixel value of the pixel is determined from the current frame, a historical pixel value corresponding to the pixel is determined from each historical frame, an average value of the current pixel value and the historical pixel value is calculated or a weighted average value of the current pixel value and the historical pixel value is calculated, to obtain a target pixel value of the pixel, the current pixel value of the pixel in the current frame is replaced by the target pixel value, and a processed current frame is obtained.
[0039] The embodiment of the present disclosure provides a texture rendering method, for each pixel of a target model surface in a current frame to be rendered, step number adjustment processing is performed on an initial sampling step number of the pixel to obtain a target sampling step number of the pixel; wherein the target sampling step numbers of at least part of the pixels after the step number adjustment processing are different; a target step length of the pixel is determined according to the target sampling step number of the pixel; wherein the target step lengths of at least part of the pixels are different; for each pixel, a target sampling point of the pixel is determined according to the target step length of the pixel in a manner of disparity mapping occlusion; texture information corresponding to the target sampling point is determined as texture information of the pixel, a target model surface is rendered based on the texture information of the pixel to obtain a current frame; pixel values of the current frame and pixel values of a historical frame are mixed to obtain a processed current frame. In this way, the initial sampling step number of each pixel is randomly adjusted, the target sampling step numbers of each pixel are different, the sampling phases of adjacent pixels are staggered, through the mixing mechanism of the current frame and the historical frame, the performance consumption is reduced while the artifacts are solved, and the rendering effect is improved.
[0040] The step of adjusting the initial sampling step number of the pixel to obtain the target sampling step number of the pixel, in one possible implementation, for each pixel, a random number value corresponding to the pixel is determined; wherein the random number values corresponding to at least part of the pixels are different; the initial sampling step number of the pixel is multiplied by the random number value to obtain the target sampling step number of the pixel.
[0041] The random number value is determined by the blue noise. The target sampling step numbers of the pixel in different frames after the step number adjustment processing are different.
[0042] In actual implementation, the target sampling point of each pixel in each frame is determined by multiplying the initial sampling step number of each pixel by the bluenoiseDitherTAA. The sampling points of adjacent pixels in the same frame can be staggered in space (i.e., non-uniformly distributed), and the positions of the sampling points of the same pixel in different frames can change over time (i.e., staggered in time). In this way, the ladder-shaped artifacts that originally appear at a fixed position in a single frame can be "scattered" to different positions in space and time.
[0043] The calculation formula of the bluenoiseDitherTAA is as follows: ∈ blue is a high-frequency noise, and after being filtered by the human eye, ∫∈ blue dt≈0. Wherein, C true is the real color of the blue noise texture, N is the number of frames, output is the final output color, which is obtained by averaging the sampling results for N times.
[0044] Specifically, the blue noise texture is highly spatially uncorrelated. That is, the corresponding random values (i.e., offsets) of adjacent pixels in the blue noise texture are independent of each other and uniformly distributed. Therefore, when we apply this offset to each pixel, the sampling point positions of adjacent pixels will be misaligned due to different offsets.
[0045] In addition, in order to introduce temporal changes, a time-varying parameter (e.g., a frame counter) is usually used to sample the blue noise texture. Specifically, this can be achieved by modifying the sampling coordinates of the blue noise texture.
[0046] For example, BN_sample = texture(blueNoiseTex, vec2(pixel_uv) + time_offset); where texture() is a texture sampling function used to obtain the pixel value of a specified coordinate from a texture; vec2(pixel_uv) is the texture coordinate of the current pixel, which is usually a two-dimensional vector ranging from [0, 1]; BN_sample is the sampling result, which stores the noise value (i.e., the random value) obtained from the blue noise texture, blueNoiseTex is the blue noise texture, and time_offset can be a time-varying vector (e.g., rotating a certain angle every frame or using a different offset every frame). In this way, the same pixel in different frames will have different blue noise values (i.e., random values) due to the change of time_offset, which in turn causes the sampling point position to change over time.
[0047] For example, a global frame counter is used as a random seed to generate different blue noise patterns every frame, and the blue noise texture corresponding to each frame is different. Finally, the random value determined by the same pixel in different frames will also be different (but usually a pre-generated texture is used to obtain noise values for different frames by changing the sampling method).
[0048] The above method of parallax mapping occlusion determines the target sampling point of each pixel according to the target step length of the pixel. One possible implementation is as follows:
[0049] (1) Obtain the depth map and height map corresponding to the target model surface;
[0050] The above depth map and height map are maps generated in advance according to the target model surface.
[0051] (2) By the method of parallax mapping occlusion, for each pixel, determine a plurality of sampling points of the pixel and a sampling order of the plurality of sampling points according to a target step length of the pixel;
[0052] Specifically, the virtual camera in the virtual scene containing the target model surface is controlled to emit a step ray to the target model surface; an initial sampling point of a pixel is determined, and the step ray is controlled to step from the initial sampling point to a second sampling point of the pixel according to a target step length along a step direction; the second sampling point is taken as the initial sampling point, and the step of controlling the step ray corresponding to the pixel to step from the initial sampling point to a third sampling point according to the target step length along the step direction is continued until the number of steps reaches a target sampling number, to obtain a plurality of sampling points and a sampling order of the plurality of sampling points. The initial sampling point of the pixel is usually the pixel center of the pixel.
[0053] (3) taking the first sampling point in the sampling order as a current sampling point, determining a depth value corresponding to the current sampling point from the depth map and a height value corresponding to the current sampling point from the height map, and judging whether the intersection point corresponding to the pixel is found according to the depth value and the height value;
[0054] Specifically, if the height value is greater than or equal to the depth value, it is determined that the intersection point corresponding to the pixel is found, and if the height value is less than the depth value, it is determined that the intersection point corresponding to the pixel is not found.
[0055] (4) if yes, determining a target sampling point of the pixel according to the current sampling point and a sampling point located in front of the current sampling point;
[0056] Specifically, if the height value is equal to the depth value, the current sampling point is determined as the target sampling point of the pixel; if the height value is greater than the depth value, interpolation calculation is performed between the current sampling point and the sampling point located in front of the current sampling point, and the target sampling point of the pixel is determined through thread interpolation or bisection.
[0057] (5) if no, taking the second sampling point in the sampling order as the current sampling point until the target sampling point of the pixel is determined, or until the current sampling point is the last sampling point in the sampling order, and the last sampling point is determined as the target sampling point of the pixel.
[0058] The step of mixing the pixel value of the current frame with the pixel value of the historical frame to obtain the processed current frame, and one possible implementation manner is as follows: for each pixel in the current frame, an initial pixel value of the pixel is determined; a pixel value of a target pixel corresponding to the pixel is determined from the historical frame; the initial pixel value of the pixel is mixed with the pixel value of the target pixel through weighted mixing to determine a target pixel value of the pixel, and the processed current frame is obtained.
[0059] Optionally, a target pixel corresponding to the pixel is determined from a history frame by a motion vector. Specifically, the pixel in the history frame is re-projected to a position in the current frame according to motion information of the camera and the object. The pixel value of the pixel in the current frame is mixed with the pixel value of the target pixel in the history frame after re-projection by weighting (usually the weight corresponding to the current frame is low, such as 0.1-0.2).
[0060] The method further includes: obtaining a virtual camera in a virtual scene containing the target model surface, creating a mask based on a camera position of the virtual camera; determining a target virtual scene in the virtual scene within the mask; and performing, for each pixel in the target virtual scene, the step of adjusting the initial sampling step number of the pixel.
[0061] Specifically, a circular mask is made with the position of the virtual camera as the center, so that the POM calculation is only performed in the range that can be seen in front, thereby optimizing the performance consumption.
[0062] In the above manner, due to the blue noise dithering, the artifacts appear as rapidly changing high-frequency noise in the time domain (the position of each frame is different). The multi-frame mixing of TAA (Temporal Anti-Aliasing) is equivalent to low-pass filtering (averaging operation) in the time domain on these high-frequency noises. The human eye has weak perception on high-frequency noise (visual persistence effect will fuse multiple frames), and finally a continuous and smooth result is obtained in vision, for example, as shown in Figure 3 .
[0063] Corresponding to the method embodiment, the embodiment of the disclosure provides a texture rendering device, as shown in Figure 4 . The device includes:
[0064] The sampling step number adjustment module 401 is configured to perform, for each pixel of a target model surface in a current frame to be rendered, step number adjustment processing on an initial sampling step number of the pixel to obtain a target sampling step number of the pixel; and wherein the target sampling step numbers of at least part of the pixels after the step number adjustment processing are different.
[0065] The step length determination module 402 is configured to determine a target step length of the pixel according to the target sampling step number of the pixel; and wherein the target step lengths of at least part of the pixels are different.
[0066] The sampling point determination module 403 is configured to determine, for each pixel, a target sampling point of the pixel according to the target step length of the pixel by means of disparity mapping masking.
[0067] The model rendering module 404 is configured to determine texture information corresponding to the target sampling point as texture information of the pixel, and render the target model surface based on the texture information of the pixel to obtain the current frame.
[0068] The mixing processing module 405 is configured to mix pixel values of the current frame with pixel values of the historical frame to obtain a processed current frame.
[0069] The embodiment of the present disclosure provides a texture rendering device. For each pixel of a target model surface in a current frame to be rendered, step number adjustment processing is performed on an initial sampling step number of the pixel to obtain a target sampling step number of the pixel. At least part of the target sampling step numbers of the pixels after the step number adjustment processing are different. A target step length of the pixel is determined according to the target sampling step number of the pixel. At least part of the target step lengths of the pixels are different. For each pixel, a target sampling point of the pixel is determined according to the target step length of the pixel in a manner of disparity mapping masking. Texture information corresponding to the target sampling point is determined as texture information of the pixel. The target model surface is rendered based on the texture information of the pixel to obtain the current frame. Pixel values of the current frame are mixed with pixel values of a historical frame to obtain a processed current frame. In this way, the initial sampling step number of each pixel is randomly adjusted, the target sampling step number of each pixel is different, the sampling phase of adjacent pixels is staggered, the mixing mechanism of the current frame and the historical frame is used, the performance consumption is reduced while the artifacts are solved, and the rendering effect is improved.
[0070] The sampling step number adjustment module is further configured to: for each pixel, determine a random number value corresponding to the pixel. At least part of the random number values corresponding to the pixels are different. The initial sampling step number of the pixel is multiplied by the random number value to obtain the target sampling step number of the pixel.
[0071] The random number value is determined by a blue noise.
[0072] For the same pixel, the target sampling step number of the pixel is different after the step number adjustment processing in different frames.
[0073] The step length determination module is further configured to: calculate a ratio of a maximum depth value of the target model surface to the target sampling step number of the pixel to obtain the target step length of the pixel.
[0074] The sampling point determination module is further configured to: obtain a depth map and a height map corresponding to the target model surface; determine, for each pixel, a plurality of sampling points and a sampling order of the plurality of sampling points according to a target step length of the pixel by means of parallax mapping occlusion; take a first sampling point in the sampling order as a current sampling point, determine a depth value corresponding to the current sampling point from the depth map, determine a height value corresponding to the current sampling point from the height map, and determine whether an intersection point corresponding to the pixel is found according to the depth value and the height value; if yes, determine a target sampling point of the pixel according to the current sampling point and a sampling point located before the current sampling point; and if no, take a second sampling point in the sampling order as the current sampling point until the target sampling point of the pixel is determined, or until the current sampling point is a last sampling point in the sampling order, and determine the last sampling point as the target sampling point of the pixel.
[0075] The sampling point determination module is further configured to: control a virtual camera in a virtual scene containing the target model surface to emit a step ray to the target model surface; determine an initial sampling point of a pixel, and control the step ray to perform a step from the initial sampling point according to a target step length along a step direction to obtain a second sampling point of the pixel; take the second sampling point as the initial sampling point, and continue to perform the step of controlling the step ray corresponding to the pixel to perform a step from the initial sampling point according to the target step length along the step direction to obtain a third sampling point until a step number reaches a target sampling number, to obtain a plurality of sampling points and a sampling order of the plurality of sampling points.
[0076] The mixing processing module is further configured to: for each pixel in a current frame, determine an initial pixel value of the pixel; determine a pixel value of a target pixel corresponding to the pixel from a historical frame; and perform weighted mixing processing on the initial pixel value of the pixel and the pixel value of the target pixel to determine a target pixel value of the pixel, to obtain a processed current frame.
[0077] The device further includes a mask creation module configured to: obtain a virtual camera in a virtual scene containing a target model surface, and create a mask based on a camera position of the virtual camera; determine a target virtual scene in the virtual scene located in the mask, and perform the step of performing step number adjustment processing on an initial sampling step number of each pixel in the target virtual scene.
[0078] The texture rendering device provided by the embodiments of the present disclosure has the same technical features as the texture rendering method provided by the above embodiments, and can solve the same technical problems and achieve the same technical effects.
[0079] The embodiment also provides an electronic device, comprising a processor and a memory, the memory storing machine executable instructions capable of being executed by the processor, and the processor executes the machine executable instructions to implement the above texture rendering method. The electronic device can be a server or a terminal device.
[0080] Referring to Figure 5 The electronic device shown in the figure comprises a processor 100 and a memory 101, the memory 101 storing machine executable instructions capable of being executed by the processor 100, and the processor 100 executes the machine executable instructions to implement the above texture rendering method.
[0081] Further, Figure 5 The electronic device shown in the figure further comprises a bus 102 and a communication interface 103, and the processor 100, the communication interface 103 and the memory 101 are connected through the bus 102.
[0082] The memory 101 can contain a high-speed random access memory (RAM, Random Access Memory) and can also include a non-volatile memory, such as at least one disk memory. The communication connection between the system network element and at least one other network element is realized through at least one communication interface 103 (which can be wired or wireless), and the Internet, a wide area network, a local area network, a metropolitan area network, etc. can be used. The bus 102 can be an ISA (Industry Standard Architecture, Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect, Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture, Extended Industry Standard Architecture) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 5 Only one bidirectional arrow is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0083] The processor 100 can be an integrated circuit chip with processing capability. In the implementation process, each step of the above method can be completed by the integrated logic circuit of hardware in the processor 100 or the instruction in the form of software. The processor 100 described above can be a general processor, including a central processing unit (CPU), a network processor (NP), etc.; can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component. Each method, step and logic block diagram disclosed in the embodiments of the present disclosure can be implemented or executed. The general processor can be a microprocessor or the processor can also be any conventional processor. The steps of the method disclosed in combination with the embodiments of the present disclosure can be directly embodied as a hardware code processor for execution, or a combination of hardware and software modules in the code processor for execution. The software module can be located in a random memory, a flash memory, a read-only memory, a programmable read-only memory, an electrically erasable programmable memory, a register or other mature storage medium in the art. The storage medium is located in the memory 101, and the processor 100 reads the information in the memory 101, and combines the hardware to complete the steps of the method of the above embodiments.
[0084] The processor in the above electronic device can implement the following operations in the above texture rendering method by executing machine executable instructions:
[0085] For each pixel of a target model surface in a current frame to be rendered, a step number adjustment is performed on an initial sampling step number of the pixel to obtain a target sampling step number of the pixel; wherein the target sampling step number of at least part of the pixels after the step number adjustment is different; a target step length of the pixel is determined according to the target sampling step number of the pixel; wherein the target step length of at least part of the pixels is different; for each pixel, a target sampling point of the pixel is determined according to the target step length of the pixel in a manner of disparity mapping occlusion; texture information corresponding to the target sampling point is determined as texture information of the pixel, and the target model surface is rendered based on the texture information of the pixel to obtain the current frame; pixel values of the current frame and pixel values of a historical frame are mixed to obtain a processed current frame. In this way, the initial sampling step number of each pixel is randomly adjusted, so that the target sampling step number of each pixel is different, so as to realize the interlacing of adjacent pixel sampling phases, and through the mixing mechanism of the current frame and the historical frame, the performance consumption is reduced while solving the artifacts, and the rendering effect is improved.
[0086] The step of adjusting the initial sampling step number of the pixel to obtain the target sampling step number of the pixel includes: for each pixel, determining a random number value corresponding to the pixel; wherein the random number values corresponding to at least part of the pixels are different; and multiplying the initial sampling step number of the pixel by the random number value to obtain the target sampling step number of the pixel.
[0087] The random number value is determined by blue noise.
[0088] For the same pixel, the target sampling step number of the pixel is different after the step number adjustment in different frames.
[0089] The step of determining the target step length of the pixel according to the target sampling step number of the pixel includes: calculating a ratio of a maximum depth value of the target model surface to the target sampling step number of the pixel to obtain the target step length of the pixel.
[0090] The step of determining the target sampling point of the pixel according to the target step length of the pixel by the parallax mapping occlusion method comprises: obtaining a depth map and a height map corresponding to the target model surface; determining, by the parallax mapping occlusion method, the multiple sampling points of the pixel and the sampling order of the multiple sampling points according to the target step length of the pixel; taking the first sampling point in the sampling order as the current sampling point, determining the depth value corresponding to the current sampling point from the depth map and the height value corresponding to the current sampling point from the height map, and judging whether the intersection point corresponding to the pixel is found according to the depth value and the height value; if yes, determining the target sampling point of the pixel according to the current sampling point and the sampling point located before the current sampling point; if no, taking the second sampling point in the sampling order as the current sampling point until the target sampling point of the pixel is determined or until the current sampling point is the last sampling point in the sampling order, and determining the last sampling point as the target sampling point of the pixel.
[0091] The step of determining the multiple sampling points of the pixel and the sampling order of the multiple sampling points according to the target step length of the pixel comprises: controlling a virtual camera in a virtual scene containing the target model surface to emit a step ray to the target model surface; determining an initial sampling point of the pixel, and controlling the step ray to perform a step from the initial sampling point according to the target step length along a step direction to obtain a second sampling point of the pixel; taking the second sampling point as the initial sampling point, and continuing to perform the step of controlling the step ray corresponding to the pixel to perform a step from the initial sampling point according to the target step length along the step direction to obtain a third sampling point until the step number reaches a target sampling number, to obtain the multiple sampling points and the sampling order of the multiple sampling points.
[0092] The step of mixing the pixel value of the current frame with the pixel value of the historical frame to obtain the processed current frame comprises: determining an initial pixel value of the pixel for each pixel in the current frame; determining the pixel value of the target pixel corresponding to the pixel from the historical frame; and performing weighted mixing processing on the initial pixel value of the pixel and the pixel value of the target pixel to determine the target pixel value of the pixel, to obtain the processed current frame.
[0093] The method further comprises: obtaining a virtual camera in a virtual scene containing the target model surface, and creating a mask based on the camera position of the virtual camera; determining a target virtual scene in the virtual scene located in the mask, and performing the step of adjusting the step number of the initial sampling step of the pixel for each pixel in the target virtual scene.
[0094] The embodiment also provides a machine readable storage medium, which stores machine executable instructions. When the machine executable instructions are called and executed by a processor, the machine executable instructions cause the processor to implement the texture rendering method.
[0095] The machine executable instructions stored in the machine readable storage medium can realize the following operations in the texture rendering method by executing the machine executable instructions:
[0096] For each pixel of a target model surface in a current frame to be rendered, step number adjustment processing is performed on an initial sampling step number of the pixel to obtain a target sampling step number of the pixel; wherein the target sampling step number of at least part of the pixels after the step number adjustment processing is different; a target step length of the pixel is determined according to the target sampling step number of the pixel; wherein the target step length of at least part of the pixels is different; for each pixel, a target sampling point of the pixel is determined according to the target step length of the pixel in a manner of disparity mapping occlusion; texture information corresponding to the target sampling point is determined as texture information of the pixel, and the target model surface is rendered based on the texture information of the pixel to obtain the current frame; pixel values of the current frame and pixel values of a historical frame are mixed to obtain a processed current frame. In this way, the initial sampling step number of each pixel is randomly adjusted, so that the target sampling step number of each pixel is different, so as to realize the interlacing of adjacent pixel sampling phases, and through the mixing mechanism of the current frame and the historical frame, the performance consumption is reduced while solving the artifacts, and the rendering effect is improved.
[0097] The step of adjusting the initial sampling step number of the pixel to obtain the target sampling step number of the pixel includes: for each pixel, determining a random number value corresponding to the pixel; wherein the random number values corresponding to at least part of the pixels are different; and multiplying the initial sampling step number of the pixel by the random number value to obtain the target sampling step number of the pixel.
[0098] The random number value is determined by blue noise.
[0099] For the same pixel, the target sampling step number of the pixel is different after the step number adjustment processing in different frames.
[0100] The step of determining the target step length of the pixel according to the target sampling step number of the pixel includes: calculating a ratio of a maximum depth value of the target model surface to the target sampling step number of the pixel to obtain the target step length of the pixel.
[0101] The step of determining the target sampling point of the pixel according to the target step length of the pixel in the manner of parallax mapping occlusion includes: obtaining a depth map and a height map corresponding to the target model surface; in the manner of parallax mapping occlusion, for each pixel, determining a plurality of sampling points of the pixel and a sampling order of the plurality of sampling points according to the target step length of the pixel; taking the first sampling point in the sampling order as a current sampling point, determining a depth value corresponding to the current sampling point from the depth map and a height value corresponding to the current sampling point from the height map, and judging whether an intersection point corresponding to the pixel is found according to the depth value and the height value; if yes, determining the target sampling point of the pixel according to the current sampling point and a sampling point located in front of the current sampling point; if no, taking the second sampling point in the sampling order as the current sampling point until the target sampling point of the pixel is determined, or until the current sampling point is the last sampling point in the sampling order, and determining the last sampling point as the target sampling point of the pixel.
[0102] The step of determining the plurality of sampling points of the pixel and the sampling order of the plurality of sampling points according to the target step length of the pixel includes: controlling a virtual camera in a virtual scene containing the target model surface to emit a step ray to the target model surface; determining an initial sampling point of the pixel, and controlling the step ray to perform a step from the initial sampling point in a step direction according to the target step length to obtain a second sampling point of the pixel; taking the second sampling point as the initial sampling point, and continuing to perform the step of controlling the step ray corresponding to the pixel to perform a step from the initial sampling point in the step direction according to the target step length to obtain a third sampling point until the number of steps reaches a target sampling step number, to obtain the plurality of sampling points and the sampling order of the plurality of sampling points.
[0103] The step of mixing the pixel value of the current frame with the pixel value of the historical frame to obtain a processed current frame includes: determining an initial pixel value of the pixel for each pixel in the current frame; determining a pixel value of a target pixel corresponding to the pixel from the historical frame; and performing weighted mixing processing on the initial pixel value of the pixel and the pixel value of the target pixel to determine a target pixel value of the pixel to obtain the processed current frame.
[0104] The method further includes: obtaining a virtual camera in a virtual scene containing a target model surface, creating a mask based on a camera position of the virtual camera; determining a target virtual scene in the virtual scene located in the mask, and performing the step of performing step number adjustment processing on an initial sampling step number of each pixel in the target virtual scene.
[0105] The computer program product of the texture rendering method, device, electronic device and system provided by the embodiments of the present disclosure includes a computer readable storage medium storing program codes, the program codes include instructions for executing the method described in the foregoing method embodiments, and specific implementation can be referred to the method embodiments, which will not be described here.
[0106] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the system and device described above can refer to the corresponding process in the foregoing method embodiments, which will not be described here.
[0107] In addition, in the description of the embodiments of the present disclosure, unless otherwise explicitly specified and limited, the terms "mounting", "connection", "connecting" should be understood in a broad sense, for example, can be fixedly connected, can also be detachably connected, or integrally connected; can be mechanically connected, can also be electrically connected; can be directly connected, can also be indirectly connected through an intermediate medium, can be the communication inside two elements. For those skilled in the art, the specific meaning of the above terms in the present disclosure can be understood according to the specific circumstances.
[0108] If the functions are realized in the form of software function units and sold or used as independent products, they can be stored in a computer readable storage medium. Based on such understanding, the technical solutions of the present disclosure essentially or the parts that make contributions to the prior art or parts of the technical solutions can be embodied in the form of software products. The computer software product is stored in a storage medium, includes a plurality of instructions for making a computer device (which can be a personal computer, a server, or a network device, etc.) execute all or part of the steps of the method described in various embodiments of the present disclosure. The foregoing storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a magnetic disk or an optical disk, and various media that can store program codes.
[0109] In the description of the present disclosure, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer" and the like indicate the orientation or positional relationship shown in the drawings, and are only for the convenience of describing the present disclosure and simplifying the description, and do not indicate or imply that the device or element referred to must have a particular orientation, be constructed and operated in a particular orientation, and therefore cannot be understood as a limitation on the present disclosure. In addition, the terms "first", "second", "third" are only for the purpose of description, and cannot be understood as indicating or implying relative importance.
[0110] Finally, it should be noted that the above embodiments are merely specific implementations of this disclosure, used to illustrate the technical solutions of this disclosure, and not to limit it. The protection scope of this disclosure is not limited thereto. Although this disclosure has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can still modify or easily conceive of changes to the technical solutions described in the foregoing embodiments, or make equivalent substitutions for some of the technical features, within the scope of the technology disclosed in this disclosure. Such modifications, changes, or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this disclosure, and should all be covered within the protection scope of this disclosure. Therefore, the protection scope of this disclosure should be determined by the protection scope of the claims.
Claims
1. A texture rendering method, characterized in that, The method includes: For each pixel on the surface of the target model in the current frame to be rendered, the initial sampling step number of the pixel is adjusted to obtain the target sampling step number of the pixel; wherein, at least some of the pixels have different target sampling step numbers after the step adjustment process. The target step size of a pixel is determined based on the target sampling number of the pixel; wherein, at least some of the pixels have different target step sizes; By using parallax mapping occlusion, for each pixel, the target sampling point of the pixel is determined according to the target step size of the pixel; The texture information corresponding to the target sampling point is determined as the texture information of the pixel, and the surface of the target model is rendered based on the texture information of the pixel to obtain the current frame; The pixel values of the current frame are mixed with the pixel values of historical frames to obtain the processed current frame.
2. The method according to claim 1, characterized in that, The step of adjusting the initial sampling step number of the pixel to obtain the target sampling step number of the pixel includes: For each pixel, a random value is determined; wherein at least some of the pixels have different random values. The initial sampling step number of the pixel is multiplied by the random value to obtain the target sampling step number of the pixel.
3. The method according to claim 2, characterized in that, The random value was determined using blue noise.
4. The method according to claim 1, characterized in that, For the same pixel, the target sampling steps are different in different frames after the step adjustment process.
5. The method according to claim 1, characterized in that, The step of determining the target step size of a pixel based on the target sampling step number of the pixel includes: The target step size of the pixel is obtained by calculating the ratio of the maximum depth value of the target model surface to the target sampling step number of the pixel.
6. The method according to claim 1, characterized in that, The step of determining the target sampling point of a pixel for each pixel based on the target step size using parallax mapping occlusion includes: Obtain the depth map and height map corresponding to the surface of the target model; By using parallax mapping occlusion, for each pixel, multiple sampling points and the sampling order of the multiple sampling points are determined according to the target step size of the pixel. The first sampling point in the sampling order is taken as the current sampling point. The depth value corresponding to the current sampling point is determined from the depth map, and the height value corresponding to the current sampling point is determined from the height map. Based on the depth value and the height value, it is determined whether the intersection point corresponding to the pixel is found. If so, determine the target sampling point of the pixel based on the current sampling point and the sampling point preceding the current sampling point; If not, the second sampling point in the sampling order is taken as the current sampling point until the target sampling point of the pixel is determined, or until the current sampling point is the last sampling point in the sampling order, and the last sampling point is determined as the target sampling point of the pixel.
7. The method according to claim 6, characterized in that, The step of determining multiple sampling points of a pixel and the sampling order of the multiple sampling points based on the target step size of the pixel includes: Control the virtual camera in the virtual scene containing the surface of the target model to emit a stepping ray toward the surface of the target model; Determine the initial sampling point of the pixel, and control the stepping ray to take one step along the stepping direction from the initial sampling point according to the target step size, so as to obtain the second sampling point of the pixel; Using the second sampling point as the initial sampling point, the process continues to execute the stepping ray corresponding to the pixel, starting from the initial sampling point and moving along the stepping direction according to the target step size, to obtain the third sampling point. This process continues until the number of steps reaches the target number of sampling steps, thus obtaining the multiple sampling points and their sampling order.
8. The method according to claim 1, characterized in that, The step of mixing the pixel values of the current frame with the pixel values of historical frames to obtain the processed current frame includes: For each pixel in the current frame, determine the initial pixel value of the pixel; Determine the pixel value of the target pixel corresponding to the pixel from the historical frame; The initial pixel value of the pixel and the pixel value of the target pixel are weighted and mixed to determine the target pixel value, thus obtaining the processed current frame.
9. The method according to claim 1, characterized in that, The method further includes: Obtain a virtual camera in a virtual scene containing the surface of the target model, and create a mask based on the camera position of the virtual camera; The target virtual scene located within the mask in the virtual scene is determined, and the step of adjusting the initial sampling step number of each pixel in the target virtual scene is performed.
10. A texture rendering apparatus, characterized in that, The device includes: The sampling step adjustment module is used to adjust the initial sampling step of each pixel on the surface of the target model in the current frame to be rendered, so as to obtain the target sampling step of the pixel; wherein, at least some of the pixels have different target sampling steps after the step adjustment process. A step size determination module is used to determine the target step size of a pixel based on the target sampling number of the pixel; wherein, at least some of the pixels have different target step sizes. The sampling point determination module is used to determine the target sampling point of each pixel by means of parallax mapping occlusion, based on the target step size of the pixel. The model rendering module is used to determine the texture information corresponding to the target sampling point as the texture information of the pixel, and render the surface of the target model based on the texture information of the pixel to obtain the current frame; The mixing processing module is used to mix the pixel values of the current frame with the pixel values of historical frames to obtain the processed current frame.
11. An electronic device, characterized in that, It includes a processor and a memory, the memory storing computer-executable instructions that can be executed by the processor, the processor executing the computer-executable instructions to implement the texture rendering method according to any one of claims 1-9.
12. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when invoked and executed by a processor, cause the processor to implement the texture rendering method according to any one of claims 1-9.