OpenGL research 4.0 sample and reverse sample
Dionysoslai ([email protected]) 2014-06-25
This is also called obfuscation and anti-obfuscation. The so-called sample distortion is caused by the use of discrete (pixel) to represent the continuous amount (graphics.
Symptoms:
1. tiered graphic Boundary
:
Because the pixels are one by one, there are sertices.
2. Distortion of image details
Since the smallest unit of the display image is pixel, the pixel is width. Sometimes, we may display smaller and narrower line segments than pixels. There may be two situations: A. If the width of the displayed line segment is smaller than the pixel width, it will be retained; B. If the line segment is very small, it will not be shown. ----> The image details are distorted.
3. Loss of small images and flickering of dynamic images
This is caused by image details distortion. If the line segment is relatively small, it will be displayed if it falls in the center of the pixel; if the line segment falls between two pixels, it will not be displayed. ----> Flashing
This method is used to reduce or eliminate the phenomenon during the graphic display process.
Anti-sample method:
1. Improve Resolution:
Add pixels through hardware. ---> The cost is very high, and it will cause scanning and conversion time and frame cache capacity.
2. Non-weighted area sampling method
Reason: In reality, the pixel is not 0 from the actual area, and the width of the line segment is at least 1 pixel. We assume that the pixel area is 0, the brightness is determined by the brightness of the point covered, and the line segment width is 0. The contradiction between the two is the cause of the situation.
Solution:
Changes the straightness model, and the gray level (color) of the online pixels varies.
Procedure:
A. Think of a straight line segment as a long and narrow rectangle with a certain width;
B. When the straightness overlaps with a certain pixel, the area of the intersection area is obtained.
C. Set the brightness of the pixel based on the area of the intersection area.
Key:
Is how to calculate the area size of the intersection area. Since the pixel is a square, the intersection area can be calculated. A simple method is to divide a square into n areas and determine whether each area (as a point) is in an online segment. :
Then the intersection area of this pixel is 3/9 square meters;
3. Weighted regions
For the area calculation in the non-weighted area sampling method, because the weights of each region are the same, the contribution of the area to the center is large. Therefore, the weight of each area of the pixel is different. The center of the pixel, the larger the weight, the smaller the weight. Weight. Generally, we can use a matrix representation:
Therefore, the intersection area is 5/16.