12
$\begingroup$

I'm trying to create a nice little mug with some coffee in it:

I can't quite figure out how to describe the issue, but I guess the coffee looks too dense. There's usually a gradient falloff effect on the edges of the fluid, like in this screenshot:

enter image description here

How would I recreate this in Blender? Here's my node setup:

enter image description here

My guess is volumetrics, but I haven't dabbled with it before so I'm not quite sure. It's for a still-frame render, so I don't care about render times.

$\endgroup$
  • $\begingroup$ I complement you on you power of observation. There are many things going on... bubbles, scattering, surface tension (MENISCUS), reflection and maybe more. The more you address the more realistic the result. There is no one solution. $\endgroup$ – Dontwalk Jan 30 '17 at 3:16
21
$\begingroup$

This can actually be done quite easily (and efficiently) using the volume absorption shader:

example of using volume absorption for liquid edges

You're correct that this is a volumetric effect - it's dependent on how far the light travels through the coffee. There are two volume shaders (three, if you count emission) - volume absorption, and volume scattering. Volume scattering is the slow and noisy one everyone is talking about when they say "volumes are slow". Volume scattering adds an additional bounce possibility within an object, hence the noise.

Volume absorption, however, does not alter a ray path or do any other probabilistic anything. It just attenuates a ray based on how far it transmitted through the object. As a result, it's not really any noisier or slower to calculate then coloring your glass or transparent shader, and the result is much more realistic. In fact, in pretty much any case where you'd use a non-white transparent or glass shader, it's best to leave the glass/transparent shader as full white and color your object instead with the volume absorption shader. This will allow the color to vary through your object based on thickness, which is where almost all color comes from in transparent objects.

Note that finding the exact color will take some trial and error to balance saturation, brightness, and the "density" (overall strength) of the absorption. Be prepared to fiddle around in rendered view for a bit.

$\endgroup$
  • 1
    $\begingroup$ Your second paragraph about volume absorption with glass is a nugget of gold. $\endgroup$ – lumpynose Jan 31 '17 at 17:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.