【Unity Shader】第二节 为上一节课的shader增加属性
来源:互联网 发布:手机注册淘宝店铺 编辑:程序博客网 时间:2024/04/28 23:16
昨天的代码里讲到了Properties这个里面显示的是给Unity GUI上显示的名字,到底可以显示哪些呢?
今天的内容就是给昨天的shader增加新的功能
In our Properties block of our Shader, remove the current property by deleting the
following code from our current Shader.
_MainTex ("Base (RGB)", 2D) = "white" {}
2. Now enter the following code, save the Shader, and re-enter the Unity editor.
_EmissiveColor ("Emissive Color", Color) = (1,1,1,1)
3. When you return to Unity, the Shader will compile and you will see that our Material's
Inspector tab now has a color swatch, named Emissive Color, instead of a texture
swatch. Let's add one more and see what happens. Enter the following code:
_AmbientColor ("Ambient Color", Range(0,10)) = 2
Chapter 1
4. We have added another Color Swatch to the Material's Inspector tab. Now let's
add one more to get a feel for other kinds of properties that we can create. Add the
following code to the properties block:
_MySliderValue ("This is a Slider", Range(0,10)) = 2.5
可以增加:
_MainTex ("Base (RGB)", 2D) = "white" {}
_AmbientColor ("Ambient Color", Color) = (1,1,1,1)
_EmissiveColor ("Emissive Color", Color) = (1,1,1,1)
_MySliderValue ("This is a Slider", Range(0,10)) = 2.5
Shader "CookbookShaders/BasicDiffuse"{//We define Properties in the properties blockProperties{_EmissiveColor ("Emissive Color", Color) = (1,1,1,1)_AmbientColor ("Ambient Color", Color) = (1,1,1,1)_MySliderValue ("This is a Slider", Range(0,10)) = 2.5}SubShader Diffuse Shading{Tags { "RenderType"="Opaque" }LOD 200CGPROGRAM#pragma surface surf Lambert//We need to declare the properties variable type inside of theCGPROGRAM so we can access its value from the properties block.float4 _EmissiveColor;float4 _AmbientColor;float _MySliderValue;struct Input{float2 uv_MainTex;};void surf (Input IN, inout SurfaceOutput o){//We can then use the properties values in our shaderfloat4 c;c = pow((_EmissiveColor + _AmbientColor), _MySliderValue);o.Albedo = c.rgb;o.Alpha = c.a;}ENDCG}FallBack "Diffuse"}
- 【Unity Shader】第二节 为上一节课的shader增加属性
- Unity Shader修改Shader属性
- Unity Shader 属性及标签
- Unity的shader
- 基本的unity shader
- unity shader的组织形式
- Shader 学习二:Unity shader 的组织形式
- Unity Shader学习笔记:简单的shader
- Unity shader教程-第二课:Shader的框架和Properties详细介绍
- unity shader
- Unity Shader
- Unity-Shader
- unity shader
- Unity Shader
- Unity Shader
- Unity Shader
- unity shader
- Unity Shader入门精要读书笔记第二篇
- Java方法继承、方法重载、方法覆盖小总结
- Matlab plotmatrix 子坐标轴控制
- MySql数据库操作
- 图像处理中的数学原理详解(已发布的部分链接整理)
- C语言实现栈
- 【Unity Shader】第二节 为上一节课的shader增加属性
- Slider
- servlet初始
- http://blog.csdn.net/singwhatiwanna/article/details/42343847
- 自定义进度弧形条
- 2016 Multi-University Training Contest 1 1002 hdu 5724 博弈
- php % (末)
- C语言实现队列
- 改变ListView的item条目按下瞬间的背景