Disclosure of Invention
In view of this, the embodiments of the present disclosure provide an image drawing method and apparatus, a computing device, and a storage medium, so as to solve the technical drawbacks in the prior art.
According to a first aspect of embodiments of the present specification, there is provided an image drawing method including:
acquiring the real depth of pixel points in an image to be drawn, wherein the position information of each pixel point is represented by a three-dimensional coordinate, and the depth value of each pixel point is represented by a Z-axis value in the three-dimensional coordinate; comparing the real depth with a preset threshold value;
performing first projection on the pixel point with the real depth smaller than a preset threshold along the Z-axis direction to obtain a first Z-value depth, wherein the first Z-value depth is used as the Z-value depth of the pixel point;
performing second projection on the pixel points with the real depths larger than the preset threshold along the Z axis direction to obtain second Z value depths, wherein the second Z value depths are used as the Z value depths of the pixel points, and the nonlinearity of the pixel points with the real depths larger than the preset threshold in the second projection is smaller than that in the first projection;
and drawing the pixel point according to the Z value depth of the pixel point.
Optionally, performing a first projection on the pixel point with the real depth smaller than the preset threshold along the Z-axis direction includes:
and performing first projection on the pixel points with the real depth smaller than the preset threshold along the Z-axis direction by adopting a perspective projection method along the Z-axis direction.
Optionally, performing a second projection on the pixel point with the real depth greater than the preset threshold along the Z-axis direction, including:
and performing second projection on the pixel points with the real depths larger than the preset threshold value along the Z-axis direction by adopting a linear projection method along the Z-axis direction.
Optionally, performing the second projection on the pixel point with the true depth greater than the preset threshold along the Z-axis direction further includes:
and carrying out second projection on the pixel points with the real depths larger than the preset threshold value along the Z-axis direction by adopting a reverse mapping method along the Z-axis direction.
Optionally, the reverse mapping method includes:
and according to the second Z value depth, reversing the second Z value to realize reverse mapping.
Optionally, the drawing the pixel point according to the Z value depth of the pixel point includes:
judging whether the pixel points of the drawn image exist at the positions of the pixel points to be drawn;
if not, directly drawing the pixel points to be drawn;
if the Z value depth of the pixel point to be drawn is larger than the Z value depth of the pixel point of the drawn image, drawing is not performed; and if the Z-value depth of the pixel point to be drawn is smaller than that of the pixel point of the drawn image, drawing.
According to a second aspect of the embodiments of the present specification, there is provided an image drawing apparatus comprising:
the pixel point acquisition module is configured to acquire the real depth of a pixel point in an image to be drawn, the position information of each pixel point is represented by a three-dimensional coordinate, and the depth value of each pixel point is represented by a Z-axis value in the three-dimensional coordinate;
a depth comparison module configured to compare the true depth with a preset threshold;
the first projection module is configured to perform first projection on the pixel points with the real depth smaller than a preset threshold along the Z-axis direction to obtain first Z-value depth, wherein the first Z-value depth is used as the Z-value depth of the pixel points;
the second projection module is configured to perform second projection on the pixel points with the real depths larger than a preset threshold along the Z-axis direction to obtain second Z-value depth, wherein the second Z-value depth is used as the Z-value depth of the pixel points, and the nonlinearity of the pixel points with the real depths larger than the preset threshold in the second projection is smaller than that in the first projection;
and the image drawing module is configured to draw the pixel points according to the Z-value depth of the pixel points.
Optionally, the first projection module performs a first projection on the pixel point with the real depth smaller than the preset threshold along the Z-axis direction by adopting a perspective projection method along the Z-axis direction.
Optionally, the second projection module performs a second projection on the pixel point with the real depth greater than the preset threshold along the Z-axis direction by adopting a linear projection method along the Z-axis direction.
Optionally, the second projection module performs a second projection on the pixel point with the real depth greater than the preset threshold along the Z-axis direction by adopting a reverse mapping method along the Z-axis direction.
Optionally, the reverse mapping method includes:
and according to the second Z value depth, reversing the second Z value to realize reverse mapping.
Optionally, the image drawing module includes:
the judging submodule is configured to judge whether the pixel points of the drawn image exist at the positions of the pixel points to be drawn or not;
the drawing submodule: is configured to directly draw a pixel to be drawn under the condition that no pixel of an image is drawn on the position of the pixel to be drawn; under the condition that the pixel point of the drawn image exists at the position of the pixel point to be drawn, comparing the Z-value depth of the pixel point to be drawn with the Z-value depth of the pixel point of the drawn image, and if the Z-value depth of the pixel point to be drawn is larger than the Z-value depth of the pixel point of the drawn image, not drawing; and if the Z-value depth of the pixel point to be drawn is smaller than that of the pixel point of the drawn image, drawing.
According to a third aspect of embodiments of the present specification, there is provided a computing device comprising a memory, a processor and computer instructions stored on the memory and executable on the processor, the processor implementing the steps of the image rendering method when executing the instructions.
According to a fourth aspect of embodiments of the present description, there is provided a computer-readable storage medium storing computer instructions which, when executed by a processor, implement the steps of the image rendering method.
In the embodiment of the present disclosure, perspective projection is performed on an image pixel point with a real depth smaller than a preset threshold along a Z-axis direction to obtain a first Z-value depth, and then second projection is performed on an image pixel point with a real depth larger than the preset threshold along the Z-axis direction to obtain a second Z-value depth, where the second projection includes two methods of linear projection or reverse mapping. Compared with the first projection, the second Z value depth obtained by the second projection of the pixel point image with the real depth larger than the preset threshold value is lower in nonlinearity and higher in Z value precision, so that the problem that the system cannot judge the spatial position relation among a plurality of pixel points and displays a front-back staggered flickering picture due to the fact that the second Z value depth obtained by the second projection of a plurality of image pixel points with the real depth larger than the preset threshold value in the conventional perspective projection technology is solved, and the precision of image drawing is improved.
Detailed Description
In the following description, numerous specific details are set forth in order to provide a thorough understanding of the present description. This description may be embodied in many other forms than described herein and similarly generalized by those skilled in the art to whom this disclosure pertains without departing from the spirit of the disclosure and, therefore, this disclosure is not limited by the specific implementations disclosed below.
Fig. 2 is a block diagram illustrating a configuration of acomputing device 200 according to an embodiment of the present description. The components of thecomputing device 100 include, but are not limited to, a memory 210 and a processor 220. The processor 220 is connected to the memory 210 via a bus 230, and the database 250 is used for storing the actual depth data of the pixels in the image to be drawn.
Computing device 200 also includes an access device 240, access device 240 enablingcomputing device 200 to communicate via one or more networks 260. Examples of such networks include the Public Switched Telephone Network (PSTN), a Local Area Network (LAN), a Wide Area Network (WAN), a Personal Area Network (PAN), or a combination of communication networks such as the internet. The access device 140 may include one or more of any type of network interface, wired or wireless (e.g., a Network Interface Card (NIC)), such as an IEEE802.11 Wireless Local Area Network (WLAN) wireless interface, a worldwide interoperability for microwave access (Wi-MAX) interface, an ethernet interface, a Universal Serial Bus (USB) interface, a cellular network interface, a bluetooth interface, a Near Field Communication (NFC) interface, and so forth.
In one embodiment of the present description, the other components ofcomputing device 200 described above and not shown in FIG. 2 may also be connected to each other, such as via a bus. It should be understood that the block diagram of the computing device shown in FIG. 2 is for exemplary purposes only and is not intended to limit the scope of the present description. Those skilled in the art may add or replace other components as desired.
Computing device 200 may be any type of stationary or mobile computing device, including a mobile computer or mobile computing device (e.g., tablet, personal digital assistant, laptop, notebook, netbook, etc.), mobile phone (e.g., smart phone), wearable computing device (e.g., smart watch, smart glasses, etc.), or other type of mobile device, or a stationary computing device such as a desktop computer or PC.Computing device 200 may also be a mobile or stationary server.
Wherein the processor 220 may perform the steps of the method shown in fig. 3. Fig. 3 is a flow schematic diagram showing an image drawing method according to an embodiment of the present specification, includingsteps 302 to 310.
Step 302: and acquiring the real depth of the pixel points in the image to be drawn, wherein the position information of each pixel point is represented by a three-dimensional coordinate, and the depth value of each pixel point is represented by a Z-axis value in the three-dimensional coordinate.
In an embodiment of the present disclosure, the position information of each pixel point is represented by a three-dimensional coordinate, and the depth value of each pixel point is represented by a Z-axis value in the three-dimensional coordinate. Each pixel in the image to be drawn has a real depth, which indicates the distance between the pixel and the screen in the Z-axis direction in the three-dimensional coordinate system, for example, the depth of a pixel is 400, which indicates the distance between the pixel and the screen in the Z-axis direction in the three-dimensional coordinate system is 400.
Step 304: and comparing the real depth with a preset threshold value.
In an embodiment of the present disclosure, a preset threshold is preset for comparing with an obtained true depth of a pixel, for example, the preset threshold is set to be 500, and the pixel is divided into a pixel with a true depth less than 500 and a pixel with a true depth greater than 500 according to the magnitude of the true depth, and different projection methods are used for the two pixels respectively.
Step 306: and carrying out first projection on the pixel points with the real depth smaller than the preset threshold along the Z-axis direction to obtain a first Z-value depth, wherein the first Z-value depth is used as the Z-value depth of the pixel points.
In an embodiment of the present disclosure, performing a first projection on the pixel point with the true depth smaller than the preset threshold along the Z-axis direction includes:
and performing first projection on the pixel points with the real depth smaller than the preset threshold along the Z-axis direction by adopting a perspective projection method along the Z-axis direction.
The nonlinearity of the first Z value depth and the real depth, which are obtained by the perspective projection method of the pixel point with the real depth smaller than the preset threshold value, is low, and the nonlinearity is larger than the lower limit of the Z value precision in the process of caching, so that the pixel point can be directly used for image drawing, for example, thereal depth 400 of the pixel point in the image to be drawn is smaller than thepreset threshold value 500, and the first Z value depth obtained by the perspective projection method is 0.88 and larger than the lower limit of the Z value precision and can be used as the Z value depth of the pixel point.
Step 308: and carrying out second projection on the pixel points with the real depths larger than the preset threshold along the Z axis direction to obtain second Z value depth, wherein the second Z value depth is used as the Z value depth of the pixel points, and the nonlinearity of the pixel points with the real depths larger than the preset threshold in the second projection is smaller than that in the first projection.
In an embodiment of the present disclosure, performing a second projection on the pixel point with the true depth greater than the preset threshold along the Z-axis direction includes:
and performing second projection on the pixel points with the real depths larger than the preset threshold value along the Z-axis direction by adopting a linear projection method along the Z-axis direction.
And the second Z value depth obtained by adopting the linear projection is 0.8 and is larger than the Z value precision lower limit, and can be used as the Z value depth of the pixel point.
In an embodiment of the present disclosure, performing a second projection on the pixel point with the true depth greater than the preset threshold along the Z-axis direction further includes:
and carrying out second projection on the pixel points with the real depths larger than the preset threshold value along the Z-axis direction by adopting a reverse mapping method along the Z-axis direction.
And the second Z value depth obtained by reverse mapping of the pixel point with the real depth larger than thepreset threshold 500 has low nonlinearity with the real depth, and is larger than the lower limit of Z value precision in caching, so that the second Z value depth can be used as the Z value depth of the pixel point.
In an embodiment of the present disclosure, the threshold is determined by drawing precision, where the smaller the threshold is, the lower the precision requirement is, and the larger the threshold is.
In an embodiment of the present disclosure, the reverse mapping method includes:
and according to the second Z value depth, performing inverse operation on the second Z value to realize inverse mapping and performing second projection along the Z axis direction.
For example, the projection range is 1000, the threshold value is determined to be 500 according to the drawing precision, the pixel point with the real depth larger than 500 obtains the depth of the second Z value by using reverse mapping, the Z value obtained by mapping the pixel point with the largest obtained depth value is 0 by the reverse mapping, the Z value obtained by mapping the pixel point with the smallest depth value is 1, and the Z value obtained by mapping the pixel point with the larger depth value is smaller.
Step 310: and drawing the pixel point according to the Z value depth of the pixel point.
In an embodiment of the present disclosure, the drawing the pixel according to the Z-value depth of the pixel includes:
judging whether the pixel points of the drawn image exist at the positions of the pixel points to be drawn;
if not, directly drawing the pixel points to be drawn;
if the Z value depth of the pixel point to be drawn is larger than the Z value depth of the pixel point of the drawn image, drawing is not performed; and if the Z-value depth of the pixel point to be drawn is smaller than that of the pixel point of the drawn image, drawing.
For example, for the position of the pixel point to be drawn on the screen, judging that the pixel point with the Z value depth of 0.7 is drawn, if the Z value depth of the pixel point to be drawn is 0.6 and less than 0.7, drawing the pixel point to be drawn by the system; if the Z value depth of the pixel to be drawn is 0.8 and is larger than 0.7, the system does not draw the pixel to be drawn.
By the image drawing method, the problem that in the prior art, the Z value depth obtained by perspective projection of the pixel points with the real depth larger than the preset threshold value is cached to the same Z value depth because the Z value depth reaches the lower limit of Z value precision in caching is effectively solved, so that the system cannot judge the spatial position relation between the pixel points, and the display positions are staggered and flash images in front and back is solved, and the image drawing precision is improved.
Fig. 4 is a schematic view showing a second projection according to an embodiment of the present specification using a linear projection method.
In an embodiment of the present disclosure, the actual depth of a pixel in an image to be drawn is obtained, where the actual depth of each pixel is any value between 0 and 1000, for example, the actual depth of a certain pixel is 400.
In an embodiment of the present disclosure, the preset threshold is set to be 500, and the real depth of each pixel to be drawn is compared with thepreset threshold 500, so that the pixel to be drawn is divided into a pixel with the real depth smaller than thepreset threshold 500 and a pixel with the real depth larger than thepreset threshold 500.
In an embodiment of the present disclosure, for pixels to be drawn having different true depths, a projection method is adopted:
the abscissa in the projection method function diagram represents the real depth of the pixel point to be drawn, and the ordinate represents the Z-value depth obtained by projecting the pixel point to be drawn.
In an embodiment of the present disclosure, a first projection is performed on a pixel point with the real depth smaller than a preset threshold along a Z-axis direction, for example, the real depth of a pixel point C in an image to be drawn is 300 and smaller than apreset threshold 500, and then a perspective projection method is adopted to project the pixel point C along the Z-axis direction, where the obtained first Z-value depth is 0.8 and larger than a lower precision limit of the Z-value, and may be used as the Z-value depth of the pixel point;
in an embodiment of the present disclosure, the second projection is performed on the pixel point with the true depth greater than the preset threshold along the Z-axis direction, for example, the true depths of the other pixel points A, B in the image to be drawn are 600 and 650 respectively and greater than thepreset threshold 500, and then the obtained second Z-value depths are 0.6 and 0.65 respectively by adopting a linear projection method, which are different from the second Z-value depth obtained by perspective projection, and the second Z-value depths obtained by linear projection are both greater than the lower limit of the Z-value precision and can be used as the Z-value depths of the two pixel points.
In an embodiment of the present disclosure, the pixel point is drawn according to the Z value depth of the pixel point, and whether there is a pixel point of the drawn image at the position of the pixel point to be drawn is first determined, if not, the pixel point to be drawn is directly drawn;
if so, comparing the Z value depth of the pixel to be drawn with the Z value depth of the pixel of the drawn image, if the Z value depth of the pixel to be drawn is larger than the Z value depth of the pixel of the drawn image, not drawing, for example, if the position of the pixel to be drawn on a screen is judged that the pixel with the Z value depth of 0.7 is already drawn, and if the Z value depth of the pixel to be drawn is 0.6 and smaller than 0.7, drawing the pixel to be drawn by the system; if the Z value depth of the pixel to be drawn is 0.8 and is larger than 0.7, the system does not draw the pixel to be drawn.
By the image drawing method, the problem that in the prior art, the Z value depth obtained by perspective projection of the pixel points with the real depth larger than the preset threshold value is cached to the same Z value depth because the Z value depth reaches the lower limit of Z value precision in caching is effectively solved, so that the system cannot judge the spatial position relation between the pixel points, and the display positions are staggered and flash images in front and back is solved, and the image drawing precision is improved.
Fig. 5 is a schematic view showing a second projection using a reverse mapping method according to an embodiment of the present specification.
In an embodiment of the present disclosure, the actual depth of a pixel in an image to be drawn is obtained, where the actual depth of each pixel is any value between 0 and 1000, for example, the actual depth of a certain pixel is 400.
In an embodiment of the present disclosure, the preset threshold is set to be 500, and the pixel to be drawn is divided into a pixel with a real depth smaller than thepreset threshold 500 and a pixel with a real depth larger than thepreset threshold 500 by comparing the real depth of each pixel to be drawn with thepreset threshold 500.
In an embodiment of the present disclosure, for pixels to be drawn having different true depths, a projection method is adopted:
the abscissa in the projection method function diagram represents the real depth of the pixel point to be drawn, and the ordinate represents the Z-value depth obtained by projecting the pixel point to be drawn.
In an embodiment of the present disclosure, a first projection is performed on a pixel point with the real depth smaller than a preset threshold along a Z-axis direction, for example, the real depth of a pixel point C in an image to be drawn is 300 and smaller than apreset threshold 500, and then a perspective projection method is adopted to project the pixel point C along the Z-axis direction, where the obtained first Z-value depth is 0.8 and larger than a lower precision limit of the Z-value, and may be used as the Z-value depth of the pixel point;
in an embodiment of the present disclosure, the second projection is performed on the pixel points with the true depth greater than the preset threshold along the Z-axis direction, for example, the true depths of the other pixel points A, B in the image to be drawn are all greater than thepreset threshold 500, and then the inverse mapping method is adopted, where the obtained second Z-value depths are respectively 0.46 and 0.45, and different from the second Z-value depth obtained through perspective projection, the second Z-value depths obtained through inverse mapping are both greater than the lower precision limit of the Z-value, and may be used as the Z-value depths of the two pixel points.
In an embodiment of the present disclosure, the pixel point is drawn according to the Z value depth of the pixel point, and whether there is a pixel point of the drawn image at the position of the pixel point to be drawn is first determined, if not, the pixel point to be drawn is directly drawn;
if so, comparing the Z value depth of the pixel to be drawn with the Z value depth of the pixel of the drawn image, if the Z value depth of the pixel to be drawn is larger than the Z value depth of the pixel of the drawn image, not drawing, for example, if the position of the pixel to be drawn on a screen is judged that the pixel with the Z value depth of 0.7 is already drawn, and if the Z value depth of the pixel to be drawn is 0.6 and smaller than 0.7, drawing the pixel to be drawn by the system; if the Z value depth of the pixel to be drawn is 0.8 and is larger than 0.7, the system does not draw the pixel to be drawn.
By the image drawing method, the problem that in the prior art, the Z value depth obtained by perspective projection of the pixel points with the real depth larger than the preset threshold value is cached to the same Z value depth because the Z value depth reaches the lower limit of Z value precision in caching is effectively solved, so that the system cannot judge the spatial position relation between the pixel points, and the display positions are staggered and flash images in front and back is solved, and the image drawing precision is improved.
Fig. 6 is a schematic diagram showing drawing of a pixel to be drawn according to an embodiment of the present specification.
In an embodiment of the present disclosure, the position information of each pixel point is represented by a three-dimensional coordinate x-y-Z, and the depth value of each pixel point is represented by a value of a Z-axis in the three-dimensional coordinate. The screen plane is an x-o-y plane, and the drawn image B in the three-dimensional coordinates has a pixel point B1 with a Z value depth of 0.5 and a pixel point B2 with a Z value depth of 0.7. The image a is an image to be drawn in three-dimensional coordinates, and the gray area represents an area where the image a to be drawn and the drawn image B overlap in the Z-axis direction.
In an embodiment of the present disclosure, the actual depth of the pixel in the image a to be drawn is obtained, the pixel includes the pixel in the gray area and the pixel outside the gray area in the image a to be drawn, for example, the actual depth of the pixel A1 outside the gray area in the image a to be drawn is 300, the actual depth of the pixel A2 in the gray area in the image a to be drawn is 600, and the actual depth of the pixel A3 in the gray area in the image a to be drawn is 650.
In an embodiment of the present disclosure, a preset threshold is set to be 500, the actual depth of the pixel in the image to be drawn is compared with thepreset threshold 500, and the pixel to be drawn is divided into a pixel with the actual depth smaller than the preset threshold and a pixel with the actual depth larger than the preset threshold.
In an embodiment of the present disclosure, a first projection is performed on a pixel point with a real depth smaller than a preset threshold along a Z-axis direction, for example, a perspective projection method is adopted on a pixel point A1 to be drawn with a real depth smaller than apreset threshold 500 along the Z-axis direction, and the obtained first Z-value depth is 0.8 and larger than a lower precision limit of the Z-value, which can be used as the Z-value depth of the pixel point A1 to be drawn.
In an embodiment of the present disclosure, a second projection is performed on a pixel point with a real depth greater than a preset threshold along a Z-axis direction, for example, a linear projection method is adopted on pixel points A2 and A3 to be drawn with a real depth greater than apreset threshold 500 along the Z-axis direction, so as to obtain corresponding second Z-value depths of 0.6 and 0.65, which are used as Z-value depths of the pixel points A2 and A3 to be drawn.
In an embodiment of the present disclosure, according to a Z-value depth drawing pixel of the pixel, whether a pixel of the drawn image exists at a position where the pixel to be drawn is first determined, and if not, the pixel to be drawn is directly drawn;
if yes, comparing the Z value depth of the pixel point to be drawn with the Z value depth of the pixel point of the drawn image, and if the Z value depth of the pixel point to be drawn is larger than the Z value depth of the pixel point of the drawn image, not drawing.
For example, if the pixel point A1 to be drawn is not located at the position where the pixel point A1 to be drawn is located, the pixel point A1 to be drawn is directly drawn;
the pixel point A2 to be drawn is provided with a pixel point B2 of the drawn image B, the pixel point A2 to be drawn and the pixel point B2Z value depth to be drawn are compared, the Z value depth of the pixel point A2 to be drawn is 0.6 and is smaller than the Z value depth of the pixel point B2 to be drawn by 0.7, and the pixel point A2 to be drawn is drawn to cover the pixel point B2 to be drawn;
and the pixel point A3 to be drawn is provided with a pixel point B1 of the drawn image B, the Z value depth of the pixel point A3 to be drawn is compared with the Z value depth of the pixel point B1 to be drawn, the Z value depth of the pixel point A3 to be drawn is 0.65 and is larger than the Z value depth of the pixel point B1 to be drawn by 0.5, and the pixel point A3 to be drawn is not drawn.
In an embodiment of the present disclosure, a second projection is performed on a pixel point with a real depth greater than a preset threshold along a Z-axis direction, for example, a reverse mapping method is adopted on pixel points A2 and A3 to be drawn with a real depth greater than apreset threshold 500 along the Z-axis direction, so as to obtain corresponding second Z-value depths of 0.4 and 0.6, which are used as Z-value depths of the pixel points A2 and A3 to be drawn.
In an embodiment of the present disclosure, according to a Z-value depth drawing pixel of the pixel, whether a pixel of the drawn image exists at a position where the pixel to be drawn is first determined, and if not, the pixel to be drawn is directly drawn;
if yes, comparing the Z value depth of the pixel point to be drawn with the Z value depth of the pixel point of the drawn image, and if the Z value depth of the pixel point to be drawn is larger than the Z value depth of the pixel point of the drawn image, not drawing.
For example, if the pixel point A1 to be drawn is not located at the position where the pixel point A1 to be drawn is located, the pixel point A1 to be drawn is directly drawn;
the pixel point A2 to be drawn is provided with a pixel point B2 of the drawn image B, the pixel point A2 to be drawn and the pixel point B2Z value depth to be drawn are compared, the Z value depth of the pixel point A2 to be drawn is 0.4 and is smaller than the Z value depth of the pixel point B2 to be drawn by 0.7, and the pixel point A2 to be drawn is drawn to cover the pixel point B2 to be drawn;
and the pixel point A3 to be drawn is provided with a pixel point B1 of the drawn image B, the Z value depth of the pixel point A3 to be drawn is compared with the Z value depth of the pixel point B1 to be drawn, the Z value depth of the pixel point A3 to be drawn is 0.6 and is larger than the Z value depth of the pixel point B1 to be drawn by 0.5, and the pixel point A3 to be drawn is not drawn.
By the image drawing method, the problem that in the prior art, the Z value depth obtained by perspective projection of the pixel points with the real depth larger than the preset threshold value is cached to the same Z value depth because the Z value depth reaches the lower limit of Z value precision in caching is effectively solved, so that the system cannot judge the spatial position relation between the pixel points, and the display positions are staggered and flash images in front and back is solved, and the image drawing precision is improved.
The present specification also provides an image rendering apparatus embodiment, in accordance with the above-described method embodiment. Fig. 7 is a block diagram showing an image drawing apparatus according to an embodiment of the present specification. As shown in fig. 7, the apparatus 700 includes:
the pixelpoint obtaining module 710 is configured to obtain the real depth of the pixel point in the image to be drawn;
adepth comparison module 720 configured to compare the true depth to a preset threshold;
thefirst projection module 730 is configured to perform a first projection on the pixel point with the real depth smaller than the preset threshold value to obtain a first Z value depth, where the first Z value depth is used as the Z value depth of the pixel point;
thesecond projection module 740 is configured to perform second projection on the pixel point with the real depth being greater than the preset threshold value to obtain a second Z value depth, where the second Z value depth is used as the Z value depth of the pixel point, and the nonlinearity of the pixel point with the real depth being greater than the preset threshold value in the second projection is smaller than that in the first projection;
theimage drawing module 750 is configured to draw the pixel point according to the Z-value depth of the pixel point.
In an optional embodiment, the first projection module performs a first projection on the pixel point with the real depth smaller than the preset threshold along the Z-axis direction by adopting a perspective projection method along the Z-axis direction.
In an optional embodiment, the second projection module performs a second projection on the pixel point with the real depth greater than the preset threshold along the Z-axis direction by using a linear projection method along the Z-axis direction.
In an optional embodiment, the second projection module performs a second projection on the pixel point with the real depth greater than the preset threshold along the Z-axis direction by adopting a reverse mapping method along the Z-axis direction.
In an alternative embodiment, the reverse mapping method includes:
and according to the second Z value depth, reversing the second Z value to realize reverse mapping.
In an alternative embodiment, the image rendering module includes:
judging whether the pixel points of the drawn image exist on the screen position where the pixel points to be drawn are located;
and a judging sub-module: the method comprises the steps of judging whether a pixel point of a drawn image exists at a position of the pixel point to be drawn;
the drawing submodule: is configured to directly draw a pixel to be drawn under the condition that no pixel of an image is drawn on the position of the pixel to be drawn; under the condition that the pixel point of the drawn image exists at the position of the pixel point to be drawn, comparing the Z-value depth of the pixel point to be drawn with the Z-value depth of the pixel point of the drawn image, and if the Z-value depth of the pixel point to be drawn is larger than the Z-value depth of the pixel point of the drawn image, not drawing; and if the Z-value depth of the pixel point to be drawn is smaller than that of the pixel point of the drawn image, drawing.
The implementation process of the functions and roles of each unit in the above device is specifically shown in the implementation process of the corresponding steps in the above method, and will not be described herein again.
For the device embodiments, reference is made to the description of the method embodiments for the relevant points, since they essentially correspond to the method embodiments. The apparatus embodiments described above are merely illustrative, wherein the elements illustrated as separate elements may or may not be physically separate, and the elements shown as elements may or may not be physical elements, may be located in one place, or may be distributed over a plurality of network elements. Some or all of the modules may be selected according to actual needs to achieve the purposes of the present description. Those of ordinary skill in the art will understand and implement the present invention without undue burden.
An embodiment of the present disclosure also provides a computing device including a memory, a processor, and computer instructions stored on the memory and executable on the processor, the processor implementing the steps of the image rendering method described above when executing the instructions.
An embodiment of the present specification also provides a computer-readable storage medium storing computer instructions that, when executed by a processor, implement the steps of the image rendering method as described above.
The above is an exemplary version of a computer-readable storage medium of the present embodiment. It should be noted that, the technical solution of the storage medium and the technical solution of the image drawing method belong to the same concept, and details of the technical solution of the storage medium which are not described in detail can be referred to the description of the technical solution of the image drawing method.
The computer instructions include computer program code that may be in source code form, object code form, executable file or some intermediate form, etc. The computer readable medium may include: any entity or device capable of carrying the computer program code, a recording medium, a U disk, a removable hard disk, a magnetic disk, an optical disk, a computer Memory, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), an electrical carrier signal, a telecommunications signal, a software distribution medium, and so forth. It should be noted that the computer readable medium contains content that can be appropriately scaled according to the requirements of jurisdictions in which such content is subject to legislation and patent practice, such as in certain jurisdictions in which such content is subject to legislation and patent practice, the computer readable medium does not include electrical carrier signals and telecommunication signals.
It should be noted that, for the sake of simplicity of description, the foregoing method embodiments are all expressed as a series of combinations of actions, but it should be understood by those skilled in the art that the present description is not limited by the order of actions described, as some steps may be performed in other order or simultaneously in accordance with the present description. Further, those skilled in the art will appreciate that the embodiments described in the specification are all preferred embodiments, and that the acts and modules referred to are not necessarily all necessary in the specification.
In the foregoing embodiments, the descriptions of the embodiments are emphasized, and for parts of one embodiment that are not described in detail, reference may be made to the related descriptions of other embodiments.
The preferred embodiments of the present specification disclosed above are merely used to help clarify the present specification. Alternative embodiments are not intended to be exhaustive or to limit the invention to the precise form disclosed. Obviously, many modifications and variations are possible in light of the above teaching. The embodiments were chosen and described in order to best explain the principles of the disclosure and the practical application, to thereby enable others skilled in the art to best understand and utilize the disclosure. This specification is to be limited only by the claims and the full scope and equivalents thereof.