Help with creating screen-in-screen effect.

Godot Version

4.1.1

Question

Hello everyone,

I am trying to create a prototype of a game about baiting enemies into flying off screen, and I’ve run into an issue with an effect I’m trying to achieve.

Basically the idea is that there is a play area which is always 648px by 648px in the center of the screen which is rendered in black, white, and red, and the outside of the play area is rendered in gray indicating that it is out of bounds.

I have been able to create the individual shaders for both of these effects, and put the play area in the center of the screen, but I’ve run into an issue where after I apply a shader to the screen I can’t figure out how to reference the original output of the camera.

image

This is my scene hierarchy.

For further clarification it does this:

Camera output > black background > gray filter > white and red filter

And I want it to do this:

Camera output > black background > gray filter

Camera output copy > white and red filter

Edit: Edited the text describing the inputs and outputs for clarity since it got formatted weird.

This seems like a great time to use a subviewport. You could probably have a couple of subviewports with viewport textures that have your filters.