|
使用方法:打开vscode,文件→首选项→用户片段,输入shaderlab,复制粘贴即可 - {
- // Place your snippets for shaderlab here. Each snippet is defined under a snippet name and has a prefix, body and
- // description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
- // $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
- // same ids are connected.
- // Example:
- // "Print to console": {
- // "prefix": "log",
- // "body": [
- // "console.log('$1');",
- // "$2"
- // ],
- // "description": "Log output to console"
- // }
- "Unity3D Shaderlab": {
- "prefix": "shaderlab",
- "body":[
- "Shader \"${1:New Shader}\"",
- "{",
- "\tProperties",
- "\t{",
- "\t\t_MainTex (\"Texture\", 2D) = \"white\" {}",
- "\t}",
- "\tSubShader",
- "\t{",
- "\t\tTags { \"RenderType\"=\"${2:Opaque}\" }\n",
- "\t\tPass",
- "\t\t{",
- "\t\t\t$3",
- "\t\t}",
- "\t}",
- "}"
- ],
- "description": "Unity3D Shaderlab"
- },
- "Unity3D SurfaceShader":{
- "prefix": "surfaceShader",
- "body": [
- "Shader \"${1:New Shader}\"",
- "{",
- "\tProperties",
- "\t{\n",
-
- "\t}",
- "\tSubShader",
- "\t{",
- "\t\tTags { \"RenderType\"=\"${2:Opaque}\" \"Queue\"=\"${3:Geometry}\" }\n",
- "\t\tCGPROGRAM",
- "\t\t#pragma surface surf Standard\n",
- "\t\tstruct Input{\n",
- "\t\t};\n\n",
-
- "\t\tvoid surf(Input IN,inout SurfaceOutput o) {\n",
-
- "\t\t}",
- "\t\tENDCG",
- "\t}",
- "\tFallBack \"Diffuse\"",
- "}"
-
- ],
- },
- "CGPROGRAM": {
- "prefix": "cg",
- "body": [
- "CGPROGRAM",
- "#pragma vertex vert",
- "#pragma fragment frag\n",
- "#include \"UnityCG.cginc\"\n",
- "struct appdata",
- "{",
- "\tfloat4 vertex : POSITION;",
- "\tfloat2 uv : TEXCOORD0;",
- "};\n",
- "struct v2f",
- "{",
- "\tfloat2 uv : TEXCOORD0;",
- "\tfloat4 vertex : SV_POSITION;",
- "};\n",
- "sampler2D _MainTex;\n",
- "v2f vert(appdata v)",
- "{",
- "\tv2f o;",
- "\to.vertex = UnityObjectToClipPos(v.vertex);",
- "\to.uv = TRANSFORM_TEX(v.uv, _MainTex);\n",
-
- "\treturn o;",
- "}\n",
-
- "fixed4 frag(v2f i) : SV_Target",
- "{",
- "\t// sample the texture",
- "\tfixed4 col = tex2D(_MainTex, i.uv);",
- "\treturn col;",
- "}",
- "ENDCG"
- ],
- "description": "Unity3D Shaderlab CGPROGRAM"
- },
- "Multi Lighting Control":{
- "prefix": "multi_compile_fwdbase",
- "body": [
- "multi_compile_fwdbase",
-
- ],
- "description": "instructs Unity to compile all variants necessary for forward base rendering"
- },
- "Shadow Caster":{
- "prefix": "multi_compile_shadowcaster",
- "body": [
- "multi_compile_shadowcaster",
-
- ],
- "description": "ensures that the shader compiles all necessary variants required for shadow casting"
- },
- "SHADOW_ATTENUTATION":{
- "prefix": "SHADOW_ATTENUATION",
- "body": [
- "SHADOW_ATTENUATION($0)",
- ],
- "description": "a macro that returns a value between 0 and 1, where 0 indicates no shadow and 1 is fully shadowed"
- },
- "Camera Depth Texture":{
- "prefix": "_CameraDepthTexture",
- "body": "_CameraDepthTexture",
- "description": "the depth buffer globally available that Unity provides"
- },
- "Linear Eye Depth":{
- "prefix": "LinearEyeDepth",
- "body": "LinearEyeDepth($0)",
- "description": " convert the raw value to the linear depth"
- },
- "SAMPLE_DEPTH_TEXTURE":{
- "prefix": "SAMPLE_DEPTH_TEXTURE",
- "body": "SAMPLE_DEPTH_TEXTURE(_CamperaDepthTexture,${float2:uv})",
- "description": "a macro that for sampling the background depth"
- },
- "UNITY_Z_0_FAR_FROM_CLIPSPACE":{
- "prefix": "UNITY_Z_0_FAR_FROM_CLIPSPACE",
- "body": "UNITY_Z_0_FAR_FROM_CLIPSPACE($0)",
- "description": "a macro that takes the Z component of screenPos—which is the interpolated clip space depth—and converts it to linear depth"
- },
- "Check Top-To-Bottom":{
- "prefix": "CheckTopToBottom",
- "body": [
- "#if Unity_UV_STARTS_AT_TOP",
- &#34;\tif(_CameraDepthTexture_TexelSize.y <0){&#34;,
- &#34;\t\tuv.y = 1 - uv.y;&#34;,
- &#34;\t}&#34; ,
- &#34;#endif&#34;
- ],
- &#34;description&#34;: &#34;check if our platforms work with top-to-bottom coordinates&#34;
- },
- &#34;SHADOW_CASTER_FRAGMENT&#34;:{
- &#34;prefix&#34;: &#34;SHADOW_CASTER_FRAGMENT&#34;,
- &#34;body&#34;: &#34;SHADOW_CASTER_FRAGMENT($0)&#34;,
- &#34;description&#34;: &#34;shadow caster&#34;
- },
- &#34;UnityApplyLinearShadowBias&#34;:{
- &#34;prefix&#34;: &#34;UnityApplyLinearShadowBias&#34;,
- &#34;body&#34;: &#34;UnityApplyLinearShadowBias($0);&#34;,
- &#34;description&#34;: &#34;Applying the bias prevents artifacts from appearing on the surface&#34;
- },
- &#34;Toggle&#34;:{
- &#34;prefix&#34;: &#34;Toggle&#34;,
- &#34;body&#34;: &#34;Toggle&#34;,
- &#34;description&#34;: &#34;Make a toggle visual on the panel&#34;
- },
- &#34;UNITY_PROJ_COORD&#34;:{
- &#34;prefix&#34;:&#34;UNITY_PROJ_COORD&#34;,
- &#34;body&#34;: &#34;UNITY_PROJ_COORD($0)&#34;,
- &#34;description&#34;: &#34;处理平台差异,一般直接返回输入的值&#34;
- }
- }
复制代码 使用示例:
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?立即注册
×
|