{"id":677,"date":"2012-02-22T00:43:35","date_gmt":"2012-02-21T21:43:35","guid":{"rendered":"http:\/\/unitycoder.com\/blog\/?p=677"},"modified":"2020-08-16T18:49:00","modified_gmt":"2020-08-16T15:49:00","slug":"x-ray-cutout-shader-with-mouse","status":"publish","type":"post","link":"https:\/\/unitycoder.com\/blog\/2012\/02\/22\/x-ray-cutout-shader-with-mouse\/","title":{"rendered":"X-Ray \/ CutOut Shader With Mouse"},"content":{"rendered":"<p><a title=\"start webplayer demo\" href=\"http:\/\/unitycoder.com\/upload\/demos\/mXRayShaderMouse1\/\" target=\"_blank\" rel=\"noopener noreferrer\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"678\" data-permalink=\"https:\/\/unitycoder.com\/blog\/2012\/02\/22\/x-ray-cutout-shader-with-mouse\/mxrayshadermouse1\/\" data-orig-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/02\/mxrayshadermouse1.jpg?fit=680%2C454&amp;ssl=1\" data-orig-size=\"680,454\" 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;}\" data-image-title=\"x-ray shader with mouse\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/02\/mxrayshadermouse1.jpg?fit=680%2C454&amp;ssl=1\" class=\"alignnone size-full wp-image-678\" title=\"x-ray shader with mouse\" src=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/02\/mxrayshadermouse1.jpg?resize=680%2C454\" alt=\"\" width=\"680\" height=\"454\" srcset=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/02\/mxrayshadermouse1.jpg?w=680&amp;ssl=1 680w, https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/02\/mxrayshadermouse1.jpg?resize=300%2C200&amp;ssl=1 300w\" sizes=\"auto, (max-width: 680px) 100vw, 680px\" \/><\/a><\/p>\n<p>X-Ray (or kind of CutOut) Shader With Mouse (using mousecursor position inside shader, compared with worldPos distance)<\/p>\n<p>Interesting effect.. took a while to get transparency working with 2 sided surface shader,<br \/>\nalways had the problem that faces were drawn in wrong order (back side of the box was drawn before front..)<br \/>\nSolution was here: <a href=\"http:\/\/answers.unity3d.com\/questions\/209018\/cutout-diffuse-shader-visible-from-both-sides-on-a.html\" target=\"_blank\" rel=\"noopener noreferrer\">http:\/\/answers.unity3d.com\/questions\/209018\/cutout-diffuse-shader-visible-from-both-sides-on-a.html<\/a><br \/>\nbut it lost the smooth alpha transparent (xray), see *image#2<\/p>\n<p>Ideas:<br \/>\n&#8211; fake &#8220;fluid blob&#8221; (double the object, vertex displacement, color transp?)<\/p>\n<p><strong>Webplayer:<\/strong><br \/>\n<a title=\"http:\/\/unitycoder.com\/upload\/demos\/mXRayShaderMouse1\/\" href=\"http:\/\/unitycoder.com\/upload\/demos\/mXRayShaderMouse1\/\" target=\"_blank\" rel=\"noopener noreferrer\">http:\/\/unitycoder.com\/upload\/demos\/mXRayShaderMouse1\/<\/a><\/p>\n<p><strong>Download webplayer source:<\/strong><br \/>\n<a title=\"Download\" href=\"http:\/\/unitycoder.com\/download\/index2.php?link=184&amp;uid=un1t3c0d5r\" target=\"_blank\" rel=\"noopener noreferrer\">xRayWithMouse.unityPackage<\/a><\/p>\n<p>&#8212;<\/p>\n<p>With Cull Back, this smooth transparency works, but with Cull Off, transparency breaks the shader..(?)<\/p>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"687\" data-permalink=\"https:\/\/unitycoder.com\/blog\/2012\/02\/22\/x-ray-cutout-shader-with-mouse\/mxrayshadermouse1_soft_alpha\/\" data-orig-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/02\/mxrayshadermouse1_soft_alpha.jpg?fit=680%2C387&amp;ssl=1\" data-orig-size=\"680,387\" 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;}\" data-image-title=\"mxrayshadermouse1_soft_alpha\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/02\/mxrayshadermouse1_soft_alpha.jpg?fit=680%2C387&amp;ssl=1\" class=\"alignnone size-full wp-image-687\" title=\"mxrayshadermouse1_soft_alpha\" src=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/02\/mxrayshadermouse1_soft_alpha.jpg?resize=680%2C387\" alt=\"\" width=\"680\" height=\"387\" srcset=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/02\/mxrayshadermouse1_soft_alpha.jpg?w=680&amp;ssl=1 680w, https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/02\/mxrayshadermouse1_soft_alpha.jpg?resize=300%2C170&amp;ssl=1 300w\" sizes=\"auto, (max-width: 680px) 100vw, 680px\" \/><\/p>\n<p>&#8212; New Shader for Unity 2017 *Note in the comments, there is C# version of the script also by &#8220;forsini&#8221;<\/p>\n<style>.gist table { margin-bottom: 0; }<\/style>\n<div style=\"tab-size: 8\" id=\"gist82869687\" class=\"gist\">\n<div class=\"gist-file\" translate=\"no\" data-color-mode=\"light\" data-light-theme=\"light\">\n<div class=\"gist-data\">\n<div class=\"js-gist-file-update-container js-task-list-container\">\n<div id=\"file-xray2017-shader\" class=\"file my-2\">\n<div itemprop=\"text\"\n      class=\"Box-body p-0 blob-wrapper data type-shaderlab  \"\n      style=\"overflow: auto\" tabindex=\"0\" role=\"region\"\n      aria-label=\"XRay2017.shader content, created by unitycoder on 08:16AM on November 09, 2017.\"\n    ><\/p>\n<div class=\"js-check-hidden-unicode js-blob-code-container blob-code-content\">\n<p>  <template class=\"js-file-alert-template\"><\/p>\n<div data-view-component=\"true\" class=\"flash flash-warn flash-full d-flex flex-items-center\">\n  <svg aria-hidden=\"true\" data-component=\"Octicon\" height=\"16\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" data-view-component=\"true\" class=\"octicon octicon-alert\">\n    <path d=\"M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z\"><\/path>\n<\/svg><br \/>\n    <span><br \/>\n      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.<br \/>\n      <a class=\"Link--inTextBlock\" href=\"https:\/\/github.co\/hiddenchars\" target=\"_blank\">Learn more about bidirectional Unicode characters<\/a><br \/>\n    <\/span><\/p>\n<div data-view-component=\"true\" class=\"flash-action\">        <a href=\"{{ revealButtonHref }}\" data-view-component=\"true\" class=\"btn-sm btn\">    Show hidden characters<br \/>\n<\/a>\n<\/div>\n<\/div>\n<p><\/template><br \/>\n<template class=\"js-line-alert-template\"><br \/>\n  <span aria-label=\"This line has hidden Unicode characters\" data-view-component=\"true\" class=\"line-alert tooltipped tooltipped-e\"><br \/>\n    <svg aria-hidden=\"true\" data-component=\"Octicon\" height=\"16\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" data-view-component=\"true\" class=\"octicon octicon-alert\">\n    <path d=\"M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z\"><\/path>\n<\/svg><br \/>\n<\/span><\/template><\/p>\n<table data-hpc class=\"highlight tab-size js-file-line-container\" data-tab-size=\"4\" data-paste-markdown-skip data-tagsearch-path=\"XRay2017.shader\">\n<tr>\n<td id=\"file-xray2017-shader-L1\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"1\"><\/td>\n<td id=\"file-xray2017-shader-LC1\" class=\"blob-code blob-code-inner js-file-line\">\/\/ xray mouse pos shader test v2.0 &#8211; mgear &#8211; http:\/\/unitycoder.com\/blog<\/td>\n<\/tr>\n<tr>\n<td id=\"file-xray2017-shader-L2\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"2\"><\/td>\n<td id=\"file-xray2017-shader-LC2\" class=\"blob-code blob-code-inner js-file-line\">\n<\/td>\n<\/tr>\n<tr>\n<td id=\"file-xray2017-shader-L3\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"3\"><\/td>\n<td id=\"file-xray2017-shader-LC3\" class=\"blob-code blob-code-inner js-file-line\">Shader &quot;UnityLibrary\/Effects\/XRay2017&quot;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-xray2017-shader-L4\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"4\"><\/td>\n<td id=\"file-xray2017-shader-LC4\" class=\"blob-code blob-code-inner js-file-line\">{<\/td>\n<\/tr>\n<tr>\n<td id=\"file-xray2017-shader-L5\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"5\"><\/td>\n<td id=\"file-xray2017-shader-LC5\" class=\"blob-code blob-code-inner js-file-line\">\tProperties <\/td>\n<\/tr>\n<tr>\n<td id=\"file-xray2017-shader-L6\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"6\"><\/td>\n<td id=\"file-xray2017-shader-LC6\" class=\"blob-code blob-code-inner js-file-line\">\t{<\/td>\n<\/tr>\n<tr>\n<td id=\"file-xray2017-shader-L7\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"7\"><\/td>\n<td id=\"file-xray2017-shader-LC7\" class=\"blob-code blob-code-inner js-file-line\">\t\t_MainTex (&quot;Base (RGB)&quot;, 2D) = &quot;white&quot; {}<\/td>\n<\/tr>\n<tr>\n<td id=\"file-xray2017-shader-L8\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"8\"><\/td>\n<td id=\"file-xray2017-shader-LC8\" class=\"blob-code blob-code-inner js-file-line\">\t\t_ObjPos (&quot;ObjPos&quot;, Vector) = (1,1,1,1)<\/td>\n<\/tr>\n<tr>\n<td id=\"file-xray2017-shader-L9\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"9\"><\/td>\n<td id=\"file-xray2017-shader-LC9\" class=\"blob-code blob-code-inner js-file-line\">\t\t_Cutoff (&quot;Alpha cutoff&quot;, Range(0,1)) = 0.5<\/td>\n<\/tr>\n<tr>\n<td id=\"file-xray2017-shader-L10\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"10\"><\/td>\n<td id=\"file-xray2017-shader-LC10\" class=\"blob-code blob-code-inner js-file-line\">\t\t_Radius (&quot;HoleRadius&quot;, Range(0.1,5)) = 2<\/td>\n<\/tr>\n<tr>\n<td id=\"file-xray2017-shader-L11\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"11\"><\/td>\n<td id=\"file-xray2017-shader-LC11\" class=\"blob-code blob-code-inner js-file-line\">\t}<\/td>\n<\/tr>\n<tr>\n<td id=\"file-xray2017-shader-L12\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"12\"><\/td>\n<td id=\"file-xray2017-shader-LC12\" class=\"blob-code blob-code-inner js-file-line\">\tSubShader <\/td>\n<\/tr>\n<tr>\n<td id=\"file-xray2017-shader-L13\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"13\"><\/td>\n<td id=\"file-xray2017-shader-LC13\" class=\"blob-code blob-code-inner js-file-line\">\t{<\/td>\n<\/tr>\n<tr>\n<td id=\"file-xray2017-shader-L14\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"14\"><\/td>\n<td id=\"file-xray2017-shader-LC14\" class=\"blob-code blob-code-inner js-file-line\">\t\tTags {&quot;Queue&quot;=&quot;AlphaTest&quot; &quot;IgnoreProjector&quot;=&quot;True&quot; &quot;RenderType&quot;=&quot;TransparentCutout&quot;}<\/td>\n<\/tr>\n<tr>\n<td id=\"file-xray2017-shader-L15\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"15\"><\/td>\n<td id=\"file-xray2017-shader-LC15\" class=\"blob-code blob-code-inner js-file-line\">\t\tLOD 100<\/td>\n<\/tr>\n<tr>\n<td id=\"file-xray2017-shader-L16\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"16\"><\/td>\n<td id=\"file-xray2017-shader-LC16\" class=\"blob-code blob-code-inner js-file-line\">\n<\/td>\n<\/tr>\n<tr>\n<td id=\"file-xray2017-shader-L17\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"17\"><\/td>\n<td id=\"file-xray2017-shader-LC17\" class=\"blob-code blob-code-inner js-file-line\">\t\tCull Off \/\/ draw backfaces also, comment this line if no need for backfaces<\/td>\n<\/tr>\n<tr>\n<td id=\"file-xray2017-shader-L18\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"18\"><\/td>\n<td id=\"file-xray2017-shader-LC18\" class=\"blob-code blob-code-inner js-file-line\">\t\t<\/td>\n<\/tr>\n<tr>\n<td id=\"file-xray2017-shader-L19\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"19\"><\/td>\n<td id=\"file-xray2017-shader-LC19\" class=\"blob-code blob-code-inner js-file-line\">\t\tCGPROGRAM<\/td>\n<\/tr>\n<tr>\n<td id=\"file-xray2017-shader-L20\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"20\"><\/td>\n<td id=\"file-xray2017-shader-LC20\" class=\"blob-code blob-code-inner js-file-line\">\t\t#pragma surface surf Lambert alphatest:_Cutoff<\/td>\n<\/tr>\n<tr>\n<td id=\"file-xray2017-shader-L21\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"21\"><\/td>\n<td id=\"file-xray2017-shader-LC21\" class=\"blob-code blob-code-inner js-file-line\">\n<\/td>\n<\/tr>\n<tr>\n<td id=\"file-xray2017-shader-L22\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"22\"><\/td>\n<td id=\"file-xray2017-shader-LC22\" class=\"blob-code blob-code-inner js-file-line\">\t\tstruct Input <\/td>\n<\/tr>\n<tr>\n<td id=\"file-xray2017-shader-L23\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"23\"><\/td>\n<td id=\"file-xray2017-shader-LC23\" class=\"blob-code blob-code-inner js-file-line\">\t\t{<\/td>\n<\/tr>\n<tr>\n<td id=\"file-xray2017-shader-L24\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"24\"><\/td>\n<td id=\"file-xray2017-shader-LC24\" class=\"blob-code blob-code-inner js-file-line\">\t\t\tfloat2 uv_MainTex;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-xray2017-shader-L25\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"25\"><\/td>\n<td id=\"file-xray2017-shader-LC25\" class=\"blob-code blob-code-inner js-file-line\">\t\t\tfloat3 worldPos;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-xray2017-shader-L26\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"26\"><\/td>\n<td id=\"file-xray2017-shader-LC26\" class=\"blob-code blob-code-inner js-file-line\">\t\t};<\/td>\n<\/tr>\n<tr>\n<td id=\"file-xray2017-shader-L27\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"27\"><\/td>\n<td id=\"file-xray2017-shader-LC27\" class=\"blob-code blob-code-inner js-file-line\">\t\t<\/td>\n<\/tr>\n<tr>\n<td id=\"file-xray2017-shader-L28\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"28\"><\/td>\n<td id=\"file-xray2017-shader-LC28\" class=\"blob-code blob-code-inner js-file-line\">\t\tsampler2D _MainTex;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-xray2017-shader-L29\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"29\"><\/td>\n<td id=\"file-xray2017-shader-LC29\" class=\"blob-code blob-code-inner js-file-line\">\t\tuniform float4 _ObjPos;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-xray2017-shader-L30\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"30\"><\/td>\n<td id=\"file-xray2017-shader-LC30\" class=\"blob-code blob-code-inner js-file-line\">\t\tuniform float _Radius;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-xray2017-shader-L31\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"31\"><\/td>\n<td id=\"file-xray2017-shader-LC31\" class=\"blob-code blob-code-inner js-file-line\">\n<\/td>\n<\/tr>\n<tr>\n<td id=\"file-xray2017-shader-L32\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"32\"><\/td>\n<td id=\"file-xray2017-shader-LC32\" class=\"blob-code blob-code-inner js-file-line\">\t\tvoid surf (Input IN, inout SurfaceOutput o) <\/td>\n<\/tr>\n<tr>\n<td id=\"file-xray2017-shader-L33\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"33\"><\/td>\n<td id=\"file-xray2017-shader-LC33\" class=\"blob-code blob-code-inner js-file-line\">\t\t{<\/td>\n<\/tr>\n<tr>\n<td id=\"file-xray2017-shader-L34\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"34\"><\/td>\n<td id=\"file-xray2017-shader-LC34\" class=\"blob-code blob-code-inner js-file-line\">\t\t\thalf3 col = tex2D (_MainTex, IN.uv_MainTex).rgb;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-xray2017-shader-L35\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"35\"><\/td>\n<td id=\"file-xray2017-shader-LC35\" class=\"blob-code blob-code-inner js-file-line\">\t\t\tfloat dx = length(_ObjPos.x-IN.worldPos.x);<\/td>\n<\/tr>\n<tr>\n<td id=\"file-xray2017-shader-L36\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"36\"><\/td>\n<td id=\"file-xray2017-shader-LC36\" class=\"blob-code blob-code-inner js-file-line\">\t\t\tfloat dy = length(_ObjPos.y-IN.worldPos.y);<\/td>\n<\/tr>\n<tr>\n<td id=\"file-xray2017-shader-L37\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"37\"><\/td>\n<td id=\"file-xray2017-shader-LC37\" class=\"blob-code blob-code-inner js-file-line\">\t\t\tfloat dz = length(_ObjPos.z-IN.worldPos.z);<\/td>\n<\/tr>\n<tr>\n<td id=\"file-xray2017-shader-L38\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"38\"><\/td>\n<td id=\"file-xray2017-shader-LC38\" class=\"blob-code blob-code-inner js-file-line\">\t\t\tfloat dist = (dx*dx+dy*dy+dz*dz)*_Radius;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-xray2017-shader-L39\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"39\"><\/td>\n<td id=\"file-xray2017-shader-LC39\" class=\"blob-code blob-code-inner js-file-line\">\t\t\tdist = clamp(dist,0,1);<\/td>\n<\/tr>\n<tr>\n<td id=\"file-xray2017-shader-L40\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"40\"><\/td>\n<td id=\"file-xray2017-shader-LC40\" class=\"blob-code blob-code-inner js-file-line\">\t\t\to.Albedo = col; \/\/ color is from texture<\/td>\n<\/tr>\n<tr>\n<td id=\"file-xray2017-shader-L41\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"41\"><\/td>\n<td id=\"file-xray2017-shader-LC41\" class=\"blob-code blob-code-inner js-file-line\">\t\t\to.Alpha = dist;  \/\/ alpha is from distance to the mouse<\/td>\n<\/tr>\n<tr>\n<td id=\"file-xray2017-shader-L42\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"42\"><\/td>\n<td id=\"file-xray2017-shader-LC42\" class=\"blob-code blob-code-inner js-file-line\">\t\t}<\/td>\n<\/tr>\n<tr>\n<td id=\"file-xray2017-shader-L43\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"43\"><\/td>\n<td id=\"file-xray2017-shader-LC43\" class=\"blob-code blob-code-inner js-file-line\">\t\tENDCG<\/td>\n<\/tr>\n<tr>\n<td id=\"file-xray2017-shader-L44\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"44\"><\/td>\n<td id=\"file-xray2017-shader-LC44\" class=\"blob-code blob-code-inner js-file-line\">\t} <\/td>\n<\/tr>\n<tr>\n<td id=\"file-xray2017-shader-L45\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"45\"><\/td>\n<td id=\"file-xray2017-shader-LC45\" class=\"blob-code blob-code-inner js-file-line\">\tFallBack &quot;Diffuse&quot;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-xray2017-shader-L46\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"46\"><\/td>\n<td id=\"file-xray2017-shader-LC46\" class=\"blob-code blob-code-inner js-file-line\">}<\/td>\n<\/tr>\n<\/table>\n<\/div><\/div>\n<\/p><\/div>\n<\/div><\/div>\n<div class=\"gist-meta\">\n        <a href=\"https:\/\/gist.github.com\/unitycoder\/e64363b9b08285535f22a17680633424\/raw\/c0578aac0c60590fd83248243d6ca250fd390280\/XRay2017.shader\" style=\"float:right\" class=\"Link--inTextBlock\">view raw<\/a><br \/>\n        <a href=\"https:\/\/gist.github.com\/unitycoder\/e64363b9b08285535f22a17680633424#file-xray2017-shader\" class=\"Link--inTextBlock\"><br \/>\n          XRay2017.shader<br \/>\n        <\/a><br \/>\n        hosted with &#10084; by <a class=\"Link--inTextBlock\" href=\"https:\/\/github.com\">GitHub<\/a>\n      <\/div>\n<\/p><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>X-Ray (or kind of CutOut) Shader With Mouse (using mousecursor position inside shader, compared with worldPos distance) Interesting effect.. took a while to get transparency working with 2 sided surface shader, always had the problem that faces were drawn in wrong order (back side of [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":678,"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":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[13,3],"tags":[181,50,87,14,814,180,179],"class_list":["post-677","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-shaders","category-unity3d","tag-2-sided","tag-effect","tag-mouse","tag-shader","tag-transparent","tag-x-ray","tag-xray"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/02\/mxrayshadermouse1.jpg?fit=680%2C454&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/p1KTaT-aV","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/677","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=677"}],"version-history":[{"count":14,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/677\/revisions"}],"predecessor-version":[{"id":5277,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/677\/revisions\/5277"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/media\/678"}],"wp:attachment":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/media?parent=677"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/categories?post=677"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/tags?post=677"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}