{"id":3613,"date":"2015-02-17T02:17:23","date_gmt":"2015-02-16T23:17:23","guid":{"rendered":"http:\/\/unitycoder.com\/blog\/?p=3613"},"modified":"2015-02-17T17:11:05","modified_gmt":"2015-02-17T14:11:05","slug":"leap-motion-passthrough-threshold-shader","status":"publish","type":"post","link":"https:\/\/unitycoder.com\/blog\/2015\/02\/17\/leap-motion-passthrough-threshold-shader\/","title":{"rendered":"Leap Motion PassThrough Threshold Shader"},"content":{"rendered":"<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"3614\" data-permalink=\"https:\/\/unitycoder.com\/blog\/2015\/02\/17\/leap-motion-passthrough-threshold-shader\/leap_motion_threshold_shader_unity\/\" data-orig-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2015\/02\/leap_motion_threshold_shader_unity.jpg?fit=680%2C463&amp;ssl=1\" data-orig-size=\"680,463\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"leap_motion_threshold_shader_unity\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2015\/02\/leap_motion_threshold_shader_unity.jpg?fit=680%2C463&amp;ssl=1\" class=\"alignnone size-full wp-image-3614\" src=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2015\/02\/leap_motion_threshold_shader_unity.jpg?resize=680%2C463\" alt=\"leap_motion_threshold_shader_unity\" width=\"680\" height=\"463\" srcset=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2015\/02\/leap_motion_threshold_shader_unity.jpg?w=680&amp;ssl=1 680w, https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2015\/02\/leap_motion_threshold_shader_unity.jpg?resize=300%2C204&amp;ssl=1 300w\" sizes=\"auto, (max-width: 680px) 100vw, 680px\" \/><\/p>\n<p>You can add adjustable threshold to Leap Motion passthrough shader, so that your hands are more visible (less transparent) in the overlay image.<\/p>\n<p><strong>TUTORIAL<\/strong><br \/>\n&#8211; Download unity examples package, <a title=\"https:\/\/developer.leapmotion.com\/downloads\/unity\" href=\"https:\/\/developer.leapmotion.com\/downloads\/unity\" target=\"_blank\">https:\/\/developer.leapmotion.com\/downloads\/unity<\/a><br \/>\n&#8211; Import package to Unity<br \/>\n&#8211; Open &#8220;PassthroughWithTracking.scene&#8221;<br \/>\n&#8211; Select &#8220;Quad&#8221; from hierarchy<br \/>\n&#8211; Enable [x] Overlay image (in LeapImageRetriever script component)<br \/>\n&#8211; Edit shader file: &#8220;LeapIRUndistorted_foreground.shader&#8221;<br \/>\nAdd these customisations to the shader:<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\n\r\n\/\/ FIND LINE\r\n_MainTex (&quot;Base (A=Opacity)&quot;, 2D) = &quot;&quot;\r\n\/\/ INSERT AFTER IT\r\n_Threshold (&quot;Threshold&quot;, Float) = 0.1\r\n\r\n\/\/ FIND LINE\r\nuniform float4 _Color;\r\n\/\/ INSERT AFTER IT\r\nuniform float _Threshold;\r\n\r\n\/\/ FIND LINE\r\ncolor.a *= a;\r\n\/\/ REPLACE WITH\r\ncolor = float4(a,a,a,step(_Threshold,a)) * _Color;\r\n\r\n<\/pre>\n<p>&#8211; Save, now test the scene and adjust threshold value from inspector if needed (try adjusting material color value also).<\/p>\n<p><strong>Notes:<\/strong><br \/>\n&#8211; LeapImageRetriever script re-assigns the shader at start, so your inspector threshold value might resets to default..?<br \/>\n&#8211; Adjust material color for skincolor in the inspector<\/p>\n<p><strong>More info:<\/strong><br \/>\n&#8211; step() : <a title=\"http:\/\/http.developer.nvidia.com\/Cg\/step.html\" href=\"http:\/\/http.developer.nvidia.com\/Cg\/step.html\" target=\"_blank\">http:\/\/http.developer.nvidia.com\/Cg\/step.html<\/a><br \/>\n&#8211; Leap+Oculus : <a title=\"https:\/\/www.leapmotion.com\/product\/vr\" href=\"https:\/\/www.leapmotion.com\/product\/vr\" target=\"_blank\">https:\/\/www.leapmotion.com\/product\/vr<\/a><br \/>\n&#8211; [x] Allow images must be enabled in Leap Control panel : <a title=\"https:\/\/developer.leapmotion.com\/gallery\/oculus-passthrough \" href=\"https:\/\/developer.leapmotion.com\/gallery\/oculus-passthrough\u00a0\" target=\"_blank\">https:\/\/developer.leapmotion.com\/gallery\/oculus-passthrough\u00a0<\/a><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>You can add adjustable threshold to Leap Motion passthrough shader, so that your hands are more visible (less transparent) in the overlay image. TUTORIAL &#8211; Download unity examples package, https:\/\/developer.leapmotion.com\/downloads\/unity &#8211; Import package to Unity &#8211; Open &#8220;PassthroughWithTracking.scene&#8221; &#8211; Select &#8220;Quad&#8221; from hierarchy &#8211; Enable [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":3614,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[420,3],"tags":[704,14,705,383],"class_list":["post-3613","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials","category-unity3d","tag-leap-motion","tag-shader","tag-threshold","tag-tutorial"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2015\/02\/leap_motion_threshold_shader_unity.jpg?fit=680%2C463&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/p1KTaT-Wh","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/3613","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/comments?post=3613"}],"version-history":[{"count":9,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/3613\/revisions"}],"predecessor-version":[{"id":3623,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/3613\/revisions\/3623"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/media\/3614"}],"wp:attachment":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/media?parent=3613"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/categories?post=3613"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/tags?post=3613"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}