Real-time Colour Cast Neutralizer

More
1 year 11 months ago - 1 year 11 months ago #1 by Duran.te
Real-time Colour Cast Neutralizer was created by Duran.te
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:
)
Last edit: 1 year 11 months ago by Duran.te.
The following user(s) said Thank You: MaxG3D, Viper_Joe, Arkane, Teh_pwnisher, thalixte, prod80

Please Log in or Create an account to join the conversation.

More
1 year 11 months ago #2 by Marty
Replied by Marty on topic Real-time Colour Cast Neutralizer
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.

Please Log in or Create an account to join the conversation.

More
1 year 11 months ago #3 by Wicked Sick
Replied by Wicked Sick on topic Real-time Colour Cast Neutralizer
That would be nice to try.

Please Log in or Create an account to join the conversation.

More
1 year 11 months ago #4 by Fu-Bama
Replied by Fu-Bama on topic Real-time Colour Cast Neutralizer
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 :/

Please Log in or Create an account to join the conversation.

More
1 year 11 months ago #5 by Chavolatra
Replied by Chavolatra on topic Real-time Colour Cast Neutralizer
i very like this ideia hahaha =)

Please Log in or Create an account to join the conversation.

More
1 year 11 months ago - 1 year 11 months ago #6 by Daodan
Replied by Daodan on topic Real-time Colour Cast Neutralizer

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: 1 year 11 months ago by Daodan.
The following user(s) said Thank You: j4712

Please Log in or Create an account to join the conversation.

More
1 year 11 months ago - 1 year 3 months ago #7 by Daodan
Replied by Daodan on topic Real-time Colour Cast Neutralizer
There are still some things to tweak but I guess it works: RemoveTint.fx
[Old Version]

[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: 1 year 3 months ago by Daodan.
The following user(s) said Thank You: Wicked Sick, MaxG3D, OtisInf, Uncle Crassius, Marty, j4712, Duran.te, prod80

Please Log in or Create an account to join the conversation.

More
1 year 11 months ago #8 by MaxG3D
Replied by MaxG3D on topic Real-time Colour Cast Neutralizer
OMG, this is beautiful! I needed that in my life. Thanks a lot!
The following user(s) said Thank You: Daodan

Please Log in or Create an account to join the conversation.

More
1 year 11 months ago #9 by Duran.te
Replied by Duran.te on topic Real-time Colour Cast Neutralizer
It looks phenomenal. Thank you very much!
The following user(s) said Thank You: Daodan

Please Log in or Create an account to join the conversation.

More
1 year 11 months ago - 1 year 11 months ago #10 by OtisInf
Replied by OtisInf on topic Real-time Colour Cast Neutralizer

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: 1 year 11 months ago by OtisInf.
The following user(s) said Thank You: Daodan

Please Log in or Create an account to join the conversation.

More
1 year 11 months ago - 1 year 11 months ago #11 by Daodan
Replied by Daodan on topic Real-time Colour Cast Neutralizer
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!
Last edit: 1 year 11 months ago by Daodan.
The following user(s) said Thank You: Wicked Sick, Ryukou36, Marty, Cul

Please Log in or Create an account to join the conversation.

More
1 year 11 months ago #12 by Wicked Sick
Replied by Wicked Sick on topic Real-time Colour Cast Neutralizer
Man, what the hell? This is beautiful!

flic.kr/p/2ev64bZ
The following user(s) said Thank You: Daodan

Please Log in or Create an account to join the conversation.

More
1 year 11 months ago #13 by crosire
Replied by crosire on topic Real-time Colour Cast Neutralizer

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.
The following user(s) said Thank You: Marty, Daodan

Please Log in or Create an account to join the conversation.

More
1 year 11 months ago #14 by Daodan
Replied by Daodan on topic Real-time Colour Cast Neutralizer
Thanks Wicked Sick!
This is one of my all-time favourites :)

Please Log in or Create an account to join the conversation.

More
1 year 3 months ago #15 by sulpherStaer
Replied by sulpherStaer on topic Real-time Colour Cast Neutralizer
I am having issues getting the correct color correction when the UI is visible. I tried using UImask to select a sample area, so that it ignored the UI (as this resulted in a always black & always white - so no correction at all)

Here are two images to show what I mean.

The top image one has the UI hidden. and as you can see, the right side (where the UImask is) is being corrected.
The bottom image shows the ui, and the masked area is no longer corrected. How would I solve this? How do I create a 'sample area' so that the UI is ignored in the color pick.

Please Log in or Create an account to join the conversation.

More
1 year 3 months ago #16 by Daodan
Replied by Daodan on topic Real-time Colour Cast Neutralizer
I've updated the shader - see one of my posts with the link in it. Using that might help a bit with your problem as the min/max rgb values are now taken from a mipmap and not the full resolution.

Please Log in or Create an account to join the conversation.

More
1 year 1 month ago #17 by klotim
Replied by klotim on topic Real-time Colour Cast Neutralizer

Daodan wrote: I've updated the shader - see one of my posts with the link in it. Using that might help a bit with your problem as the min/max rgb values are now taken from a mipmap and not the full resolution.


With strength 1.0

I'm not sure but it still looks way different to photoshop neutralize.
Is it possible to make it look like PS Neutralize?

PS Neutralize


Reshade Remove Tint

Please Log in or Create an account to join the conversation.

More
1 year 4 weeks ago #18 by mirt81
Replied by mirt81 on topic Real-time Colour Cast Neutralizer
Th@nks

Please Log in or Create an account to join the conversation.

More
1 year 3 weeks ago - 1 year 2 weeks ago #19 by Daodan
Replied by Daodan on topic Real-time Colour Cast Neutralizer

klotim wrote: I'm not sure but it still looks way different to photoshop neutralize.
Is it possible to make it look like PS Neutralize?


Have you tried setting REMOVE_TINT_MIPLEVEL_EXP2 to 1 so the min/max RGB values are taken from the native resolution and not a mipmap? This will probably not work as there could be too many iterations in the for-loop (-> shader fails to compile).

This shader is still some sort of "draft" - when I find time I will rework it and post it in the presentation thread.
Last edit: 1 year 2 weeks ago by Daodan.

Please Log in or Create an account to join the conversation.

More
1 year 2 weeks ago #20 by klotim
Replied by klotim on topic Real-time Colour Cast Neutralizer

Daodan wrote:

klotim wrote: I'm not sure but it still looks way different to photoshop neutralize.
Is it possible to make it look like PS Neutralize?


Have you tried setting REMOVE_TINT_MIPLEVEL_EXP2 to 1 so the min/max RGB values are taken from the native resolution and not a mipmap? This will probably not work as there could be too many iterations in the for-loop (-> shader fails to compile).

This shader is still some sort of "draft" - when I find time I will rework it and post it in the presentation thread.


Alright, thanks anyway, im looking forward to a updated version. To neutralize colors for a game is really nice to have.

Please Log in or Create an account to join the conversation.