Vscode for Unity Shader 用户代码片段(持续更新)_vscode写unity shader_TA_Soli的博客-程序员宅基地

技术标签: unity  shader  Shader  

使用方法:打开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",
            "\tif(_CameraDepthTexture_TexelSize.y <0){",
            "\t\tuv.y = 1 - uv.y;",
            "\t}"   ,
            "#endif"
        ],
        "description": "check if our platforms work with top-to-bottom coordinates"
    },

    "SHADOW_CASTER_FRAGMENT":{
    
        "prefix": "SHADOW_CASTER_FRAGMENT",
        "body": "SHADOW_CASTER_FRAGMENT($0)",
        "description": "shadow caster"
    },

    "UnityApplyLinearShadowBias":{
    
        "prefix": "UnityApplyLinearShadowBias",
        "body": "UnityApplyLinearShadowBias($0);",
        "description": "Applying the bias prevents artifacts from appearing on the surface"

    },
    "Toggle":{
    
        "prefix": "Toggle",
        "body": "Toggle",
        "description": "Make a toggle visual on the panel"
    },

    "UNITY_PROJ_COORD":{
    
        "prefix":"UNITY_PROJ_COORD",
        "body": "UNITY_PROJ_COORD($0)",
        "description": "处理平台差异,一般直接返回输入的值"
    }
}

效果示例:
在这里插入图片描述
在这里插入图片描述

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/weixin_42653501/article/details/106923277

智能推荐

We‘re sorry but web-admin doesn‘t work properly without JavaScript enabled. Please enable it to cont_we're sorry but iview-admin doesn't work properly -程序员宅基地

前言: 这里是vue获取本地js文件报错。报错截图:报错原因:history的话必须后端来配合,这里请求本地文件的时候,是默认一个服务地址,并不是我们的直接路径,请求报错,解决办法:1、将history改成hash2、使用history,请求后端同时在nginx配置允许访问,..._we're sorry but iview-admin doesn't work properly without javascript enabled

用例设计方法-程序员宅基地

用例设计方法用例设计方法三角形用例黑白盒动静态用例设计方法动态黑盒测试测试对象数据与程序通过测试等价类边界值因果图判定表数据流分析流程分析状态转换图无经验假设错误推测探索测试动态白盒测试白盒测试与单元测试测试对象数据与程序语句覆盖分支覆盖路径覆盖基本路径测试减少路径覆盖用例循环测试经验积累引入测试策略的概念 书是要带着目的去读的。华罗庚的读书法_用例设计方法

weave 命令行参数-程序员宅基地

weave --help | help weave setup weave version weave launch [--password <password>] [--nickname <nickname>] ...

OpenGL学习(一)VAO,VBO,EBO_opengl不同立方体的vao和vbo怎么设置-程序员宅基地

下面,你会看到一个图形渲染管线的每个阶段的抽象展示。要注意蓝色部分代表的是我们可以注入自定义的着色器的部分。渲染管线的东西我就不详细说了,首先我们在openGL绘制图形前,必须先输入一些顶点数据(在OpenGL中我们必须输入NDC坐标,才能可见),然后我们会把它作为输入发送给图形渲染管线的第一个阶段:顶点着色器。它会在GPU创建内存用与储存这些数据,还要要配置OpenGL如何解释这些内存,并且指定其如何发送给显卡,然后顶点着色器就可以处理我们指定的数据了。那么我们如何管理这个内存呢,这里引出这_opengl不同立方体的vao和vbo怎么设置

AD中off grid pin问题解决_off grid ad软件-程序员宅基地

AD软件在使用过程中提示“off grid pin”的警告,并不是原理图电气连接出问题了,而是元器件或者器件PIN脚没有和栅格对齐造成的原因,解决办法如下:(1)打开AD,点击“工程”-“工程参数”(2)“Error Reporting”-“Violation Associated with Others”-“off-grid object”-鼠标右键点击-“被选关闭”..._off grid ad软件

MATLAB如何生成勒让德序列,matlab实现勒让德多项式拟合-程序员宅基地

Legendre polynomial fittingFinds the weighting coefficients of the linear combination of a set of Legendre polynomials up to order N.Three methods are available (actually just for fun): 'inv' (default..._勒让德序列

随便推点

GPU随想——OpenGL函数加载流程_gpu随想——opengl辅助工具-程序员宅基地

导航: GLX基本流程 OpenGL函数的分发 到底什么是context?-----------------------------读前须知-------------------------历代dri:dri1、dri2、dri3 根据wikipedia词条等整理。另,对X窗口系统方面有兴趣的读者可以阅览Keith Packard(80年代就开始参与设计并开发X窗口系统了,无需赘言……btw,另一位厉害的人物是Kristian Høgsberg)的博客,wikipedia中的不少内容也借鉴与此。_gpu随想——opengl辅助工具

剑指offer 10- II. 青蛙跳台阶问题-程序员宅基地

剑指offer 10- II. 青蛙跳台阶问题题目描述解题思路此题就是斐波那契数列的变体。class Solution { public int numWays(int n) { if (n == 0 || n == 1) return 1; if (n == 2) return 2; //base case int dp_0 = 1, dp_1 = 2; int res = -1; for

服务器文件更改审核,查看文件服务器修改写删除文件的记录设置方法------通过设置文件夹审核策略...-程序员宅基地

windows可以使用审核策略跟踪用于访问文件或其他对象的用户账户、登录尝试、系统关闭或重新启动以及类似的事件,而审核文件和NTFS分区下的文件夹可以保证文件和文件夹的安全。为文件和文件夹设置审核的步骤如下:第一步,在组策略窗中(文件服务器在DC上此时打开域控制器策略),逐级展开左侧窗口中的“计算机配置”→“Windows设置”→“安全设置”→“本地策略”分支,在该分支下选择“审核策略”选项。第二...

ATC分类模型转换工具报错: opname[data] is not exist_华为升腾atc 模型转化出现了utf-8错误_南沙的星星的博客-程序员宅基地

华为ATC分类模型转换工具报错:root@zhou:/media/sf_share/08-model/resnet50# atc --model=ResNet-50-deploy-2.prototxt --weight=resnet50.caffemodel --framework=0 --output=resnet50 --soc_version=Ascend310 --input_format=NCHW --input_fp16_nodes=data -output_type=FP32 --out_n_华为升腾atc 模型转化出现了utf-8错误

教你如何突破被拒绝的13种方法(精典)业务员必看-程序员宅基地

1.如果客户说:“我没时间!”那么推销员应该说:“我理解。我也老是时间不够用。不过只要3分钟,你就会相信,这是个对你绝对重要的议题……”   2.如果客户说:“我现在没空!”推销员就应该说:“先 生,美国富豪洛克菲勒说过,每个月花一天时间在钱上好好盘算,要比整整30天都工作来得重要!我们只要花25分钟的时间!麻烦你定个日子,选个你方便的时间!我星期一和星期二都会在贵公司附近,所以可以在星期一上午或

Mysql--Host 'xxx' is blocked because of many connection errors;unblock with 'mysqladmin flush-hosts'-程序员宅基地

报错信息:1、后台控制台报错:2018-12-17 10:41:48.643 ERROR 4768 --- [eate-1259283097] com.alibaba.druid.pool.DruidDataSource : create connection error, url: jdbc:mysql://192.168.160.129:3306/znbt?autoReconn...

推荐文章

热门文章

相关标签