To see how color interpolation works we need to change our code a bit.
Again, copy the material and make sure to adjust all names.
The only thing we need to change in the material is that we don't need a texture unit. We can just delete it.
In the application code, we need to replace the
textureCoord()
withcolor():
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);
The vertex shader also needs some adjustments. Replace the two texture coordinate parameters with color parameters and also change the assignment line:
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; }
The fragment...