Welcome, Guest.
Username: Password: Remember me

TOPIC: Real-time Colour Cast Neutralizer

Real-time Colour Cast Neutralizer 2 months 4 weeks ago #1

Hi guys
I was wondering if it was possible to achieve an effect like the neutralize filter seen in photoshop to reduce color casting.
(What is the neutralize filter)

I'll take the game Need for Speed 2015 as an example. I took screenshots of two scenes with excessive color tint, I then applied the filter in photoshop and here's the result:



(gameplay source: https://www.youtube.com/watch?v=kxZGNUQPsNI&feature=youtu.be&t=46)
Last Edit: 2 months 4 weeks ago by Duran.te.
The administrator has disabled public write access.
The following user(s) said Thank You: MaxG3D, Viper_Joe, Arkane, Teh_pwnisher, thalixte

Real-time Colour Cast Neutralizer 2 months 4 weeks ago #2

This effect would really make my life easier :cheer: I'm no programmer but it sounds like it should be possible.
At the very least you can apply the effect to LUT in Photoshop.
The administrator has disabled public write access.

Real-time Colour Cast Neutralizer 2 months 4 weeks ago #3

  • Wicked Sick
  • Wicked Sick's Avatar
  • Offline
  • Die young or suffer (Forgive my poor English)
That would be nice to try.
Finding relief somewhere between a tree's branch and its shade.
The administrator has disabled public write access.

Real-time Colour Cast Neutralizer 2 months 3 weeks ago #4

It looks like a simple histogram normalization or curves RGB levels adjustment.

Principle is this:
• Sample whole image and determine maximum and minimum levels for Red Green and Blue
• On second pass apply this to the image:
CastRemoved = (SourceImg.rgb-Minimum.rgb)/(Maximum.rgb-Minimum.rgb)
• Then maybe mix original image.x in YUV with CastRemoved.yz in YUV to change only color

I would try it, but don't know how to pass variables between passes :/
The administrator has disabled public write access.

Real-time Colour Cast Neutralizer 2 months 3 weeks ago #5

i very like this ideia hahaha =)
The administrator has disabled public write access.

Real-time Colour Cast Neutralizer 2 months 3 weeks ago #6

Fu-Bama wrote:
I would try it, but don't know how to pass variables between passes :/

Maybe save the min/max RGB values into a 1x1 texture and use RGBA16 as the format (max value stored in the upper, min value in the lower 8 bits).
And then read from that texture when applying the color correction.

[Edit]
Or, having a pass that has two render targets (1x1 texture) would be easier.
@Fu-Bama I just wrote up a gist that could act as a baseline.
It gets the min/max RGB values and applies them in the formula you provided.
Last Edit: 2 months 3 weeks ago by Daodan.
The administrator has disabled public write access.

Real-time Colour Cast Neutralizer 2 months 3 weeks ago #7

There are still some things to tweak but I guess it works: RemoveTint.fx

[Edit]
  • Added control to set the interpolation speed of min/max values between frames (does anyone know how to do that framerate independent?)
  • Added control to set the effect strength

Base image:


Tinted:


Neutralized:
Last Edit: 2 months 3 weeks ago by Daodan. Reason: Changed shader name
The administrator has disabled public write access.
The following user(s) said Thank You: Wicked Sick, MaxG3D, OtisInf, Uncle Crassius, Marty, Duran.te

Real-time Colour Cast Neutralizer 2 months 3 weeks ago #8

OMG, this is beautiful! I needed that in my life. Thanks a lot!
The administrator has disabled public write access.
The following user(s) said Thank You: Daodan

Real-time Colour Cast Neutralizer 2 months 3 weeks ago #9

It looks phenomenal. Thank you very much!
The administrator has disabled public write access.
The following user(s) said Thank You: Daodan

Real-time Colour Cast Neutralizer 2 months 3 weeks ago #10

Daodan wrote:
Added control to set the interpolation speed of min/max values between frames (does anyone know how to do that framerate independent?)
I assume you use a temporal lerp between 2 1pixel textures? You could adjust the speed with a timer, instead of simply adding a value with each pass (frame), so if the framerate is low or high it doesn't matter.

Shader looks great! good job :)
Last Edit: 2 months 3 weeks ago by OtisInf.
The administrator has disabled public write access.
The following user(s) said Thank You: Daodan

Real-time Colour Cast Neutralizer 2 months 3 weeks ago #11

I've updated the shader a bit:
  • More meaningful name: RemoveTint.fx
  • When interpolating the min/max RGB values the frametime is taken into account
  • It is possible to set custom min/max RGB values, can lead to some interesting results (add REMOVE_TINT_CUSTOM_COLORS to the preprocessor defs)

But, it seems the shader doesn't work in d3d9 yet.
Changed tex2Dfetch() with tex2D() and it works now. tex2Dfetch() in d3d9 seems to be bugged at the moment.
Warning: Spoiler! [ Click to expand ]
Last Edit: 2 months 3 weeks ago by Daodan.
The administrator has disabled public write access.
The following user(s) said Thank You: Wicked Sick, Ryukou36, Marty

Real-time Colour Cast Neutralizer 2 months 3 weeks ago #12

  • Wicked Sick
  • Wicked Sick's Avatar
  • Offline
  • Die young or suffer (Forgive my poor English)
Man, what the hell? This is beautiful!

flic.kr/p/2ev64bZ
Finding relief somewhere between a tree's branch and its shade.
The administrator has disabled public write access.
The following user(s) said Thank You: Daodan

Real-time Colour Cast Neutralizer 2 months 3 weeks ago #13

Daodan wrote:
Changed tex2Dfetch() with tex2D() and it works now. tex2Dfetch() in d3d9 seems to be bugged at the moment.
Fixed: github.com/crosire/reshade/commit/0fc8fe...e793afdd47cf958513d7
tex2Dfetch didn't work on the backbuffer and depth buffer in D3D9 (worked on user textures). This fixes that.
Cheers, crosire =)
The administrator has disabled public write access.
The following user(s) said Thank You: Marty, Daodan

Real-time Colour Cast Neutralizer 2 months 3 weeks ago #14

Thanks Wicked Sick!
This is one of my all-time favourites :)
The administrator has disabled public write access.