Connexion




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 
NooFondateur
Avatar de l’utilisateur
Inscription: Mar Jan 09, 2007 3:21 am
Messages: 1166
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/phpBB3/viewtopic.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:
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/YannSteadyDoubleAlpha_674.mov
(the .ogv file for Unity http://www.noomuseum.net/mov/YannSteadyDoubleAlpha_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/SoizicRotatekey-2-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:
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/cyberesthesia-3d/Cyberesthesia.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
http://noozone.free.fr/noocrypte/viewtopic.php?f=16&t=1011
http://noozone.free.fr/noocrypte/viewtopic.php?f=16&t=1797

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 2 invités

Panel

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
Rechercher:
Aller à:  

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Traduction par: phpBB-fr.com
Dizayn Ercan Koc