Uploaded November 2018 | Updated November 2026, 3 hours ago
There is still so much to learn in Unity's new Shader Graph feature. In this video our focus is twofold. We will be learning how to use Properties so our shaders can have their inputs tweaked without requiring us to recompile them, but we will also be revising some of the previous code we built based on some of the other stuff we've been learning. We'll drop the branching in our code in favor of the `step` function and will remove the Subgraph's we'd created because they're having trouble loading and it's preventing the Graph from being compiled into a new Shader.

The end result of this is will allow us to tweak the radius, location, inside and outside color of the circle we draw in world space. This allows us to do a lot more than we could previously even though we haven't really added that many new features. We also migrate to use an unlit shader instead of using the default PBR shader. This is new compared to our original surface shader and is closer to the end result we're trying to build. An unlit shader ignores lighting in the scene including things like global illumination and allows us to get a single consistent color across the entire surface our shaders material is applied to.
The World of Zero Discord Server: discord.gg/hU5Kq2u
There is still so much to learn in Unity's new Shader Graph feature. In this video our focus is twofold. We will be learning how to use Properties so our shaders can have their inputs tweaked without requiring us to recompile them, but we will also be revising some of the previous code we built based on some of the other stuff we've been learning. We'll drop the branching in our code in favor of the `step` function and will remove the Subgraph's we'd created because they're having trouble loading and it's preventing the Graph from being compiled into a new Shader.

The end result of this is will allow us to tweak the radius, location, inside and outside color of the circle we draw in world space. This allows us to do a lot more than we could previously even though we haven't really added that many new features. We also migrate to use an unlit shader instead of using the default PBR shader. This is new compared to our original surface shader and is closer to the end result we're trying to build. An unlit shader ignores lighting in the scene including things like global illumination and allows us to get a single consistent color across the entire surface our shaders material is applied to.
The World of Zero Discord Server: discord.gg/hU5Kq2u





