Unity Shaders and Effects Cookbook: Chapter 6

Chapter 6: Transparency

In chapter 6 you learn the following:

  • Creating transparency with alpha
  • Transparent cutoof shader
  • Depth sorting with render queus
  • GUI and transparency

In chapter 6, you practice how to construct a simple Shader using transparency, create Shaders for objects like hair, learn about depth sorting or the draw order of objects and finally finish by creating a GUI texture for a game menu.

From a beginners point of view, the best points parts of this chapter are that you are told about the default render queues provided to you by Unity with an explanation of the use of each.  Also, you are talked through an error that is encountered when implementing the game GUI.  The reason why it has occurred is explained along with the resolution helping you to learn from your mistake.

A positive of this chapter is that you are introduced to two types of transparency when dealing with Shaders: cutoff and semi-transparent and right at the beginning it is explained which is the better technique to use when creating games for mobile devices as opposed to desktop or consoles.  Invaluable advice right there. 

The only negative point that I will mention is not about what the chapter has included but what the book overall so far has missed including.  During the last section they mention an error and described how to overcome, yet this is not done throughout the book.  From a beginner’s point of view, this would have been very helpful and a great way to show those that are practically working through each section to mention the common mistakes or pitfalls with the specific techniques and how to overcome them.

In conclusion, I would say the difficulty rating of this chapter is Average/Challenging with the last recipe leaning more towards something more challenging.  This chapter will be extremely useful when creating Shaders for realistic looking, 3D games so my advice is to hone your skills and master the techniques presented here if you intend to build a 3D game project.

Read my reviews for previous chapters of this book:

Unity Shaders and Effects Cookbook is available from PacktPubAmazon.co.ukAmazon.com, Kindle etc http://bit.ly/1eu8XpD

Unity Shaders and Effects Cookbook: Chapter 5

Chapter 5: Lighting Models

In chapter 5 you learn the following:

  • The Lit Sphere lighting model
  • The diffuse convolution lighting model
  • A vehicle paint lighting model
  • The Skin shader
  • The Cloth shader

In chapter 5, you practice how to create textures that are used as lighting in Shaders, blur the details of the Shader but not diminish the lighting, you put all your knowledge together so far and create a production-ready car shader. Lastly, you’ll learn techniques which are widely used in a multitude of 3D games, creating skin and cloth shaders.

From a beginners point of view, the best points parts of this chapter are the most difficult, the skin and cloth shaders, as they stretch your knowledge and grow your skills.  Youy may have to practice this a couple of times to really understand the basics but after you have mastered these, you’ll be armed with two techniques that will be useful across a number of genres.

A positive of this chapter is that you are introduced to an external tool called MaCrea.  MaCrea allows you to create the textures that will become the lighting in the Shader and you’re shown the basics of using it. This tool is free to use and if you need anymore information you are pointed to videos on Vimeo. The vehicle paint lighting model section is also good because it helps you consolidate all that you’ve learned so far so you can see the fruits of your labour.

In conclusion, this chapter adds another set of valuable skills to your knowledge of Shaders.  The realism of games is getting better and better and in the last 5 years has come along in leaps and bounds so in most companies being able to create a realistic looking Shader for skin or cloth will be a useful skill.  If you don’t plan on making games with a realistic art style, this is still a good skill to have in your Shaders arsenal.  Overall I would say the difficulty rating of this chapter is Average/Challenging.

Read my reviews for previous chapters of this book:

Unity Shaders and Effects Cookbook is available from PacktPubAmazon.co.ukAmazon.com, Kindle etc http://bit.ly/1eu8XpD

Mastering Unity 4 Scripting

If you’re new to scripting in Unity 4, want to brush up on some techniques or fill some gaps in your skills then you should try Mastering Unity 4 Scripting video series by Kyle D’Aoust and published by PacktPub.

The course content includes:

  • Creating a Background Audio Controller
  • Incorporating Sound Effects
  • How to make 2D Parallax Backgrounds
  • How to make 3D Parallax Backgrounds
  • Creating an Enemy Character Controller
  • Creating Enemy AI
  • Creating Level Changing Systems
  • Creating an Item Carry-Over System

Mastering Unity 4 Scripting is now available on PacktPub http://bit.ly/1bvUOMU.

Unity Shaders and Effects Cookbook: Chapter 4

Chapter 4: Reflecting Your World

In chapter 4 you learn the following:

  • Creating Cubemaps in Unity3D
  • Simple Cubemap reflection in Unity3D
  • Masking reflections in Unity3D
  • Normal maps and Reflections in Unity3D
  • Fresnel reflections in Unity3D
  • Creating a simple dynamic Cubemap system in Unity3D

