{"id":7709,"date":"2024-04-17T20:01:01","date_gmt":"2024-04-17T12:01:01","guid":{"rendered":""},"modified":"2024-04-17T20:01:01","modified_gmt":"2024-04-17T12:01:01","slug":"Unity \u5b9e\u73b0\u6e38\u620f\u4e2d\u591a\u76f8\u673a\u5c4f\u5e55CutIn\u6548\u679c","status":"publish","type":"post","link":"https:\/\/mushiming.com\/7709.html","title":{"rendered":"Unity \u5b9e\u73b0\u6e38\u620f\u4e2d\u591a\u76f8\u673a\u5c4f\u5e55CutIn\u6548\u679c"},"content":{"rendered":"

\n <\/path> \n<\/svg> <\/p>\n

\u6548\u679c\u5c55\u793a<\/h3>\n

\u4e0b\u56fe\u662fGame\u7a97\u53e3\u91cc\u9762\u663e\u793a\u7684\u4e24\u4e2a\u4e0d\u540c\u7269\u4f53\u7684cutin\u62fc\u63a5\u8d77\u6765\u7684\u6548\u679c\uff0c\u5f53\u7136\u53ef\u4ee5\u81ea\u7531\u8c03\u6574\u659c\u5207\u7684\u89d2\u5ea6\uff0c\u4ee5\u53ca\u62cd\u6444\u7684\u5185\u5bb9
\"Unity
\"Unity
\"Unity<\/p>\n

\u539f\u7406\u8bf4\u660e<\/h3>\n

\u57fa\u672c\u539f\u7406\u8fd8\u662f\u4f7f\u7528\u7684RenderTexture\uff0c\u5c06\u76f8\u673a\u7167\u5c04\u7684\u5185\u5bb9\u90fd\u62fc\u63a5\u8d77\u6765\uff0c\u76f8\u4fe1\u57fa\u672c\u7684\u4f7f\u7528RenderTexture\u5b9e\u73b0\u5de6\u53f3\u5206\u5c4f\u663e\u793a\u4e0d\u540c\u7684\u5185\u5bb9\uff0c\u5e94\u8be5\u662f\u6bd4\u8f83\u7b80\u5355\u7684\u4e86\uff1b\u4f46\u662f\uff0c\u8981\u5b9e\u73b0\u4e0a\u9762\u8fd9\u79cd\u4e0d\u89c4\u5219\u7684\u5207\u5c4f\uff0c\u76f8\u5bf9\u6765\u8bf4\u5c31\u6bd4\u8f83\u56f0\u96be\u4e86\u3002
\u6240\u8c13\u62fc\u63a5\uff0c\u672c\u8d28\u4e0a\u8fd8\u662f\u6307\u6211\u4eec\u53ea\u60f3\u628a\u4e00\u4e2a\u76f8\u673a\u7167\u5c04\u7684\u5185\u5bb9\u7684\u67d0\u4e00\u90e8\u5206\u663e\u793a\u51fa\u6765\uff0c\u53e6\u5916\u7684\u90e8\u5206\u6211\u4eec\u4e0d\u60f3\u5c55\u793a\u51fa\u6765\uff0c\u987a\u7740\u8fd9\u4e2a\u601d\u8def\uff0c\u6211\u4eec\u53ef\u4ee5\u5c1d\u8bd5\u7740\u7528\u51e0\u4e2a\u9762\u7247\u53bb\u906e\u6321\u6574\u4e2a\u5c4f\u5e55\uff0c\u7136\u540e\u53ea\u7559\u4e0b\u6211\u4eec\u4e0d\u60f3\u906e\u6321\u7684\u90a3\u90e8\u5206\uff0c\u7136\u540e\u591a\u590d\u5236\u51e0\u7ec4\u9762\u7247\uff0c\u5206\u522b\u6253\u5f00\u5404\u4e2a\u90e8\u5206\uff0c\u6700\u540e\u628a\u6240\u6709\u90e8\u5206\u770b\u5230\u7684\u5185\u5bb9\u62fc\u8d77\u6765\u5c31\u662f\u4e00\u4e2a\u5b8c\u6574\u7684\u5c4f\u5e55\u4e86\u3002
\"Unity
\u6bd4\u5982\u4e0a\u9762\u7684\u6548\u679c\uff0c\u6211\u5c31\u7528\u4e86\u4e24\u4e2a\u659c\u7740\u7684\u9762\u7247\u53bb\u6321\u4f4f\u4e86\u955c\u5934\uff0c\u7136\u540e\u60f3\u663e\u793a\u5de6\u8fb9\uff0c\u6211\u5c31\u628a\u5de6\u8fb9\u7684\u9762\u7247\u9690\u85cf\uff0c\u540c\u7406\uff0c\u53f3\u8fb9\u4e5f\u662f\u4e00\u6837\u3002
\u4f46\u662f\u4f7f\u7528\u9ed8\u8ba4\u6750\u8d28\u662f\u65e0\u6cd5\u8fd9\u6837\u505a\u51fa\u6765\uff0c\u6444\u50cf\u673a\u7167\u5230\u7684\u53ea\u4f1a\u662f\u4e00\u8fb9\u767d\uff0c\u4e00\u8fb9\u6709\u5185\u5bb9\u7684\uff08\u76f8\u673a\u4f7f\u7528Clear Depth\uff0c\u4f1a\u53e0\u52a0\u6700\u4e0a\u5c42\u548c\u4e0b\u4e00\u5c42\u76f8\u673a\u7167\u5c04\u7684\u5185\u5bb9\uff09
\"Unity<\/p>\n

\u6211\u4eec\u5e0c\u671b\u7684\u662f\uff0c\u767d\u7684\u90a3\u4e00\u90e8\u5206\u662f\u201c\u900f\u660e\u7684\u201d\uff0c\u4e5f\u5c31\u662f\u6211\u4eec\u80fd\u591f\u901a\u8fc7\u8fd9\u90e8\u5206\u53bb\u770b\u5230\u4e0b\u4e00\u5c42\u7684\u76f8\u673a\u7167\u5230\u7684\u5185\u5bb9\u3002
\u800c\u8fd9\u53ea\u9700\u8981\u6211\u4eec\u518dShader\u91cc\u9762\u53bb\u5f00\u542f\u6df1\u5ea6\u5199\u5165\uff0c\u7136\u540e\u5254\u9664\u6389\u4e00\u90e8\u5206\u7684\u6df1\u5ea6\u4fe1\u606f\u5373\u53ef\uff0c\u5177\u4f53Shader\u5982\u4e0b<\/p>\n

Shader \"Custom\/CutInMask\"<\/span>\n{ \n   <\/span>\n    Properties\n    { \n   <\/span>\n        _Stencial (<\/span>\"Stencial ID\"<\/span>,<\/span> Float)<\/span> =<\/span> 100<\/span>\n        _StencialComp (<\/span>\"Stencial Compression\"<\/span>,<\/span> Float)<\/span> =<\/span> 8<\/span>\n        _StencialOp (<\/span>\"Stencial Operation\"<\/span>,<\/span> Float)<\/span> =<\/span> 2<\/span>\n    }<\/span>\n\n    SubShader\n    { \n   <\/span>\n        Tags{ \n   <\/span>\n            \"RenderType\"<\/span> =<\/span> \"Opaque\"<\/span>\n            \"Queue\"<\/span> =<\/span> \"Geometry-500\"<\/span>\n        }<\/span>\n\n        Lighting Off\n        ZWrite On\n        ColorMask 0<\/span>\n\n        Stencil\n        { \n   <\/span>\n            Ref[<\/span>_Stencil]<\/span>\n            Comp[<\/span>_StencilComp]<\/span>\n            Pass[<\/span>_StencilOp]<\/span>\n        }<\/span>\n\n        Pass\n        { \n   <\/span>\n            CGPROGRAM\n\n            #pragma<\/span> vertex vert<\/span>\n            #pragma<\/span> fragment frag<\/span>\n\n            fixed4<\/span> vert<\/span>(<\/span>float4<\/span> v :<\/span> POSITION)<\/span> :<\/span> SV_POSITION\n            { \n   <\/span>\n                return<\/span> UnityObjectToClipPos<\/span>(<\/span>v)<\/span>;<\/span>\n            }<\/span>\n\n            fixed4<\/span> frag<\/span>(<\/span>)<\/span> :<\/span> SV_TARGET\n            { \n   <\/span>\n                return<\/span> float4<\/span>(<\/span>0<\/span>,<\/span>0<\/span>,<\/span>0<\/span>,<\/span>0<\/span>)<\/span>;<\/span>\n            }<\/span>\n\n            ENDCG   \n        }<\/span>\n        \n    }<\/span>\n}<\/span>\n<\/code><\/pre>\n

\u8fd9\u4e2aShader\u91cc\u9762\u7684\u9876\u70b9\u548c\u7247\u5143\u7740\u8272\u5668\u5e76\u4e0d\u91cd\u8981\uff0c\u5c31\u662f\u6700\u57fa\u7840\u7684\u5750\u6807\u8f6c\u6362\u548c\u8f93\u51fa\u989c\u8272\uff08\u989c\u8272\u662f\u5565\u90fd\u4e0d\u91cd\u8981\uff0c\u56e0\u4e3a\u90fd\u4f1a\u88ab\u5254\u9664\u6389\uff09\uff0c\u7136\u540e\u5c06\u8fd9\u4e2aShader\u653e\u5230\u4e00\u4e2a\u6750\u8d28\u4e0a\uff0c\u5c31\u53ef\u4ee5\u5728\u573a\u666f\u4e2d\u770b\u5230\u6548\u679c\u4e86\u3002\u6d4b\u8bd5\u573a\u666f\u5982\u4e0b\uff0c\u4e24\u4e2a\u4e00\u6a21\u4e00\u6837\u7684\u906e\u7f69\u7269\u4f53\uff0c\u7136\u540e\u4e00\u4e2a\u6253\u5f00\u4e00\u4e2a\uff0c\u90fd\u7528\u76f8\u673a\u53bb\u7167\u81ea\u5df1\u60f3\u770b\u7684\u7269\u4f53\uff08\u4e24\u4e2a\u76f8\u673a\u90fd\u5f97\u662fDepth only\uff09
\"Unity<\/p>\n","protected":false},"excerpt":{"rendered":"Unity \u5b9e\u73b0\u6e38\u620f\u4e2d\u591a\u76f8\u673a\u5c4f\u5e55CutIn\u6548\u679c\u6548\u679c\u5c55\u793a\u4e0b\u56fe\u662fGame\u7a97\u53e3\u91cc\u9762\u663e\u793a\u7684\u4e24\u4e2a\u4e0d\u540c\u7269\u4f53\u7684cutin\u62fc\u63a5\u8d77\u6765\u7684\u6548\u679c\uff0c\u5f53\u7136\u53ef\u4ee5\u81ea\u7531\u8c03...","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"_links":{"self":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/7709"}],"collection":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/comments?post=7709"}],"version-history":[{"count":0,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/7709\/revisions"}],"wp:attachment":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/media?parent=7709"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/categories?post=7709"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/tags?post=7709"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}