- Unity 2018 Shaders and Effects Cookbook
- John P. Doran Alan Zucconi
- 392字
- 2021-06-18 19:04:13
Getting ready
To get started with this recipe, you will need to have Unity running and must have a project opened. As mentioned before, there will also be a Unity project included with this cookbook, so you can use that one as well and simply add your own custom shaders to it as you step through each recipe. With this completed, you are now ready to step into the wonderful world of real-time shading!
Before getting into our first shader, let's create a small scene for us to work with:
- Let's create a scene by navigating to File | New Scene.
- Once you create the scene, create a plane to act as the ground by going to GameObject | 3D Objects | Plane in the Unity editor. Next, select the object in the Hierarchy tab and then go into the Inspector tab. From there, right-click on the Transform component and select the Reset Position option:

This will reset the position property of the object to be at 0, 0, 0:
- To make it easier to see what our shaders will look like when applied, let's add some shapes to visualize what each of our shaders will do. Create a sphere by going to GameObject | 3D Objects | Sphere. Once created, select it and go to the Inspector tab. Next, change the Position to 0, 1, 0 so it is above the origin of the world (which is at 0, 0, 0) and our previously created plane:

- Once this sphere is created, create two more spheres, placing them to the left and right of the spheres at positions -2, 1, 0 and 2, 1, 0 respectively:

- Lastly, confirm that you have a directional light (it should be seen in the Hierarchy tab). If not, you can add one by selecting GameObject | Light | Directional Light to make it easier to see the effect of your changes and how your shaders react to light.
If you are using the Unity project that came with the cookbook, you can open up the Chapter 2 | Starting Point scene instead as it has been set up already.
推薦閱讀
- 黑客攻防從入門到精通(實戰(zhàn)秘笈版)
- The Complete Rust Programming Reference Guide
- ThinkPHP 5實戰(zhàn)
- Go語言高效編程:原理、可觀測性與優(yōu)化
- Learning Linux Binary Analysis
- Raspberry Pi 2 Server Essentials
- Python機器學(xué)習(xí)經(jīng)典實例
- C語言程序設(shè)計學(xué)習(xí)指導(dǎo)與習(xí)題解答
- Rust Essentials(Second Edition)
- Scala程序員面試算法寶典
- Python全棧數(shù)據(jù)工程師養(yǎng)成攻略(視頻講解版)
- Learning Cocos2d-JS Game Development
- Node.js 6.x Blueprints
- 網(wǎng)頁設(shè)計與制作
- 透視C#核心技術(shù):系統(tǒng)架構(gòu)及移動端開發(fā)