Shader(固定管线着色器)

来源:互联网 发布:李世默 知乎 编辑:程序博客网 时间:2024/06/07 06:04
//第一种Shader "VRShader/AlphaTestDemo" {    Properties{   _AlphaValue("透明度值",Range(0,1))=0.5   _Color("主颜色",Color)=(1,1,1,1)   _MainTex("主贴图",2D)=""{}}SubShader{Pass{    //透明度测试AlphaTest Greater [_AlphaValue]//顶点光照Lighting OnMaterial{Diffuse[_Color]}SetTexture[_MainTex]{//贴图与满发射颜色融合Combine Texture * Primary}}}}//第二种Shader "VRShader/ConstentShader02" {Properties {_Diffuse("Diffuse",Color)=(1,1,1,1)_Ambient("Ambient",Color)=(1,1,1,1)_Specular("Specular",Color)=(1,1,1,1)_Emission("Emission",Color)=(1,1,1,1)_Shininess("Shininess",Range(0.1,1))=1_MainTexture("MainTexture",2D)=""{}_DetailTexture("DetailTexture",2D)=""{}}SubShader{ Pass{Lighting On  //顶点光照       SeparateSpecular On  //镜面反射    //Blend SrcAlpha OneMinusSrcAlpha //开启Alpha透明通道    //Blend One One     //相加混合    //Blend One OneMinusDstColor  //柔和混合    //Blend DstColor Zero //相乘混合    //Blend DstColor SrcColor //2倍相乘混合   Material{      Diffuse[_Diffuse] //漫反射      Ambient[_Ambient] //环境光      Specular[_Specular] //高光      Emission[_Emission] //自发光      Shininess[_Shininess] //光泽度    }    SetTexture[_MainTexture]{    //constantColor创建一个固定颜色     constantColor(1,0,0,1)     //Texture表示当前图片---_MainTexture     //Constant表示固定颜色----constantColor的结果    combine Texture+Constant   }   //Texture表示当前图片-----DetailTexture   //Previlous表示上一次SetTexture后的结果   SetTexture[_DetailTexture]{   combine Texture*Previous Quad   }}    }}//第三种Shader "VRShader/ConstentShader03" {Properties {_Color("Color",Color)=(1,1,1,1)_Texture01("_Texture01",2D)=""{}_Texture02("_Texture02",2D)=""{}_LerpValue("插值参数",Color)=(1,1,1,1)}SubShader{Pass{  Material{Diffuse[_Color]}SetTexture[_Texture01]{combine texture * Primary}SetTexture[_Texture02]{ConstantColor[_LerpValue]combine Previous lerp(Constant) texture}}}}//第四种Shader "VRShader/ContentShaer01" {Properties{_DiffuseColor("漫反射颜色",Color)=(1,1,1,1)_AmbientColor("环境光颜色",Color)=(1,1,1,1)_Shininess("光泽度",Range(0.1,1))=0.1_Specular("高光颜色",Color)=(1,1,1,1)_Emission("自发光",Color)=(1,1,1,1)}SubShader{    //设置渲染队列    Tags{"Queue"="Transparent"}    Tags{"Queue"="Background+500"}Pass{//剔除前面Cull Front//打开顶点光照    Lighting On    //开启镜面反射    SeparateSpecular On    //关闭深度测试    Ztest Off    Material    {    //满反射    Diffuse[_DiffuseColor]    //环境光    Ambient[_AmbientColor]    //光泽度    Shininess[_Shininess]    //高光颜色    Specular[_Specular]    //自发光颜色    Emission[_Emission]    }}Pass{//剔除背面Cull Back//红色Color(1,0,0,1)}       }}//第五种Shader "VRShader/FirstShader" //定义shader的路径及名称{   //当前shader属性Properties{//定义一个浮点类型的属性//_FirstFloat-----变量名//“一个浮点数”在Inspector面板显示的该属性的名称(提示信息)//Float----变量类型//0.8-----变量初值_FirstFloat("一个浮点数",Float)=0.8//定义一个范围浮点数_FirstRange("一个范围数",Range(0,8))=4//定义一个四维数_FirstVector("一个四维数",Vector)=(1,2,3,4)//定义一个颜色_MainColor("主颜色",Color)=(0,0,255,1)//定义一个2阶贴图(宽高是2的N次幂)_MainTexture("主贴图",2D)=""{}//定义一个非2阶贴图_MainRect("副贴图",Rect)=""{}//定义一个立方体贴图_Cube("立方体贴图",Cube)=""{}}//子着色器(一个材质的解决方案)SubShader {//固定管线需要(Pass通道)Pass{//第一个Shader,渲染一个纯色//Color(1,1,0,1)//通过外部属性,渲染一个纯色//Color[_MainColor]            //开启顶点光照Lighting On//特殊材质 Material{//漫反射效果去渲染一个纯色Diffuse[_MainColor]}}    }    FallBack "Diffuse"}

0 0
原创粉丝点击