1.1 What is a shader

Source: Internet
Author: User

1. HLSL entry

1.1What is a shader?

DirectX uses the pipeline technology (pipeline) for graphic rendering. Its architecture is as follows:

Figure 1.1 direct3d graphics pipeline

The steps for using pipelines are as follows:

1. Set data information such as vertices, elements, and textures;

2. Set MPs queue status information;

2. Rendering status

Use the setrenderstate method to set the rendering state;

In addition, use the following methods to set the conversion, material, and illumination:

Settransform

Setmaterial

Setlight

Lightenable

2. sampling device status

The setsamplerstate method is used to set the samplerstate;

2. texture layer status

Use settexturestagestate to set the texture layer status;

3. Rendering;

This is done by the d3d pipeline according to the previous settings. This operation is pre-fixed by d3d. Therefore, this pipeline technology is called fixed function pipeline );

 

The fixed function pipeline provides some flexibility for programming, but there are still many effects that are hard to be achieved in this way, such:

1. during rendering, we require that the vertices with Y coordinate values greater than 10 be drawn to the coordinates (0, 0, 0). In the previous fixed function pipeline, the position where the vertex is drawn is set in step 1, which cannot be changed during rendering, so it is not feasible;

2. Map the vertex to Vertex a on Texture 1 and map to vertex B on Texture 2. We require that the color of the vertex be jointly determined by A and B, that is:

Fixed Point color = a point color value * 0.7 + B point color value * 0.3

This is also not feasible in fixed pipeline programming.

The above two problems can be solved by the programmable pipeline (pragrammable pipeline.

The programmable pipeline allows you to customize a program that can be executed on the GPU, instead of the vertex processing and pixel processing phases in the fixed pipeline technology (see Figure 1.1 ), so that we can achieve greater flexibility in programming. The part that replaces vertex processing is called vertex shader, and the part that replaces pixel proccessing is called pixel shader. This is what we call the shader.

 

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.