Universal Chroma Key Shader

Universal Chroma Key Shader

A simple shader to achieve the chroma key compositing effect on any texture, including movie textures.

View Example Open in Asset Store »

Chroma Key Shader in Action

It makes the selected color of your texture (image, video or webcam capture) transparent, so you can easily remove the background. You can place any other content behind or in front, also using the shader, so you can get your desired composition.

Ideas for uses:

  • Removing the background of a video to simulate another background
  • Get textures with transparency using JPG files instead of bigger PNGs with alpha
  • Create a 3D parallax effect

Features:

  • You can select the color to be removed (most often used is green, but any color can be assigned). -You can control the color tolerance to remove similar colors
  • You can control the strength of the cutoff
  • You can change these values on runtime
  • You can use the shader multiple times in the same scene

Included in the package:

  • The shader
  • Sample scene

Tested platforms:

  • Windows and Mac Standalone
  • Android (not movie texture!)
  • WebPlayer
  • It should work in all platforms.

To change programatically on runtime the behavior of the shader, you can do it on this way:

1
2
3
renderer.material.SetFloat("_Sens", 0.2f);
renderer.material.SetFloat("_Cutoff", 0.4f);
renderer.material.SetColor("_Color", new Color(0f, 1f, 0f));

Reviews

View Example Open in Asset Store »