In chapter 4 you will find techniques introducing you to Cubemaps, simulating reflections in Cubemaps, creating effects like frosted glass or the surface of an ice cube, fresnel reflections like those seen on the body of a car and switching Cubemaps of your shader when the environment changes.

From a beginners point of view the best points of this chapter are that you are taught how to create a custom Cubemaps for your projects.  It walks you through so that someone with no knowledge of Cubemaps can easily follow the examples and understand where to use them.  You are also pointed to some online example resources for generating Cubemaps.

The positives of this chapter is that is gives you a great understanding of Cubemaps, where and how to implement them.  There are no negatives in this chapter but you will have to sit down and work through the basics of creating Cubemaps before jumping to the latter sections.  This is definitely a chapter that I recommend you working your way from start to finish.

In conclusion,  this chapter introduces a new level of complexity and will add further depth to your projects shaders, but you need to fully understand where and how to implement them correctly so that the performance of your game is not compromised especially at pivotal points in the gameplay.  I’d rate the difficulty rating for this chapter as Average.

Read my reviews for previous chapters of this book:

Unity Shaders and Effects Cookbook is available from PacktPubAmazon.co.ukAmazon.com, Kindle etc http://bit.ly/1eu8XpD

Unity Shaders and Effects Cookbook: Chapter 3

Chapter 3: Using Textures for Effects

In chapter 3 you learn the following:

  • Utilizing Unity3D’s built-in Specular type
  • Creating a Phong Specular type
  • Creating a BlinnPhong Specular type
  • Masking Specular with textures
  • Metallic versus soft Specular
  • Creating an Anisotropic Specular type

In chapter 3 you will find techniques that introduce you to setting up Specular, Phong and BlinnPhong Specular effects; how to combine two different types of Specular’s; changing the properties of a Specular to create a soft or hard looking effect which is useful when you want the same shader for a soft, shiny object then a hard metallic object.  Lastly, you look at how to modify/stretch the Specular in a direction which can be used to create the effect of brushed metal, like on the underside of a CD.

From a beginner’s point of view, the best parts of this chapter are the sections which introduce to setting up the Specular effects as they are in depth and easy to follow. Although we are now entering a higher level of complexity don’t be put off trying to use these effects.

A slight negative with these two introduction sections is that although you are told when to use the BlinnPhong Specular type, you are not told when to use the Phong type or if you should use it at all after learning the BlinnPhong type so more investigation alongside this book may be needed.

A positive of this chapter is that there are links to external resources that give you more information about techniques used in sections, like within Metallic versus soft Specular, for information regarding Cook Torrance Specular on page 79.

With the basics covered, you are ready to learn techniques that imitate the effects you see on everyday items like CDs and cloth in the later sections. When I learn new techniques I find it’s sometimes not very clear when to use them, but this is not the case here. It is very clear from the examples when and on what objects to use these effects on.

In conclusion, this chapter starts to introduce more complex but useful techniques that you see in everyday life so I’d rate the difficulty of this chapter as Average. But, like the previous chapters, you are walked through each section slowly so you can understand and implement the technique effectively. With the additional links listed at the end of some of the sections you are also pointed to more information to give you background on the effect, tool or technique and a detailed understanding.

Read my reviews for previous chapters of this book:

Unity Shaders and Effects Cookbook is available from PacktPubAmazon.co.ukAmazon.com, Kindle etc http://bit.ly/1eu8XpD

Unity Shaders and Effects Cookbook: Chapter 2

In this post I talk about my thoughts on the second chapter of the Unity Shaders and Effects Cookbook.  Even though I may give recommendations on what chapters I find are useful I would advise and encourage beginners to read the entire book chapter by chapter and to work through each example within the Unity Engine

Obviously your projects may require different techniques so I’ll try and give an example of  how they can be useful and for what.

Chapter 2: Using Textures for Effects

In chapter 2 you learn the following:

  • Scrolling textures by modifying UV values
  • Animating sprite sheets
  • Packing and blending textures
  • Normal mapping
  • Creating procedural textures in the Unity editor
  • Photoshop levels effect

Chapter 2 begins to introduce you to techniques that are widely used within game development to create effects that you find in most AAA titles.  You will find techniques that are useful for creating flowing liquids such as water and lava; animating sprites e.g. for 2D games; combining textures to create materials with multiple textures e.g. ground materials and using textures to create depth on a flat objects e.g. for brick walls.

After the introduction where you are shown the product of the recipe, you start with Getting Ready which talks you through the basics of the set up.  How To Do It walks you through a step by step set up of using this technique and How It Works explains what you have just done.  Lastly, Theres More provides you with other ways to adapt or extend what you have just created to build something more .

