Uploaded December 2018 | Updated November 2026, 3 hours ago
One issue that is often encountered when building first person games is that the really close objects like weapons or hands will clip through nearby walls. To solve this a common trick is to create a second camera that selectively renders all the objects that you want in the foreground on top of the background. In this video we're going to explore how that can be done.
Unity's Camera objects have a number of really handy flags on them that allow you to tweak a number of different settings about them. We're going to need to take advantage of a few of them.
The first is the `clear flags` option which tells the camera what to clear before drawing. To accomplish our overwrite effect we'll want to set the second foreground camera's `clear flags` to "Depth Only". This clears the depth so newly drawn objects aren't culled by the depth buffer but doesn't overwrite the previously drawn scene.
The second option is the `culling mask` this determines which layers the camera will draw. For example setting the `culling mask` to only the "UI" layer will cause that camera to only draw objects in the "UI" layer and ignore everything else.
The final option we care about is the cameras depth. This isn't a measure of the camera's physical depth in the scene but is instead an measure of the order of the camera when multiple camera's exist. Camera's are ordered from least to greatest and then drawn in order one after the other. This means that a camera with a depth of 1 is drawn after a camera with a depth of 0. At the time of writing this Camera depths may range from -100 to 100.
By combining these three options we can create a camera that renders on top of the existing scene, is rendered after the main camera and only renders a specific layer of objects. By doing this we can allow objects to pop through the terrain and effectively ignore everything else in the scene.
Unity has a few other tips and tricks for cool things you can do with cameras here: docs.unity3d.com/Manual/MultipleCameras.html
The World of Zero Discord server: discord.gg/hU5Kq2u
One issue that is often encountered when building first person games is that the really close objects like weapons or hands will clip through nearby walls. To solve this a common trick is to create a second camera that selectively renders all the objects that you want in the foreground on top of the background. In this video we're going to explore how that can be done.
Unity's Camera objects have a number of really handy flags on them that allow you to tweak a number of different settings about them. We're going to need to take advantage of a few of them.
The first is the `clear flags` option which tells the camera what to clear before drawing. To accomplish our overwrite effect we'll want to set the second foreground camera's `clear flags` to "Depth Only". This clears the depth so newly drawn objects aren't culled by the depth buffer but doesn't overwrite the previously drawn scene.
The second option is the `culling mask` this determines which layers the camera will draw. For example setting the `culling mask` to only the "UI" layer will cause that camera to only draw objects in the "UI" layer and ignore everything else.
The final option we care about is the cameras depth. This isn't a measure of the camera's physical depth in the scene but is instead an measure of the order of the camera when multiple camera's exist. Camera's are ordered from least to greatest and then drawn in order one after the other. This means that a camera with a depth of 1 is drawn after a camera with a depth of 0. At the time of writing this Camera depths may range from -100 to 100.
By combining these three options we can create a camera that renders on top of the existing scene, is rendered after the main camera and only renders a specific layer of objects. By doing this we can allow objects to pop through the terrain and effectively ignore everything else in the scene.
Unity has a few other tips and tricks for cool things you can do with cameras here: docs.unity3d.com/Manual/MultipleCameras.html
The World of Zero Discord server: discord.gg/hU5Kq2u

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 havent 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 were 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: https://discord.gg/hU5Kq2u Using Properties and Steps in Part 2 of our Ripple in Shader Graph](https://i.ytimg.com/vi/tL3GbBAqF3E/mqdefault.jpg)





![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)