We will use a fragment shader to modify the texture, so change the material to also make use of a fragment shader. Also copy the material and the compositor. This compositor should have the name Compositor2
, the material Ogre3DBeginnersGuide/Comp2
.
fragment_program_ref MyFragmentShader5
{ }
Don't forget to define the fragment program in the material file before using the reference:
fragment_program MyFragmentShader5 cg { source Ogre3DBeginnersGuideShaders.cg entry_point MyFragmentShader5 profiles ps_1_1 arbfp1 }
Also create a new fragment shader in our shader file. This shader has, as input, the texture coordinates and a texture sample. Once the color of the fragment is computed, this color is returned:
void MyFragmentShader5(float2 uv : TEXCOORD0, out float4 color : COLOR, uniform sampler2D texture) {
Get the color of the texture at the position of the texture coordinates:
float4 temp_color = tex2D(texture, uv);
Convert the color to grayscale:
float greyvalue...