26
$\begingroup$

I just watched the Blender Guru video How to Make a Beer in Blender and stopped at the point where it advises us to make the liquid slightly larger in diameter than the inner diameter of the glass - approximately half way between the inner and outer walls.

I then turned to Fluid in a Glass (and why you’ve been doing it wrong your whole life) where the video points. Although the wording there isn't exactly correct, I think that I understand the point. In the glass shader where you specify IOR, you are not actually specifying the index of refraction of the material inside the volume defined by the mesh. You are actually only specifying the ratio of the index of refractions of the spaces on either side of the mesh. And that's all that Snell's Law actually needs when applied to a single interface:

$$ \mathbf{n_1} \sin(\theta_1) = \mathbf{n_2} \sin(\theta_2) $$

$$ \sin(\theta_1) = \frac{\mathbf{n_2}}{\mathbf{n_1}} \sin(\theta_2) $$

$$ \theta_1 = \sin^{-1}\left(\frac{\mathbf{n_2}}{\mathbf{n_1}} \sin(\theta_2)\right) $$

The problem is that in the physical world, the interface between liquid and glass has a very small index difference - the ratio is nearly 1.0. This is why some transparent object can seem to almost completely disappear when submerged in water.

But it seems to me that the workaround of embedding the liquid into the glass is not going to have the desired effect - if the desired effect is to get closer to a realistic image. It creates two interfaces and each has a large ratio of indices of refraction of something like 1.3 or 1.4, or 1/1.3 and 1/1.4 depending on the directions of the normals.

Question: Wouldn't embedding the liquid inside the glass wall as described in the video produce physically wrong and unrealistic refraction? Since there is just one interface, using two meshes that just touch, or overlap seems like it's just asking for trouble. From a rendering point of view, meshes are interfaces between physical materials, even though we say that we assign "materials" to them we're actually assigning surface characteristics.


edit: I've just found an excellent explanation here, yes the IOR < 1 technique should be correct and a single mesh for the glass-liquid interface used.

I'll use an index of refraction of 1.4 and 1.3 for glass and liquid respectively in the following discussion just to make it simpler.

Wouldn't a more realistic method be to just use a single mesh for the boundary between glass and liquid, and choose IOR = 0.93 with the normals pointing out, or IOR = 1.08 with the normals pointing in?

That doesn't mean that there is an actual index of refraction is 0.93, it just means that when rays pass between the space inside the glass mesh and the space inside the liquid mesh they will be refracted and (Fresnel) reflected based on the correct physics for a single interface between materials within indices of refraction of 1.4 and 1.3?

note: This would require the top of the liquid to have a different mesh or at least a different material, with the IOR set to 1.3 for the correct liquid-air interface behavior. Or you could just put foam on top.

$\endgroup$
20
  • 1
    $\begingroup$ @AndrewPrice comments? $\endgroup$
    – uhoh
    Commented Oct 7, 2016 at 10:21
  • 1
    $\begingroup$ I'm sure there are some pretty smart people around here, certainly smarter than me, just that most are busy and developers rarely stop by, they barely have time for development. Most of the 36000 users are first one-question timers, some never even stick around for the answer. Just saying that good questions like this some times get buried in the avalanche of newcomer questions and regrettably end up forgotten. $\endgroup$ Commented Oct 7, 2016 at 12:16
  • 1
    $\begingroup$ @DuarteFarrajotaRamos OK I see, thanks! Like I say I'll keep an eye on it and let daytime pass around the planet a few times. I think the separate mesh for each interface is indeed the best way to go, so that's what I'll do now. I'm trying to understand why embedding beer inside the wall of the glass is a good thing to do and how it is supposed to be the "right way" to do this, but I'm not in an absolute rush for the answer. $\endgroup$
    – uhoh
    Commented Oct 7, 2016 at 12:19
  • 1
    $\begingroup$ Sounds wise, I'm also curious about an answer $\endgroup$ Commented Oct 7, 2016 at 12:27
  • 1
    $\begingroup$ For what its worth, I believe you are 100% correct. I've been meaning to update my old answer with some comparisons and observations for a while now, and this question seems like the perfect opportunity to do it from scratch. $\endgroup$
    – gandalf3
    Commented Jan 5, 2017 at 3:13

