imagination XD

realizing dream


3 Comments

[Unity] Keyed Lipsync using Blendshape + Tagarela

edfedfe

I still research on how to make automated keyless lipsync. So, I found this plug in, it’s free, and it’s easy to use so I got that goin’ for me, which is nice.

Recipe (What you’ll need) :

  • PC with Unity 4.3 or above
  • Tagarela
  • Mesh that has blendshape (If you don’t know how to make blendshape, read this)
  • Blendshape that has at least A,I,U,E,O keys. (if you are too lazy to make E key, you can use I for every E)

Alright let’s start! I’ll use Kagamine Len by Animasa model as example.

  1. After finished download, open it in Unity.
  2. Select an object that has blendshape / skinned mesh renderer on it. Open Component > Tagarela. After that insert Audio Clip and then press Add.lt1
  3. Click Open Editor then press Create New Animation, choose Audio Sync, name it whatever you want, press save.lt2
  4. First, slide the tiny slider near audio’s start, then press + to add new keyframe, locate the new keyframe at the middle of audio, and adjust the blendshape below.
    lt3
  5. I use Unity chan’s konnichiwa (こんにちは私ユニティちゃん). 1 is all Zero, 2 is 100% 001 (O (I forgot to change name), 3 is also zero because it’s closing its mouth when saying kon’, and 4 is 100% i, when it says ni.
    lt4
  6. Set it till near perfection. Also remember to set keyframe to zero on all flat audio which is mute (does your mouth open when you say nothing ? unless you breathing with mouth, like me). For example, your voice was “Hello World”, 1 all zero keyframe was located before Hello, 2 keyframe was located in ‘He’ has 100% ‘E’, and 3 keyframe was located in the ‘llo” has 100% ‘O’ and 0% ‘E’, at the end of ‘Hello’ add 4 keyframe that is zero keyframe, and 5 keyframe was located at the beginning of ‘World’ which also zero. 6 keyframe repat like 2 keyframe but with different value.
    lt5
  7. After you done naturalising the lipsync, always remember to put zero keyframe at the start of audio not voice. and then save it. You may ask how to use it on gameplay, well, you’ll only need to put this GetComponent<Tagarela>().Play( <Your animation number (mine is 0 because it’s the first animation)> ); on a C# script. Also attach this script on the same place where your blendshape mesh.
    lt6
  8. Ta-da… Not bad I see. I also forgot to add some Mecanim animator, so it looks like stupid people says “Hello, I’m Unity-chan” but actually you are Len Kagamine.

Next, I’ll research much easier to use lipsync or Anime-like lipsync. Most anime I watch, they only use 1 key. Even they say “What the hell are you doing”, their mouth will be always open and close only, no wide or narrow. Also remember to make it jagged, so it’ll look like Anime. I also researching on how to combine cloth shader with Toon shader like cloth crumple shadow in usual anime.

Ah and Imagine-chan’s model has finished, and it’ll release probably this november. I think I’ll need to remodel, because her head looks ridiculous. However, morphless FBX and PMX download will be available. I’m kinda busy working. My supervisor wont let me to do this, so that’s why I wont upload this model soon.


1 Comment

[Unity] Taking In-Game Screenshot

Hello, everyone, Sorry I didn’t post something here in long time. I’m very busy, leveling up my CG skills. I also post some random unity things.

So, basically, taking screenshot in Unity is very easy. Copy this script below, and attach it in Main Camera

var folderName : String = "DCIM";
var captureSound : AudioClip;
var quality : float; //Set screenshot resolutions, default is 1. 1 equals your monitor size.
private var screenshotFader : GameObject;

function LateUpdate(){
 if(screenshotFader){ //Flashing effect
 screenshotFader.guiTexture.color.a -= Time.deltaTime;
 if(screenshotFader.guiTexture.color.a < 0){
 Destroy(screenshotFader);
 screenshotFader = null;
 }
 }
 
 if(Input.GetKeyDown("C") && !screenshotFader){
 if (!System.IO.Directory.Exists(folderName)) System.IO.Directory.CreateDirectory(folderName);
 
 screenshotFilename = folderName+"/DSC_"+System.DateTime.Now.Day.ToString()+"_"+System.DateTime.Now.Hour.ToString()+System.DateTime.Now.Minute.ToString()+System.DateTime.Now.Second.ToString()+".png";
 if(!System.IO.File.Exists(screenshotFilename)){
 Application.CaptureScreenshot(screenshotFilename,quality);
 AudioSource.PlayClipAtPoint(captureSound,transform.position);
 DrawWhiteItem();
 }
 }
}

function DrawWhiteItem(){
 yield new WaitForSeconds(0.5); //wait for a few frames so the application can capture before the white flash comes out.
 screenshotFader = DrawFader();
}

static function DrawFader() : GameObject{
 var fdt = new Texture2D(1,1);
 fdt.SetPixel(0,0,Color.white);
 fdt.Apply();
 
 var fadex = new GameObject("CSader");
 fadex.AddComponent(GUITexture);
 fadex.transform.position = Vector3(.5,.5,1000);
 fadex.guiTexture.texture = fdt;
 
 return fadex;
}

now it’ll save the screenshot on your game root folder / DCIM (you can change the folder name).


12 Comments

Joint-based Hair / Cloth Physics for Unity

I was doing the MMD4Unity research. I do this because, on Google, if you want a Hair Physics, you have to wrote a script, or key frame it naturally in your model. Ain’t nobody got time for that keyframing! So, this might be very useful for easy Joint-based hair / cloth physics, even wrote a script was useful too.

Okay, so it’ll be like this. It could be very awesomely epic if you are not lazy to set the character joint setting.

“It’s long and complicated, i better use keyframe method.” Yeah true, but what to do when the hair colliding object because of your keyframing method ?

Let’s get Neru Akita as example (Model from MMD, some motion from Unity-chan).

Unity 2014-07-27 14-07-06-60_2

1. Now Select cloth / hair bones and then add Capsule Collider like the picture below.
1(bones)

2. After that, adjust the size of the colliders and then add Character Joint.
2(bones)

3. If your character has a Character Controller on it / Playable, Open Tags & Layer, add 2 layers. Set ‘Player’ layer to object that has Character Controller on it. Else, set the object that you want to have a hair / cloth physics like Hair Bones1, Hair Bones2, and so on, or Hair/Cloth physics collider like MidSpine (That has Collider, so hair / cloth wont clip like hell). Basically, Just set Cloth Layer to Skinned Mesh Renderer, and set it to all children.
3b (Bones)

4. Go to your character controller script. Whatever script is OK as long as its located on Object that has Character Controller on it. Don’t make a new script. Just add this line to function Start() or void Start(). Works on both C# and JS. 8 is Cloth layer, 9 is Player layer. it’s all up to you on what layer you set the Cloth or Player layer. If you set cloth layer to 10, then write 10.

Physics.IgnoreLayerCollision(8,9);

3c (bones)
5. Alright now let’s add Rigidbody on cloth’s / hair’s root bone. For the root of the cloth (like this below), turn on isKinematic and turn off useGravity. Root doesn’t need a Character Joint, Collider is optional.

4 (bones)
6. Now set the Character Joint’s connected body. For instance, 1 (Cloth Root), 2 (1’s child), 3 (2’s child). 3’s connected body is 2, 2’s connected body is 1, and 1 doesn’t have a Character Joint. Like the picture below.
5 (bones)
7. Set bone’s swing limit, spring, high twist limit, low twist limit that suits to your model.
6 (bones)
8. Now add some collider to body that Hair or cloth will collide. Remember to set the body layer to CLOTH, so your character controller wont collide it. I add the colliders on Body, Hands, and Head.
7 (bones)

Because if you don’t add colliders, it’ll look like this:
Unity 2014-07-27 14-07-06-60

Now look! A cloths dynamic! It much better than the method I use on Wild West Showdown (Skinned Cloth). Look at her front hair and tie.
Unity 2014-07-27 14-07-06-60_1

 

As I said, I leave making games because I need to level up my CG level. I said I was give up right ? No, and never. I just need to learn to make a better CG Artwork. I’m currently making a mascot model for Imagination, named Imajine-chan. but, I don’t have an inspiration for her character design.

EDIT : “My Character raycast’s script is broken because of this.” Well, you could replace Cloth to IgnoreRaycast layer.


Leave a comment

[Shader] Reflective Transparent / Water-like Unity Indie

This is what I promised. Sorry for being late, I’m kinda busy recently. I made this shader by merging between Transparent>Diffuse and Reflective>Diffuse. But I haven’t done with Normal Mapped Specular. My Unity kinda hates me, everytime I add Normal Map to this shader Unity Yells “Too many texture interpolators would be used for ForwardBase pass!” or “_ReflectColor no Properties!”. Perhaps you can do it yourself.

NOTE : I didn’t copy this script from internet. I just merge Unity’s Transparent>Diffuse and Reflective>Diffuse. So, if you are saying that I copy your script like that movie script I was made in 2012 and you found in 2014, go f*** yourself… By the way, this script ALREADY Exist on Nitro Racer XD on Epic Living Room track. I just made a lot of modification from Nitro Racer XD.

Shader name in Unity is “Glass Reflective_N”, and this is the preview / how to use the shader.

Ref_BLWater Ref_Full Ref_BLRef Ref_MStUnity - Untitled - RT - PC, Mac & Linux Standalone_4

Want More Realistic ?

If you want more realistic, you could add UVMover (Moving main texture’s offset from script * Time.deltaTime), and Realtime Reflection INDIE. Adding some Caustic effects or Underwater effects or Normal Map or Specular Shininess. You can also use this shader for a glass…

Glass Reflective_N

Shader name is a little bit ironic isn’t it ? It says N for Normal Map support, but this shader couldn’t support Normal Map. Alright here’s the shader.

Shader "Glass Reflective_N" {
 Properties {
 _Color ("Main Color", Color) = (0.5,0.5,0.5,1)
 _ReflectColor ("Reflection Color", Color) = (1,1,1,0.5)
 //_Shininess ("Shininess", Range (0.01, 1)) = 0.078125
 _MainTex ("Base (RGB) TransGloss (A)", 2D) = "white" {}
 //_BumpMap ("Normalmap", 2D) = "bump" {}
 _Cube ("Reflection Cubemap", Cube) = "black" { TexGen CubeReflect }
 }
 SubShader {
 Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
 Blend SrcAlpha OneMinusSrcAlpha
 //Pass {
 // Color [_Color]
 // SetTexture [_MainTex] {
 // combine texture * primary
 // }
 // }
 LOD 300
 
 CGPROGRAM
 //#pragma surface surf BlinnPhong decal:add nolightmap
 #pragma surface surf BlinnPhong alpha
 //#pragma target 3.0
 sampler2D _MainTex;
 //sampler2D _BumpMap;
 samplerCUBE _Cube;
 //half _Shininess;
 
 fixed4 _ReflectColor;
 fixed4 _Color;
 
 struct Input {
 float3 worldRefl;
 float2 uv_MainTex;
 //float2 uv_BumpMap;
 INTERNAL_DATA
 };
 
 void surf (Input IN, inout SurfaceOutput o) {
 fixed4 tex = tex2D(_MainTex, IN.uv_MainTex);
 //o.Albedo = 1;
 //o.Gloss = 0;
 o.Albedo = tex.rgb * _Color.rgb;
 o.Gloss = tex.a;
 //o.Normal = UnpackNormal (tex2D (_BumpMap, IN.uv_BumpMap));
 
 //o.Specular = _Shininess;
 float3 worldRefl = WorldReflectionVector (IN, o.Normal);
 fixed4 reflcol = texCUBE (_Cube, IN.worldRefl);
 reflcol *= tex.a;
 o.Emission = reflcol.rgb * _ReflectColor.rgb;
 //o.Alpha = reflcol.a * _ReflectColor.a;
 o.Alpha = tex.a * _Color.a;
 
 }
 ENDCG
 }
 FallBack "Transparent/VertexLit"
}

 


2 Comments

[Tutorial] Realtime Render Animation With Unity3D

Seiten Taisei's MV Intro | ‎Wednesday, ‎February ‎27, ‎2013, ‏‎6:26:49 PM

Seiten Taisei’s MV Intro | ‎Wednesday, ‎February ‎27, ‎2013, ‏‎6:26:49 PM

That’s my first ever Realtime Render Animation. Back then I used FRAPS to record the animation in Unity, but now, I use better Sequenced PNG renderer. I found this script on Unity3D Wiki named ScreenshotMovie. But in this tutorial, let’s just use my version of ScreenshotMovie (It’s running on background, so you can play psxfin while Unity rendering). It works both on Indie and Pro. But Indie wont get an epic effect. If you use Indie but you want to get an epic effect, use After Effect.

You’ll need this

  • Unity3D
  • VirtualDub
  • Xvid Codec (Optional)
  • A knowledge on Animation (At least Level 3(You’ll need to know what is Flat, Spline, Constant, Keying, Free Smooth and something like that))
  • And Not TLDR Personality (Too long, didn’t read. :D)

Create a new Javascript, named it whatever you wanted, then attach this on MainCamera, and then REMEMBER to disable it (So you wont got lag when previewing the animation).

var folder = "ScreenshotFolder";
var frameRate = 25;

private var realFolder = "";

function Start () {
	Screen.showCursor = false;
	Application.runInBackground = true;

    // Set the playback framerate!
    // (real time doesn't influence time anymore)
    Time.captureFramerate = frameRate;

    // Find a folder that doesn't exist yet by appending numbers!
    realFolder = folder;
    count = 1;
    while (System.IO.Directory.Exists(realFolder)) {
        realFolder = folder + count;
        count++;
    }
    // Create the folder
    System.IO.Directory.CreateDirectory(realFolder);
}

function Update () {
    // name is "realFolder/0005 shot.png"
    var name = String.Format("{0}/{1:D04}.png", realFolder, Time.frameCount );

    // Capture the screenshot
    Application.CaptureScreenshot (name); // Use Application.CaptureScreenshot(name,2) if you want 1080HD
}

function OnDisable(){ enabled = true; }
  1. RT-1You have to animate the scene first, create a new Game Object, then child all objects that you want to animate. Character and NPC also able to animate using this (with NavMeshAgent), but it’s kinda very difficult. I created a special script to animate the movement of the AI using NavMeshAgent and Animator. In this tutorial, I’ll only teach you how to make a simple realtime camera animation.
  2. RT-2Select ‘Actor’ GameObject then click Record on Animation Tab (Press CTRL+6 if you don’t have an Animation Tab).
  3. RT-3You can animate everything you want (turning off gameObject, turning off a certain script, adjusting script value, everything). To animate the Camera, just change any value that you wanted. The animator will automatically key it.
  4. So, if you are saying that you want change camera, you just simply key the first position, then select camera key > Right Click  > Right Tangent > Constant, and then go for 1 frame , and then change the camera position again > Select The camera key > Right Click > Left Tangent > Constant. Repeat this step everytime you wanted to change camera position.
  5. Camera moves crazily ? Check your Position or Rotation Curves, or just set Select The Camera Key > Right Click > Flat.
  6. NOTE : Your animation clip will automatically Loop, to disable this, go to the folder where you save this animation clip and then uncheck Loop.
  7. RT-4After you finish with animating, Click Record Button to stop recording, and then Add that script to Main Camera. You need to adjust the Folder name (It’ll save to your Unity Project’s folder), and the frame rate (I usually use 24). Press Play and LET IT RENDER!
  8. RT-5The renderer will running in background, so you can do anything while Unity Render this (I play psxfin while rendering, haha yeah). Go back and check your Unity, if you believe your animation already finished render, press play again (that button above).
  9. RT-6Check your Unity Project folder, you’ll found a folder that you’ve named on Unity. That’s a large amount of PNG Sequences!
  10. RT-7Go launch VirtualDub, click File > Open Video File
  11. RT-8Open your Unity Project Folder, and then Select the First Image (Usually it’s 0002.png), then Open.
  12. RT-9Now let’s adjust the frame rate, so it wont look very lag (Default frame rate was 10)
  13. RT-10Remember to change the Frame Rate as the rate that you set in Unity (I set 24FPS)
  14. RT-11This is an optional step. You don’t want a huge video file, do you ? Skipping this step will give you 2GB Video for 40 seconds. So you’ll need to compress it using Xvid.
  15. RT-12Alright this is the final step. Click File > Save as AVI. “Hey! Wait! What about the resolution?” Ahaha, yeah. I’m sorry, I was forgot about that. The Resolution will be same as how large you render it on Unity. I use 16:9 Aspect on Unity while rendering. If you are using Free Aspect, you’ll gonna have a large letter box. “My monitor just 1360px, can I render 1920?” Sure you can! Just read back my script comment. Also, you’ll gotta be very patient when rendering 1080.

That’s just a simple camera animation. I’m tired writing very long text with slow internet, so I’ll post about Full Character Animation later. But here, I’ll give you an example of using Full Character Animation.

I don't have Motion Capture, So I have to animate non Walking motion.

I don’t have Motion Capture, So I have to animate non Walking motion.

Here's a sample to play sound. All animation event controlled by ANIMATOR CORE.

Here’s a sample to play sound. All animation event controlled by ANIMATOR CORE.

This is how my Camera Position looks like

This is how my Camera Position looks like

Also make a new Scene everytime you want to shot other location. It makes animating easier, and faster. Since NavMeshAgent only can do walk motion, you’ll need to duplicate the character (1 NavMeshAgent, and 1 just animator). I also made new Animator Controller on the character. I’ll explain what are those (Animator Core)

  • Actors[] : All walkable actors in this scene.
  • ActorsHead[] : All actors that have facial animation.
  • ActorAnimatorValue[] : Unused. Should be set like “Speed”, or “Direction”
  • ActorAnimatorValue[] : Unused. Should be like 1.0, or 0.2
  • NPCDestination[] : an empty game object tells NavMeshAgent where to go.
  • SoundBank[] : All AudioSource that available on this scene.

And this is the final product.


3 Comments

[Research] Unity Underwater Caustic Effect

I can't see the caustic effect clearly. That's why this is still just a research.

I can’t see the caustic effect clearly. That’s why this is still just a research.

Hello everybody, yeah I’m a bit late. I was promised that I’ll give Underwater Caustic Effect on this thread. So yeah, it was simple enough to create this Caustic Effect. It only use Directional Light’s cookie or Projector. For the water, I use Reflective>Bumped Specular. You can create double-sided by adding ” Cull Off ” on Reflective>Bumped Specular shader, but if you are lazy to add it, you can duplicate the water mesh and mirror it (Original(Quad) : 90,0,0, doubleSided : -90,0,0).

1. Go make a new JavaScript and then attach it to your water mesh. Your player also need to be tagged as “Player”. You’ll need this

#pragma strict

var scrollSpeed = 0.25;
var waterCausticSpeed = 2;
var isWater = true; // Just set it true.

var cubeMap : Cubemap;
var causticTextures : Texture;
var causticSize = 10.0;

private var entered = false;
private var awakeFogCol : Color;
private var awakeFogDense : float;
private var defSky : Material;
private var lungColor = Color.green;
private var causticator : GameObject;

function Awake () {
    if(isWater){ 

        awakeFogCol = RenderSettings.fogColor;
        awakeFogDense = RenderSettings.fogDensity;
        defSky = RenderSettings.skybox;

        renderer.material.SetTexture("_Cube",cubeMap);

    }
}

function FixedUpdate(){
    var offset = Time.time * scrollSpeed;
    renderer.material.mainTextureOffset = Vector2(0,-offset);
    renderer.material.SetTextureOffset("_BumpMap", Vector2(0,-offset));

    if(isWater && entered){
        /*lungCapacity -= 0.5;
        if(lungCapacity < 125) lungColor = Color.yellow;
        if(lungCapacity < 50) lungColor = Color.red;
        if(lungCapacity <= 0)player.ApplyDamage(1);*/

        if(causticator){
            causticator.transform.Rotate(Vector3(0,waterCausticSpeed*Time.deltaTime,0),Space.World);
        }
    }
}

function OnTriggerEnter(col : Collider){    
    if(col.gameObject.tag == "Player" && isWater){
        entered = true;
        RenderSettings.fogColor = Color(0,0.4,0.7,0.6);
        RenderSettings.fogDensity = 0.1;

        CreateCaustic();
    }
}    

function OnTriggerExit(col : Collider){
    if(col.gameObject.tag == "Player" && isWater){
        entered = false;
        RenderSettings.fogColor = awakeFogCol;
        RenderSettings.fogDensity = awakeFogDense;

        Destroy(causticator);
    }
}

function CreateCaustic(){
    causticator = new GameObject("Causticator");
    causticator.AddComponent(Light);
    causticator.light.type = LightType.Directional;
    causticator.light.intensity = 0.5;
    causticator.light.color = Color(0.5,0.5,0.5);
    causticator.light.cookie = causticTextures;
    causticator.light.cookieSize = causticSize;
    causticator.transform.rotation.eulerAngles = Vector3(90,0,0);
}

2. After that, You’ll need Loopable Caustic Texture, you can find it on Google.

3. And then import that texture to Unity, remember to enable Alpha from Grayscale.

4. Also, remember to add Triggered BoxCollider on water mesh. Make sure that Box Collider Size covered all ground, but you also need to adjust the center of Y Axis because You don’t want an obvious transition, do you ?

As you can see, the Box Collider was offset-ed from water mesh. So it'll give you a nice transition.

As you can see, the Box Collider was offset-ed from water mesh. So it’ll give you a nice transition.

5. Finally, you just have to adjust all those thing until you fully satisfied.

6. So, you want to use Projection Method ? Well… Create empty Game Object, Add Projector to it, set it to Orthographic projection, set the rotation to 90,0,0. After that adjust the size until you happy. But you’ll need a Light Projection Shader (You can obtain it on Assets > Import Package > Projector). Create new material with Light Projection Shader, insert Caustic Texture to Cookie and Falloff Texture to Falloff. Use the script to rotate it.

So what’s the best ? What should i choose ?
Here’s the comparison between Directional Light Method and Projector Method

Directional Light

  • Quick, fast, and easy to use.
  • All area included.
  • Sometimes causes Obvious Transition.
  • My eyes! Too bright! The intensity must be high, if low, you wouldn’t be able to see the caustic.

Projector

  • OK transition (No screen brightening)
  • You don’t need to adjust the intensity, you’ll always be able to see the caustic.
  • Difficult, Requires High patience, and High Accuracy.
  • You have to adjust the projection area.


5 Comments

[Tutorial] Unity Facial Animation / Blendshape / Morph

This is an update from Unity 4.3. This is very amazing feature that I really wanted back then. Realize I don’t know how to make a facial animation with bones. This is very fast method to make a facial animation. Works in Both Unity Indie and Pro. In this tutorial, I split my Head’s mesh and body mesh. It also works if your mesh were joined with head. I split head and body because, blender can’t read my model’s bone.

Unity 4.3 Blendshape

Unity 4.3 Blendshape

So, you’ll require this thing to make a blendshape:

  • Unity3D 4.3 (Download here)
  • Blender 2.69 / Blender 2.68 (Download here)
Launch Blender 2.69 and import your model file.

Launch Blender 2.69 and import your model file.

In Object mode, click your model, then click triangle icon there and on the Shape Keys section, press +

In Object mode, click your model, then click triangle icon there and on the Shape Keys section, press +

After you add new keys, switch it to Edit Mode. That Propositional editing is just used to help you transforms the vertex or should I say, Soft Selection.

After you add new keys, switch it to Edit Mode. That Propositional editing is just used to help you transforms the vertex or should I say, Soft Selection. Remember to set the Key value that you want to edit to 1 and set the other that you don’t want to edit right now to 0.

Shape / Deform your model whatever you like and then name your keys.

Shape / Deform your model whatever you like and then name your keys.

If you want to add / delete keys, you have to switch from Edit Mode to Object Mode. REMEMBER! BEFORE YOU ADD NEW KEYS, MAKE SURE THAT YOUR CURRENT KEY VALUE IS 0 AND YOUR NEW KEY VALUE IS 1

If you want to add / delete keys, you have to switch from Edit Mode to Object Mode. REMEMBER! BEFORE YOU ADD NEW KEYS, MAKE SURE THAT YOUR CURRENT KEY VALUE IS 0 AND YOUR NEW KEY VALUE IS 1

After set the key as many as you want, it's time to Export it to Unity. REMEMBER to SET all keys value to 0! If you don't do this, You'll gonna had a bad time.

After set the key as many as you want, it’s time to Export it to Unity. REMEMBER to SET all keys value to 0! If you don’t do this, You’ll gonna had a bad time.

Import your Exported model to Unity. Unity refuse to read your model? Export it to FBX. Basically, you don't need to adjust everything above. Check if Import Animation is turned on. and then Put it to your scene

Import your Exported model to Unity. Unity refuse to read your model? Export it to FBX. Basically, you don’t need to adjust everything above. Check if Import Animation is turned on. and then Put it to your scene

Set your keys until you happy with it.

Set your keys until you happy with it.

To animate it, Create new Animation Controller and Add Animator component to your character game object. Remember to turn off Apply Root Motion. Create new Animation, then press Add Curve, then select your head game object > Skinned Mesh Renderer > #YOUR KEYS NAME#. and Animate it (set curves). After finished animate, remember to set the animation loop by clicking the animation clip. After that, open your animator controller and insert your animation. Just set it whatever you like. Mine just Idle > EE_Blink. I haven't made talk function yet.

To animate it, Create new Animation Controller and Add Animator component to your character game object. Remember to turn off Apply Root Motion. Create new Animation, then press Add Curve, then select your head game object > Skinned Mesh Renderer > #YOUR KEYS NAME#. and Animate it (set curves). After finished animate, remember to set the animation loop by clicking the animation clip. After that, open your animator controller and insert your animation. Just set it whatever you like. Mine just Idle > EE_Blink. I haven’t made talk function yet.

So what do you think ? Now, it’s done, your model now has a facial animation. Be creative for the further animation and add more realism. If you want a quick lipsync, You can create a script that reads voice frequency and put it to your mouth keys. Like SkinnedMeshRenderer.SetBlendShapeWeight(0,audioFreq);. Read more on Unity’s Scripting Reference about Skinned Mesh Renderer.


7 Comments

Shadowed Transparent Cutout Shader

Want to make a realistic tree but the leaves don’t cast shadows ? Having a problem with built-in Transparent/Cutout/Diffuse or Transparent/Cutout/Soft-edge unlit ?

Well, just use my customized shader named “ALPHARIZED SHADOW”.

Before. Culled!

Before. Culled!

After. Not culled, shadowed.

After. Not culled, shadowed.

Unity - Main.unity - MagicPuppy - PC, Mac & Linux Standalone_5Actually, in this code, Alpharized Shadow, I just disabled the cull on Transparent Cutout Diffuse shader. I’m having a research on making Additively Alpharized Shadow. What does it do ? Well, it’s simple, we enable shadow on Particle/Additive shader. It’ll make a realistic cloud effect.

Here’s the code for Alpharized Shadow

Shader "Alpharized Shadow" {
Properties {
	_Color ("Main Color", Color) = (1, 1, 1, 1)
	_MainTex ("Base (RGB) Alpha (A)", 2D) = "white" {}
	_Cutoff ("Base Alpha cutoff", Range (0,.9)) = .5
	_Multiplier("Color Multiplier",Range(1,10)) = 1.0
}
SubShader {
	Tags { "Queue"="AlphaTest" "RenderType"="TransparentCutout" }
	LOD 200
	Cull Off Lighting Off

CGPROGRAM
#pragma surface surf Lambert alphatest:_Cutoff

sampler2D _MainTex;
fixed4 _Color;
float _Multiplier;

struct Input {
	float2 uv_MainTex;
};

void surf (Input IN, inout SurfaceOutput o) {
	fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color * _Multiplier;
	o.Albedo = c.rgb;
	o.Alpha = c.a;
}

ENDCG
}

Fallback "Transparent/Cutout/VertexLit"
}


9 Comments

[TUTORIAL] REALTIME Reflection on Unity Indie

I really amazed when I found this trick. I know that Unity INDIE could make a realtime reflection via CAMERA.RENDERCUBEMAP. However, there still has some limitations like not really slow, and only 64 pixels. If you set the update rate to 0.03, it’ll slow as hell (about 14 fps), and if you set the update rate to 1, it’s not slow (about 60 fps).

And this is the tutorial :

  1. Go make a new javascript. The code are in the below of this post.
  2. Go make a new Cubemap by clicking CREATE > CUBEMAP on project tab.
  3. I named it “CUBOMAPO_REF”;
  4. Assign this script on an object that you want to enable the reflection.
  5. Assign CUBOMAPO_REF or your cubemap to CUBEMAP properties in your Reflective Object.
  6. Assign YOUR CURRENT MATERIAL to CURRENT MATERIAL properties in your reflective object.
  7. meshos
  8. Adjust the update rate.
  9. DONE! Now look what have you done! This is my preview…. With 0.2 Update Rate about 40 fps.

Realtime Reflection

This is the code

#pragma strict

var cubemap : Cubemap;
var currentMaterial : Material;
var updateRate = 1.0;
private var renderFromPosition : Transform;
private var minz = -1.0;

function Start () {
    renderFromPosition = transform;
}

function Update () {
    if(Time.time - updateRate > minz){
        minz = Time.time - Time.deltaTime;
        RenderMe();
        currentMaterial.SetTexture("_Cube",cubemap);
        renderer.material = currentMaterial;
    }
}

function RenderMe(){
    var go = new GameObject( "CubemapCamera"+Random.seed, Camera );
        
    go.camera.backgroundColor = Color.black;
    go.camera.cullingMask = ~(1<<8);
    go.transform.position = renderFromPosition.position;
    if(renderFromPosition.renderer )go.transform.position = renderFromPosition.renderer.bounds.center;
    go.transform.rotation = Quaternion.identity;
    
    go.camera.RenderToCubemap( cubemap );

    DestroyImmediate( go );
}


2 Comments

[Research] Realtime Global Illumination Unity Indie

Again, I found this when I was taking a bath on my bathroom (man! Bathroom was my source of inspiration!). My shirt was red, and my bathroom was dark and I saw that the wall become red. I think that realtime GI can be made by using point light. Here’s my research, you can develop it further.

  1. Add a Point Light Game Object and set it as a Child of your object that you want to add a GI.
  2. Set the render mode on Point Light to Important.
  3. Also, set the position of Point Light to 0,0,0. So it could be centered on your object.
  4. Optional, if you only want that environment to receive a GI, you can set your Environment object’s layer to ” Environment ” and you also need to set the GI Light’s Culling Mask only ” Environment “.
  5. If your object are long, you can add more point lights.
  6. You should adjust the GI Light intensity and Range. Make it more realistic.

Yeah, it’s very simple right ? This is just a research, you can develop it further. And here’s my screenshot.

Unity - shh_hh.unity - NitroRacerXD - PC, Mac & Linux Standalone