Download

Add New Custom Material Input Node

I noticed a lot of my shaders look much better with some Fresnel shading on them. Currently I have custom Fresnel material network copied and pasted into each material I make, but I’d like to expose those controls globally to the material network: Fresnel (a multiplier), and Fresnel Power (sharpness towards the edge). First off, would it be cheaper to code the Fresnel in HLSL as part of the base shader pass, or is it better to keep it expanded as a material function in every material I make?

You can use Material Instances here.

Provide your base Fresnel code in one of your Material Functions with parameters.
Make multiple Materials that fit your needs and use the Fresnel Function and create Material Instances based on these Materials.

Unfortunately, I can’t really do that. I need this effect on everything. I was able to solve it using a fresnel shader as a post process. Unfortunately, it shows up crisp where it should be blurry due to the depth of field, so I have to blend it out as it recedes in the distance. Access to the G-buffer really helps a lot with making such post process chains. Using this method, the effect is almost free.

Try to change post process order.

Why don’t you just modify the shading model to suit your needs?

How can I place the blendable post process material before the Depth of Field?

Ideally I would like to expose parameters to adjust the power and strength of the fresnel, not just a basic pass across everything. I got it working as a basic post process pass, the only issue pertinent right now is the blend order. But if it’s possible to expose properties in the material editor that would be awesome!

There’s a good post on adding new shading models to the engine, there’s another showing how to add a custom toon shading shading model which works with all lighting types and etc. and looking at both of those they show exactly how to expose new parameters to the material editor (as inputs to the final nodegraph on the right side, similar to base texture, ambient occlusion etc etc.) so I would try to follow the tutorial except instead of having a toon shader, have the normal base shading model which has the addition of the fresnel stuff and follow through with exposing the parameters to the material editor. Do note, all your shaders and materials will need recompiling once you’re done because it’ll change the entire basepass.