O'Reilly logo

Unity 4 Game Development HOTSHOT by Jate Wittayabundit

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Shader programming – Ambient and Specular light

In this step, we will add Ambient and Specular light to our shader script as well as create our custom lighting models.

Note

The custom lighting model is basically the function that will be used to calculate our surface shader, which is the output of the surf() function's interaction with the lights.

The surf() function is the function that will take any UVs or data we need as input and fill in the output structure SurfaceOutput (the predefined structure, such as Albedo, Normal, Emission, Specular, Gloss, and Alpha).

Engage thrusters

Let's get started. Go to MonoDevelop, open the MyShader file, and go to the Properties section and add the highlighted script:

Properties {
 _AmbientColor ("Ambient Color", ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required