Image Effect help

I’m trying to make a script which can be placed onto a camera to make the camera render only the reds of a scene. Here’s what I have so far:

Script placed onto camera

var redMat : Material;

function OnRenderImage (source : RenderTexture, destination : RenderTexture)
{
	RenderTexture.active = destination;
	redMat.SetTexture ("_MainTex", source);
}

And this is the shader applied to the redMat:

Shader "Red Filter" {
	Properties {
		_MainTex ("Texture", RECT) = ""
	}
	SubShader {
		Pass {
			ColorMask R
			Blend One One
			SetTexture [_MainTex]
		}
	}
}

All this seems to do is create thick soft lines around the edge of the screen. Anyone know what I’m doing wrong?

Thanks

You’re not rendering anything into destination render texture. Take a look at Material.SetPass documentation for quite small image effect to get your started.

Next step should be: change the shader to select only the red channel of the input texture. This would probably be easiest with a small Cg fragment program (instead of trying to do that via SetTexture).