17
$\begingroup$

In this youtube video Cynicatpro explains how Fresnel works and builds a shader for dielectric materials. In explaining how roughness has an impact on the fresnel effect and how to simulate that in Blender he built this Fresnel node group:

enter image description here

When introducing the Geometry node he loses me. I think I understand why the "standard" Fresnel node has the Normal as an input (EDIT: I now think I don't). And I understand why roughness has an impact on Fresnel. But I don't understand why the Geometry - Incoming should be a "good" approach for simulating the effect of roughness on Fresnel. Who can explain ?

BOUNTY QUESTION:

The answers of @Leander and @lbalazscs were certainly helpful but I still don't truly understand how the current Fresnel node works and why CynicatPro is constructing a Fresnel node group with the "average normal" and the "Geometry - Incoming".

I did some reading like this about microfacet normals (and also papers on that like this one and this one), but most of these papers are full of math and are too high brow for me. This document about PBR was really helpful and it makes me understand things like diffuse, normal reflectiveness, roughness, fresnel and even microfacets.

But I cannot make the switch to Blender. Why is the standard Fresnel node using the average normal and does the Fresnel node group use this average normal and the incoming rays. I think I understand what he tries to accomplish but I don't understand the model. Who can explain and not use high-level math ?

What I am looking for ...

A) an explanation on a conceptual level (without diving into the math) how things like diffuse, normal reflectiveness, fresnel, average normals, incident light and reflected light, microfacets and roughness relate would be very nice but

B) an explanation of the "CynicatPro Fresnel node group" is maybe the most important part of my question.

I am not asking a complete syllabus ... I have done some readings.

I think a real understanding how to construct Physically Based shaders is crucial for photorealistic rendering and this starts with a real understanding of concepts and the tools of Blender. I am happy to raise the Bounty is someone feels that this is adequate.

EDIT: Now I better understand how the normal input is used I understand that the Fresnel node is fed with a normal input. This normal input comes from the Mix node. Now ...

A) what is Geometry - Incoming ? Is this the incoming ray like shown in the image below ? Or is it the incoming ray into the camera ?

enter image description here

B) What is exactly what the Mix node produces ? What normal ??

$\endgroup$
3
  • $\begingroup$ you ask good questions. $\endgroup$
    – 10 Replies
    Dec 21, 2016 at 1:36
  • $\begingroup$ Looks that chasing the same rabbit lead to same related topics ^^. Same topic but different sub topic, look here, the answer isn't complete but you'll find more info about fresnel : blender.stackexchange.com/questions/69343/… I'll add an answer here too, because I have infos about the fresnel issue. $\endgroup$
    – Mareck
    Dec 21, 2016 at 5:06
  • $\begingroup$ What do you call "average normal"? Never saw this one. By the way, if you're stuck on Cynicat's tutorial, check out that one of Blender Guru. He got some help by Cynicat, so the approach is roughly the same, but he explains it differently. $\endgroup$
    – piegames
    Dec 21, 2016 at 21:07

5 Answers 5

7
+100
$\begingroup$

The Geometry node's Incoming socket

The manual has this to say about the Incoming socket of the Geometry node.

Vector pointing towards the point the shading point is being viewed from.

(I know, not that helpful).

The Geometry node's Incoming socket is a a "ray" along the camera's Z axis. Think of it as a vector that is at the same angle as the camera. So when you use this in a shader it is one vector, meaning the entire surface of the object will have the exact same value.

animated gif describing the Incoming socket
Imagine this plane is a ray coming from the camera, it travels down a path straight out of the camera, along its local Z axis. It does not matter where the plane first hits a object, because it is always at the exact same angle. It is this angle (a vector) that the Incoming socket holds.


The mix node in Wyatt Reehill's Fresnel node group

All the mix node is doing is literately mixing between the Incoming and Normal vectors.
In this gif, I have the Incoming vector plugged in to the bottom socket (so it is showing when the Fac is at 1), and the Normal vector in the top color socket (Fac at 0). That composite vector is plugged in the Normal socket of a Fresnel node.
animated gif showing the mix Fac between *Incoming* and *Normal* vectors

