- Unity 2018 Shaders and Effects Cookbook
- John P. Doran Alan Zucconi
- 273字
- 2021-06-18 19:04:15
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.
- OpenStack Cloud Computing Cookbook(Third Edition)
- AngularJS Testing Cookbook
- Java高手真經(jīng)(高級編程卷):Java Web高級開發(fā)技術(shù)
- MariaDB High Performance
- PostgreSQL 11從入門到精通(視頻教學(xué)版)
- Java程序設(shè)計(jì)與實(shí)踐教程(第2版)
- The HTML and CSS Workshop
- Node.js Design Patterns
- 青少年學(xué)Python(第1冊)
- CoffeeScript Application Development Cookbook
- Managing Microsoft Hybrid Clouds
- 深入解析Java編譯器:源碼剖析與實(shí)例詳解
- 官方 Scratch 3.0 編程趣味卡:讓孩子們愛上編程(全彩)
- PHP Microservices
- Java Web開發(fā)教程:基于Struts2+Hibernate+Spring