How exactly do CameraClearFlags work??

So, i’m trying to create an effect similar to this one, where stars rotate in the sky leaving star trails behind. My idea was the following:

Add an overlay Camera on top of the Background which render only objects in the “Stars” layer. Create a game object called “Stars” with a 2D sprite of the stars. Add a script rotating the stars. Set the CameraClearFlags of the Stars camera as CameraClearFlags.Nothing.

Well, that’s what i did. I set up a script with the following:

cam = GetComponent<Camera>();

cam.clearFlags = CameraClearFlags.Nothing;

I of course set this up at the Stars camera and hit play but it did nothing. The stars just rotated normally. I then added the same script to my base camera to see what has happening. Nothing. Nothing even changes. I added to ALL my other cameras and nothing happened again.

Why??

Is your “stars” a single opaque mostly opaque texture, or is it transparent with just the stars? If it’s opaque, it’s going to be rendering over the previous frame every time. It doesn’t really matter what was rendered previously. You need to use a texture with alpha, or an additive shader.

My stars sprite is a transparent png with white dots on it. However, i tried the same with a complete black png and it didn’t work as well. It just rotated there. I think it has something to do with the UR pipeline. I think i’ll just have to try some other technique.

Have you tried setting the Background Type on the camera via the inspector instead of via script?