CorgiFX: CanvasFog, CanvasMasking and other stuff

More
7 months 4 weeks ago - 7 months 5 days ago #1 by originalnicodr
CorgiFX

Hi everyone, so I use reshade for some time now, and there were a few things that i was always tought as "hmm that would be cool", so this last week I decided to write them down instead of studying (hehe).

I like using reshade to make a game look better, but also to make screenshots. What i like the most about it is the depth buffer and how you can play with it to make cool stuff. I primarly did these things for myself and shared them with some friends who told me to share it here too, so shout out to the FRAMED folks for helping me test them out. Special shout out to Otis for answering my questions.

The thing is i didnt knew much about writting shaders before this (i still dont really), so i started editing those shaders, copy-pasting stuff and seeing how people do stuff. In the shaders i share today i wrote down in which shader i based the stuff i did or if there was any specific shader that i took some ideas from. Hopefully I am not breaking any rule by sharing them here. If i do please let me know to resolve it.

Also, since its my first time writting shaders, expect to find some "uncommon" things in the code (to put it lightly). Hopefully i can clean them up more and add stuff that i come up with.

So without furtherdo here are the shaders.

CanvasFog

If you are familiar with the Adaptive Fog shader then you know how the fog from that shader looks like, if not its basically a color you choose to blend with the depth. Taking that as an initial point i added the option to use gradients in the fog instead of a single color.

Features

- Gradients: The available gradients are linear, radial, strip and diamond, all of them with their own settings.
- Colors with alpha channel: Besides having the option to choose 2 colors in the gradient, you can also change the alpha channel values to play around
- Color samplers: You can select the colors of the gradients to be the same as a pixel on the screen
- Fog Types: The name isnt the best, but it means that you can choose to use the adaptive fog-type or the emphasize fog-type wich isnt a fog technically speaking, but it affects the "surface" that are on the fog range (rather than the whole space in the area). Will let some pictures bellow.
- Blending modes: I added different ways for the fog to blend with the screen. The available blending modes are the following:
  • Normal
  • Multiply
  • Screen
  • Overlay
  • Darken
  • Lighten
  • Color Dodge
  • Color Burn
  • Hard Light
  • Soft Light
  • Difference
  • Exclusion
  • Hue
  • Saturation
  • Color
  • Luminosity
  • Linear burn
  • Linear dodge
  • Vivid light
  • Linearlight
  • Pin light
  • Hardmix
  • Reflect
  • Glow

Last blending modes functions kindly provided by prod80.

Some example images


Radial gradient with screen blending mode


Example of "emphasize-type fog"

CanvasMask

While doing the CanvasFog shader i thought that it would be cool to have these gradient stuff alongside the depth buffer to use as a mask, so here it is.

Its has almost the same features as in the CanvasFog shader, not very much to add. Some example images below.

Some example images

Using a LUT shader with "emphasize type fog mask"


StageDepthPlus

So again in one of the "i want this shader to have this option" moments i made some changes to the StageDepth shader. Here are the stuff it can do.

- Scale: Possibility to adjust the scale of the image in both axis individually
- Rotation: This one speaks for itself, you can rotate the image
- Blending Modes: I wrote them for the CanvasFog shader and figured out they can be usefuls if applied to an image
- Depth Control: It already was in the original StageDepth. It uses the depth buffer to decide to show the image or not

Since this last one is more an enhanced shader than a new one i will understand if i have to take it out from the post.

You can find these shaders and more example images on my repo: CorgiFX .

So thats it. Sorry for the low quality images, Monster Hunter World is one of the few game i have installed to test stuff right now.

Things to do:

- Make the shaders interface more user friendly
- Fix the strip gradient dont mantaining the scale while changing the angle
- Fix the diamond gradient to rotate with the modifications done in the x and y axes
- Fix blending modes that clip some values
- Fix the StageDepthPlus shader loading the image with square aspect ratio
- Change the gradient to other color space
- Work on the emphasize-type fog more

Any bug or suggestion you got don't hesitate in hitting me up.

I made these shaders for screenshooting propuses, but maybe you find an use for them in gameplay. Hopefully these shaders will come handy, my intention with this was creating more freedom to make stuff, so cant wait for what you came up with!
Last edit: 7 months 5 days ago by originalnicodr. Reason: Added more blending modes
The following user(s) said Thank You: crosire, OtisInf, Viper_Joe, Marty, mbah.primbon, Matt Gore, Cul, SpajdrEX, moyevka, prod80 and 2 other people also said thanks.

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

More
7 months 5 days ago #2 by originalnicodr
Replied by originalnicodr on topic CorgiFX: CanvasFog, CanvasMasking and other stuff
So a little update that i think it deserve its own post:
StageDepthPlus

So I added a new feature in the StageDepthPlus shader. Now you can use a depth map with the image to decide wether or not show the .png. Example below.



Not the best quiality example, but enough to show how it works


