Universal Chroma Key Shader
Universal Chroma Key Shader provides you a simple shader to achieve the chroma key compositing effect on any texture, including movie textures.
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.
Examples of 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 3D parallax.
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
- WebPlayer
- It should work in all platforms.
To change programatically on runtime the behavior of the shader, you can do it on this way:
renderer.material.SetFloat("_Sens", 0.2f); renderer.material.SetFloat("_Cutoff", 0.4f); renderer.material.SetColor("_Color", new Color(0f, 1f, 0f));
12 Comments
Haim
Mié 4, febrero 2015How can I use this on android?
Unity wont compile with MovieTexture.
Daniel
Vie 13, febrero 2015Can this be inverted? Say I JUST want the green part and to key out the rest?
rodripf
Jue 19, marzo 2015The shader works perfectly on Andrid. However, as you say, if you want to play video MovieTexture is not a valid alternative. Although the shader works in android you should use another method to show movies. I recommend this one from the asset store.
Thanks for your interest and sorry for the delayed answer.
rodripf
Jue 19, marzo 2015Yes, you can accomplish that with a simple modification in the shader. You can buy it and modify it by yourself or if you want I can code it for you. Thanks for your interest.
danielm
Jue 28, mayo 2015hi, i want to use this shader with the method Graphics.Blit, and i want to know if it works, because i’ve tried with other shaders and they don´t work
georgem
Jue 11, junio 2015Hi
Can I use it with vuforia (android, unity) , so to get a transparent video in front of an image target?
Thanks
David
Mar 30, junio 2015Hi! Does your shader works on iOS?
Tiago
Sáb 10, octubre 2015Can I use this with a real-time webcam feed in Unity where I would have a chroma set up behind the person facing the camera?
rodripf
Lun 15, febrero 2016Yes it does
rodripf
Lun 15, febrero 2016Yes you can!
rodripf
Lun 15, febrero 2016Yes you can, I’ve used this for one of my projects!
rodripf
Lun 15, febrero 2016I sincerly don’t know, never tested that.