官术网_书友最值得收藏!

How it works...

When you declare a new property in the Properties block, you are providing a way for the shader to retrieve the tweaked value from the material's Inspector tab. This value is stored in the variable name portion of the property. In this case, _AmbientColor, _Color, and _MySliderValue are the variables in which we are storing the tweaked values.

In order for you to be able to use the value in the SubShader block, you need to create three new variables with the same names as the property's variable name. This automatically sets up a link between these two so that they know they have to work with the same data. Additionally, it declares the type of data that we want to store in our SubShader variables, which will come in handy when we look at optimizing shaders in a later chapter. Once you have created the SubShader variables, you can then use the values in the surf() function. In this case, we want to add the _Color and _AmbientColor variables together and take it to a power of whatever the _MySliderValue variable is equal to in the material's Inspector tab. The vast majority of shaders start out as Standard Shaders and get modified until they match the desired look. We have now created the foundation for any Surface Shader you will create that requires a diffuse component.

Materials are assets. This means that any change made to them while your game is running in the editor are permanent. If you have changed the value of a property by mistake, you can undo it using Ctrl Z.

主站蜘蛛池模板: 阆中市| 福建省| 绥江县| 泰安市| 新化县| 基隆市| 博客| 汉沽区| 天长市| 吉林市| 阳曲县| 扎鲁特旗| 孟州市| 荆门市| 繁昌县| 石楼县| 扶余县| 屏东县| 桐城市| 稷山县| 美姑县| 阿拉善左旗| 三都| 通河县| 昭苏县| 乳山市| 攀枝花市| 漳平市| 雷州市| 邯郸市| 蒙阴县| 奉贤区| 镇平县| 临沭县| 通道| 霍林郭勒市| 伊春市| 绥芬河市| 怀远县| 佛教| 通海县|