6

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.

preview of material with dot-product mix shader factor

If I reverse the shaders I will get something like a puff of smoke, gradually becoming transparent at the edges.

iKlsR
  • 43,379
  • 12
  • 156
  • 189
Gunslinger
  • 6,392
  • 2
  • 28
  • 40

1 Answers1

5

Try using the Layer weight node with the Facing value as a mix factor:

enter image description here

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

enter image description here

When used to mix a diffuse and a transparent shader:

enter image description here

Blending:

The Blend value controls the blending between angles:

With a low Blend value:

enter image description here

With a high Blend value:

enter image description here

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

enter image description here

enter image description here

gandalf3
  • 157,169
  • 58
  • 601
  • 1,133