Mask to render only background

Hi there!

I using Unity 2022LTS and I just want to do like this


with some conditions

  1. I can’t mess with props, all props are in Default layer
  2. only sky and camera is available to do a shader or something
  3. My game is 2d sprite renderer + shader graph

Someone said I should do some stencils buffer or something, I can’t use a sprite mask because it show whole object not just the part that not intersected.

any suggestion?
Thanks!!!

All these specific stipulations make this sound like a homework assignment.

1 Like

Yes, actually it just for a stars in my game, because my game is 2d and have some Light Sprite Renderer to cover all object or everything to make it dark when night time,

But also cover a stars too because a stars able to under all props, and a stars should brighter than anything by not under that light Sprite Renderer.

Props > Sky
Props > Stars
Light > Props
But
Stars > Light

This is sound like WTF thing…

Why don’t you just put the star texture on a background plane and use an unlit material on the plane so it doesn’t get affected by lights?

1 Like

Thank you very much for your suggestion
But the Light that I said is similar to Sprite Renderer,

because it just cover all scene by black alpha 0.8 texture, it from Smart 2D Lighting Asset, and the support of Smart 2D Lighting can’t help me about this.

Why not just use the 2D lights in Unity itself? URP has supported 2D lights since at least version 8. We’re on something like version 17 now.

1 Like

My game is stable with Unity 2022.3.5LTS I don’t sure if this version have 2d light yet,
and I used to update to latest Unity
But it has a lots of errors that I can’t handle them.

Unity 2022.3 uses URP 14.

1 Like

Wow I did’t know that!
I will try.

Thanks!