{"id":159,"date":"2020-10-12T01:54:31","date_gmt":"2020-10-11T17:54:31","guid":{"rendered":"https:\/\/meecarlo.wordpress.com\/?p=159"},"modified":"2020-12-28T18:21:12","modified_gmt":"2020-12-28T10:21:12","slug":"shader%e5%85%a5%e9%97%a8-4-%e5%8d%a1%e9%80%9a%e6%9d%90%e8%b4%a8%ef%bc%882-%e6%ad%a3%e5%bc%8f%e5%88%b6%e4%bd%9ctoon-shading%ef%bc%89","status":"publish","type":"post","link":"https:\/\/meecarlo.com\/old\/2020\/10\/12\/shader%e5%85%a5%e9%97%a8-4-%e5%8d%a1%e9%80%9a%e6%9d%90%e8%b4%a8%ef%bc%882-%e6%ad%a3%e5%bc%8f%e5%88%b6%e4%bd%9ctoon-shading%ef%bc%89\/","title":{"rendered":"Shader\u5165\u95e8\u20144.\u5361\u901a\u6750\u8d28\uff082.\u6b63\u5f0f\u5236\u4f5cToon-Shading\uff09"},"content":{"rendered":"\n<p>        \u6211\u4eec\u6765\u56de\u987e\u4e0b\u5982\u4f55\u5236\u4f5c\u5361\u901a\u6750\u8d28\uff0c\u6211\u4eec\u7528\u4e24\u4e2aPass\u6765\u5b9e\u73b0\uff0c\u4e00\u4e2aPass\u7528\u6765\u6e32\u67d3\u80cc\u90e8\u6765\u8fbe\u5230\u63cf\u8fb9\u7684\u6548\u679c\uff0c\u4e00\u4e2aPass\u7528\u6765\u6e32\u67d3\u6b63\u9762\u8fbe\u5230\u989c\u8272\u7740\u8272\u7684\u6548\u679c\u3002\u8fd9\u5176\u4e2d\u9700\u8981\u7528\u5230\u4e00\u4e2a\u6307\u4ee4Cull Front\u4e0eCull Back\uff0c\u8fd9\u4e24\u4e2a\u6307\u4ee4\u53ef\u4ee5\u544a\u8bc9GPU\u6211\u6e32\u67d3\u7684\u65f6\u5019\u4e0d\u9700\u8981\u6e32\u67d3\u90a3\u4e00\u90e8\u5206\uff0c\u6240\u4ee5\u53eb\u505a\u5254\u9664\u6307\u4ee4\u3002<\/p>\n\n\n\n<p>        \u9996\u5148\u6211\u4eec\u6765\u5236\u4f5cCull Front\u90e8\u5206\u7684\u6e32\u67d3\uff0c\u5728\u6e32\u67d3\u8f6e\u5ed3\u7ebf\u7684\u65f6\u5019\uff0c\u6211\u4eec\u53ef\u4ee5\u8fdb\u884c\u6cd5\u7ebf\u63cf\u8fb9\uff0c\u4f46\u8fd9\u65f6\u5019\u6709\u4e2a\u95ee\u9898\uff0c\u6a21\u578b\u7684\u6cd5\u7ebf\u7684\u6df1\u5ea6\u6709\u533a\u5206\uff0c\u5982\u679c\u4e0d\u5bf9\u4ed6\u8fdb\u884c\u91cd\u7f6e\uff0c\u6211\u4eec\u5f97\u5230\u7684\u8f6e\u5ed3\u7ebf\u4f1a\u6709\u65ad\u7ebf\u7684\u60c5\u51b5\u3002\u6240\u4ee5\u5728\u8fdb\u884c\u63cf\u8fb9\u4e4b\u524d\u6211\u4eec\u9700\u8981\u8fdb\u884c\u6cd5\u7ebf\u7684\u6df1\u5ea6\u7edf\u4e00\u5316\uff0c\u8fd9\u4e00\u6b65\u4e5f\u5f88\u7b80\u5355\uff0c\u76f4\u63a5\u8fdb\u884cnormali.z=-0.5\u5c31\u53ef\u4ee5\u7edf\u4e00\u63cf\u8fb9\uff0c\u4e3a\u4ec0\u4e48\u662f-\u7684\u5462\uff0c\u8fd9\u91cc\u6211\u4eec\u8981\u518d\u6b21\u590d\u4e60\u4e0b\u5de6\u624b\u5750\u6807\u7cfb\uff0c<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"559\" height=\"417\" src=\"http:\/\/meecarlo.com\/wp-content\/uploads\/2020\/12\/2-2.png\" alt=\"\" class=\"wp-image-483\" srcset=\"https:\/\/meecarlo.com\/old\/wp-content\/uploads\/2020\/12\/2-2.png 559w, https:\/\/meecarlo.com\/old\/wp-content\/uploads\/2020\/12\/2-2-300x224.png 300w\" sizes=\"auto, (max-width: 559px) 100vw, 559px\" \/><figcaption>\u5de6\u624b\u5750\u6807\u7cfb<\/figcaption><\/figure>\n\n\n\n<p>        Z\u8f74\u4ee3\u8868\u6211\u4eec\u7684\u6df1\u5ea6\u5750\u6807\uff0c\u8d8a\u8fdcz\u7684\u503c\u8d8a\u5927\uff0c\u800c\u6211\u4eec\u7684\u5361\u901a\u6750\u8d28\u9700\u8981\u6211\u4eec\u6e05\u6670\u7684\u770b\u5230\u4ed6\u7684\u63cf\u8fb9\u9632\u6b62\u88ab\u6b63\u9762\u6e32\u67d3\u7684\u90e8\u5206\u7ed9\u906e\u6321\u4f4f\u6240\u4ee5\u8fdb\u884c\u7edf\u4e00\u7684-0.5\u7684\u5b9a\u503c\u3002\u6240\u4ee5\u6211\u4eec\u6b63\u5f0f\u6765\u7f16\u5199\u63cf\u8fb9\u7684Pass\u3002<\/p>\n\n\n<pre class=\"brush: objc; highlight: [11,12,33,39]; title: ; notranslate\" title=\"\">\nShader&quot;Custom\/Toon-Shading&quot;{\n    Properties{\n        _Outline(&quot;Outline Size&quot;,Range(0,1))=0.5\n        _OutLineColor(&quot;OutLine Color&quot;,Color)=(1,1,1,1)\n        _Color(&quot;Color Tint&quot;,Color)=(1,1,1,1)\n    }\n    Subshader{\n        Pass{\n            NAME &quot;OUTLINE&quot;\n            Cull Front\n            CGPROGRAM\n            \n            \n            #pragma vertex vert\n            #pragma fragmengt frag\n            #include &quot;Lighting.cginc&quot;\n            #include &quot;UnityCG.cginc&quot;\n            struct a2v{\n                float4 vertex:POSITION;\n                float3 normal:NORMAL;\n            };\n            struct v2f{\n                float4 pos:SV_POSITION;\n            };\n            v2f vert(a2v v){\n                v2f o;\n                float4 pos=UnityObjectToClipPos(v.vertex);\n                float3 normal=mul((float3x3)UNITY_MATRIX_IT_MV,v.normal);\n                normal.z=-0.5;\n                pos=pos+float4(normalize(normal),0)*_Outline;\n                o.pos=mul(UNITY_MATRIX_P,pos);\n                return o;\n            }\n            fixed4 frag(v2f i):SV_Target{\n                    return float4(_OutLineColor.rgb,1);\n            }\n            ENDCG\n        }\n    }\n    Fallback &quot;Diffuse&quot;\n}\n<\/pre>\n\n\n<p>        \u4e0a\u8ff0\u4ee3\u7801\u4e2d\uff0c\u6211\u6807\u4eae\u7684\u5730\u65b9\u9700\u8981\u7279\u522b\u6ce8\u610f\u4e0b\uff0c\u9996\u5148\u662fCull Front\uff0c\u524d\u6587\u5df2\u7ecf\u8bf4\u660e\u4e86\uff0c\u8fd9\u90e8\u5206Pass\u6211\u4eec\u4e13\u95e8\u7ed9\u5979\u547d\u540d\u6210OUTLINE\uff0c\u4ee5\u540e\u5982\u679c\u5199\u5176\u4ed6\u8fd9\u79cd\u9700\u8981\u63cf\u8fb9\u7684\u6548\u679c\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528UsePass&#8221;Toon-Shading\/OUTLINE&#8221;,\u6ce8\u610f\u4e0b\uff0cunity\u4e2d\u4f1a\u628a\u6709\u540d\u79f0\u7684Pass\u7684\u540d\u79f0\u8f6c\u6210\u5168\u90e8\u5927\u5199\uff0c\u6240\u4ee5\u6211\u4eec\u5728\u547d\u540d\u7684\u65f6\u5019\u76f4\u63a5\u547d\u540d\u6210\u5927\u5199\uff0c\u8fd9\u6837\u5c31\u4e0d\u592a\u4f1a\u5fd8\u8bb0\u8fd9\u79cd\u5c0f\u7ec6\u8282\u3002<\/p>\n\n\n\n<p>        \u7136\u540efloat4 \u8fd9\u4e2a\u5b9a\u4e49\uff0c\u8fd9\u91cc\u6709\u4e00\u4e2a\u8c46\u77e5\u8bc6\uff0c\u660e\u660e\u4e09\u4e2a\u6570\u5b57\u5c31\u80fd\u8868\u8fbe\u70b9\u7684\u5750\u6807\uff0c\u4e3a\u4ec0\u4e48\u8981\u7528float4\u6765\u5b9a\u4e49\uff0c\u4e00\u4e2a\u539f\u56e0\u662f\u6211\u4eec\u5728\u53d8\u6362\u7684\u65f6\u5019\u7528\u7684\u77e9\u9635\u662f4X4\u7684\u77e9\u9635\uff0c\u6240\u4ee5\u4e3a\u4e86\u8fbe\u5230\u8f6c\u6362\u6548\u679c\u897f\u836f\u5c06\u4ed6\u4eec\u8f6c\u6362\u5230\u4e00\u4e2a\u9f50\u6b21\u5750\u6807\u7684\u7a7a\u95f4\u8fdb\u884c\u8f6c\u5316\u3002\u8fd9\u4e2a\u662f\u8f6c\u6362\u65f6\u7684\u610f\u4e49\uff0c\u8fd8\u6709\u5c31\u662f\u5f53\uff08x,y,z,1\uff09\u65f6\u4ee3\u8868\u4e00\u4e2a\u70b9\uff0c\u800c\uff08x,y,z,0\uff09\u65f6\u4ee3\u8868\u4e00\u4e2a\u5411\u91cf\u3002\u6240\u4ee5\u6211\u4eec\u5728\u5c06\u9876\u70b9\u4f4d\u7f6e\u5411\u5916\u5ef6\u7533\u7684\u65f6\u5019\u9664\u4e86\u8981normalize\u8fd8\u9700\u8981\u5c06\u4ed6\u8865\u9f50\u4e3a\u4e00\u4e2a4X4\u7684\u5411\u91cf\u3002<\/p>\n\n\n\n<p>        \u63a5\u4e0b\u6765\u6211\u4eec\u6765\u5b9e\u73b0\u771f\u6b63\u5173\u952e\u7684\u5149\u7167\u6a21\u578b\u6240\u5728Pass\u3002\u5728\u8fd9\u6211\u4eec\u518d\u6b21\u56de\u987e\u4e00\u4e0bBlinn-Phong\u6a21\u578b\uff0c<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Specular=C<sub><em>light<\/em><\/sub>*M<sub><em>diffuse<\/em><\/sub>*max(0,n\u00b7halfDir)^<sup>_gloss<\/sup><\/code><\/pre>\n\n\n\n<p>\u5199\u6210\u4ee3\u7801\u5c31\u662f<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>fixed4 specular=_LightColor0.rgb*_Diffuse*pow(max(0,dot(normal,halfDir)),_Gloss);<\/code><\/pre>\n\n\n\n<p>\u5176\u4e2dhalfDir\u76f8\u4fe1\u5927\u5bb6\u8fd8\u6ca1\u6709\u5fd8\u8bb0\uff0c\u5c31\u662fviewDir+lightDir\u4e5f\u5c31\u662f\u89c6\u89d2\u5411\u91cf+\u5165\u5c04\u5149\u7ebf\u5411\u91cf\uff0c\u5176\u4e2d\u89c6\u89d2\u5411\u91cf\u53ef\u4ee5\u7528_WorldSpaceCameraPos0.xyz-UnityObjectToWorldNormal(normal)\u6765\u5f97\u5230\u3002\u8fd9\u91cc\u7a0d\u5fae\u590d\u4e60\u4e00\u4e0bBlinn-Phong\u7684\u9ad8\u5149\u6a21\u578b\uff0c\u867d\u7136\u6211\u4eec\u4e0d\u4f1a\u5728\u8fd9\u4e2ashader\u4e2d\u7528\u5b83\uff0c\u4f46\u5c06\u4ed6\u4fee\u6539\u4e0b\uff0c\u5c31\u80fd\u591f\u4e3a\u6211\u4eec\u6240\u7528\u3002<\/p>\n\n\n\n<p>\u6211\u4eec\u7167\u6837\u9700\u8981normal\u4e0ehalfDir\u7684\u70b9\u79ef\uff0c\u4f46\u6211\u4eec\u9700\u8981\u7684\u4e0d\u662f\u6e10\u53d8\u7684\u9ad8\u5149\uff0c\u800c\u662f\u7528\u5b83\u7684\u70b9\u79ef\u8ddf\u4e00\u4e2a\u9608\u503c\u6bd4\u8f83\u3002\u8fd9\u65f6\u5019\u6211\u4eec\u8981\u7528\u4e00\u4e2aCG\u51fd\u6570step(a,x)\u8fd9\u662f\u4e00\u4e2a\u6bd4\u8f83\u51fd\u6570\uff0c\u5f53x\u5927\u4e8ea\u7684\u65f6\uff0c\u8fd4\u56de1\u5426\u5219\u8fd4\u56de0\uff0c\u6240\u4ee5\u8fd9\u90e8\u5206\u6211\u4eec\u53ef\u4ee5\u8fd9\u4e48\u5199\uff0c<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>float spec=dot(worldNormal,halfDir);<br>spec=step(a,spec);<\/code><\/pre>\n\n\n\n<p>\u4f46\u6211\u4eec\u4f7f\u7528\u8fd9\u4e2a\u8fdb\u884c\u7740\u8272\u7684\u65f6\u5019\uff0c\u4f1a\u53d1\u73b0\u8868\u9762\u952f\u9f7f\u6709\u70b9\u5927\uff0c\u6240\u4ee5\u6211\u4eec\u5f15\u5165<code>smoothstep(-w,w,spec-a)<\/code> smoothstep\uff08a,b,c\uff09\u7684\u6570\u5b66\u610f\u4e49\u662f\uff0c\u5f53c\u5c0f\u4e8ea\u7684\u65f6\u5019\u8fd4\u56de0\uff0c\u5927\u4e8eb\u7684\u65f6\u5019\u8fd4\u56de1\u5728\u8fd9\u4e4b\u95f4\u7684\u65f6\u5019\u8fdb\u884c\u63d2\u503c\uff0c\u6211\u4eec\u7ed3\u5408\u8fd9\u4e24\u4e2a\u51fd\u6570\u770b\uff0c\u5176\u5b9esmoothstep\u662fstep\u7684\u8fdb\u5316\u7248\uff0cstep\u662f\u76f4\u63a5\u62ffspec-a\uff0c\u5f53\u5176&gt;0\u7684\u65f6\u5019\u8fd4\u56de1\uff0c&lt;0\u7684\u65f6\u5019\u8fd4\u56de0\uff0c\u6240\u4ee5spec-a\u7684\u65f6\u5019\u65e0\u5916\u4e4e\u6709\u4e09\u79cd\u60c5\u51b5\uff0c&lt;-w,&gt;w,\u4e0e\u5728-w,w\u4e4b\u95f4\uff0c\u800c\u8fd9\u4e2aw\u6709\u6211\u4eec\u6765\u5b9a\u4e49\uff0c\u5728\u672c\u4f8b\u4e2d\u6211\u4eec\u4f1a\u7528\u5230fwidth\u51fd\u6570\uff0c\u6765\u5f97\u5230\u4e34\u8fd1\u50cf\u7d20\u4e4b\u95f4\u7684\u8fd1\u4f3c\u5bfc\u6570\u3002<\/p>\n\n\n\n<p>\u6240\u4ee5\u6211\u4eec\u6765\u5199\u8fd9\u90e8\u5206\u7684shader\u3002\u9996\u5148\u6211\u4eec\u5728\u8fbe\u6210\u8fd9\u4e2a\u6548\u679c\u7684\u65f6\u5019\u9700\u8981\u4ec0\u4e48\uff1f\u6bcb\u5eb8\u7f6e\u7591\u7684\u8868\u9762\u989c\u8272_Color,_Specular,_SpecularScale\uff0c\u8fd9\u4e09\u4e2a\u662f\u9ad8\u5149\u6a21\u578b\u4e2d\u5fc5\u5907\u7684\uff0c\u7136\u540e\u5305\u542b\u6211\u4eec\u4e0a\u9762\u4e00\u4e2apass\u6240\u9700\u8981\u7684_Outline\u4e0e_OutlineColor\uff0c<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Shader&nbsp;\"Custom\/Toon-ShadingShader2\"<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp;Properties<br>&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_Color&nbsp;(\"Color\",&nbsp;Color)&nbsp;=&nbsp;(1,1,1,1)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_Specular(\"Specular&nbsp;Color\",Color)=(1,1,1,1)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_SpecularScale(\"Specular&nbsp;Scale\",Range(0,0.1))=0.1<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_Outline(\"Outline&nbsp;Size\",Range(0,1))=0.5<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_OutlineColor(\"Outline&nbsp;Color\",Color)=(1,1,1,1)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_MainTex(\"Main&nbsp;Tex\",2D)=\"white\"{}<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;SubShader<br>&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Tags{\"RenderType\"=\"Opaque\"&nbsp;&nbsp;\"Queue\"=\"Geometry\"}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Pass{<br>&nbsp;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0c\u7136\u540e\u6211\u4eec\u5f00\u59cb\u7f16\u5199\u4ee3\u7801\u7684\u521d\u59cb\u5de5\u4f5c\uff0c\u9996\u5148\u6211\u4eec\u7684#pragma vertex\u4e0e#pragma fragment\u4e0d\u7528\u8c08\u90fd\u8981\u7684\uff0c\u7136\u540e\u6211\u4eec\u8fd9\u91cc\u8981\u7528\u5230#pragma multi_compile_fwdbase\u8fd9\u4e2a\u7ec4\u5305\u542b\u4e86\u6240\u6709\u5411\u524d\u6e32\u67d3\u7684\u5173\u952e\u5b57\uff0c\u4f46\u662f\u8fd9\u4e2a\u53ea\u80fd\u5904\u7406\u5e73\u884c\u5149\u3002\u5982\u679c\u7f3a\u5c11\u8fd9\u6bb5\u4ee3\u7801\u7684\u8bdd\uff0cunity\u4f1a\u9ed8\u8ba4\u7f16\u8bd1<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>DIRECTIONAL LIGHTMAP_ON DIRLIGHTMAP_ON SHADOWS_OFF<\/code><\/pre>\n\n\n\n<p>\u63a5\u4e0b\u6765\u662f\u5934\u6587\u4ef6\uff0cunityCG.cginc\u4e0eLighting.cginc\u5fc5\u4e0d\u53ef\u5c11\u3002\u7531\u4e8e\u6211\u4eec\u9700\u8981\u8ba1\u7b97\u9634\u5f71\uff0c\u6240\u4ee5\u8fd8\u9700\u8981AutoLight.cginc\uff0c\u8fd9\u91cc\u8981\u989d\u5916\u6dfb\u52a0\u4e00\u4e2aUnityShaderVariables.cginc\uff0c\u5177\u4f53\u7684\u542b\u4e49\u53ef\u4ee5\u5728\u4ed6\u7684\u5934\u6587\u4ef6\u4e2d\u83b7\u53d6\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>                        #pragma&nbsp;vertex&nbsp;vert&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#pragma&nbsp;fragment&nbsp;frag&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#pragma&nbsp;multi_compile_fwdbase<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#include&nbsp;\"UnityCg.cginc\"<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#include&nbsp;\"Lighting.cginc\"<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#include&nbsp;\"AutoLight.cginc\"<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#include&nbsp;\"UnityShaderVariables.cginc\"<\/code><\/pre>\n\n\n\n<p>\u63a5\u4e0b\u6765\u5c31\u662f\u5b9a\u4e49\u6211\u4eec\u9700\u8981\u7684\u53c2\u6570\u4e86\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fixed4&nbsp;_Color;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sampler2D&nbsp;_MainTex;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;float4&nbsp;_MainTex_ST;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fixed4&nbsp;_Specular;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fixed&nbsp;_SpecularScale;<\/code><\/pre>\n\n\n\n<p>\u8fd9\u4e9b\u57fa\u672c\u5b9a\u4e49\u5c31\u4e0d\u518d\u8d58\u8ff0\uff0c\u63a5\u7740\u5199\u6211\u4eec\u7684\u9876\u70b9\u6570\u636e\u5230\u9876\u70b9\u7740\u8272\u5668\u7684\u7ed3\u6784\u4f53<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;struct a2v{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;float4&nbsp;vertex:POSITION;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;float3&nbsp;normal:NORMAL;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;float4&nbsp;texcoord:TEXCOORD0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;};<\/code><\/pre>\n\n\n\n<p>\u6211\u4eec\u9700\u8981\u4ece\u9876\u70b9\u6570\u636e\u90a3\u8fb9\u62ff\u5230\u7684\u9996\u5148\u662f\u5c31\u662f\u9876\u70b9\u5750\u6807\u4e0e\u9876\u70b9\u6cd5\u7ebf\uff0c\u8fd8\u6709uv\u5750\u6807\uff0c\u7531\u4e8e\u6211\u4eec\u8f93\u51fa\u5230\u7247\u5143\u7740\u8272\u5668\u4e2d\u4e5f\u9700\u8981uv\u6240\u4ee5\u4eec\u5728a2v\u4e2d\u7528texcoord\u4f5c\u4e3a\u9876\u70b9UV\u7684\u53c2\u6570\uff0c\u5e76\u9644\u4e0a\u7b2c\u4e00\u5957\u5750\u6807\u503c\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;v2f&nbsp;vert(a2v&nbsp;v){<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;v2f&nbsp;o;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;o.pos=UnityObjectToClipPos(v.vertex);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;o.uv=TRANSFORM_TEX(v.texcoord,_MainTex);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;o.worldNormal=UnityObjectToWorldNormal(v.normal);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;o.worldPos=mul(unity_ObjectToWorld,v.vertex).xyz;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TRANSFER_SHADOW(o);<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;o;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<\/code><\/pre>\n\n\n\n<p>\u8fd9\u91cc\u6211\u4eec\u89e3\u91ca\u4e24\u4e2a\u5b8f\uff0c\u4e00\u4e2a\u662fTRANSFORM_TEX(a,b)\uff0c\u5173\u4e8e\u8fd9\u4e2a\u89e3\u91caUnity\u7684\u5b98\u65b9\u7ed9\u51fa\u7684\u89e3\u91ca\u5982\u4e0b<code>vertex program uses the&nbsp;<strong>TRANSFORM_TEX<\/strong>&nbsp;macro from UnityCG.cginc to make sure texture scale and offset is applied correctly, and fragment program just samples the texture and multiplies by the color property.<\/code>\u7ffb\u8bd1\u4e00\u4e0b\u5c31\u662f\u9876\u70b9\u7740\u8272\u5668\u4f7f\u7528\u8fd9\u4e2a\u5b8f\u53ef\u4ee5\u786e\u4fdd\u5e94\u7528\u7eb9\u7406\u7684\u6bd4\u4f8b\u4e0e\u504f\u79fb\uff0c\u4f46\u7247\u5143\u7740\u8272\u5668\u4e2d\u53ea\u9700\u8981\u901a\u8fc7\u4e0e\u989c\u8272\u7684\u76f8\u4e58\u5c31\u80fd\u8fbe\u5230\u91c7\u6837\u7684\u7ed3\u679c\u3002\u5c31\u662f\u8bf4\u5f53\u5bf9\u9876\u70b9\u8fdb\u884c\u7eb9\u7406\u7740\u8272\u7684\u65f6\u5019\uff0c\u4f7f\u7528\u8fd9\u4e2a\u5b8f\u53ef\u4ee5\u6b63\u786e\u7684\u8fdb\u884c\u7740\u8272\u4e0d\u81f3\u4e8e\u4f7f\u4ed6\u7684\u5750\u6807\u8fdb\u884c\u504f\u79fb\u3002<\/p>\n\n\n\n<p>\u63a5\u4e0b\u6765\u662fTRANSFER_SHADOW(o);\u8fd9\u4e2a\u5b8f\u5176\u5b9e\u662f\u5bf9\u5e94\u4e0b\u4e00\u4e2av2f\u7684\u7ed3\u6784\u4f53\u4e2d\u7684SHADOW_COORDS\uff08\uff09\u6765\u4f7f\u7528\u7684\uff0c\u4ed6\u5c06SHADOW_COORDS()\u58f0\u660e\u7684\u9634\u5f71\u5750\u6807\u8f6c\u6362\u6210\u7247\u5143\u7740\u8272\u5668\u4e2d\u6240\u9700\u8981\u7684\u9634\u5f71\u5750\u6807\uff0c\u4f9b\u5176\u7740\u8272\u3002\u6240\u4ee5\u4e0b\u9762\u6211\u4eec\u6765\u8fdb\u884cstruct v2f\u7684\u7f16\u5199<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;struct&nbsp;v2f&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;float4&nbsp;pos:SV_POSITION;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;float2&nbsp;uv:TEXCOORD0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;float3&nbsp;worldNormal:TEXCOORD1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;float3&nbsp;worldPos:TEXCOORD2;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SHADOW_COORDS(3)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;};<\/code><\/pre>\n\n\n\n<p>        \u8fd9\u90e8\u5206\u4ee3\u7801\u4e2d\u7684\u5173\u952e\u5728\u524d\u6587\u5df2\u7ecf\u89e3\u91ca\u8fc7\u4e86\uff0cSHADOW_COORDS()\u4ec5\u8d77\u5230\u4e00\u4e2a\u58f0\u660e\u9634\u5f71\u5750\u6807\u7684\u4f5c\u7528\u3002\u63a5\u4e0b\u6765\u662f\u6211\u4eec\u6700\u91cd\u8981\u7684\u7247\u5143\u7740\u8272\u5668\u3002\u9996\u5148\u6211\u4eec\u518d\u6765\u56de\u987e\u4e0b\u6211\u4eec\u9700\u8981\u4ec0\u4e48\uff0cBlinn-Phong\u6a21\u578b\u4e2d\u6211\u4eec\u9700\u8981\u8868\u9762\u6cd5\u7ebf\u70b9\u4e58halfDir\uff0c\u6240\u4ee5\u6211\u4eec\u9700\u8981\u4e16\u754c\u5750\u6807\u4e0b\u7684\u6cd5\u7ebf\uff0c\u89c6\u89d2\u5411\u91cf\uff0c\u5165\u5c04\u5149\u5411\u91cf\u3002\u4e0e\u4e4b\u76f8\u5bf9\u7684halfDir\u3002\u6240\u4ee5\u6211\u4eec\u7ee7\u7eed\u521d\u59cb\u7684\u58f0\u660e\u8ba1\u7b97<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fixed4&nbsp;frag(v2f&nbsp;i):SV_TARGET{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;float3&nbsp;worldNormal=normalize(i.worldNormal);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;float3&nbsp;worldLightDir=normalize(UnityWorldSpaceLightDir(i.worldPos));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;float3&nbsp;worldViewDir=normalize(UnityWorldSpaceViewDir(i.worldPos));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;float3&nbsp;halfDir=normalize(worldLightDir+worldViewDir);<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<\/code><\/pre>\n\n\n\n<p>\u867d\u7136\u672c\u6848\u4f8b\u4e0d\u7528\u8fdb\u884c\u8d34\u56fe\uff0c\u4f46\u4ee5\u9632\u4e07\u4e00\uff0c\u6211\u4eec\u4ecd\u5728\u504f\u8fdc\u7740\u8272\u5176\u4e2d\u8fdb\u884c\u8d34\u56fe\u7740\u8272\uff0c\u6309\u7167\u4e4b\u524d\u7684\u8d34\u56fe\u7eb9\u7406\uff0c\u6211\u4eec\u4e86\u89e3\u4e86\u4e00\u4e2a\u51fd\u6570tex2D\uff08tex\uff0cuv\uff09\u5e76\u4e58\u4e0a\u6211\u4eec\u7684_Color\u8fdb\u884c\u4e00\u4e2a\u6b63\u7247\u53e0\u52a0\u7684\u6548\u679c\uff0c\u5f97\u5230\u6211\u4eec\u7684\u53cd\u5c04\u7387\u6548\u679c<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>fixed3 tex=tex2d(_MainTex,i.uv);<br>fixed3 albedo=tex.rgb*_Color;<\/code><\/pre>\n\n\n\n<p>\u63a5\u7740\u6211\u4eec\u83b7\u53d6\u73af\u5883\u5149\u901a\u8fc7UNITY_LIGHTMODEL_AMBIEN.xyz\u4e58\u4e0aalbedo<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>fixed3 ambient=UNITY_LIGHTMODEL_AMBIENT.xyz*albedo;<\/code><\/pre>\n\n\n\n<p>\u7136\u540e\u6211\u4eec\u8fdb\u884c\u6f2b\u53cd\u5c04\u7684\u8ba1\u7b97\uff0c\u5728\u8fd9\u91cc\u4e3a\u4e86\u4f7f\u6b63\u9762\u989c\u8272\u66f4\u52a0\u7a81\u51fa\uff0c\u6211\u4eec\u53ef\u4ee5\u7528\u4e00\u4e2a\u65b0\u7684\u6a21\u578b\u534a\u5170\u4f2f\u7279\u6f2b\u53cd\u5c04\u6a21\u578b\uff08half-Lambert diffuse model)\uff0c\u8fd9\u662f\u4e00\u4e2a\u6548\u679c\u6a21\u578b\uff0c\u8ddf\u73b0\u5b9e\u4e2d\u7684\u53cd\u5c04\u6a21\u578b\u6ca1\u6709\u4e00\u70b9\u5173\u7cfb\uff0c\u6211\u4eec\u56de\u5fc6\u4e00\u4e0b\u6211\u4e48\u7684\u5170\u4f2f\u7279\u6a21\u578b\u7684\u8ba1\u7b97\u516c\u5f0f<em>diffuse=c<sub>ligh<\/sub>t*m<sub>diffuse<\/sub>*max(0,n*l<\/em>) \u5176\u4e2dmax(0,n*l)\u6211\u4eec\u518d\u4ee3\u7801\u4e2d\u662f\u8fd9\u6837\u4f53\u73b0\u7684<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>saturate(0,dot(worldNormal,worldLightDir));<\/code><\/pre>\n\n\n\n<p>\u800c\u6211\u4eec\u7684\u534a\u5170\u4f2f\u7279\u6a21\u578b\uff0c\u5219\u662f\u5c06\u5176\u4e58\u4ee50.5\u5e76\u52a0\u4e0a0.5\u7684\u504f\u79fb\u8fd9\u5176\u4e2d\u7684\u4ee3\u7801\u6211\u4eec\u53ef\u4ee5\u8fd9\u4e48\u5199<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>diff=dot(worldNormal,worldLightDir);<br>diff=0.5*diff+0.5;<\/code><\/pre>\n\n\n\n<p>\u5982\u679c\u8fd9\u65f6\u5019\u6211\u4eec\u76f4\u63a5\u4e58\u4e0a_LightColor0.rgb\u4e0e_Diffuse\u5c31\u53ef\u4ee5\u76f4\u63a5\u83b7\u5f97\u6211\u4eec\u7684\u534a\u5170\u4f2f\u7279\u6f2b\u53cd\u5c04\u6a21\u578b\u3002\u4f46\u56e0\u4e3a\u8fd9\u4e2a\u6848\u4f8b\u4e2d\u6211\u4eec\u9700\u8981\u8fdb\u884c\u9634\u5f71\u7684\u8ba1\u7b97\uff0c\u6211\u4eec\u6765\u5f15\u5165\u4e00\u4e2a\u65b0\u7684\u5b8fUNITY_LIGHT_ATTENUATION(atten,i,i.worldPos)\u8fd9\u4e2a\u5b8f\u53ef\u4ee5\u5e2e\u6211\u4eec\u8ba1\u7b97\u9634\u5f71\u7684\u8870\u51cf\uff0catten\u4e0d\u7528\u58f0\u660e\uff0c\u8fd9\u4e2a\u5b8f\u4f1a\u81ea\u52a8\u58f0\u660e\uff0c\u7b2c\u4e8c\u4e2a\u53c2\u6570\u662f\u524d\u9762\u7ed3\u6784\u4f53\u6240\u53d6\u5f97\u7684\u9634\u5f71\u5750\u6807\uff0c\u7528\u6765\u8ba1\u7b97\u9634\u5f71\u503c\uff0c\u540e\u9762\u7684\u662f\u5728\u4e16\u754c\u7a7a\u95f4\u5750\u6807\u7cfb\u554a\u7684\u5750\u6807\uff0c\u7528\u6765\u8ba1\u7b97\u5149\u6e90\u4e0b\u7684\u5750\u6807\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>UNITY_LIGHT_ATTENUATION(atten,i,i.worldPos);<\/code><\/pre>\n\n\n\n<p>\u6211\u4eec\u518d\u5c06\u5176\u5f97\u5230\u7684atten\u4e0e\u534a\u5170\u4f2f\u7279\u516c\u5f0f\u76f8\u4e58\uff0c\u5f97\u5230\u5176\u9634\u5f71\u90e8\u5206\u7684\u9634\u5f71\u8870\u51cf\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>diff=(0.5*diff+0.5)*atten;<\/code><\/pre>\n\n\n\n<p>\u5728\u6211\u4eec\u5f97\u5230\u8fd9\u4e2a\u9634\u5f71\u8870\u51cf\u540e\u53ef\u4ee5\u7528\u4e00\u5f20\u6e10\u53d8\u56fe\u5bf9\u5176\u91c7\u6837\uff0c\u8fd9\u6837\u6211\u4eec\u5728\u6548\u679c\u4e0a\u53ef\u4ee5\u5b9e\u73b0\u6e10\u53d8\u9634\u5f71\u7684\u8870\u51cf\uff0c\u8fd9\u65f6\u5019\u6211\u4eec\u5728\u5934\u90e8\u5c5e\u6027\uff0c\u589e\u52a0_Ramp(&#8220;Ramp Texture&#8221;,2D)=&#8221;whiter&#8221;{}\uff0c\u5e76\u5b9a\u4e49\u4e0e\u4e4b\u76f8\u5bf9\u5e94\u7684\u53d8\u91cfsampler2D _Ramp;float _Ramp_ST;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Shader\"Custom\/Toon-Shading\"{<br>    Properties{<br>        ...<br>        _Ramp(\"Ramp Texture\",2D)=\"white\"{}<br>        ...<br>    }<br>    Subshader{<br>        ...<br>        sampler2D _Ramp;<br>        float _Ramp_ST;<br>        ...<br><br>       fixed4 diffuse=_LightColor0.rgb*albedo*tex2D(_Ramp,float2(diff,diff)).rgb;<\/code><\/pre>\n\n\n\n<p>\u8fd9\u6837\u6211\u4eec\u7684\u6f2b\u53cd\u5c04\u90e8\u5206\u5c31\u5df2\u7ecf\u7ed3\u675f\u4e86\u3002<\/p>\n\n\n\n<p>\u63a5\u7740\u6211\u4eec\u8fdb\u884c\u9ad8\u5149\u90e8\u5206\u7684\u7f16\u5199\uff0c\u6211\u4eec\u6765\u56de\u987e\u4e00\u4e0b\uff0cBlinn-Phong\u7684\u516c\u5f0f<\/p>\n\n\n\n<p><em>specular=C<sub>light<\/sub>*M<sub>diffuse<\/sub>*max(0,n*halfDir)^<sup>Gloss<\/sup><\/em>  \u7136\u540e\u6211\u4eec\u6539\u8fdb\u540e\u7684\u4e00\u90e8\u5206\u516c\u5f0fsmoothstep(-w,w,spec-a)\uff0c\u5176\u4e2dw\u662f\u6211\u4eec\u901a\u8fc7fwidth\u51fd\u6570\u5b9e\u73b0\u7684\uff0c\u800cfwidth\u8fd9\u4e2a\u51fd\u6570\u5728CG\u8bed\u8a00\u4e2d\u7684\u542b\u4e49\u5982\u4e0b\uff1a<code>fwidth \u2014 return the sum of the absolute value of derivatives in x and y<\/code>  \u610f\u601d\u662f\u8fd4\u56dex\uff0cy\u4e2d\u5bfc\u6570\u7edd\u5bf9\u503c\u7684\u548c\uff0c\u4f46\u6211\u4eec\u53ea\u9700\u8981\u4e34\u8fd1\u50cf\u7d20\u4e4b\u95f4\u7684\u8fd1\u4f3c\u5bfc\u6570\u503c\uff0c\u800c\u9ad8\u5149\u90e8\u5206\u6211\u4eec\u53ea\u9700\u8981\u5982\u6b64\u8ba1\u7b97\uff1afixed w=fwidth(dot(worldNormal,halfDir))*2\u5219\u53ef<\/p>\n\n\n\n<p>\u6240\u4ee5\u8fd9\u90e8\u5206\u4ee3\u7801\u5982\u4e0b<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>fixed w=fwidth(dot(worldNormal.halfDir))*2.0;<br>fixed3 specular=_Specular.rgb*lerp(0,1,smoothstep(-w,w,spec+_SpecularScale-1));<\/code><\/pre>\n\n\n\n<p>\u8fd9\u90e8\u5206\u4e3a\u4ec0\u4e48\u6ca1\u6709\u4e58\u4ee5_LightColor0.rgb\u5462\uff0c\u56e0\u4e3a\u5728\u5361\u901a\u6e32\u67d3\u7684\u8fc7\u7a0b\uff0c\u6211\u4eec\u5e0c\u671b\u9ad8\u5149\u90e8\u5206\u4e0d\u88ab\u73af\u5883\u5149\u6253\u6270\uff0c\u4f46\u5982\u679c\u4f60\u6709\u8fd9\u90e8\u5206\u9700\u6c42\u4e5f\u80fd\u4e58\uff0c\u4f46\u6211\u8bd5\u8fc7\uff0c\u6548\u679c\u4e0d\u662f\u90a3\u4e48\u597d\uff0c\u9ad8\u5149\u90e8\u5206\u5bb9\u6613\u88ab\u5e72\u6270\uff0c\u4ece\u800c\u8fbe\u4e0d\u5230\u5e94\u6709\u7684\u6548\u679c\u3002\u4f46\u5982\u679c\u4f60\u8fd9\u65f6\u5019\u4f60\u8fd0\u884c\u4ee3\u7801\u7684\u65f6\u5019\uff0c\u5c06_SpecularScale\u62c9\u52300\u4f60\u4f1a\u53d1\u73b0\u8fd8\u4f1a\u6709\u9ad8\u5149\u53cd\u5c04\u7684\u5149\u7167\uff0c\u8fd9\u65f6\u5019\u8be5\u600e\u4e48\u529e\u5462\uff0c\u5176\u5b9e\u5f88\u7b80\u5355\u76f4\uff0c\u8fd0\u7528\u6211\u4eec\u7684step\u51fd\u6570\u5c06_SpecularScale\u4e0e\u4e00\u4e2a\u6781\u5c0f\u7684\u503c\u8fdb\u884c\u6bd4\u8f83\uff0c\u5f53_SpecularScale\u7b49\u4e8e0\u7684\u65f6\u5019\u8fd4\u56de0\uff0c\u4fee\u6539\u8fc7\u540e\u7684\u9ad8\u5149\u90e8\u5206\u7684\u4ee3\u7801\u5982\u4e0b<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>fixed3 specular=_Specular.rgb*lerp(0,1,smoothstep(-w,w,spec+_SpecualrScale-1))*step(0.00001,_SpecularScale);<\/code><\/pre>\n\n\n\n<p>\u5982\u6b64\u6211\u4eec\u8fb9\u5b8c\u6210\u4e86\u9ad8\u5149\u90e8\u5206\u7684\u4ee3\u7801\u5de5\u4f5c\uff0c\u6700\u540e\u6211\u4eec\u5c06\u73af\u5883\u5149\u3001\u6f2b\u53cd\u5c04\u3001\u9ad8\u5149\u76f8\u52a0\u5c31\u53ef\u4ee5\u4e86\uff0c\u5982\u679c\u4f60\u8981\u5b9e\u73b0\u81ea\u53d1\u5149\u7684\u6548\u679c\uff0c\u53ef\u4ee5\u76f4\u63a5\u5b9a\u4e49\u4e00\u4e2a_Emission\u7684Color\uff0c\u7136\u540e\u4e0e\u7ed3\u679c\u7684\u548c\u76f8\u4e58\u4fbf\u80fd\u8fbe\u5230\u6548\u679c\u3002<\/p>\n\n\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\nShader &quot;Custom\/Toon-ShadingShader2&quot;\n{\n    Properties\n    {\n        _Color (&quot;Color&quot;, Color) = (1,1,1,1)\n        _Specular(&quot;Specular Color&quot;,Color)=(1,1,1,1)\n        _SpecularScale(&quot;Specular Scale&quot;,Range(0,0.1))=0.1\n        _Outline(&quot;Outline Size&quot;,Range(0,1))=0.5\n        _OutlineColor(&quot;Outline Color&quot;,Color)=(1,1,1,1)\n        _MainTex(&quot;Main Tex&quot;,2D)=&quot;white&quot;{}\n        _Ramp(&quot;Ramp Texture&quot;,2D)=&quot;white&quot;{}\n    }\n    SubShader\n    {\n        Tags{&quot;RenderType&quot;=&quot;Opaque&quot;  &quot;Queue&quot;=&quot;Geometry&quot;}\n        \n        Pass{\n            \n            \n            NAME &quot;OUTLINE&quot;\n            Cull Front\n            CGPROGRAM\n            #pragma vertex vert\n            #pragma fragment frag \n            #include &quot;Lighting.cginc&quot;\n            #include &quot;UnityCG.cginc&quot;\n            float _Outline;\n            fixed4 _OutlineColor;\n            struct a2v{\n               float4 vertex:POSITION;\n               float3 normal:NORMAL;\n            };\n            struct v2f{\n                float4 pos:SV_POSITION;\n                \n            };\n            v2f vert(a2v v){\n                v2f o;\n                float4 pos=UnityObjectToClipPos(v.vertex);\n                float3 normal=mul((float3x3)UNITY_MATRIX_IT_MV,v.normal);\n                normal.z=-0.5;\n                pos=pos+float4(normalize(normal),0)*_Outline;\n                o.pos=mul(UNITY_MATRIX_P,pos);\n                return o;\n                \n            }\n            fixed4 frag(v2f i):SV_TARGET{\n                return float4(_OutlineColor.rgb,1.0);\n            }\n            \n            ENDCG\n        }\n        Pass{\n            Tags{&quot;LightMode&quot;=&quot;ForwardBase&quot;}\n            Cull Back\n            CGPROGRAM\n            #pragma vertex vert \n            #pragma fragment frag \n            #pragma multi_compile_fwdbase\n            #include &quot;UnityCg.cginc&quot;\n            #include &quot;Lighting.cginc&quot;\n            #include &quot;AutoLight.cginc&quot;\n            #include &quot;UnityShaderVariables.cginc&quot;\n            fixed4 _Color;\n            sampler2D _MainTex;\n            float4 _MainTex_ST;\n            fixed4 _Specular;\n            fixed _SpecularScale;\n            sampler2D _Ramp;\n            float _Ramp_ST;\n            \n            struct a2v{\n                float4 vertex:POSITION;\n                float3 normal:NORMAL;\n                float4 texcoord:TEXCOORD0;\n                \n            };\n            struct v2f {\n                float4 pos:SV_POSITION;\n                float2 uv:TEXCOORD0;\n                float3 worldNormal:TEXCOORD1;\n                float3 worldPos:TEXCOORD2;\n                SHADOW_COORDS(3)\n           };\n           \n            v2f vert(a2v v){\n                v2f o;\n                o.pos=UnityObjectToClipPos(v.vertex);\n                o.uv=TRANSFORM_TEX(v.texcoord,_MainTex);\n                o.worldNormal=UnityObjectToWorldNormal(v.normal);\n                o.worldPos=mul(unity_ObjectToWorld,v.vertex).xyz;\n                TRANSFER_SHADOW(o);\n                return o;\n            }\n           \n            \n            fixed4 frag(v2f i):SV_TARGET{\n                fixed3 worldNormal=normalize(i.worldNormal);\n                fixed3 worldLightDir=normalize(UnityWorldSpaceLightDir(i.worldPos));\n                fixed3 worldViewDir=normalize(UnityWorldSpaceViewDir(i.worldPos));\n                fixed3 halfDir=normalize(worldLightDir+worldViewDir);\n                \n                fixed3 tex=tex2D(_MainTex,i.uv);\n                fixed3 albedo=tex.rgb*_Color.rgb;\n                fixed3 ambient=UNITY_LIGHTMODEL_AMBIENT.xyz*albedo;\n                fixed diff=dot(worldNormal,worldLightDir);\n                UNITY_LIGHT_ATTENUATION(atten,i,i.worldPos);\n                diff=(diff*0.5+0.5)*atten;\n                fixed3 diffuse=_LightColor0.rgb*albedo*tex2D(_Ramp,float2(diff,diff)).rgb;\n                fixed w=fwidth(dot(worldNormal,halfDir))*2.0;\n                fixed3 specular=_Specular*lerp(0,1,smoothstep(-w,w,dot(worldNormal,halfDir)+_SpecularScale-1))*step(0.0001,_SpecularScale);\n                return fixed4 (ambient+diffuse+specular,1.0);\n            }\n            ENDCG\n        }\n    }\n    FallBack &quot;Diffuse&quot;\n}\n\n<\/pre>\n\n\n<p>\u4ee5\u4e0a\u5c31\u662f\u6211\u4eec\u7684\u5b8c\u6574\u4ee3\u7801\u4e86\u3002\u8fd9\u90e8\u5206\u5982\u4f55\u518dshadergraph\u4e2d\u5b9e\u73b0\uff0c\u6211\u660e\u5929\u6478\u9c7c\u7684\u65f6\u5019\u518d\u5f04\u5427\u3002\u6628\u5929\u6d4b\u8bd5\u4e86\u4e0b\u4ee3\u7801\uff0c\u53d1\u73b0\u8f6e\u5ed3\u7ebf\u6709\u95ee\u9898\uff0c\u6211\u6000\u7591\u662f\u63cf\u8fb9pass \u7684\u6cd5\u7ebf\u7684\u9505\uff0c\u679c\u4e0d\u51fa\u5176\u7136\uff0c\u5728debug\u7684\u8fc7\u7a0b\u4e2d\uff0c\u53d1\u73b0\u662funityObjectToClipPos\u8fd9\u4e2a\u5185\u7f6e\u51fd\u6570\u7684\u9505\u5c06\u5176\u6362\u6210\u539f\u5148\u8001\u7248\u7684\u77e9\u9635\u53d8\u6362<code>mul((float3x3)UNITY_MARITX_MV,v.vertex)<\/code>\u8fd9\u4e2a\u662f\u8001\u7248\u7684\u77e9\u9635\u8f6c\u6362\uff0c\u4f5c\u7528\u662f\u5c06\u9876\u70b9\u5750\u6807\u8f6c\u6362\u81f3\u88c1\u526a\u7a7a\u95f4\u5185\uff0c\u66f4\u65b0\u540e\u8fd9\u4e2a\u5185\u7f6e\u77e9\u9635\u88abUnityObjectToClipPos(v.vertex)\u7ed9\u53d6\u4ee3\u3002\u5177\u4f53\u4e3a\u4f55\u4f1a\u51fa\u73b0\u8fd9\u4e2a\u60c5\u51b5\uff0c\u6709\u5f85\u8fdb\u4e00\u6b65\u7684\u5206\u4eab\u3002<\/p>\n\n\n\n<p>\u5728\u5236\u4f5cshadergraph\u7684\u65f6\u5019\u518d\u5c06\u6211\u4eec\u7684custom function\u7684\u4ee3\u7801\u4f18\u5316\u4e00\u4e0b\u3002<\/p>\n\n\n<pre class=\"brush: plain; highlight: [1]; title: ; notranslate\" title=\"\">\nvoid LWRPLightingFunction_float (float3 ObjPos, out float3 Direction, out float3 Color, out float ShadowAttenuation )\n{\n   #ifdef LIGHTWEIGHT_LIGHTING_INCLUDED\n   #define LIGHTWEIGHT_LIGHT_INCLUDE\n      \/\/Actual light data from the pipeline\n      Light light = GetMainLight(GetShadowCoord(GetVertexPositionInputs(ObjPos)));\n      Direction = light.direction;\n      Color = light.color;\n      ShadowAttenuation = light.shadowAttenuation;\n      \n   #else\n   \n      \/\/Hardcoded data, used for the preview shader inside the graph\n      \/\/where light functions are not available\n      Direction = float3(-0.5, 0.5, -0.5);\n      Color = float3(1, 1, 1);\n      ShadowAttenuation = 0.4;\n      \n   #endif\n}\n<\/pre>\n\n\n<p>\u4e4b\u524d\u7684CG\u4ee3\u7801\u4e0eHLSL\u5f88\u7c7b\u4f3c\uff0c\u6240\u4ee5\u76f8\u5f53\u4e8e\u5e73\u94fa\u76f4\u53d9\u3002\u5c06\u6b64\u4ee3\u7801\u76f4\u63a5\u590d\u5236\u5230txt\u4e2d\u7136\u540e\u6539\u6587\u4ef6\u540e\u7f00\u4e3ahlsl\uff0c\u6dfb\u52a0\u5230\u573a\u666f\u8d44\u6e90\u4e2d\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"679\" src=\"http:\/\/meecarlo.com\/wp-content\/uploads\/2020\/12\/shader1-1024x679.png\" alt=\"\" class=\"wp-image-529\" srcset=\"https:\/\/meecarlo.com\/old\/wp-content\/uploads\/2020\/12\/shader1-1024x679.png 1024w, https:\/\/meecarlo.com\/old\/wp-content\/uploads\/2020\/12\/shader1-300x199.png 300w, https:\/\/meecarlo.com\/old\/wp-content\/uploads\/2020\/12\/shader1-768x509.png 768w, https:\/\/meecarlo.com\/old\/wp-content\/uploads\/2020\/12\/shader1.png 1260w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>\u521b\u5efa\u6211\u4eec\u7684custom function\uff0c\u8fd9\u91cc\u8981\u6ce8\u610f\u4e24\u4e2a\u70b9\uff0c\u9996\u5148\u662fName\u8fd9\u91cc\u8981\u4e0e\u4ee3\u7801\u4e2d\u7684\u51fd\u6570\u540d\u4e00\u6837\uff0c\u7136\u540e\u8f93\u51fa\u7684\u4e09\u4e2a\u53c2\u6570\u7684\u4e0a\u4e0b\u987a\u5e8f\u5e94\u8be5\u4e0e\u51fd\u6570\u4e2d\u7684\u4e09\u4e2a\u987a\u5e8f\u76f8\u540c\uff0c\u4e14\u547d\u540d\u76f8\u540c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6211\u4eec\u6765\u56de\u987e\u4e0b\u5982\u4f55\u5236\u4f5c\u5361\u901a\u6750\u8d28\uff0c\u6211\u4eec\u7528\u4e24\u4e2aPass\u6765\u5b9e\u73b0\uff0c\u4e00\u4e2aPass\u7528\u6765\u6e32\u67d3\u80cc\u90e8\u6765\u8fbe\u5230\u63cf\u8fb9\u7684\u6548\u679c\uff0c\u4e00\u4e2aPass &hellip; <a href=\"https:\/\/meecarlo.com\/old\/2020\/10\/12\/shader%e5%85%a5%e9%97%a8-4-%e5%8d%a1%e9%80%9a%e6%9d%90%e8%b4%a8%ef%bc%882-%e6%ad%a3%e5%bc%8f%e5%88%b6%e4%bd%9ctoon-shading%ef%bc%89\/\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">Shader\u5165\u95e8\u20144.\u5361\u901a\u6750\u8d28\uff082.\u6b63\u5f0f\u5236\u4f5cToon-Shading\uff09<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":336,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,1],"tags":[],"class_list":["post-159","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-study-note","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/meecarlo.com\/old\/wp-json\/wp\/v2\/posts\/159","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/meecarlo.com\/old\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/meecarlo.com\/old\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/meecarlo.com\/old\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/meecarlo.com\/old\/wp-json\/wp\/v2\/comments?post=159"}],"version-history":[{"count":3,"href":"https:\/\/meecarlo.com\/old\/wp-json\/wp\/v2\/posts\/159\/revisions"}],"predecessor-version":[{"id":570,"href":"https:\/\/meecarlo.com\/old\/wp-json\/wp\/v2\/posts\/159\/revisions\/570"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/meecarlo.com\/old\/wp-json\/"}],"wp:attachment":[{"href":"https:\/\/meecarlo.com\/old\/wp-json\/wp\/v2\/media?parent=159"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meecarlo.com\/old\/wp-json\/wp\/v2\/categories?post=159"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meecarlo.com\/old\/wp-json\/wp\/v2\/tags?post=159"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}