Mercurial > hg > Game > Games
diff Orchestland/Assets/LeapMotion/Scripts/LeapImageBasedMaterial.cs @ 3:0030a1b971fb default tip
merge
author | Yuta ANSE <e135745@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 17 Jul 2015 23:23:43 +0900 |
parents | f7675884f2a1 |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Orchestland/Assets/LeapMotion/Scripts/LeapImageBasedMaterial.cs Fri Jul 17 23:23:43 2015 +0900 @@ -0,0 +1,37 @@ +using UnityEngine; +using System.Collections; +using System.Collections.Generic; + +public class LeapImageBasedMaterial : MonoBehaviour { + public ImageMode imageMode = ImageMode.STEREO; + + public enum ImageMode { + STEREO, + LEFT_ONLY, + RIGHT_ONLY + } + + void Awake() { + if (FindObjectOfType<LeapImageRetriever>() == null) { + Debug.LogWarning("Place a LeapImageRetriever script on a camera to enable Leap image-based materials"); + enabled = false; + } + } + + void OnEnable() { + LeapImageRetriever.registerImageBasedMaterial(this); + // Make shader consistent with settings + + if (QualitySettings.activeColorSpace == ColorSpace.Linear) { + GetComponent<Renderer> ().material.SetFloat ("_ColorSpaceGamma", 1.0f); + } else { + float gamma = -Mathf.Log10(Mathf.GammaToLinearSpace(0.1f)); + GetComponent<Renderer> ().material.SetFloat ("_ColorSpaceGamma", gamma); + //Debug.Log ("Derived gamma = " + gamma); + } + } + + void OnDisable() { + LeapImageRetriever.unregisterImageBasedMaterial(this); + } +}