Shadder and Effect - 3.2 pixel shader input and output

zhaozj2021-02-16  58

3.2 pixel shader input and output

Different things to enter the pixel shader: color and texture coordinates. Both are all pixels.

Note: Recalling that the vertex color is interpolated between the face of primities.

The texture coordinates of each pixel are simple (U, V) coordinates, which specifies the texture unit that positively prepared to be mapped. Direct3D calculates colors and texture coordinates, from vertex colors and vertex texture coordinates, before entering the pixel shader. The number of color and texture coordinates input to the pixel shader depends on the number of colors and texture coordinates output from the vertex shader. For example, if a vertex shader outputs two colors and three texture coordinates, Direct3D will calculate two colors and three texture coordinates each pixel and turn them into pixel shaders. We use the language of syntax (Semantic Syntax, Translator Note: See Translation Chapter 1) Mapping These inputs colors and textures into our shader's variables. Use the previous example, we can write this:

Struct PS_INPUT

{

Vector C0: Color0;

Vector C1: Color1;

Float2 T0: Texcoord0;

FLOAT2 T1: Texcoord1;

FLOAT2 T2: Texcoord2;

}

For output, the pixel shader outputs a single color value of the calculated pixel:

Struct ps_output

{

Vector FinalPixelcolor: Color0;

}

转载请注明原文地址:https://www.9cbs.com/read-17771.html

New Post(0)