2 Answers 2

1
$\begingroup$

Putting the liquid inside of the glass wall forces the ratio given by Snell's law. Blender gives the inverse of the refraction index when exiting the glass. This brings the refraction back to that of the environment. So, if the ray enters the fluid just before it exits the glass, you get the ratio you're looking for. Yes, this means an inaccurate IOR for the small distance between these surfaces, but unless you're doing an extreme closeup of the edge of this manifold, I don't think you will ever see it in a render.

Your other options are creating a mesh for the liquid that has an ior that corrects for this ratio, but where does that mesh lie? Is it exactly on the glass mesh? In this case you get the same flickering artifacts seen with doubled faces elsewhere. If you space this mesh just beyond where the ray exits the glass, you will have inaccurate results which are more visible in renders. You can of course make a completely new mesh at the interface that is a combination of the glass and the beer, but what happens if you need the beer to slosh around? This turns into a very complex animation.

So, basically putting the beer slightly inside of the glass gives you semi accurate results that seem to give the best trade-offs for accuracy and usability. It's easy to animate, it eliminates the need for multiple meshes and separate materials for the sides and top of the beer. I'm trying to explain this without illustrations, but hopefully you follow.

$\endgroup$
-1
$\begingroup$

I think I heard an explanation somewhere that our real world does this sort of refraction very accurately, the real world is analog and not digital. 3d models and the math behind it are at best an close estimate to the real world, often these estimate would not work in extreme cases like the liquid and glass interface. So there needs to be a way (A cheat), so blender developer made it possible to replicate that effect via making that liquid model sticking itself into the glass.

It's important to have a good clear knowledge on the math behind Snell's law for making close approximate renders to the real world. But unfortunately, the math is really an estimate to the complex quantum physics behavior of light.

Another point is that sometimes physically accurate method rendering engine comes at a cost. The physically accurate system often have the limitation when it comes to real production value because they are so bent on accuracy they take much longer to produce imagery, from a business vantage point it's bad.

NOTE
An engineer on the youtube once said, a scientist job is to find the absolute answer to the question and an engineer tweaks those absolute truths so that knowledge can be transferred to a useful and profitable cause in real world application. We need both scientist and engineers.

$\endgroup$
7
  • 1
    $\begingroup$ I'm pretty sure this is not the best possible answer, and that Blender is perfectly capable of doing refraction within multi-interface structures, as long as you get the normals correct and enter the appropriate RI ratio rather than the absolute RI. However, dispersion (wavelength-dependent RI) requires some substantial cleverness. $\endgroup$
    – uhoh
    Commented Mar 25, 2017 at 5:09
  • $\begingroup$ It's not the best, but one I have personally accepted as an answer a long time ago. I was looking for accuracy but then it's not the same world, one is digital the other analog. $\endgroup$
    – hawkenfox
    Commented Mar 25, 2017 at 5:16
  • 1
    $\begingroup$ That was a polite way to say that it's a bunch of baloney. It's wrong. We have had Maxwell's equations for 150+ years and they just keep working for practical - every day problems like rendering. Can you name anything specifically about the visual appearance of Andrew's beer that can't be modeled accurately with classical electrodynamics? $\endgroup$
    – uhoh
    Commented Mar 25, 2017 at 5:19
  • 4
    $\begingroup$ Okay, but let's stick to Blender-relevant topics. This sounds like metaphysic or philosophy. $\endgroup$
    – uhoh
    Commented Mar 25, 2017 at 5:26
  • 2
    $\begingroup$ This does not answer the question but dodges it with some unrelevant nonsense to the topic like that light is not fully understood and is quantum physics in nature and blah blah - imho refraction and reflection in basic optics is understood well enough to model and simulate properly. I am calling all arguments here invalid as we are not dealing with double slit diffraction and similar quantum effects. $\endgroup$ Commented Feb 13, 2018 at 13:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .