Color correction (gradient) shader for a viewport?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Macryc

Hi All. I am trying to build an FPS rig where the weapon is on a separate cull-mask and has a separate camera that is set to only see the cull-mask the weapon is on. (This is to prevent gun clipping).

So in the main scene I have the main camera that sees the world and I have a viewport with the first-person camera as a child of a TectureRect - this viewport is set to transparent bg. That way the weapon camera renders just the weapon over what the main camera sees.

This is working fine and all except one thing: some of the environment properties of the gun camera (the one that renders its view into the viewport) are ignored by the engine, such as DoF or post-processing effects like color correction, brightness, contrast etc.

In effect, even though the rig works flawlessly, the weapon looks out of place without color correction (like early vfx in movies).

QUESTION:
How can I replicate color correction on the viewport’s ‘content’ to match it to the outside environment?

I’ve tried adding a shader to the textureRect that I’m rendering the viewport into, but it affected the whole scene BUT the viewport. Is there a way to color correct JUST what the viewport is showing?

I am trying to build an FPS rig where the weapon is on a separate cull-mask and has a separate camera that is set to only see the cull-mask the weapon is on. (This is to prevent gun clipping).

You don’t need to use a separate viewport for this. You can scale down the gun and bring it closer to the player. Also, to simulate larger/lower FOV for the gun only, you can scale it non-uniformly.

Calinou | 2021-08-07 11:55

this would work if it was o FPS game only but it’s actually a third person game - I only have a contextual FPS mode which you can switch on in certain situations and it’s basically just swapping cameras from 3ps to one that is located where they player’s eyes are.

Macryc | 2021-08-07 11:58