![Exploring Top-Level Programs in C# 9
Top-Level Programs is a new feature being introduced in C# 9.0 that significantly simplifies certain C# programs and allows you to remove almost all of the boilerplate code from them. This pattern allows you to call functions at the top-level of your C# program meaning that you do not need a class or function definition in order to call those functions. Instead C# automatically generates that code for you when your code is compiled.
The simplest top-level program is just one line:
```csharp
System.Console.WriteLine(Hello, World of Zero!);
```
There are a few special features included with top-level programs that help you to fully use some of the features like accepting command line arguments or async functions.
### `args` variable
C#s top-level programs include a magic `args` variable which contains a `string[]` of command-line arguments provided. Here is a working example script that accepts a command line argument to greet you by name.
```csharp
using System;
// If there is 1 argument greet that argument by name
if (args.Length 1)
{
Console.WriteLine($Hello, {args[0]}!);
} else { // Otherwise greet a generic Internet 🤖
Console.WriteLine(Hello Internet!);
}
```
Use `dotnet run World of Zero` or similar to run this code and be greeted with Hello, World of Zero!
### `async` and `await` support
You may take advantage of async functions inside of a top-level program. This allows for things like async file operations, web requests etc to be made without having to wrap them in a separate async function.
For example this task will print two numbers with a short pause between them.
```csharp
using System;
using System.Threading.Tasks;
Console.WriteLine(One);
await Task.Delay(1000);
Console.WriteLine(Two);
```
***
More info about some of the new features in C# 9.0 and how to use them is available here: https://devblogs.microsoft.com/dotnet/welcome-to-c-9-0/
Join the World of Zero Discord Server: https://discord.gg/hU5Kq2u Exploring Top-Level Programs in C# 9](https://i.ytimg.com/vi/uxxROAx6MMU/mqdefault.jpg)
![Installing Nyancat using the .NET CLI
The .NET CLI includes the ability to install additional developer tools like powershell. This is a powerful feature that enables you to add tools to your developer environment without leaving your terminal. In this video well take full advantage of the feature by installing an animated nyancat tool. My productivity will never been the same!
To learn more run `dotnet tool help`.
You may use `dotnet tool install [PACKAGE_NAME]` and dotnet tool uninstall `[PACKAGE_NAME]` to install and uninstall packages.
The tool uses the same Nuget package manager that provides your dotnet libraries and chocolatey packages.
You can explore the available tools on [ToolGet](https://www.toolget.net/).
More information about managing dotnet tools: https://docs.microsoft.com/en-us/dotnet/core/tools/global-tools
Join the World of Zero Discord Server: https://discord.gg/hU5Kq2u Installing Nyancat using the .NET CLI](https://i.ytimg.com/vi/uzaFeSxM32k/mqdefault.jpg)


 a project for creating an interactive data notebook. Its extremely common among data scientists and python programmers as a way to document an AI model and show the data that is being worked on. We are able to take advantage of that same platform and provide a .NET runtime (.NET interactive) that allows us to compile and run .NET code in these notebooks. This gives us access to many of the same features while allowing us to write our code in C# or another .NET language.
***
* You can learn more about Project Jupyter here: https://jupyter.org/
* You can find more information about working with Jupyter Notebooks in VS Code here: https://code.visualstudio.com/docs/datascience/jupyter-notebooks
* The Jupyter extension for Visual Studio Code is available here: https://marketplace.visualstudio.com/items?itemName=ms-toolsai.jupyter
* .NET Interactive is open source on GitHub here: https://github.com/dotnet/interactive
***
Join the World of Zero Discord Server: https://discord.gg/hU5Kq2u Using .NET Interactive and Jupyter Notebooks](https://i.ytimg.com/vi/vlp4B6C81xQ/mqdefault.jpg)
 object. This provides information about the collider you impacted, the point of impact, that objects transform and more. Because of the way values are returned a typical pattern of using Raycasts looks like this:
```csharp
var ray = new Ray(this.transform.position, this.transform.forward);
RaycastHit hit;
if (Physics.Raycast(ray, out hit))
{
objectHit = hit.transform.gameObject;
}
```
### Raycasting Examples
Here is a collection of a few ways you could apply raycasts from my previous projects:
* [Obstacle Avoidance and Steering Algorithms](https://youtu.be/SVazwHyfB7g)
* [Reflecting Projectiles Off Walls](https://youtu.be/GttdLYKEJAM)
* [Adding Gravity and Trajectory Prediction](https://youtu.be/d7pwmO6IS2I)
* [Projectile Penetration and Shooting Through Walls](https://youtu.be/RIru7m73HZA)
* [Help Debugging Rays with Unity Gizmos](https://www.youtube.com/watch?v=USwrSUpIgLI)
### Raycast Alternatives
Unity includes a set of functions that can be used in place of raycasts that use different shapes such as spheres or boxes to detect collisions. These function similarly to raycasts for the most part besides having a different shape.
#### [`SphereCast`](https://docs.unity3d.com/ScriptReference/Physics.SphereCast.html)
`SphereCast` projects a sphere along a ray effectively allowing your raycast to have a radius around itself when detecting objects. This has a few uses but one of the most common is in the development of [third person cameras](https://youtu.be/Cfcr7FtbYQo) to prevent them from clipping into level geometry and ensure they behave more cleanly in tight corners.
#### [`BoxCast`](https://docs.unity3d.com/ScriptReference/Physics.BoxCast.html)
`Boxcast` projects a box along the ray and allow you to test if a box may move without colliding with an object.
#### [`CapsuleCast`](https://docs.unity3d.com/ScriptReference/Physics.CapsuleCast.html)
`CapsuleCast` projects a capsule along a ray and can be useful for detecting things like potential player movement.
#### [`LineCast`](https://docs.unity3d.com/ScriptReference/Physics.Linecast.html)
This functions identically to a `Raycast` however instead of expecting an origin and direction and `LineCast` expects two points and detects if an object is between those two points.
### 2D Raycasts
Variants of the 3D Raycasts and its alternatives can be used when your using Unitys 2D Physics system. These have a different syntax and the two raycasting systems are *not* intercompatible. `Physics.Raycast` will interact with 3D Colliders, `Physics2D.Raycast` will interact with 2D Colliders. To learn more about using Raycasts in a 2D scene see the documentation for [`Physics2D.Raycast`](https://docs.unity3d.com/ScriptReference/Physics2D.Raycast.html).
***
The Raycasting documentation is here: https://docs.unity3d.com/ScriptReference/Physics.Raycast.html
Join the World of Zero Discord Server: https://discord.gg/hU5Kq2u
Ive published additional content on my website at https://worldofzero.com
You may find some of the World of Zero Open Source projects at https://github.com/WorldOfZero Detecting Objects with Raycasts in Unity3D](https://i.ytimg.com/vi/vqc9f7HU-Vc/mqdefault.jpg)