imagination XD

realizing dream


3 Comments

Take 360 Photo and Upload to Facebook with Unity

It’s actually not new thing, but since many people ask me how to do it, then yeah I decided to make some writing about this.

1-nakane-eri-almost-done-for-the-environment-finally-can-get-back-google-chrome_2016-11-03_01-02-22-336-png-picasa-photo-viewer

What you need :

So here’s how you do it

  1. Download the 360 Panorama Capture asset and import it to Unity
  2. vrunity_1
  3. Select your main camera or camera to be rendered, and put Capture Panorama. Leave the settings default.
  4. REMEMBER to set the IMAGE FORMAT to JPEG. If you use PNG, you’ll have to convert that again to JPG.
  5. Press play if you see it’s good enough.
  6. In play mode, press [P] to capture the panorama, the screen would fade to black, don’t do anything while screen is black.
  7. Then you’d hear a sound effect and screen fade off. That’s mean the rendering is done.
  8. vrunity_2
  9. Now go to your root folder, folder where Unity put stuff like Assets, Library and stuff.
  10. Now bring those file to where you put the exiftool.exe
  11. vrunity_3
  12. You might need to rename your exiftool to just exiftool.exe
  13. Then press Shift + Right Click on the explorer and choose Open command window here.
  14. vrunity_4
  15. Copy this code to command window
  16. exiftool -ProjectionType=”equirectangular” photo.jpg
  17. That photo.jpg is your 360 photo file name.
  18. Then press [Enter]
  19. And yeah ! You will get the JPG once it done, now it’s ready to upload to Facebook as 360 photo !

Also, I have uploaded few assets on my Asset Store, be sure to check it out.

imgvertex-asset-store-google-chrome

Advertisements


1 Comment

[Unity] Realtime Lipsync


Back on my manual lipsync using Tagarela. This one is faster to do and also easier, but of course, you’ll get only Anime lipsync (Anime lipsync only have 1 open mouth, there’s no O, U, I or any other mouth shape than A).

The method I’m using is just get Audio Source frequency. So basically it’s like music visualisation but for mouth.

What you need

  • Head mesh with 1 mouth blendshape
  • Voice
  • Audio Source

Here’s the script you should attach to head mesh.

using UnityEngine;
using System.Collections;

public class RealtimeLipsync : MonoBehaviour {

//LIPSYNC CORE
 [Header("Lipsync")]
 public AudioSource audioSource;
 public int mouthBlendShape;
 private float[] _samples = new float[64];
 private float clampedLipsync = 0f;

//PRIVATES
 private SkinnedMeshRenderer blendMesh;

void Awake(){
 blendMesh = GetComponent<SkinnedMeshRenderer>();
 }

void LateUpdate(){
 if(audioSource) DoLipsync();
 }

void DoLipsync(){
 if(audioSource.isPlaying){
 audioSource.GetSpectrumData(_samples,0,FFTWindow.BlackmanHarris);

clampedLipsync = Mathf.Clamp(_samples[2]*3000,0,100);

blendMesh.SetBlendShapeWeight(mouthBlendShape,clampedLipsync);
 }
 }
}

And here’s how to do it

  1. Attach this script to your head mesh.
  2. Also don’t forget to add audio source and assign audio source in this script. You can put Audio Source in whereever you want, but remember to assign audio source variable on this script.
  3. To play sound, use like audioSource.clip = <your clip name>; then audioSource.Play();
  4. Assembly-CSharp - VertexScriptCOREPlayerCORE.cs - MonoDevelop-Unity
  5. Here’s my example to use this. I put it on my player script. It’ll automatically works whenever you have audioSrc.clip = clipName; audioSrc.Play();
  6. That’s it, your mouth will move whenever the audio src playing sounds.

 


2 Comments

[Unity UI 4.6] Parallax style menu

So yesterday I was trying to make parallax styled menu with Unity 4.6 UI, although it’s very simple to do.

  1. UnityUIPar (1)
  2. Check your canvas setting, the render mode should be Screen Space Camera.
  3.  UnityUIPar (3)
  4. After that, add empty game object like Content. Content is like a group of everything that will be moved by script
  5. UnityUIPar (2)
  6. Add this script on Canvas and set Canvas variable as your Content Rect transform.
  7. also you need to adjust minMaxAxis, it’s an array, 0 usually -15, and 1 usually 15

