How to mix shaders depending on the direction normals are facing? How to make a gradual transition between two shaders, depending on the normal of the surface against the angle of the view.

The use case is I want to make bubbles of a white, somewhat opaque, liquid. When passing through the center (from the camera) it will pass through minimal liquid so it is most transparent there. When a ray passes near the rim it will pass through maximum liquid and be most opaque there.

I will just mix a transparent and opaque material. If the normal faces the camera, select the transparent material. If the normal is perpendicular to the camera, select the opaque material.

I have tried fresnel but it is meant for items refracting light.

I have tried the normal node but can't get it to work. I think that if I just use this correctly, this is the right way.

I have tried taking the normal of the object, normalize it and dot-product with the camera normal (normalized). It gives the result below. It is in the right ballpark, but not correct. Nevermind that it is black.



If I reverse the shaders I will get something like a puff of smoke, gradually becoming transparent at the edges.
Try using the Layer weight node with the Facing value as a mix factor:



The Layer weight node gives a map based on the angle of the surface to the camera:



When used to mix a diffuse and a transparent shader:



Blending:

The Blend value controls the blending between angles:

With a low Blend value:



With a high Blend value:



As mentioned by CharlesL you could further control the blending with a Color Ramp node: