O'Reilly logo

Ogre 3D 1.7 by Felix Kerger

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action — selecting a color channel

We are going to use the previous code, but we have to add and delete a lot:

  1. Start with the fragment program. Besides the normal parameter, add a float4 uniform parameter to store the color channel factors. Use these factors to multiply the color we retrieved from the original scene texture:
    void MyFragmentShader10(float2 uv : TEXCOORD0,
    out float4 color : COLOR,
    uniform sampler2D texture,
    uniform float4 factors
    )
    {
    color = tex2D(texture, uv);
    color *= factors;
    }
    
  2. Create a new material that uses the fragment shader and add the parameter with the default value of (1,1,1,0). This means that without changing the parameter, the scene will be rendered normally:
    fragment_program MyFragmentShader10 cg { source ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required