Uploaded July 2018 | Updated November 2026, 3 hours ago
Lets make a new shader in Unity that sends a ripple out across an object to reveal the texture underneath it! We'll get to play with some basic geometry and look at how to add an exponential smoothing function to a linear curve to get a better looking falloff on our rings glow. We'll explore a few different styles including an expanding circle, sphere and ring (eventually settling on the ring).
The approach for developing this is taken in two parts. First we build a simple detector that can detect when something is inside or outside of a circle. The formula for this is (distance greater than radius) to detect if a point is outside the circle. The second step is to take the point where distance == radius and create two equa-distant rings on either side. The distance between these two rings should be equal to the intended width of the ripple we want to create (each ripple width / 2 from the middle point). Once we have that we can build a function that works so that the edges closest to these boundaries are 0 and the points near the center ring are equal to 1. This will give us a gradient falloff we can use to create a smooth pulsing ripple effect.
We also briefly touch on the swizzle operator when working with vectors in a shader and how you can use it to transform a vector easily in shader languages in this video.
In the past we've worked on a lot of different circle based shaders including a similar ripple technique when building the [shield shader](youtube.com/watch?v=NeZcAYJdkv4&list=PLEwYhelKHmihp8GNb-XXWE5VhqikYwluj&index=1) in an earlier video series. You can accomplish a lot with basic distance formula to create a number of very cool effects!
If you have suggestions for how we could improve this shader or ideas on what we should do with it next let me know in the comments!
Join the World of Zero Discord channel: discord.gg/hU5Kq2u
Lets make a new shader in Unity that sends a ripple out across an object to reveal the texture underneath it! We'll get to play with some basic geometry and look at how to add an exponential smoothing function to a linear curve to get a better looking falloff on our rings glow. We'll explore a few different styles including an expanding circle, sphere and ring (eventually settling on the ring).
The approach for developing this is taken in two parts. First we build a simple detector that can detect when something is inside or outside of a circle. The formula for this is (distance greater than radius) to detect if a point is outside the circle. The second step is to take the point where distance == radius and create two equa-distant rings on either side. The distance between these two rings should be equal to the intended width of the ripple we want to create (each ripple width / 2 from the middle point). Once we have that we can build a function that works so that the edges closest to these boundaries are 0 and the points near the center ring are equal to 1. This will give us a gradient falloff we can use to create a smooth pulsing ripple effect.
We also briefly touch on the swizzle operator when working with vectors in a shader and how you can use it to transform a vector easily in shader languages in this video.
In the past we've worked on a lot of different circle based shaders including a similar ripple technique when building the [shield shader](youtube.com/watch?v=NeZcAYJdkv4&list=PLEwYhelKHmihp8GNb-XXWE5VhqikYwluj&index=1) in an earlier video series. You can accomplish a lot with basic distance formula to create a number of very cool effects!
If you have suggestions for how we could improve this shader or ideas on what we should do with it next let me know in the comments!
Join the World of Zero Discord channel: discord.gg/hU5Kq2u





 for recommending the use of `ContextMenu`s. You can find more of their content as a guest in videos at Infallible Code: https://www.youtube.com/user/charlesamat
### Code Examples
Some example uses of Unity 3Ds `ContextMenu` and `ContextMenuItem` Attributes:
#### `ContextMenu`
A `ContextMenu` Attribute is attached to functions in your `MonoBehavior`. When that menu item is clicked it will invoke the function the attribute is assigned to:
```csharp
[ContextMenu(Context Menu Example)]
void HelloContextMenu() {
Debug.Log(Context Menu Clicked!);
}
```
#### `ContextMenuItem`
A `ContextMenuItem` Attribute is attached to a field and requires you to provide the name of a function that will be invoked when the menu item is clicked.
```csharp
[ContextMenuItem(Context Menu Item Example, nameof(InvokeContextMenuItem))]
public float someVariable;
void InvokeContextMenuItem() {
Debug.Log(Context Menu Item Clicked!);
}
```
[`nameof`](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/operators/nameof) is a C# function that returns a string representation for the name of the class, function, field, property etc that is referenced. Using this allows things like refactorings to function better and provides compiler errors if you spell a function name incorrectly (`nameof(FunctionName)` will throw an error if `FunctionName` is not defined).
Note: The functions invoked by both `ContextMenu` and `ContextMenuItem` should not have any arguments.
***
Unitys documentation on the `ContextMenu` Attribute: https://docs.unity3d.com/ScriptReference/ContextMenu.html
Unitys documentation on the `ContextMenuItem` Attribute: https://docs.unity3d.com/ScriptReference/ContextMenuItemAttribute.html
Join the World of Zero Discord Server: https://discord.gg/hU5Kq2u Using ContextMenu and ContextMenuItem in Unity 3D](https://i.ytimg.com/vi/GKG-vUFt3D4/mqdefault.jpg)


![Building a Custom Dice Model with OpenSCAD
OpenSCAD is a tool that can compile programs into 3D models allowing you to code your own CAD designs instead of building them inside of a WYSIWYG type editor like Fusion 360, SketchUp etc.
The module we created for a basic dice looks like this:
```OpenSCAD
module CreateDice(size = 16) {
textSize = size * 0.75;
textLocation = size / 2 - 1;
textExtrusionSize = 2;
difference() {
cube([size, size, size], center = true);
translate([0,0,textLocation]) linear_extrude(textExtrusionSize) text(1, size=textSize, halign=center, valign=center);
rotate([180, 0, 0]) translate([0,0,textLocation]) linear_extrude(textExtrusionSize) text(6, size=textSize, halign=center, valign=center);
rotate([0, 90, 0]) translate([0,0,textLocation]) linear_extrude(textExtrusionSize) text(2, size=textSize, halign=center, valign=center);
rotate([0, 270, 0]) translate([0,0,textLocation]) linear_extrude(textExtrusionSize) text(5, size=textSize, halign=center, valign=center);
rotate([90, 0, 0]) translate([0,0,textLocation]) linear_extrude(textExtrusionSize) text(3, size=textSize, halign=center, valign=center);
rotate([270, 0, 0]) translate([0,0,textLocation]) linear_extrude(textExtrusionSize) text(4, size=textSize, halign=center, valign=center);
}
}
```
Get OpenSCAD: https://openscad.org/index.html
OpenSCADs documentation: https://openscad.org/documentation.html
OpenSCAD on GitHub: https://github.com/openscad/openscad/
You can get a copy of my models and the SCAD files that generate them here: https://github.com/runewake2/scad-examples
Join the World of Zero Discord Server: https://discord.gg/hU5Kq2u Building a Custom Dice Model with OpenSCAD](https://i.ytimg.com/vi/HxiyUi4RQzw/mqdefault.jpg)