And not only that, I have edited the ReShade.fxh file to mix this depth image with the actual depth buffer, so you can use the images depth with other shaders that use the depth buffer. This feature is very experimental, if you want to use it check the readme file in the repo to know how to turn it on.



A little example with CineDOF


As an extra I added some bools to invert the layer horizontally or vertically.


FreezeShot

And another shader. I noticed a lot of double exposure shots recently, and I thought shooting and putting the image in a layer shader must be a bummer, so I made a thing for that.

Introducing FreezeShot, align the camera, adjust the depth of the subject you want to take the screenshot from and press the Freeze bool and uala! You can move and adjust it like any layer shader (with the benefit of making the background of the shot invisible for instance). Maybe its better if you just take save the picture in a file, but i think it might come handy for quick experimentation.

It has the same controls as the StageDepthPlus. It can also saves the depth buffer when you freeze the image, so you can make the layer interact with the scene.



Freezing and flipping the image



Frozen image using the saved depth to interact with the scene


This features might not be very useful, but i enjoyed making them. I have also started working on a ColorMask shader, but its still being worked on. If you want to check it out too head over the repo. Link in the original post.
The following user(s) said Thank You: Matt Gore

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

More
7 months 2 days ago #3 by Matt Gore
Thanks, I only tested a bit but I can finally let out my inner Bob Ross! :lol:



The only issue is that the depth buffer contains no AA, thus the leafs in my example are quite jagged – guess I have to try putting SMAA over everything.

Regarding FreezeShot, would it be possible to export the frozen image including depth to a PNG?

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

More
6 months 3 weeks ago #4 by originalnicodr
Replied by originalnicodr on topic CorgiFX: CanvasFog, CanvasMasking and other stuff
No sorry, I dont think thats possible since it would require exporting the information of a texture into a .png and I am almost sure that isnt built in reshade. The alternative would be using some strong color of fog to separate the thing you want to mask out, saving it and making the .png in an image editor.

Rewarding the depth map you can save that as a normal screenshot using the DisplayDepth shader, and you could put a fog with black color on top of it to map the things you dont have in your .png.

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

More
6 months 3 weeks ago #5 by originalnicodr
Replied by originalnicodr on topic CorgiFX: CanvasFog, CanvasMasking and other stuff

Matt Gore wrote: Thanks, I only tested a bit but I can finally let out my inner Bob Ross! :lol:



The only issue is that the depth buffer contains no AA, thus the leafs in my example are quite jagged – guess I have to try putting SMAA over everything.

Regarding FreezeShot, would it be possible to export the frozen image including depth to a PNG?


Ups forgot to quote the original message. Hope I could help.

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

More
6 months 3 weeks ago #6 by Matt Gore
Okay, I was just hoping PNG export would be possible based on seeing the import capability. But yeah, I already used DisplayDepth and just hoped there could be an easier way.

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

More
6 months 6 days ago #7 by Cul
Oh wow! Gracias, Corgi. Thank you so much! This is exactly what I wanted.

If you ever need some LUTs, just let me know.

Hope you stay safe! Hope everyone stays safe...
The following user(s) said Thank You: originalnicodr

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

More
5 months 15 hours ago #8 by originalnicodr
Replied by originalnicodr on topic CorgiFX: CanvasFog, CanvasMasking and other stuff
Had some free nights lately so I could give the ColorMask shader another try, and this time came up with something very usable!

ColorMask

As the name of the shader suggest its a shader for masking purposeses using colors as the target. My intention was to imitate the "Color Range" selection function from Photoshop, so if you are familiar with that you shouldnt have much trouble using it. The shader is based on the Color Isolation shader from Daodan, so all credits goes to him.

Features

- Target Hue: You can select the color you want with a variable or with a eyedropper.
- Hue Overlap: The bigger the number the lesser the amount of colors being masked. Think of it as controlling how close does the colors need to be in order to be accepted.
- Curve Steepness: The brigthness of the colors not being masked.
- Accept / Reject Colors: Once you have the objetive color seted up you can either mask all colors except the onces selected or vice versa.
- Mask Strength: Just a way to control the opacity of the shader.
- Debug tools: If you want to see exactly what you are masking the shader offers two debug tools:
‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎- Hue Difference: Shows a grey-scale image allowing you to see the part of the screen that is being accepted.
‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎- Debug Overlay: Show a color table with a black line that points out the colors being masked. Both of these debugs options were made by Daodan and are quite useful, would suggest you to use them.
- Highlights and Shadows selection: As the "Color Range" function in Photoshop you can use this to mask shadows independetly of the hue, and if you use the "Reject Colors" option you can mask highlights.

Some example images



Original scene



HueFx shader applied while masking all colors except blue



Using the eyedropper to sample a color from the screen, again with the HueFX shader



More example images and the shader itself on my repo: CorgiFX

I think the result is pretty close to what photoshop does, if you are masking shadows or highlights dont be afraid of using values outsides of the boundries (Control + click) in the "Fuzzines" and "Curve Steepness" variables, still have figure that out, but its quite usable.

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