Using the code from the black and white compositor, we are now going to invert our image.
Copy the shader, the material, and the compositor because later we will need both the black and white compositor and this one. Then change the fragment shader of this copy. The new fragment shader should have the name
MyFragmentShader6
, the materialOgre3DBeginnersGuide/Comp3
, and the compositorCompositor3
.This time, get the color value of the texture at the position of the fragment and then subtract each single value from 1.0 to get the inverted value:
color = float4( 1.0 - temp_color.r,1.0 - temp_color.g, 1.0 - temp_color.b,0);
Compile and run the application. This time, the background should be white and Sinbad should be in some pretty strange colors as shown in the following image: