2017-01-0420:17:10
Scan-line algorithm
Sweep algorithm
- Finding the coordinate of center of gravity of Triangle
The meaning of center of gravity coordinate
Any point in the plane of the triangle can be represented as a weighted average of the vertex, which is called the centroid coordinate.
Expressed as I,j,k, i+j+k=1
A fast algorithm for the coordinate of center of gravity is used to divide the elements into vertical and horizontal equal, and then create a "scan edge table", which can quickly calculate the coordinates of the center of gravity of the peers.
For example: Put V4, v5 save, calculate V6 time use.
(interpolcation qualifier) modifies fragment shader input, specifying an interpolation algorithm.
Smooth (default) perspective interpolation
Noperspective Linear interpolcation
Flat No Interpolcation
- 1. Point interpolation
The point interpolation does not need to calculate the center of gravity coordinates, but you can get the texture coordinates by accessing Glpointcoord [0,1.0]. The point texture coordinates can be programmed to upper_left or lower_left.
The interpolation modifier (iterpolation qualifier) has no effect on point rendering when the point is rasterized (scanning line algorithm), nor does it do mixed operations.
When Multisample is enabled, you can specify Glpointparameteriv (gl_point_fade_threshold_size) to do FADE operations on the alpha channel alone, with the final alpha value alpha = Alpha * Fade_factor.
(derived_size = gl_pointsize)
- 2. segment Interpolation
P is the coordinate of the window, and T is the center of gravity of Point D on the line AB (?)
Gets the value of the pixel f,w the W component of the clip coordinate, if W is 1. Formula is
f = fa * I + fb * J (I=1-T, j=t)
- Triangle interpolation
Formulas for calculating pixel values:
The FABC is the value of the vertex and the W component of the W homogeneous coordinates.
Formula for calculating the z-value of a pixel:
If you w=1, or omit the W value (noperspective), the formula becomes the same as the z-value.
The above is the concept of OpenGL, make it clear, you can in the fragment shader inside the custom interpolation algorithm.
- 4. AMD GCN GPU interpolation
GCNGPU when Rasterization only generates the center of gravity coordinates i,j, exists v0, V1 two registers (really saves, does not waste v2, it is 1-i-j)
This smooth interpolation for triangles:
D = P0 + p10*i + p20*j
(P0, P10, P20 is the value of the vertex)
Two steps.
V_INTERP_F1_F32 v2, V0, attr0.x//d=p0 + p10*v0
V_INTERP_F2_F32 v2, v1, attr0.x//d=d+p20*v1
Flat interpolation is done in one step:
V_INTERP_MOV_F32 v3, V0, attrib0.xyz
Attribute values need to be stored in LDS, arranged in the format
(? Where has K gone, P0 already been disposed of?
Refer:
Amd_gcn3_instruction_set_architecture.pdf
OPENGL Specification 4.5
Algorithm of scanning line and calculation method of center of gravity coordinate