Algorithm of scanning line and calculation method of center of gravity coordinate

Source: Internet
Author: User

2017-01-0420:17:10

Scan-line algorithm

Sweep algorithm

    1. 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. 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)

    1. 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)

    1. 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.

    1. 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.