{"id":1330,"date":"2012-10-25T23:54:29","date_gmt":"2012-10-25T20:54:29","guid":{"rendered":"http:\/\/unitycoder.com\/blog\/?p=1330"},"modified":"2012-10-25T23:55:10","modified_gmt":"2012-10-25T20:55:10","slug":"radar-shader","status":"publish","type":"post","link":"https:\/\/unitycoder.com\/blog\/2012\/10\/25\/radar-shader\/","title":{"rendered":"Radar Shader"},"content":{"rendered":"<p><a title=\"start webplayer demo\" href=\"http:\/\/unitycoder.com\/upload\/demos\/radar_shader_unity\/\" target=\"_blank\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1331\" data-permalink=\"https:\/\/unitycoder.com\/blog\/2012\/10\/25\/radar-shader\/radar_shader_unity3d\/\" data-orig-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/10\/radar_shader_unity3d.jpg?fit=680%2C529&amp;ssl=1\" data-orig-size=\"680,529\" 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=\"radar_shader_unity3d\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/10\/radar_shader_unity3d.jpg?fit=680%2C529&amp;ssl=1\" class=\"alignnone size-full wp-image-1331\" title=\"radar_shader_unity3d\" src=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/10\/radar_shader_unity3d.jpg?resize=680%2C529\" alt=\"\" width=\"680\" height=\"529\" srcset=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/10\/radar_shader_unity3d.jpg?w=680&amp;ssl=1 680w, https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/10\/radar_shader_unity3d.jpg?resize=300%2C233&amp;ssl=1 300w\" sizes=\"auto, (max-width: 680px) 100vw, 680px\" \/><\/a><\/p>\n<p>Converted <a title=\"http:\/\/glsl.heroku.com\/e#4190.1\" href=\"http:\/\/glsl.heroku.com\/e#4190.1\" target=\"_blank\">this shader<\/a> to Unity. (again didnt came out the same as the original..but almost)<\/p>\n<p><strong>Webplayer:<\/strong><br \/>\n<a title=\"http:\/\/unitycoder.com\/upload\/demos\/radar_shader_unity\/\" href=\"http:\/\/unitycoder.com\/upload\/demos\/radar_shader_unity\/\" target=\"_blank\">http:\/\/unitycoder.com\/upload\/demos\/radar_shader_unity\/<\/a><\/p>\n<p><strong>Shader Source:<\/strong><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n\r\n\/\/ original shader: http:\/\/glsl.heroku.com\/e#4190.1\r\n\/\/ converted to unity - mgear - http:\/\/unitycoder.com\/blog\r\nShader &quot;mShaders\/Radar1&quot;\r\n{\r\nProperties {\r\ntex (&quot;Texture (RGB)&quot;, 2D) = &quot;white&quot; {}\r\nresolution(&quot;resolution&quot;, Vector) = (1,1,0,0)\r\n\/\/mouse(&quot;mouse&quot;, Vector) = (1,1,0,0)\r\n}\r\nSubShader {\r\nTags { &quot;RenderType&quot;=&quot;Opaque&quot; }\r\nLOD 200\r\nCGPROGRAM\r\n#pragma target 3.0\r\n#pragma surface surf Lambert\r\n#define GRID_SIZE 32\r\n#define PI 3.1416\r\nuniform float2 resolution;\r\n\/\/uniform float2 mouse;\r\n\/\/uniform float time;\r\n\/\/uniform sampler2D tex;\r\nstruct Input {\r\nfloat2 uvtex;\r\n};\r\nfloat3 color(float d) {\r\nreturn d * float3(0, 1, 0);\r\n}\r\nint mod(int a, int b) {\r\nreturn a - ((a \/ b) * b);\r\n}\r\nvoid surf (Input IN, inout SurfaceOutput o)\r\n{\r\nfloat time = _Time.x*10;\r\nfloat2 p = (-1.0 + 2.0 * ((IN.uvtex.xy) \/ resolution.xy));\r\n\/\/p -= (2.0 * mouse.xy) - vec2(1.0);\r\np.x *= (resolution.x \/ resolution.y);\r\nfloat2 uv;\r\nfloat a = (atan2(p.y,p.x) + time);\r\nfloat r = sqrt(dot(p,p));\r\nuv.x = 0.1\/r;\r\nuv.y = a\/(PI);\r\nfloat len = dot(p,p);\r\nfloat3 col = color(pow(frac(uv.y \/ -2.0), 15.0));\r\nif (len &gt; 0.7) col = float3(0.8,0.8,0.8);\r\nif (len &gt; 0.73) col = float3(0,0,0);\r\n\r\nbool grid_x = mod(int(IN.uvtex.x) - int(resolution.x \/ 2.0), GRID_SIZE) == 0;\r\nbool grid_y = mod(int(IN.uvtex.y) - int(resolution.y \/ 2.0), GRID_SIZE) == 0;\r\n\r\nif (len &lt; 0.7)\r\n{\r\nif (grid_x || grid_y)\r\ncol += color(0.1);\r\n\r\nif (grid_x &amp;&amp; grid_y)\r\ncol += color(1.0);\r\n}\r\nhalf4 c = float4(col, 1.0);\r\no.Albedo = c.rgb;\r\no.Alpha = c.a;\r\n}\r\nENDCG\r\n}\r\nFallBack &quot;Diffuse&quot;\r\n}\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Converted this shader to Unity. (again didnt came out the same as the original..but almost) Webplayer: http:\/\/unitycoder.com\/upload\/demos\/radar_shader_unity\/ Shader Source: \/\/ original shader: http:\/\/glsl.heroku.com\/e#4190.1 \/\/ converted to unity &#8211; mgear &#8211; http:\/\/unitycoder.com\/blog Shader &quot;mShaders\/Radar1&quot; { Properties { tex (&quot;Texture (RGB)&quot;, 2D) = &quot;white&quot; {} resolution(&quot;resolution&quot;, Vector) [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1331,"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":[351,14],"class_list":["post-1330","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-shaders","category-unity3d","tag-radar","tag-shader"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/10\/radar_shader_unity3d.jpg?fit=680%2C529&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/p1KTaT-ls","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/1330","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=1330"}],"version-history":[{"count":2,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/1330\/revisions"}],"predecessor-version":[{"id":1333,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/1330\/revisions\/1333"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/media\/1331"}],"wp:attachment":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/media?parent=1330"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/categories?post=1330"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/tags?post=1330"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}