Here’s the script (C#)

using UnityEngine;
using UnityEngine.UI;
using System.Collections;

public class ParallaxMenu : MonoBehaviour {

 public RectTransform canvas;
 public float smoothTime = 0.3f;
 public float minMaxXAxis = new float[2]; //0 min, 1 max
 public float minMaxYAxis = new float[2]; //0 min, 1 max
 public float mouseSensitivity = 50.0f;
 private float xVelocity = 0.0f;
 private float yVelocity = 0.0f;
 private float x;
 private float y;
 private float xSmooth;
 private float ySmooth;

 void Awake(){
 Cursor.lockState = CursorLockMode.None;
 Cursor.visible = true;
 }

 void Update(){
 x -= Input.GetAxis("Mouse X") * mouseSensitivity * 0.02f;
 y -= Input.GetAxis("Mouse Y") * mouseSensitivity * .02f;

 if(y > minMaxYAxis[1]) y = minMaxYAxis[1];
 if(y < minMaxYAxis[0]) y = minMaxYAxis[0];
 if(x > minMaxXAxis[1]) x = minMaxXAxis[1];
 if(x < minMaxXAxis[0]) x = minMaxXAxis[0];

 xSmooth = Mathf.SmoothDamp(xSmooth, x, ref xVelocity, smoothTime);
 ySmooth = Mathf.SmoothDamp(ySmooth,y, ref yVelocity, smoothTime);

 Quaternion parallax = new Quaternion();
 parallax = Quaternion.Euler(ySmooth / 7,xSmooth/7,0);

 canvas.transform.localPosition = new Vector3(xSmooth, ySmooth, 0f);
 canvas.transform.localRotation = parallax;
 }
}


21 Comments

[C4D, Maya, Blender] Convert FBX to MMD

This is not game dev related, but you can also import your MMD’ed FBX model to Unity, and it gives you better physics simulation using stereoarts’ MMD4Mecanim, read tutorial here.

Anyway, I maybe will stop posting about tutorial, cause I think I post too much that my blog almost become educational site. Beside, I think there’s enough tutorial on Unity. I’ll maybe post a research about porting 2D traditional anime to Unity 3D Cel shaded Anime or Unity tips, not tutorial anymore.

On my previous post about MMD, I only tell you how to import PMD or PMX to Unity, but now, I’ll tell about how to make your own MMD model using Maya, Blender, or Cinema4D. You can also import PMD model to Cinema 4D by using MMDTools.

If you already made model with Blender, you could simply jump to step 3, and export it as PMX by using Blender2Pmx.

In this post, I’ll use Cinema 4D.

What you need is

  1. c4dmmd0Prepare your 3D character and get it MMD compatible. Everything must have skin, don’t attach head mesh to head joint. Blendshape is supported on latest version of FBX (2014 or 2015).
  2. c4dmmd1Export to FBX
  3. c4dmmd2Now, open your blender. I use blender 2.76, yep it’s totally fine just use 2.72
  4. c4dmmd3If you had problem with built-in FBX importer, try use Experimental FBX as in 2.72, else, you have to copy experimental FBX from 2.72 to your blender addon folder, along with blender2pmx
  5. c4dmmd4from blender 2.72 folder, copy io_scene_fbx_experimental to your blender addon folder. Do the same with your blender2pmx.
  6. c4dmmd5After you installed both PMX and FBX plugin and turned it on, import your FBX by using Experimental FBX import. Also check automatic bone and manual orientation if you had problem with your model.
  7. c4dmmd6Select all by pressing CTRL + A and export to PMX
  8. c4dmmd7open your PMX Editor and open your PMX file
  9. c4dmmd8Well, now you got your own 3D Model on MMD. I don’t really know how to set up physics on PMX.


2 Comments

[Tutorial] HDRI as Unity Skybox

56I actually been used HDRI as skybox back then, but it wasn’t really good cause older Unity doesn’t has GI. Now Unity 5 has GI, so HDRI is good too for Unity.

You’ll need HDRI Image (JPG, if it’s hdr or exr, you have to convert it first), and Unity 5.

  1. 0First, if your HDRI is not JPG yet, then convert it to JPG by set the channel to 8bit.
  2. 1
  3. Import your JPG HDRI to Unity. Remember, 4000px is enough, cause you’ll get 2048px in Unity. Set your HDRI to Cubemap and Cubemap type to cylindrical or latitude bla bla bla…
  4. 2Now create a material. Click Assets > Create > Material
  5. 3 Set your material shader to Skybox > Cubemap
  6. 4Now drag your HDRI Cubemap to skybox cubemap.
  7. 5Now open Lighting tab, and drag your HDRI Material to skybox. Sometimes it might happens like this, but to fix it just change the cubemap type to Cylindrical (in this screenshot, I set it to Spherical).

Yep, it’s really simple. Simple as any other 3D programs.


3 Comments

[Tutorial] IES Light on Unity

Without IES Light

Without IES Light

IES Light on Unity

IES Light on Unity

Back then, I thought IES light was useless, but when I’m making an interior scene for my Animation I notice a weirdness on ceiling lights. It was circle!!! There’s no circle shaped ceiling lights (except lightbulb)!

You’ll gonna need

    • IESviewer 2.9
    • Prtscr (Optional, if you don’t want to use MSPaint)
    • And IES / LDT light of course!

And this is how

  1. iesUnity2
  2. Go to IES Viewer and right click on your IES or LDR light and then click Render, or simply just press CTRL+R. Sometimes, the Render window just wont show, just delete .ini file and reopen IESViewer.
  3. iesUnity3
  4. Adjust brightness, Zoom, and Distance until you pleased with the result then press Prt Scn / Print Screen on your keyboard. If you don’t have PrtScr, then you’ll need to open MSPaint (Press Winkey + R and type MSPaint). If you have PrtScr, hold CTRL and left click the render window and it’ll automatically crop it.
  5. iesUnity4
  6. Paste (CTRL+V) on MSPaint and then crop the pasted clipboard like this. Save it as JPG or PNG.
  7. IESsssThis is my IES Light
  8. IESUnity5Now go to Unity and import your IES light. Set texture type as Cookie, Light type as Point, Mapping : Mirrored Ball, Glossy Reflection, Fixup Edge Seams, Alpha from Grayscale (IMPORTANT!), and filter mode to Trilinear.
  9. IESUnity6Go to Game Object > Light > Point Light, and assign your IES file to Cookie texture.
  10. IESUnity7
  11. Now look! IES Light on Unity! Although it’s not important, but it’ll make scene looks more realistic than a nonsense circle light.


5 Comments

[Unity] Blendshape Eye Controller (Look At, Random Eyes, and Random Blink)

Controlling eyes with Unity’s blendshape controller is difficult especially Unity likes to make a blendshape is a float value which harder to control and you can’t even control any movement like down or left. The picture above represents the movement of their eyes. See closely with that cyclops, her eyes were move following that ball, meanwhile the penguin just stuttered with the eye (Random Eye and blink).

You’re gonna need 4 / 5 basic eye blendshapes like Up eye, Right eye, Down eye, Left eye, and blink (optional).

pxeyes nyeyes pyeyes nxeyes

This is very useful tool especially for wannabe animator like me.

Download the script here,

Tutorial

  1. blendeye2
  2. Add this script on the root of your character.
  3. blendeye3
  4. blendeye2aAssign the number / ID of your Blendshape as in your blendshape mesh. I added isDebugging mode, that’ll ease you out finding the number of the blendshape.

  5. blendeye4
  6. After found the right ID, now you’re done! You can control eye movement via 2D Target now. But is that enough ? LOL NOPE!
    blendeye5
  7. To make it focus in 3D Way, create an empty game object and set it as target.
  8. blendeye6
  9. Sometimes this might happens (A certain eye moves in reverse way), to fix it, just invert the blendshape ID like Positive X Axis was 0 and set it to 1 and Negative X Axis was 1 and set it to 0.
    blendeye7
  10. Now look! Your character will focus on that object forever! But if that’s not please you enough, you can use Random Eyes mover (I forgot to make it move along with your target, so it’ll move along with the center of your head). But if you really do want random movement along your target, then just remove “target” line below randomizer target transform.
  11. if(!randomizerTarget){
     randomizerTarget = new GameObject("RNDTRG");
     randomizerTarget.transform.position = blendshapeEyeMesh.transform.position;
     target = randomizerTarget.transform; // remove this
     }else{
     target.position += Random.onUnitSphere * Time.fixedDeltaTime/randomCompressor;
     }
  12. And so do you want them blink ? just turn on Blinkable and your character will be blinkable. The higher value of blink speed the faster it’ll be. And what is Target Multiplier ? That’s just speed multiplier of your 3D target, how fast / sensitive their eye will follow your 3D target.