From a beginner’s point of view I would recommend reading chapter one as you are not taught how to set up a basic shader anymore.  So although the recipes do provide you with a step by step guide in How To Do It, you will not be walked through information that you have previously learned in earlier chapters. Once you are familiar with the basics, you’re able to jump to any recipe that you feel is suitable for your project, instead of going through each one.

As these recipes don’t go over basics if you have previously learned them, it would be good to have been referred back to specific recipes on pages that deal with the basics of e.g. setting up a basic shader.

For a beginner, I found all of these recipes useful but animating textures and packing a blending textures will be of general use on a wider range of projects that I’ll be  working on in the future.

On the whole, the topics within these recipes did not require a massive jump in knowledge from chapter 1 to chapter 2  and you are still touching on some techniques that I would consider rather basic in a AAA title so I would rate the difficulty of this chapter as Novice/Average.

Read my review for Chapter 1 of this book here.

Unity Shaders and Effects Cookbook is available from PacktPubAmazon.co.uk, Amazon.com, Kindle etc http://bit.ly/1eu8XpD

Unity Shaders and Effects Cookbook: Chapter 1

As my first released title was a 2D game I had little need to use shaders within the Unity engine.  However, my future projects will require a more extensive use of the engine and its features so I started looking for resources that would teach me more about these.  I then stumbled across a conversation on LinkedIn about a book published by PacktPub called Unity Shaders and Effects Cookbook.  The book is written by Kenny Lammers and is based on version 4 of the Unity 3D engine.

I want to try and give an accurate account of the use of this book from the perspective of a someone who knows the basics of the Unity engine but is completely new to shaders.  As I write these reviews I won’t be able to work through all examples, but if anyone has questions relating to anything in the book I’d be happy to put my head down to solve it with you.  Just contact me.

Chapter 1: Diffuse Shading

In chapter 1 you learn the following:

  • Creating a basic Surface Shader
  • Adding properties to a Surface Shader
  • Using properties in a Surface Shader
  • Creating a custom diffuse lighting model
  • Creating a Half Lambert lighting model
  • Creating a ramp texture to control diffuse shading
  • Creating a faked BRDF using a 2D ramp texture

Chapter 1 is a great introduction to the world of shaders for beginners within Unity.  The earlier information within the chapter also gives non-Unity users a good basis so they can grasp the concept of shaders and how they can be used within a game project.

Although this is a good book for beginners new to shaders, having basic knowledge of the Unity editor and programming I’d say is a definite must.  The terms used, although not complex, may confuse someone not used to common terms associated with scripting and programming e.g. variables.  Saying that I found the language very easy to understand and follow at each stage within the recipes.

Each recipe is self-contained which is useful as you can work through each individually. During the preface they do state that the book has been designed so that beginners or those wishing to pick up the book for specific recipes can jump to whichever chapter they require without the need to read the book from start to finish.  I would disagree with this statement solely from the perspective of a beginner new to shaders.  I think that by skipping chapter 1, as a beginner, you will miss a wealth of information that’s helpful and that you will build upon through the subsequent recipes in later chapters.  So if you’re a beginner read chapter 1, then I’d advise you to pick the chapter or recipe to work from which is more closely related to your project or work through the book from start to finish.

I’ve done a lot of flicking back and forth within the book as the recipes first start by showing you the goal then step through how to achieve it.  So this format is taking me a bit of getting used to (as it’s only the second cookbook I’ve read) but I having an eBook version is definitely helping. The only bit of constructive criticism that I would say about this chapter is that with each recipe it would be handy to have an example of what the technique you were learning could be applied to, but as this is a chapter on the basics I suppose that’s anything.

Overall, chapter 1 is a good introduction and a must read in my opinion.  A good start.

Unity Shaders and Effects Cookbook is available from PacktPub, Amazon.co.uk, Amazon.com, Kindle etc http://bit.ly/1eu8XpD

Try my game – Werdz Movies out now!

werdz_feature_imageI’ve released my first android title, Werdz Movies.  It’s suited for movie goers of all ages and has free-to-play content which gives you 120+ movies to guess.  I’ll also be planning to expand this basic set of packs in the future with additional genres to help those who are particularly strong within some genre’s over others.

Other than expansion packs I’ll be learning more along my Unity journey trying to implement all the features that apps nowadays just have to have.

The updates I’ve planned should be monthly but if you have any other ideas of how I can improve the title please let me know via my new website Junction 5 Studios.

I’ll also be writing a post mortem about my experiences with Unity, JavaScript and part-time indie game development over this past year to hopefully help others who are thinking about making a similar move.

Please Like Werdz Movies on the Facebook page

Download and review the app