The way this works is it is mixing into the object's normals (not related to the normals of the mesh in edit mode) with some of the Incoming value. Which is to say, that you are skewing the normals at the edge of the surface.

From the same view here is what viewing the Normal, and Incoming vectors look like. Normal is on the left, and Incoming is on the right.
Normal | Incoming

When you start to mix in some of the Incoming vector it skews the Normals to face more towards the camera (from the incoming vector). This is what half Normal and half Incoming mixed together looks like, notice the color has shifted slightly.
half mix of Normal and Incoming

The reason he made his own group is blender's Fresnel node does not have any setting for roughness (like most of the shader nodes do).

$\endgroup$
2
  • $\begingroup$ Thanks for answering my question. Most people start explaining me the fresnel effect but you did understand what it was that I did not understand and what was my question about. Thanks. Also thanks for the explaining the normal socket $\endgroup$
    – user13877
    Dec 25, 2016 at 13:39
  • $\begingroup$ This answer made me understand what normal vector is being fed into the Fresnel node and why that results in low reflectivity at high roughness. $\endgroup$
    – user13877
    Dec 25, 2016 at 13:42
9
$\begingroup$

[Pseudo explanation.]

The normal gives us the normal surface orientation for each surface point. The incoming output gives us the direction of incoming camera ray. In the "middle" of a sphere the normal will be pointing directly towards the camera, hence at that point (only) the incoming and normal vector will be equal.
normalincoming

enter image description here

We are especially interested in the small incoming angle, where the glossyness will be stronger. If we sample a surface area on the "side" of the sphere (from camera view) the incoming and reflected rays have a small angle.
enter image description here

The more rough the surface gets, the more rays will be reflected in the direction of incoming.
enter image description here

With the roughness converging towards 1, the ratio of incoming reflected to normal reflected direction will also converge towards 1. The ratio is represented by the slider, switching from normal glossy reflection to (fake) incoming normal reflection.

$\endgroup$
2
  • $\begingroup$ Hi, I now have read your answer a couple of times but to honest I still do not understand your sentence "The more rough the surface gets, the more rays will be reflected in the direction of incoming." I would be grateful if you would clarify. Thanks $\endgroup$
    – user13877
    Dec 20, 2016 at 14:30
  • $\begingroup$ A rougher surface means more/steeper microscopic imperfections. A perfectly smooth surface will always reflect a ray from a particular incoming direction towards a particular outgoing direction. A jagged/pitted surface (see the last two images in this answer) will reflect in a variety of directions. Roughness acts as a kind of average of how many and how severe these surface imperfections are. $\endgroup$
    – JtheNinja
    Dec 20, 2016 at 23:13
4
$\begingroup$

About the fresnel issue that calculate too much specular reflectivity around the edges if the surface is rough, there is an other thing to take care of. Rough surface looks smoother at grazing angle. Better with a sketch.
Not sure aligned normals in this direction was the best choice but you got the point.

Perhaps easyier to see micro bumps (roughness) at an other scale:

And guess what, with this added to the roughness of the glossy, there is no thin rim effect. I don't know if it correct the issue at 100%, but in all case it's way better.
To make the roughness decrease with the fresnel you need to invert the fresnel (1-fresnel) and multiply it by the roughness.

$\endgroup$
3
$\begingroup$

I think Leander's explanation is correct, but maybe this is more clear.

The basic problem is that the standard Fresnel node calculates too much specular reflectivity around the edges if the surface is rough. It is illustrated in great detail here.

So what is happening here? As the fake "roughness" increases, the node setup uses more and more the incoming vector instead of the real normal vector. The effect of this is that the Fresnel node will calculate less reflectivity because it thinks that the calculation is happening on a surface that is perpendicular to the viewer.

$\endgroup$
2
$\begingroup$

B

