O'Reilly logo

Unity 3 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 the ambient and specular light to our 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 (surf() function) interaction with the lights.

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

  1. Go to MonoDevelop, open MyShader.shader file, and go to the Properties section and add the highlighted script as follows:
    Properties { _MainTex ("Texture", 2D) = "white" {} _BumpMap ...

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