{"id":1897,"date":"2017-07-26T18:53:53","date_gmt":"2017-07-26T10:53:53","guid":{"rendered":"http:\/\/1vr.cn\/?p=1897"},"modified":"2017-07-26T18:53:53","modified_gmt":"2017-07-26T10:53:53","slug":"ar%e4%b8%ad%e7%9a%84%e9%98%b4%e5%bd%b1%e9%95%82%e7%a9%ba%e8%92%99%e6%9d%bf%e5%a4%84%e7%89%a9%e4%bd%93%e9%81%ae%e6%8e%a9%e8%92%99%e6%9d%bf%e5%a4%84%e7%89%a9%e4%bd%93%e6%98%be%e7%a4%ba%e7%ad%89","status":"publish","type":"post","link":"https:\/\/1vr.cn\/?p=1897","title":{"rendered":"AR\u4e2d\u7684\u9634\u5f71\u9542\u7a7a,\u8499\u677f\u5904\u7269\u4f53\u906e\u63a9,\u8499\u677f\u5904\u7269\u4f53\u663e\u793a\u7b49"},"content":{"rendered":"<p>\u6211\u4eec\u5728\u505aAR(\u589e\u5f3a\u73b0\u5b9e)\u7684\u65f6\u5019,\u6709\u51e0\u79cd\u6548\u679c\u9700\u6c42\u4f1a\u9047\u5230.<\/p>\n<p><strong>1:\u9634\u5f71\u9542\u7a7a<\/strong><br \/>\n\u901a\u8fc7\u6210\u529f\u8bc6\u522bMarker(\u82b1\u6735\u80cc\u666f),\u5728Marker\u4f4d\u7f6e\u751f\u6210\u7acb\u65b9\u4f53\u6a21\u578b,\u4e3a\u4e86\u6548\u679c\u903c\u771f,\u6211\u4eec\u9700\u8981\u7acb\u65b9\u4f53\u6a21\u578b\u4ea7\u751f\u4e2a\u9634\u5f71\u6295\u5f71,\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u6211\u4eec\u53ea\u80fd\u7528\u5176\u5b83\u6a21\u578b\u6765\u63a5\u53d7\u7acb\u65b9\u4f53\u7684\u9634\u5f71\u6295\u5c04,Marker\u6a21\u578b\u5728Play\u65f6\u662f\u4e0d\u80fd\u7528\u4e8e\u63a5\u53d7\u7acb\u65b9\u4f53\u9634\u5f71\u7684,\u6211\u4eec\u628a\u63a5\u53d7\u9634\u5f71\u7684Plane\u6a21\u578b\u8fdb\u884c\u5904\u7406,\u8ba9\u5b83\u4ec5\u4fdd\u7559\u6295\u5c04\u7684\u9634\u5f71\u90e8\u5206,\u5176\u4f59\u90e8\u5206\u9542\u7a7a,\u8fd9\u6837\u518d\u4e0e\u76f8\u673a\u753b\u9762\u53e0\u52a0\u5c31\u4f1a\u4ea7\u751f\u4e00\u4e2a\u8f83\u903c\u771f\u7684\u9634\u5f71\u6548\u679c\u4e86.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/1vr.cn\/wp-content\/uploads\/2017\/07\/1.jpg\" alt=\"\" width=\"800\" height=\"708\" class=\"aligncenter size-full wp-image-1902\" srcset=\"\/wp-content\/uploads\/2017\/07\/1.jpg 800w, \/wp-content\/uploads\/2017\/07\/1-300x266.jpg 300w, \/wp-content\/uploads\/2017\/07\/1-768x680.jpg 768w, \/wp-content\/uploads\/2017\/07\/1-210x186.jpg 210w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/p>\n<p>\u628a\u4e0b\u9762\u7684shader\u8d4b\u4e88\u7ed9\u63a5\u53d7\u9634\u5f71\u7684\u6a21\u578b\u5373\u53ef\u5b8c\u6210\u9634\u5f71\u900f\u660e\u9542\u7a7a\u6548\u679c,\u56fe\u4e2d\u9ed1\u8272\u9634\u5f71\u5176\u5b9e\u662f\u539f\u672c\u7684Plane,\u4e0eMaker\u65e0\u5173.<\/p>\n<pre>\r\nShader \"FX\/Matte Shadow\" {\r\n \r\nProperties {\r\n    _Color (\"Main Color\", Color) = (1,1,1,1)\r\n    _MainTex (\"Base (RGB) Trans (A)\", 2D) = \"white\" {}\r\n    _Cutoff (\"Alpha cutoff\", Range(0,1)) = 0.5\r\n}\r\n \r\nSubShader {\r\n \r\n    Tags {\"Queue\"=\"AlphaTest\" \"IgnoreProjector\"=\"True\" \"RenderType\"=\"TransparentCutout\"}\r\n    LOD 200\r\n    Blend Zero SrcColor\r\n \r\nCGPROGRAM\r\n \r\n#pragma surface surf ShadowOnly alphatest:_Cutoff\r\nfixed4 _Color;\r\nstruct Input {\r\n    float2 uv_MainTex;\r\n};\r\ninline fixed4 LightingShadowOnly (SurfaceOutput s, fixed3 lightDir, fixed atten)\r\n{\r\n    fixed4 c;\r\n    c.rgb = s.Albedo*atten;\r\n    c.a = s.Alpha;\r\n    return c;\r\n}\r\n \r\nvoid surf (Input IN, inout SurfaceOutput o) \r\n{\r\n    fixed4 c = _Color; \r\n    o.Albedo = c.rgb;\r\n    o.Alpha = 1;\r\n}\r\n \r\nENDCG\r\n}\r\n \r\nFallback \"Transparent\/Cutout\/VertexLit\"\r\n \r\n}\r\n<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/1vr.cn\/wp-content\/uploads\/2017\/07\/2.jpg\" alt=\"\" width=\"800\" height=\"616\" class=\"aligncenter size-full wp-image-1898\" srcset=\"\/wp-content\/uploads\/2017\/07\/2.jpg 800w, \/wp-content\/uploads\/2017\/07\/2-300x231.jpg 300w, \/wp-content\/uploads\/2017\/07\/2-768x591.jpg 768w, \/wp-content\/uploads\/2017\/07\/2-210x162.jpg 210w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/p>\n<p><strong>2:\u8499\u677f\u5904\u7269\u4f53\u906e\u63a9<\/strong><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/1vr.cn\/wp-content\/uploads\/2017\/07\/3.jpg\" alt=\"\" width=\"800\" height=\"670\" class=\"aligncenter size-full wp-image-1899\" srcset=\"\/wp-content\/uploads\/2017\/07\/3.jpg 800w, \/wp-content\/uploads\/2017\/07\/3-300x251.jpg 300w, \/wp-content\/uploads\/2017\/07\/3-768x643.jpg 768w, \/wp-content\/uploads\/2017\/07\/3-210x176.jpg 210w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/p>\n<p>\u9ec4\u8272\u6a21\u578b\u4e3a\u8499\u677f,\u5176\u5b83\u6a21\u578b\u51e1\u662f\u88ab\u8499\u6321\u7684\u5730\u65b9\u90fd\u4e0d\u6e32\u67d3,\u5c31\u50cf\u5e03\u5c14\u51cf\u53bb\u9ec4\u8272\u6a21\u578b\u4e00\u6837,\u8fd9\u4e2a\u6548\u679c\u53ef\u4ee5\u7528\u6765\u505a\u4ec0\u4e48\u5462?\u6bd4\u5982\u8bf4\u505a\u4e86\u4eba\u8138\u8bc6\u522b,\u8981\u7ed9\u76f8\u673a\u56fe\u50cf\u4e2d\u7684\u89d2\u8272\u6234\u526f\u773c\u955c,\u5982\u679c\u6ca1\u6709\u7528\u8499\u677f\u906e\u6321,\u90a3\u4e48\u65e0\u8bba\u76f8\u673a\u753b\u9762\u91cc\u662f\u4fa7\u8138\u8fd8\u662f\u6b63\u8138\u90fd\u5c06\u770b\u5230\u5b8c\u6574\u7684\u773c\u955c,\u8fd9\u4e0e\u73b0\u5b9e\u4e0d\u7b26,\u73b0\u5b9e\u4e2d\u4fa7\u8138\u7684\u65f6\u5019\u6211\u4eec\u53ea\u80fd\u770b\u5230\u89c6\u8ddd\u8f83\u8fd1\u7684\u773c\u955c\u817f,\u53e6\u4e00\u4fa7\u773c\u955c\u817f\u5e94\u8be5\u88ab\u8138\u90e8\u906e\u6321,\u800c\u6211\u4eec\u53d6\u7684\u76f8\u673a\u753b\u9762,\u5b83\u662f2D\u5e73\u9762\u7684\u56fe\u50cf,\u4e0d\u80fd\u81ea\u52a8\u5e2e\u6211\u4eec\u8fdb\u884c\u6b63\u786e\u7684\u663e\u9690,\u6240\u4ee5\u6211\u4eec\u8981\u505a\u4e00\u4e2a\u9002\u5f53\u7684\u5934\u90e8\u6a21\u578b\u4f5c\u4e3a\u88c1\u5207\u8499\u677f\u5373\u66ff\u4ee3\u9ec4\u8272\u6a21\u578b\u6765\u628a\u4e0d\u5e94\u663e\u793a\u7684\u90e8\u5206\u906e\u63a9\u6389.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/1vr.cn\/wp-content\/uploads\/2017\/07\/4.jpg\" alt=\"\" width=\"800\" height=\"673\" class=\"aligncenter size-full wp-image-1900\" srcset=\"\/wp-content\/uploads\/2017\/07\/4.jpg 800w, \/wp-content\/uploads\/2017\/07\/4-300x252.jpg 300w, \/wp-content\/uploads\/2017\/07\/4-768x646.jpg 768w, \/wp-content\/uploads\/2017\/07\/4-210x177.jpg 210w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/p>\n<p>\u53ea\u9700\u5c06\u4e0b\u9762\u7684shader\u4f5c\u4e3a\u6750\u8d28\u7403\u8d4b\u4e88\u7ed9\u5e0c\u671b\u4f5c\u4e3a\u8499\u677f\u7684\u6a21\u578b\u5373\u53ef.<\/p>\n<pre>\r\nShader \"DepthMask\" {\r\n   \r\n    SubShader {\r\n        \/\/ Render the mask after regular geometry, but before masked geometry and\r\n        \/\/ transparent things.\r\n       \r\n        Tags {\"Queue\" = \"Geometry-10\" }\r\n       \r\n        \/\/ Turn off lighting, because it's expensive and the thing is supposed to be\r\n        \/\/ invisible anyway.\r\n       \r\n        Lighting Off\r\n\r\n        \/\/ Draw into the depth buffer in the usual way.  This is probably the default,\r\n        \/\/ but it doesn't hurt to be explicit.\r\n\r\n        ZTest LEqual\r\n        ZWrite On\r\n\r\n        \/\/ Don't draw anything into the RGBA channels. This is an undocumented\r\n        \/\/ argument to ColorMask which lets us avoid writing to anything except\r\n        \/\/ the depth buffer.\r\n\r\n        ColorMask 0\r\n\r\n        \/\/ Do nothing specific in the pass:\r\n\r\n        Pass {}\r\n    }\r\n}\r\n<\/pre>\n<p><strong>3:\u8499\u677f\u5904\u7269\u4f53\u663e\u793a<\/strong><\/p>\n<p>\u8fd9\u4e2a\u8499\u677f\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u4f1a\u5c06\u5b83\u6240\u8986\u76d6\u7684\u6240\u6709\u5bf9\u8c61\u90fd\u88c1\u5207\u6389,\u53ef\u8c13\u6740\u7684\u6beb\u65e0\u75d5\u8ff9,\u5982\u679c\u6211\u4eec\u7528Unity\u5185\u7f6e\u7684\u76f8\u673a\u7eb9\u7406\u8d34\u5230\u6a21\u578b\u4e0a\u4f5c\u4e3a\u56fe\u50cf\u80cc\u666f\u7684\u65f6\u5019,\u5b83\u540c\u6837\u4e5f\u4f1a\u88ab\u8499\u677f\u627c\u6740\u6389,\u800c\u6211\u4eec\u4e0d\u559c\u6b22\u5b83\u88ab\u6316\u7a7a,\u6240\u4ee5\u8981\u9488\u5bf9\u5b83\u8fdb\u884c\u5904\u7406,\u8ba9\u8fd9\u90e8\u5206\u4e0d\u53d7\u8499\u677f\u5f71\u54cd.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/1vr.cn\/wp-content\/uploads\/2017\/07\/5.jpg\" alt=\"\" width=\"800\" height=\"698\" class=\"aligncenter size-full wp-image-1901\" srcset=\"\/wp-content\/uploads\/2017\/07\/5.jpg 800w, \/wp-content\/uploads\/2017\/07\/5-300x262.jpg 300w, \/wp-content\/uploads\/2017\/07\/5-768x670.jpg 768w, \/wp-content\/uploads\/2017\/07\/5-210x183.jpg 210w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/p>\n<p>\u628a\u4e0b\u9762\u7684\u811a\u672c\u6302\u63a5\u5230\u4efb\u4f55\u4e0d\u60f3\u88ab\u8499\u677f\u5f71\u54cd\u7684\u5bf9\u8c61\u4e0a,\u5982\u6211\u4eec\u6302\u5230\u84dd\u8272\u6a21\u578b\u4e0a,\u811a\u672c\u6709\u4e2a\u66b4\u9732\u7684\u53d8\u91cf,\u6211\u4eec\u5c06RenderQueue\u8bbe\u7f6e\u6bd4\u8499\u677fshader\u7684RenderQueue\u6570\u503c\u5c0f\u7684\u503c,\u5728Play\u65f6,\u84dd\u8272\u6a21\u578b\u5c31\u53ef\u4ee5\u65e0\u89c6\u8499\u677f.<\/p>\n<pre>\r\nusing UnityEngine;\r\n\r\n[AddComponentMenu(\"Rendering\/SetRenderQueue\")]\r\n\r\npublic class SetRenderQueue : MonoBehaviour {\r\n\r\n\t[SerializeField]\r\n\tprotected int[] m_queues = new int[]{3000};\r\n\r\n\tprotected void Awake() {\r\n\t\tMaterial[] materials=this.GetComponent<Renderer>().materials;\r\n\t\tfor (int i = 0; i < materials.Length &#038;&#038; i < m_queues.Length; ++i) {\r\n\t\t\tmaterials[i].renderQueue = m_queues[i];\r\n\t\t}\r\n\t}\r\n}\r\n<\/pre>\n<p>\u8d44\u6599\u53c2\u8003:<br \/>\n<a href=\"http:\/\/mec0825.net\/blog\/?p=126\">http:\/\/mec0825.net\/blog\/?p=126<\/a><br \/>\n<a href=\"http:\/\/wiki.unity3d.com\/index.php?title=DepthMask\">http:\/\/wiki.unity3d.com\/index.php?title=DepthMask<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6211\u4eec\u5728\u505aAR(\u589e\u5f3a\u73b0\u5b9e)\u7684\u65f6\u5019,\u6709\u51e0\u79cd\u6548\u679c\u9700\u6c42\u4f1a\u9047\u5230. 1:\u9634\u5f71\u9542\u7a7a \u901a\u8fc7\u6210\u529f\u8bc6\u522bMarker(\u82b1\u6735\u80cc\u666f),\u5728 &hellip; <a href=\"https:\/\/1vr.cn\/?p=1897\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">AR\u4e2d\u7684\u9634\u5f71\u9542\u7a7a,\u8499\u677f\u5904\u7269\u4f53\u906e\u63a9,\u8499\u677f\u5904\u7269\u4f53\u663e\u793a\u7b49<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[56,57,60,59,58],"class_list":{"0":"post-1897","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"hentry","6":"category-5","7":"tag-ar","9":"tag-60","10":"tag-59","11":"tag-58","12":"without-featured-image"},"_links":{"self":[{"href":"https:\/\/1vr.cn\/index.php?rest_route=\/wp\/v2\/posts\/1897","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/1vr.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/1vr.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/1vr.cn\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/1vr.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1897"}],"version-history":[{"count":1,"href":"https:\/\/1vr.cn\/index.php?rest_route=\/wp\/v2\/posts\/1897\/revisions"}],"predecessor-version":[{"id":1903,"href":"https:\/\/1vr.cn\/index.php?rest_route=\/wp\/v2\/posts\/1897\/revisions\/1903"}],"wp:attachment":[{"href":"https:\/\/1vr.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1897"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/1vr.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1897"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/1vr.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1897"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}