Uploaded November 2018 | Updated December 2026, 3 hours ago
A number of people have commented that we should be using step or smoothstep instead of some of the branching if/else blocks we've used in other videos (branches in shaders tend to perform worse than other functions). I've never tried using `step` or `smoothstep` before though so we'll need to learn what they do and how we might use them.
One of my favorite features of shaders is how easily they allow you to describe things visually. That's how we're going to go about learning `step`/`smoothstep` and hopefully it's a strategy you can apply to other functions you're unfamiliar with in other shaders.
To accomplish this we'll create a very simple shader that takes world space positions and plugs them into our function. We can combine this with a few different objects to explore what happens. A plane can provide a graph of the values and a cube can be used to probe the values at specific points more easily.
A few resources to learn more about `step`, `smoothstep` and other smoothing functions:
- thebookofshaders.com/05
- en.wikipedia.org/wiki/Smoothstep
Join the World of Zero Discord channel: discord.gg/hU5Kq2u
A number of people have commented that we should be using step or smoothstep instead of some of the branching if/else blocks we've used in other videos (branches in shaders tend to perform worse than other functions). I've never tried using `step` or `smoothstep` before though so we'll need to learn what they do and how we might use them.
One of my favorite features of shaders is how easily they allow you to describe things visually. That's how we're going to go about learning `step`/`smoothstep` and hopefully it's a strategy you can apply to other functions you're unfamiliar with in other shaders.
To accomplish this we'll create a very simple shader that takes world space positions and plugs them into our function. We can combine this with a few different objects to explore what happens. A plane can provide a graph of the values and a cube can be used to probe the values at specific points more easily.
A few resources to learn more about `step`, `smoothstep` and other smoothing functions:
- thebookofshaders.com/05
- en.wikipedia.org/wiki/Smoothstep
Join the World of Zero Discord channel: discord.gg/hU5Kq2u

![Calculating Dice Sides From A Meshs Normals
Today I wanted to take a closer look at an older video where we built a dice roller that used Dot Products to determine which face on a dice was rolled. The problem with that original solution was that you would need to manually enter each of the dices vertices to get an accurate result. Thats easy enough with a 6 sided dice, but becomes extremely annoying and tedious when you add more sides at awkward angles. Fortunately one of the things programming is great at is automating tedious things and thats exactly what were going to explore here.
The solution Im hoping to build is fairly straight forward and actually doesnt take much time at all. We can extract normals from a mesh and then take the distinct set of normals as the set of possible sides for our dice. This actually can be written in a single line of code with some LINQ.
```csharp
Vector3[] CalculateNormals(Mesh mesh)
{
return mesh.normals.Distinct().ToArray();
}
```
The solution has a few issues though and well take a look at how we might solve some of them. When looking at an object like a cylinder for example well get a large number of sides calculated because each edge of the cylinder is a unique side of our dice. We probably dont actually want that to be the case. Well design a way we might be able to solve this before stepping back and taking a bit of a longer look at the problem.
The basic question of getting unique sides for a dice is solved, but if we want to advance this solution for more complicated shapes and allow it to handle not quite aligned vertices well need to do some more work. If you have an idea for a design, let me know! Otherwise Ill be here designing something to help us provide another solution.
The original Dice Roller was built in this video: https://www.youtube.com/watch?v=hmDF9PvMDVw
Join the World of Zero Discord Server: https://discord.gg/hU5Kq2u Calculating Dice Sides From A Meshs Normals](https://i.ytimg.com/vi/0Rnj7YQJfrc/mqdefault.jpg)
 where we created an interactive canvas you could collaboratively draw on with the rest of the world!
1. [Building Real-Time Web Apps with SignalR](https://www.youtube.com/watch?v=k5rdhYj6TB8)
2. [Connecting a Web App to SignalR](https://www.youtube.com/watch?v=c0zmYjQ8KWA)
3. [Creating a Real-Time Web Canvas](https://www.youtube.com/watch?v=hgq1CYEJg_Q)
You can see some of the other content I have planned outside this channel in the Microsoft Reactor (and even come to our in-person events) at the [Microsoft Reactor San Francisco Meetup Page](https://www.meetup.com/Microsoft-Reactor-San-Francisco/).
***
Join the World of Zero Discord Server: https://discord.gg/hU5Kq2u Adding Unity Support - SignalR in Unity - Part 2](https://i.ytimg.com/vi/0mk-Kjab4as/mqdefault.jpg)




You can use the `CreateAssetMenuAttribute` to [create asset menus and more easily create new `ScriptableObject`s](https://docs.unity3d.com/ScriptReference/CreateAssetMenuAttribute.html).
Join the World of Zero Discord Server: https://discord.gg/hU5Kq2u Using Scriptable Objects in Unity](https://i.ytimg.com/vi/2P4oPtU2Rtk/mqdefault.jpg)


: Multiline strings expand the normal textbox a fixed number of vertical lines. This is less flexible than a `TextArea` but can still be useful in some situations.
* [`TextArea`](https://docs.unity3d.com/ScriptReference/TextAreaAttribute.html): Text Areas span between a minimum and maximum number of lines and - unlike a `Multiline` attribute - they will add scrollbars if the text exceeds the maximum number of lines. Additionally the `TextArea` spans the entire width of the Inspector giving more room to type.
The JSON.NET documentation is available here: https://www.newtonsoft.com/json/help/html/Introduction.htm
***
Join the World of Zero Discord Server: https://discord.gg/hU5Kq2u An Intro to Json Serialization and Deserialization in Unity](https://i.ytimg.com/vi/3F4HjM_5hZY/mqdefault.jpg)
