I'm making a twin-stick spaceship shooter in which the ship has a maximum turn speed and turns towards where the control stick is pointing instead of instantly facing that direction. Many of the weapons fire directly forwards in the direction the ship is facing, so it's useful to know both the forward direction of your ship and which direction exactly your stick is pointed. That's the problem this was created to solve, but it could be adapted for other things such as a circular timer.

Here’s a video of it in action:

There are probably many ways to achieve this, but I figured that a material would be ideal because it would keep all the computations on the GPU.

I'm using some material functions from Luos' particle toolkit, which I got for free a while back as one of the monthly free content deals. Specifically a select function and a rotate function. There are probably other ways to implement those two functions if you don't have access to them though.

The first things you need to make are some textures for the circular sections. There are two textures I made, one for all the line segments and one for the filled in section of the circle that will also mask off unwanted artifacts that can come up when rotating textures.

You can see how I constructed each of the images so that the left half of the circle is in the blue channel and the right half is in the red channel. In the green channel of the first image is a line pointing straight upwards and in the second image it contains the entire area of both images combined to use as an outer mask.

That’s it as far as textures are concerned. The material is going to be displayed on a non-rotating plane attached to the player ship, and the rest is done in the material!

The material takes 5 scalar parameters: Three to control the orientation and masking and I have two more controlling brightness and opacity so that the user can choose how they want it to look and then it can also be faded in and out independently of that.

The material blueprint looks a little daunting, but I’ve tried to arrange everything so that the flow can be made out and I’ve labeled all the relevant sections so you can see how everything goes together.

The first half shows where the textures are used, and how they are controlled to be the correct rotation. Then particular channels are multiplied to select just the appropriate regions to be colored in.

The second half colors in all those sections and masks off anything that isn’t in the circle we want. Here’s a version you can zoom and scroll to see better, however it doesn’t show which texture is on which node.