2d Shader: How to show camera view on a sprite?

I want to write a shader that shows the camera view from the same perspective & ratio (not fit to the shape of the object).

I want to achieve the grander aim of starting with a background (e.g. bricks) and have a shape “punch a see-through hole” that I can move around and place where I want.

Background (Repeated): (series of bricks- I can only upload 2 images so just imagine it!)

Foreground Object: 102045-sm-foreground.png

Hole shape: 102044-sm-window-hole.png

I want to write a shader for this hole shape, so that it shows the exact view of a camera parented to the main camera that is set up to see only background layers.

The part I am missing is the actual shader. I have almost no shader experience but am willing to learn. Point me in the right direction?

make a texture that is of type render texture.
create a camera assign it to render to that render texture.
make a material… use the render texture as the material.
Now you can put that material on an object or a sprite material… that gets you half way there.
Next on the material, you’ll want a shader that can provide a second texture as a mask / alpha to cutout the first one… You can probably find that on Unity Shader wiki website at a guess :wink: