This application is based upon and claims the benefit of priority of the prior Japanese Patent Application No. 2012-200168, filed on Sep. 12, 2012, the entire contents of which are incorporated herein by reference.
The present invention relates to an image processing apparatus.
In three-dimensional computer graphics, an image processing apparatus processes vertex data of a polygon serving as a rendering subject, and also processes image data of pixels in the polygon. Various types of image is processing are performed to generate the image data of the pixels in the polygon, one of which is texture mapping processing.
Texture mapping processing is processing for adhering texture data (texel color data) stored in advance in a memory to each pixel of the polygon. The vertex data of the polygon typically include coordinate data (texture coordinate data) indicating coordinates in a texture memory that stores the texture data to be adhered to the polygon. Texel data in the texture memory are read on the basis of texture coordinates corresponding to a pixel in the polygon, and used to generate color data for the pixel.
A textured image having a gradation pattern is often used as a textured image. For example, data of a textured image having a gradation pattern are generated by blending two colors at a gradually varying blending ratio. With a linear gradation, the pattern is simple and therefore a high degree of expressiveness is not obtained. Hence, a textured image having a non-linear gradation pattern is often used as a more richly expressive gradation pattern.
Japanese Patent Application Publication No. 2010-165058, Japanese Patent Application Publication No. 2008-148165, and so on, for example, describe gradation patterns.
The data of a textured image having a non-linear gradation pattern are data on a non-linear curve, and since calculation processing for calculating a non-linear curve is difficult, texture data determined in advance by calculation are stored in the texture memory. Corresponding texture data (texel color data) are then read from the texture memory on the basis of the texture coordinates of the pixel in the rendering subject polygon and used as the color data of the texel corresponding to the pixel.
However, a capacity of a high-speed internal memory that can be used for image processing is preferably as small as possible. It is therefore undesirable to store a large volume of texture data in an internal memory due to the limited memory capacity.
Use of the capacity of the internal memory may be avoided by providing an arithmetic circuit that generates the texture data of the pixel. However, the texture data of a non-linear gradation pattern are obtained by calculating two-dimensional data, and therefore the arithmetic circuit increases in scale, which is undesirable in terms of integration.
According to a first aspect of the embodiment, an image processing apparatus configured to perform image processing on a polygon, has: a texture mapping unit configured to obtain pixel data including first and second texture coordinates, and generate texel data corresponding to the first and second texture coordinates within a textured image having a gradation pattern based on a non-linear surface, wherein a function of the non-linear surface is defined by a product of a first Bezier curve function and a second Bezier curve function, and the texture mapping unit has: a first Bezier curve function calculation unit configured to calculate the first Bezier curve function by obtaining the first texture coordinate and control values of the first Bezier curve function; a second Bezier curve function calculation unit configured to calculate the second Bezier curve function by obtaining the second texture coordinate and control values of the second Bezier curve function; a multiplier configured to multiply respective outputs of the first and second Bezier curve function calculation units; and a blending processing unit configured to generate the texel data by blending a plurality of color data corresponding to the gradation pattern using a multiplication value of the multiplier as a blending ratio.
According to the first aspect, there is no need to store the texture data in an internal memory, and moreover, a circuit scale of the image processing apparatus is reduced.
The object and advantages of the invention will be realized and attained by means of the elements and combinations particularly pointed out in the claims.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory and are not restrictive of the invention.
As illustrated in
The non-linear gradation pattern GR illustrated in
texel_color=(1.0−br)*color—0+br*color—1
When the blending ratio br takes a value on a non-linear curve, the color data of the gradation pattern GR also take a value on a non-linear curve.
A non-linear gradation pattern can be defined by a Bezier surface, for example. As will be described below, a Bezier surface can be defined by a Bezier surface function on the basis of values of two-dimensional control points (control values hereafter). It is known that a desired non-linear curve can be defined in accordance with a Bezier surface function by defining the two-dimensional control values as desired.
However, processing for calculating a function of a Bezier surface involves large numbers of integrations and additions/subtractions. Therefore, when an arithmetic circuit is provided to calculate the Bezier surface function and the texture data are determined by calculation on the basis of the texture coordinates of the processing subject pixel, the arithmetic circuit increases in scale, and as a result, reducing the capacity of the internal memory becomes meaningless.
As a result of committed research undertaken by the present inventors, however, it has been found that data of a two-dimensional non-linear gradation pattern is generated by multiplying respective outputs of a first Bezier curve function having a first texture coordinate s as a variable and a second Bezier curve function having a second texture coordinate t as a variable, and that the scale of an arithmetic circuit for this purpose is considerably smaller than the scale of an arithmetic circuit for calculating a Bezier surface function.
The display image generation apparatus 1 includes a CPU 10, an internal memory 14, and an internal bus BUS that connects these components. The display image generation apparatus 1 also includes a program memory storing an image generation program 12, and the image generation program 12 is executed by the CPU 10. By having the CPU 10 execute the image generation program 12, polygon data constituting a 3D image to be displayed in each frame are generated. The image generation program 12 specifies the polygon data respectively, and issues a command to render the polygon data.
The image processing apparatus 16 is a hardware circuit that generates a frame image to be displayed by processing the polygon data corresponding to the rendering command and stores the generated frame image in the internal memory 14. The 3D image is constituted by a large amount of polygon data, and the image processing apparatus 16 processes the large amount of polygon data at high speed in order to write color data of pixels included in the respective polygons to a frame memory area of the internal memory 14.
When the writing processing is completed on the color data of all of the polygons within a single frame, the color data in the frame memory area are read and output to the display apparatus 2 by a display controller 18. As a result, the display apparatus 2 displays a corresponding frame image.
The image processing apparatus according to this embodiment corresponds to the image processing apparatus 16 in the display image generation apparatus 1 shown in
The internal memory 14 includes a parameter memory 14A that stores various parameter data generated by executing the image generation program 12 illustrated in
When the image generation program 12 is executed by the CPU, polygon data 30 to be rendered and a texture parameter 36 for generating data of a textured image having a non-linear gradation pattern are stored in the parameter memory 14A. When the image generation program 12 issues the polygon rendering command by specifying the polygon data 30 and the texture parameter 36, the image processing apparatus 16 performs following image processing in response thereto, whereby color data are generated for each pixel in the polygon and written to the frame memory 14B.
The image processing apparatus 16 includes a vertex processing unit 161 that processes data relating to the vertices of the polygon, and a pixel processing unit 165 that processes data relating to the pixels in the polygon. The content of the processing executed by the vertex processing unit 161 and the pixel processing unit 165 will be described below together with the internal data 30 to 37 of the polygon.
First, the rendering subject polygon data 30 and the parameter 36 of the textured image having a non-linear gradation pattern are specified by the polygon rendering command. The polygon data 30 and the texture parameter 36 are generated by the image generation program of
Next, a first coordinate conversion unit 162 of the vertex processing unit 161 reads the rendering subject polygon data 30 from the parameter memory 14A. The polygon data 30 include following data, for example.
Polygon identification number: PGID
Coordinates of the three vertices within an absolute space: (Xa1, Ya1, Za1) (Xa2, Ya2, Za2) (Xa3, Ya3, Za3)
Color data of the three vertices: CL1, CL2, CL3
Texture coordinates corresponding to the three vertices: (s1, t1) (s2, t2) (s3, t3)
The first coordinate conversion unit 162 converts the coordinates of the three vertices within an absolute space into coordinate values of a coordinate system having a viewpoint as an origin on the basis of viewpoint coordinates specified by the rendering command. As a result, the first coordinate conversion unit 162 outputs following polygon data 31.
Polygon identification number: PGID
Coordinates of the three vertices within a space having the viewpoint as the origin: (Xp1, Yp1, Zp1) (Xp2, Yp2, Zp2) (Xp3, Yp3, Zp3)
Color data of the three vertices: CL1, CL2, CL3
Texture coordinates corresponding to the three vertices: (s1, t1) (s2, t2) (s3, t3)
Next, a lighting unit 163 performs shading processing on the color data CL1, CL2, CL3 of the vertices on the basis of a light source so as to generate light source-processed color data CLL1, CLL2, CLL3. More specifically, the lighting unit 163 determines a color to be displayed at each vertex by performing shading processing on the color data of each vertex on the basis of vertex information including the coordinates (Xp1, Yp1, Zp1) to (Xp3, Yp3, Zp3) of the three vertices of the rendering subject polygon and a normal vector relative to the light source, light source information including coordinates of the light source and an orientation of the light source, and viewpoint information including the viewpoint coordinates and an orientation of the viewpoint. A generally known method is employed as a calculation method used in the shading processing performed in relation to the light source. As a result, the lighting unit 163 outputs following polygon data 32.
Polygon identification number: PGID
Coordinates of the three vertices within the space having the viewpoint as the origin: (Xp1, Yp1, Zp1) (Xp2, Yp2, Zp2) (Xp3, Yp3, Zp3)
Color data of the three vertices: CLL1, CLL2, CLL3
Texture coordinates corresponding to the three vertices: (s1, t1) (s2, t2) (s3, t3)
Next, a second coordinate conversion unit 164 converts the vertex coordinates of the polygon in the above polygon data 32 into coordinates in a coordinate system of a screen set within the space having the viewpoint as the origin. The coordinate system of the screen is constituted by two-dimensional coordinates x, y on the screen and a screen depth z. As a result, the second coordinate conversion unit 164 outputs following polygon data 33.
Polygon identification number: PGID
Screen coordinates of the three vertices: (x1, y1, z1) (x2, y2, z2) (x3, y3, z3)
Color data of the three vertices: CLL1, CLL2, CLL3
Texture coordinates corresponding to the three vertices: (s1, t1) (s2, t2) (s3, t3)
Next, various processing executed by the pixel processing unit 165 will be described. First, a rasterization processing unit 166 calculates the data of the pixels in the rendering subject polygon in rasterization order and outputs the calculated data.
The screen coordinates, color data, and texture coordinates of the pixel PX existing between the two pixels P12, P31 are then determined by performing a calculation in which the data of the two pixels P12, P31 are interpolated at an interpolation ratio I:1.0-I. As a result, the rasterization processing unit 166 outputs pixel data 34 of the polygon PG in rasterization order. The output pixel data 34 are as follows.
Screen coordinates: (x, y, z)
Color data: CLLp
Texture coordinates: (s, t)
Next, a texture mapping unit 167 obtains the pixel data 34 and calculates texel color data on the basis of the texture coordinates (s, t) of the pixels included therein and the textured image parameter 36 specified by the polygon rendering command. The texture mapping unit 167 then generates color data to be written to the frame memory 14B by synthesizing the color data CLLp included in the pixel data 34 with the texel color data (the colors of the pattern).
The texture generation circuit 41 according to this embodiment will now be described. First, the data of the textured image having a non-linear gradation pattern according to this embodiment will be described.
The non-linear gradation pattern GR illustrated in
! represents a factorial, while Pij represents (n+1)×(m+1) two-dimensionally disposed control values.
Hence, by applying n+1, m+1, (n+1)×(m+1) control values Pij as parameters, the Bezier surface is defined as the height of a non-linear surface corresponding to the (n+1)×(m+1) two-dimensionally disposed control values Pij. A calculated value of the Bezier surface is then associated with a blending coefficient such that colors obtained by performing blending processing on two colors using the blending coefficient are set as the color data of the textured image.
Ideally, the texture generation circuit 41 is constituted by an arithmetic circuit corresponding to the arithmetic expression for calculating the Bezier surface illustrated in Expression 1. In so doing, the texel color data is determined by calculation on the basis of the texture coordinates (s, t) of the pixel data, thereby eliminating the need for a texture memory.
However, the arithmetic expression for calculating the Bezier surface illustrated in Expression 1 is complicated, and the number of calculations therein is as follows.
Number of multiplications: (n+m+2) (m+1) (n+1)
Number of additions/subtractions: n(n+1) (m+1)/2+m(n+1) (m+1)/2+nm
Note that this does not include the number of calculations needed to calculate n!/i! (n−1)!, m!/ j! (m−1)! in Expressions 2 and 3.
To illustrate this point using a specific example, when n+1=4 and m+1=4 (i.e. when the number of controls values Pij is sixteen), Expression 1 takes the form of a following three-dimensional function.
In the above case, the number of multiplications is 128 (eight multiplications for each of the four terms P00 to P03 (for a total of thirty-two multiplications), and likewise for P10 to P13, P20 to P23, P30 to P33 for a total of 128 multiplications), and the number of additions/subtractions is 64 (forty-eight subtractions for sixteen terms, and sixteen additions for sixteen terms). Likewise with a three-dimensional function, therefore, the scale of the arithmetic circuit increases.
Hence, in this embodiment, the non-linear gradation pattern GR illustrated in
Expressions 6 and 7 illustrated above are functions of Bezier curves respectively having variables s, t and control values Pi, Qj. In Expression 1, (n+1)×(m+1) control values Pij exist, whereas in Expression 5, (n+1) control values Pi and (m+1) control values Qj exist. Expression 5 is obtained by multiplying first and second Bezier curves illustrated respectively in Expressions 6 and 7.
A surface having a coordinate plane (s, t) defined in Expression 5 will be made similar or identical to the ideal Bezier surface illustrated in Expression 1. In other words, Expression 1 and Expression 5 have a following relationship.
As is evident from Expression 8, when a product of the respective control values Pi, Qj of the two Bezier curves in Expression 5 is equal to the respective two-dimensional control values Pij of the Bezier surface in Expression 1 (i.e. when Pij=Pi×Qj), the surface of Expression 5 is made identical to the Bezier surface of Expression 1. Note, however, that as long as the product of the respective control values Pi, Qj of the two Bezier curves in Expression 5 is similar to the respective two-dimensional control values Pij of the Bezier surface in Expression 1, the surface of Expression 5 is made similar to the Bezier surface of Expression 1.
Moreover, as illustrated by the surface of Expression 5, by defining the non-linear gradation pattern GR by the product of two Bezier curves, the number of calculations involved therein is as follows. This number is smaller than that of Expression 1.
Number of multiplications: (n+1)2+(m+1)2+1
Number of additions/subtractions: n(n+3)/2+m(m+3)/2
Note that this does not include the number of calculations needed to calculate n!/i! (n−1)!, m!/j! (m−1)!.
To illustrate this point using a specific example, when n+1=4 and m+1=4 (i.e. when four controls values Pi and four control values Qj exist), Expression 1 takes the form of a following three-dimensional function.
In the above case, the number of multiplications is thirty-three and the number of additions/subtractions is eighteen, and therefore the arithmetic circuit scale is smaller than the scale of the arithmetic circuit used to calculate the Bezier surface of Expression 4. In Expression 9, four multiplications are performed on respective terms in parentheses in a former half, while the numbers of subtractions are three, two, and one, and three additions are performed on four terms for a total of nine additions/subtractions. This applies likewise to terms in parentheses in a latter half. Further, a single multiplication is performed between the two terms in parentheses.
In this embodiment, the texture generation circuit 41 illustrated in
In the drawing, the texture coordinates s, t and control values p [4], q [4] of the Bezier curves are constituted by floating point data, indicated in the drawing by “float”. The decimal portion extraction units 50, 52 are circuits for extracting decimal point parts of the texture coordinates s, t. As illustrated in
Further, in
CLtx=(1.0−br)*color—0+br*color—1
Color data color—0, color—1 include data for three primary colors RGB, for example, and control data A, and are thus constituted by color—0=R0, G0, B0, A0 and color—1=R1, G1, B1, A1. Further, the calculations of Expression 10 are performed in relation to the respective color data, whereas the control data A are not subjected to blending processing calculations.
Returning to the texture mapping unit of
Next, a rendering/non-rendering determination unit 168 of the image processing apparatus 16 illustrated in
When the color data CLLs of the processing subject pixel are overwritten to the frame memory 14B, the color data CLLs are recorded in the frame memory 14B having an identical pixel depth z or a separate memory such as a depth buffer, whereby the color data CLLs is used in a depth check performed on the color data of a subsequent pixel.
According to this embodiment, as described above, in texture mapping performed during image processing of a three-dimensional computer graphic, when a textured image having a non-linear gradation pattern is subjected to mapping processing, rather than mapping a textured image stored in advance in an internal memory, texel color data are generated by an arithmetic circuit during each processing operation. As a result, the capacity of the internal memory is reduced. Further, the textured image having a non-linear gradation pattern is defined by the product of two Bezier curves, and therefore the circuit scale of the arithmetic circuit is reduced.
All examples and conditional language provided herein are intended for the pedagogical purposes of aiding the reader in understanding the invention and the concepts contributed by the inventor to further the art, and are not to be construed as limitations to such specifically recited examples and conditions, nor does the organization of such examples in the specification relate to a showing of the superiority and inferiority of the invention. Although one or more embodiments of the present invention have been described in detail, it should be understood that the various changes, substitutions, and alterations could be made hereto without departing from the spirit and scope of the invention.
Number | Date | Country | Kind |
---|---|---|---|
2012-200168 | Sep 2012 | JP | national |