Poster un nouveau sujet Répondre au sujet  [ 1 message ] 
Auteur Message
 Sujet du message: Unity 3d Chromakey & alpha video (english)
UNREAD_POSTPosté: Ven Déc 16, 2011 9:04 am 
Avatar de l’utilisateur
Inscription: Mar Jan 09, 2007 3:21 am
Messages: 1164
Double image with Alpha for Chroma Key in Unity 3D


Maybe here is a trick I imagined, that could be usefull... it is not really chroma key, but it works fine...

Make a movie with both, the foreground and the alpha key image on the same picture with After Effects or other compositing soft.

Import this movie in Unity3D


create a shader with the script written by LouLou from the french forum

Apply this shader to a material, and adjust the Tile and offset of the texture of this material to hide the white alpha image.

Shader "Custom/VideoAlpha" {
   Properties {
      _MainTex ("Base (RGB)", 2D) = "white" {}
      _AlphaOffsetX ("alpha offset x", float) = 0.5
      _AlphaOffsetY ("alpha offset y", float) = 0
      _Cutoff ("Cutoff", Range (0,1)) = .5
   SubShader {
   AlphaTest Less [_Cutoff]
         #pragma surface surf Lambert
         sampler2D _MainTex;
         float _AlphaOffsetX;
         float _AlphaOffsetY;
         struct Input {
            float2 uv_MainTex;
         void surf (Input IN, inout SurfaceOutput o) {
            half4 c = tex2D (_MainTex, IN.uv_MainTex);
            IN.uv_MainTex.x += _AlphaOffsetX;
            IN.uv_MainTex.y += _AlphaOffsetY;
            half4 d = tex2D (_MainTex, IN.uv_MainTex);
            o.Albedo = c.rgb;
            o.Alpha = (d.r*-1)+1;
   FallBack "Diffuse"

It works fine, it is much more better than hiding the green by script.
A 600 pixel high sequence is fine.

If you want to test here are some demo sequences to test
(the .ogv file for Unity

Model Soizic Hess
(.ogv file for Unity

1) How could it be possible to make this texture "Unlit" ? does someone have the answer ?

2) Is it possible to do the same, but with a video movie store in a web server, or in a local computer, because the videos are really too heavy to put inside the project himself...

Yes, just put this video player script in the screen object, and put a similar jpg image from the movie in the material window.

private var url = "";  // Lien de la video
public var object:GameObject; // Objet sur lequel doit être afficher la video

function Start () {

var www = new WWW(url);

var movieTexture =;
while (!movieTexture.isReadyToPlay)

object.renderer.material.mainTexture = movieTexture;

audio.clip = movieTexture.audioClip;

movieTexture.Loop = true;

@script RequireComponent (AudioSource)

If you want to store the movie on a local URL on your Mac or PC, replace the URL address in the script by that kind of address : file:///Users/YannSteadyDoubleAlpha_674.ogv

Here a level I have done with two video inside.. [/url] avec deux videos incrustées à l'intérieur en démo. (les vidéos sont des .ogv hébergés sur le web.)

it is a multiplayer test, click "Heberger" and "entrez dans les Noobunkers"

Sorry Heavy level of 132 mega, done for
See more here

This version of the noobunker can remote E-Stims and Teledildo via OSC

Yann, NooKeyer

 Hors ligne

Afficher les messages postés depuis:  Trier par  

Poster un nouveau sujet Répondre au sujet  [ 1 message ] 

Qui est en ligne

Utilisateurs parcourant ce forum: Aucun utilisateur enregistré et 1 invité


Haut Vous ne pouvez pas poster de nouveaux sujets
Vous ne pouvez pas répondre aux sujets
Vous ne pouvez pas éditer vos messages
Vous ne pouvez pas supprimer vos messages
Aller à:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Traduction par:
Dizayn Ercan Koc