You can find a very good explanation of Cynicat's Fresnel node group about here. But you asked for it, so here my explanation:

You can, simplifying a bit, categorize materials into two categories: metals, and dielectric. Almost every material is one of those or some mixture of them. The video refers primarily to dielectric materials.

Dielectric materials have some base material (e. g. diffuse) and some reflection. The reflection is always white, and its amount is at a few percent when looking at it from straight above and increases up to almost 100% when looking at the surface with an angle of 90°. Two things influence the amount of specular reflection: the Index of refraction (IOR) of the material and its roughness. The amount of reflectivity is calculated by a Fresnel node in Blender.

In Blender use your surface shader and mix it with a glossy shader (pure white). The mix factor is the output of the Fresnel node. The Fresnel node has an input for the IOR, but no possibility to change the roughness. The explanation to why Fresnel must go down with increasing roughness is at 2:40 in the video.

The node setup Cynicat does exactly this by using the Incoming value of the Geometry node. Incoming is the direction of the ray that is hitting the surface. On camera rays, it will always point to the camera. If you look at a sphere, the normal at its center is equal to the incoming node.

Now, the normal is mixed with the incoming. This basically rotates the normal into the camera direction. This results in a higher viewing angle and thus a lower Fresnel value, reducing the Glossy amount. (The bump node is just a Blender hack; ignore it)

At the end, Cynicat puts the whole thing into a node group allowing you to add dielecric gloss to any base material; saving you some time.

A

One of the best guides is prehaps PBR Guide by Allegorithmic

In Blender, each time a ray hits a surface, the shader calculates a BSDF. Read this answer now. This is how the diffuse BDSF looks like:

diffuse scattering

The ray hits the surface and might bounce in any direction. The ray will get colored appropriately. Shader functions may also have parameters that change their output. A glossy shader normally looks like this:

sharp glossy

All rays scatter the same way. But if you increase the roughness, there will be a probability that the ray doesn't follow exactly that line:

rough glossy

Sure, most of the rays, will still go in the same direction, but it is enough to blur the reflected image.

Microdisplacement is explained in Figure 4-6 of the PBR guide. Blender uses microfacets to approximate microdisplacement effects. This is all internal, so we don't have any influence on it. Also I think that the microfacet model used is quite simple; Facets probably don't interact with each other by blocking the ray. The important thing is the result of the calculation.

EDIT:

The Fresnel node basically just does some maths: Is uses probably one of these equations and outputs the final value we are interested in. The Fresnel calculation needs some values so that the equations make sense. One of them is of course the IOR. Since the output value is somehow based on the angle between the incoming ray and the face's normal, it will need both for the calculations. It probably takes the incoming direction from a geometry node internally. The same counts for the face normal.

But there is a normal input in the node. If you plug a value in, it will overwrite the default face normal by your custom one. It is exactly like the normal input in the diffuse and the glossy node: You don't need to use it, but you can plug custom normals to overwrite the value. You'll need it every time you use a normal or a bump map for example.

If I am missing something, you want more pictures, something is wrong or unclear tell me please.

$\endgroup$
7
  • $\begingroup$ Thanks. Could you maybe include an explanation why the "standard" Fresnel node of Blender takes the "Normal" as an input ? $\endgroup$
    – user13877
    Dec 23, 2016 at 14:40
  • $\begingroup$ Short version: For the same reason and use cases the diffuse and glossy shader (and other) have a normal input. $\endgroup$
    – piegames
    Dec 23, 2016 at 14:59
  • $\begingroup$ OK. Then maybe I make that a new question (why all shaders have a normal input) ? $\endgroup$
    – user13877
    Dec 23, 2016 at 16:03
  • $\begingroup$ Yes, take out the normal part of your question and put it in a new one $\endgroup$
    – piegames
    Dec 23, 2016 at 16:08
  • $\begingroup$ Apart from that, have I missed something you asked in your question? $\endgroup$
    – piegames
    Dec 24, 2016 at 16:34

You must log in to answer this question.