To see how color interpolation works we need to change our code a bit.
textureCoord()
with color():
manual->position(5.0, 0.0, 0.0); manual->color(0,0,1); manual->position(-5.0, 10.0, 0.0); manual->color(0,1,0); manual->position(-5.0, 0.0, 0.0); manual->color(0,1,0); manual->position(5.0, 10.0, 0.0); manual->color(0,0,1);
void MyVertexShader4( float4 position : POSITION, out float4 oPosition : POSITION, float4 color :COLOR, out float4 ocolor :COLOR, uniform float4x4 worldViewMatrix) { oPosition = mul(worldViewMatrix, position); ocolor = color; }
void MyFragmentShader4( float4 color : COLOR, out float4 oColor : COLOR) { oColor = color; }
In step 3, we saw another function of the manual object, namely, adding color to a vertex using three float values for red, green, and blue. Step 4 replaced the texture coordinates with color parameters this time we wanted colors not textures. The same is true for step 5. This example wasn't really difficult or exciting, but it shows how interpolation works. This gives us a better understanding of how the vertex and fragment shader also work together.
18.226.177.151