[Graphic image] C ++ implemented software Grating

Source: Internet
Author: User
Currently, the rendering part has come to an end, implements bilinear, tri-linear, mipmap texture sampling, repetitive/image UV addressing mode, overlay of mirror light and texture, Gouraud coloring, Phong coloring, Z caching, 1/Z caching, and pivoting. texture/illumination correction and plane cropping (including triangle segmentation) orthogonal projection camera. In the future, if you add more features, such as vertex animation, the center of gravity should be in the engine layer, and the rendering layer is basically complete. .

 

1st sheets:

From sit to right, from top to bottom. No texture, no mirror light, no depth buffer, followed:

1. wireframes.

2. Solid color. That is, each triangle has a color.

3. Flat coloring (the modified effect is much better than the last one ). Each triangle is a color, but the color is based on the illumination.

4. Gouraud coloring. Calculate the vertex color of each triangle Based on illumination, and perform linear interpolation based on the vertex color in the triangle.

5. Phong coloring (the Resolution here is too low to see the difference with Gouraud ). Each pixel calculates light separately.

2nd sheets:

The colors are flat, Gouraud, and Phong respectively. Compared to the 1st images, the mirror light is added (note that the white spot appears in many places of the teapot ).

 

3rd sheets:

Texture is introduced on the basis of the previous one. Pay attention to the spot on the nozzle. The depth buffer is not enabled for this group of images, so the display is incorrect.

 

4th sheets:

High-resolution teapot. The bottleneck of software rendering is pixel processing, so the frame rate is very low for such a large teapot.

The two settings correspond to the low and high settings respectively.

First, Gouraud coloring + recent point sampling + triangle sorting (oil painter algorithm) + mirror light. The frame rate is 123.

Second, Phong coloring + tri-linear sampling + 1/Z buffer + mirror light. Frame Rate: 30.

 

5th sheets:

Plane crop. The first is a vertical plane, and the first is a vertical and horizontal plane. Note that the triangle density at the cropping edge is large because the triangle is split.

 

5-2:

Orthogonal projection and plane crop.

Orthogonal projection, which is less efficient than normal perspective projection.

The second teapot, looking at the cropping plane from the side, confirms that this is indeed a 3D space crop, not a pixel crop on the screen.

 

6th sheets:

High resolution!

Draw two triangles on the screen to display the texture filtering effect.

From top to bottom are: wireframes, recent point sampling, bilinear filtering, tri-linear filtering, and perspective texture correction.

Tri-linear filtering: it is difficult to see the difference between it and bilinear, but changes can be noticed during switching.

Perspective texture correction: Fuck, shit scared me! Compared with it, it is no wonder that the first two are strange. This proves that large-texture triangles cannot be used in disorder...

 

 

7th sheets:

Demonstrate the texture address addressing mode.

The texture coordinate of the entire image is-2 ~ + 2. From top to bottom, the addressing modes are clamp, duplicate, and image.

 

8th sheets:

Demonstrate mipmap.

The red is the 0th layer, the green is the 1st layer, the blue is the 2nd layer, the light blue is the third layer, and so on.

 

Paste another ghost header, with 60 thousand faces, and 30 frames, which is good. After all, I am very cautious about vertex processing.

Gouraud + mirror light + triangle sorting (the oil painter algorithm replaces the Z buffer ).

 

After reading the records on mercury, this project has been around for about 10 days. The finished product is 9000 lines of C ++ code, and the results are satisfactory at present. It can enjoy the visual sense of accomplishment brought by finished products. This is the advantage of graphics over other technologies.

 

Code 6: Share the file in February. The execution file is as follows:

 

Http://115.com/file/anwxb9xpscansoftware raster .rar

 

Remember the readme.txt.

Note: If the display is unnatural after running (the occlusion relationship is incorrect, especially the seek header), try to press the number of times 4 to enable the depth buffer, or press the number of times 5 to enable the oil painter algorithm.

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.