26

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.

Scott Milner
  • 4,473
  • 1
  • 22
  • 41
uhoh
  • 2,667
  • 2
  • 27
  • 56
  • 1
    @AndrewPrice comments? – uhoh Oct 07 '16 at 10:21
  • Interesting question, but judging by the amount of answers I don't think there's anyone qualified enough about physics to correctly answer it or add any further info beynd what you already established. Maybe you should post your 'edit' as an answer to your own question bellow, so that it may be helpful to others and increase this question's score making it is easier to find for future users – Duarte Farrajota Ramos Oct 07 '16 at 11:49
  • @DuarteFarrajotaRamos there are about 36,000 users here, including many developers. You're pretty sure none of them know much about how refraction is handled in Blender? This question is less than 8 hours old. I'll keep an eye on it, but there are some smart people here and I have confidence in the greater Blender community! – uhoh Oct 07 '16 at 12:04
  • 1
    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. – Duarte Farrajota Ramos Oct 07 '16 at 12:16
  • 1
    @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. – uhoh Oct 07 '16 at 12:19
  • 1
    Sounds wise, I'm also curious about an answer – Duarte Farrajota Ramos Oct 07 '16 at 12:27
  • I watched the video too and I asked me the same question as you did and I was calculating as well and I got the same results as you so It might be correct and Andrew Price did the mistake. – HenrikD Dec 23 '16 at 16:12
  • 1
    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. – gandalf3 Jan 05 '17 at 03:13
  • @gandalf3 either way would be great! You are welcome to edit/modify this question if it helps, and/or mark this one as duplicate if you think it's easier to point back to the original answer. Let me know if I can do anything to help. As a side note, there's discussion of adding MathJax support to Blender SE. – uhoh Jan 05 '17 at 03:35
  • 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. – hawkenfox Mar 25 '17 at 04:41
  • @gandalf3 I'll start an answer if you don't have time to add one here, or we can mark this as duplicate if you think your previous answer is sufficient. – uhoh Mar 25 '17 at 05:13
  • I have two concerns here for practicality. The first being that colors do not necessarily behave in a photo real way out of the box (I know there are different people's opinions on this subject, so I won't press any harder on this front), which all said and done would be physically affected here. The second is that light has to pass through the top surface of the liquid to be physically accurate, it may be covered in foam, but that is just hiding the fact there is another interface to deal with (light will still pass thru, just not as much). Any way I believe that if you are going to apply... – Rick Riggs Apr 04 '17 at 03:11
  • such a method, you would have to also consider the average sum total effect of all interfaces, and I guess at this point let the lut of each color space do what they do. I would really like to see some of @TroyS input here, because although you may seem to solve one problem, you may just trigger a chain of events that get extremely hard to rectify at the end of the day. – Rick Riggs Apr 04 '17 at 03:17
  • @RickRiggs That sounds really interesting, and I'd really like to understand more of what you're saying. I do have some understanding of the limitations of the out-of-the-box RGB three color channel rendering vs trying to propagate (or populate) a spectrum. For the scope of this particular question, I think at least knowing how to get the interfaces physically correct if one wanted to can't be bad, and I can't imagine any benefits to embedding the edge of the beer within the glass. If there are any, that would be a valuable thing to know, and worth mentioning here! – uhoh Apr 04 '17 at 03:31
  • Z fighting comes to mind, I used Andrew's method here. I'm not completely defending that idea either, nor did I use the glass shader in this answer. I am in favor of determined people finding good answers to things, I am just concerned that some of these approaches have some compounding consequences. But hey it never hurts to try. So please don't perceive it as negativity, I'm just concerned that going such a route may start fighting against you practically, like in cases of z fighting. – Rick Riggs Apr 04 '17 at 03:47
  • Am I mistaken or are you proposing that you drop the internal mesh of liquid? – Rick Riggs Apr 04 '17 at 03:48
  • @RickRiggs Double check the line in the question: "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." One mesh surface for each different combination of real-world materials. So the mesh for Glass-Beer would have Blenders IOR set to 0.92 for a transition from n=1.45 to n=1.34 (normals point out). Air-Glass: IOR=1.45, AIr-Beer: IOR=1.34 just as an illustrative example. No negs perceived at all, you've thought about it a lot so just curious! :) – uhoh Apr 04 '17 at 04:35
  • That's a pretty good explanation of the question, and gandalf3 answered the dynamic part of this in his comments to it within that thread. There is at least one more thing that I am struggling with down this thought process though. Consider Air Gaps for items like bubbles. There is no longer a density for light falloff/absorption/scatter in the glass as it is now just air. How do you deal with such things accurately (physically) when you have lost this volume (it is physically no longer there)? – Rick Riggs Apr 04 '17 at 14:46
  • Also there is viscosity to consider with the bubbles in the liquid, that will change elongation (lens properties), size, and speed of rising based on the physical properties of the liquid. Taking away this portion of the mesh leaves no surface tension for the bubbles to fight with. I guess you could still have a mesh there, but make sure it never renders for these reasons. – Rick Riggs Apr 04 '17 at 14:49
  • 1
    @uhoh Yep! I just fixed the $\sin$'s displaying weird. – Scott Milner Feb 27 '18 at 19:48

2 Answers2

1

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.

dpdp
  • 435
  • 2
  • 8
-1

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.

hawkenfox
  • 4,266
  • 1
  • 15
  • 28
  • 1
    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. – uhoh Mar 25 '17 at 05:09
  • 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. – hawkenfox Mar 25 '17 at 05:16
  • 1
    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? – uhoh Mar 25 '17 at 05:19
  • No it's not baloney, I am not belittling the question. I think understanding the math behind it is important. Even scientist don't really understand what light wave does at a quantum level. Everything is purely human assumption at this point in history. – hawkenfox Mar 25 '17 at 05:22
  • 4
    Okay, but let's stick to Blender-relevant topics. This sounds like metaphysic or philosophy. – uhoh Mar 25 '17 at 05:26
  • Philosophy? I work in a 3d production environment, it's not some theory. It's just an engineer vs a scientist argument probably. But hey it's ok if you don't like it. – hawkenfox Mar 27 '17 at 09:34
  • 2
    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. – Jaroslav Jerryno Novotny Feb 13 '18 at 13:32