 	uniform float     _MaxThreshold;
 	uniform float     _GlowThreshold;
 	uniform float     _GlowPower;
+  uniform float     _ColorSpaceGamma;
 
 	struct appdata {
 		float4 vertex : POSITION;
 		float3 normal : NORMAL;
 	};
 
-	struct frag_in{
+	struct frag_in {
 		float4 vertex : POSITION;
 		float4 screenPos  : TEXCOORD0;
 		float4 projPos  : TEXCOORD1;

		return o;
	}

	float4 getHandColor(float4 screenPos){
		float4 rawColor = LeapRawColorBrightness(screenPos);
		float3 color = pow(rawColor.rgb, _LeapGammaCorrectionExponent);
		float brightness = smoothstep(_MinThreshold, _MaxThreshold, rawColor.a);
		float glow = smoothstep(_GlowThreshold, _MinThreshold, rawColor.a) * brightness;
		return float4(color + _Color * glow * _GlowPower, brightness);
	}

	float4 frag(frag_in i) : COLOR{
		float4 handColor = getHandColor(i.screenPos);
		float sceneZ = LinearEyeDepth (SAMPLE_DEPTH_TEXTURE_PROJ(_CameraDepthTexture, UNITY_PROJ_COORD(i.projPos)));
		float partZ = i.projPos.z;
		float diff = smoothstep(_Intersection, 0, sceneZ - partZ);
		return float4(lerp(handColor.rgb, _Color.rgb * 20, diff), _Fade * handColor.a * (1 - diff));
	}

	float4 alphaFrag(frag_in i) : COLOR {

﻿Shader "LeapMotion/Passthrough/HandHighlight" {
	Properties {
		_Color           ("Color", Color)                  = (0.165,0.337,0.578,1.0)
		_Fade            ("Fade", Range(0, 1))             = 0.0
		_Extrude         ("Extrude", Float)                = 0.008
		_Intersection    ("Intersection Threshold", Float) = 0.035

		_MinThreshold    ("Min Threshold", Float)     = 0.1
		_MaxThreshold    ("Max Threshold", Float)     = 0.2
		_GlowThreshold   ("Glow Threshold", Float)    = 0.5
		_GlowPower       ("Glow Power", Float)        = 10.0
    
    _ColorSpaceGamma ("Color Space Gamma", Float) = 1.0
	}


