Unity 3d Chromakey & alpha video (english)

Informations relatives au logiciel de 3D temps réel Unity
yann.minh
Site Admin
Messages : 1160
Inscription : dim. févr. 11, 2007 7:44 pm

Unity 3d Chromakey & alpha video (english)

Message par yann.minh »

Double image with Alpha for Chroma Key in Unity 3D


Hello,

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


Image

create a shader with the script written by LouLou from the french forum http://www.unity3d-france.com
http://www.unity3d-france.com/unity/php ... ?f=8&t=901

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

Code : Tout sélectionner

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]
         CGPROGRAM
         #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;
         }
         ENDCG
      
   } 
   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

http://www.noomuseum.net/mov/YannSteady ... ha_674.mov
(the .ogv file for Unity http://www.noomuseum.net/mov/YannSteady ... ha_674.ogv
Image

Model Soizic Hess http://soizic-hess.com/
http://www.noomuseum.net/mov/SoizicDoubleAlpha-674.mov
(.ogv file for Unity http://www.noomuseum.net/mov/SoizicRota ... 800ogv.ogv
Image


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.

Code : Tout sélectionner

private var url = "http://www.noomuseum.net/mov/YannSteadyDoubleAlpha_674.ogv";  // 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 = www.movie;
while (!movieTexture.isReadyToPlay)
yield;

object.renderer.material.mainTexture = movieTexture;


audio.clip = movieTexture.audioClip;

movieTexture.Play();
movieTexture.Loop = true;
audio.Play();
}

@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.)
http://www.cyberesthesie.com/cyberesthe ... hesia.html
Image

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

Sorry Heavy level of 132 mega, done for http://www.cyberesthesia.com
See more here
noocrypte_go.php?t=1011
noocrypte_go.php?t=1797

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


Yann, NooKeyer
Répondre