{"id":183,"date":"2019-09-01T16:51:00","date_gmt":"2019-09-01T08:51:00","guid":{"rendered":"http:\/\/blog.coolcoding.cn\/?p=183"},"modified":"2020-05-09T11:38:43","modified_gmt":"2020-05-09T03:38:43","slug":"%e6%a8%a1%e5%9d%97%e7%bc%93%e5%86%b2%e6%8a%80%e6%9c%af%e8%ae%b0%e5%bd%95","status":"publish","type":"post","link":"https:\/\/blog.coolcoding.cn\/?p=183","title":{"rendered":"[Unity]\u6a21\u5757\u7f13\u51b2\u6280\u672f\u8bb0\u5f55"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code>Stencil\n{\n\tRef ref\n\tReadMask readMask\n\tWriteMask writeMask\n\tComp comp\n\tPass passOp\n\tFail failOp\n\tZFail zfailOp\n}\n\n\u6ce8\uff1a\u6a21\u5757\u7f13\u51b2\u5728\u56fe\u5f62\u7ba1\u9053\u4e2d\uff0c\u4ee5AlphaTest\u4e4b\u540e\uff0c\u5728DepthTest \u4e4b\u524d\nAlphaTest -> StencilTest -> DepthTest\n\n\u4e00\u4e2a\u50cf\u7d20\u5f53\u914d\u7f6e\u4e86Stencil\u540e\uff0c\u6267\u884c\u4ee5\u4e0b\u6267\u884c\uff1a\nif\uff08 ref&amp;readMask comp stencil&amp;readMask)\n{\n  DO: passOp\n}\nelse\n{\n  DO: failOP\n}\n\n\u5176\u4e2d\uff0c\u521d\u59cb\u5316\u65f6stencil\u7b49\u4e8e0\nRef\/ReadMask\/WriteMask \u90fd\u4e3a0~255\u7684\u6574\u6570\n\nComp\u5217\u8868:\nGreater>;\nGEqual>=;\nLess&lt;;\nLEqual&lt;=;\nEqual=;\nNotEqual!=;\nAlways\u603b\u662f\u6210\u529f\u50cf\u7d20\u6e32\u67d3;\nNever\u603b\u662f\u5931\u8d25\u50cf\u7d20\u629b\u5f03\n\nOP\u5217\u8868\uff1a\nKeep\t\u4fdd\u7559\u5f53\u524d\u7f13\u51b2\u4e2d\u7684\u5185\u503c\nZero        \u5c060\u5199\u5165\u5f53\u524d\u7f13\u51b2\u7684\u503c\nReplace\t\u5c06\u53c2\u8003\u503c\u5199\u5165\u7f13\u51b2\uff0c\u5373\u5c06Ref\u8d4b\u503c\u7ed9\u5f53\u524d\u7f13\u51b2\u7684\u503c\nIncrSat\t\u5f53\u524d\u7f13\u51b2\u7684\u503c\u52a01\uff0c\u5982\u5f53\u524d\u7f13\u51b2\u7684\u503c\u8d85\u8fc7255\u4e86\uff0c\u90a3\u4e48\u4fdd\u7559\u4e3a255\uff0c\u5373\u4e0d\u5927\u4e8e255\nDecrSat\t\u5f53\u524d\u7f13\u51b2\u7684\u503c\u51cf1\uff0c\u5982\u679c\u5f53\u524d\u7f13\u51b2\u7684\u503c\u8d85\u8fc7\u4e3a0\uff0c\u90a3\u4e48\u4fdd\u7559\u4e3a0\uff0c\u5373\u4e0d\u5c0f\u4e8e0\nInvert\t\u5f53\u524d\u7f13\u51b2\u7684\u503c\u6309\u4f4d\u53d6\u53cd\nIncrWrap \u5f53\u524d\u7f13\u51b2\u7684\u503c\u52a01\uff0c\u5982\u679c\u7f13\u51b2\u503c\u8d85\u8fc7255\u4e86\uff0c\u90a3\u4e48\u53d8\u62100\uff0c\u7136\u540e\u7ee7\u7eed\u81ea\u589e\nDecrWrap \u5f53\u524d\u7f13\u51b2\u7684\u503c\u51cf1\uff0c\u5982\u679c\u7f13\u51b2\u503c\u5df2\u7ecf\u4e3a0\uff0c\u90a3\u4e48\u53d8\u6210255\uff0c\u7136\u540e\u7ee7\u7eed\u81ea\u51cf\n\n\u793a\u4f8b\uff1a\n\n\u53ea\u6e32\u67d3\u4e00\u6b21\nStencil\n{\n  Ref 0\n  Comp Equal\n  Pass IncrSat\n}\n\n\u4ec5\u6e32\u67d3\u7b2c\u4e8c\u6b21\nStencil\n{\n  Ref 1\n  Comp Greater\n  Pass IncrSat\n}\n\nUnityEngine.Rendering.CompareFunction\n    public enum CompareFunction\n    {\n        \/\/     Depth or stencil test is disabled.\n        Disabled = 0,\n        \/\/     Never pass depth or stencil test.\n        Never = 1,\n        \/\/     Pass depth or stencil test when new value is less than old one.\n        Less = 2,\n        \/\/     Pass depth or stencil test when values are equal.\n        Equal = 3,\n        \/\/     Pass depth or stencil test when new value is less or equal than old one.\n        LessEqual = 4,\n        \/\/     Pass depth or stencil test when new value is greater than old one.\n        Greater = 5,\n        \/\/     Pass depth or stencil test when values are different.\n        NotEqual = 6,\n        \/\/     Pass depth or stencil test when new value is greater or equal than old one.\n        GreaterEqual = 7,\n        \/\/     Always pass depth or stencil test.\n        Always = 8\n    }\n\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[18],"_links":{"self":[{"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/posts\/183"}],"collection":[{"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=183"}],"version-history":[{"count":4,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/posts\/183\/revisions"}],"predecessor-version":[{"id":1870,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/posts\/183\/revisions\/1870"}],"wp:attachment":[{"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=183"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=183"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=183"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}