09-11-2023, 01:48 PM
(This post was last modified: 09-11-2023, 02:20 PM by josemendez.)
(09-11-2023, 12:51 PM)413866 Wrote: Which makes it very weird to me is that we have transparent beakers which work perfectly but only the liquids have a problem.
Because beakers (and most "regular" transparent objects) don't use refraction, just simple alpha blending. If you wanted to use something like an actual crystal shader on the beakers, you'd have the same issue.
Alpha blending just blends the object on top of the screen contents, no need to get them into a texture first. However this doesn't account for the object's thickness or surface direction, so what you see is just a tinted version of the background. Here's fluid with refraction stripped off, just alpha blending (modified the included fluid shader for this, since alpha blending isn't supported out of the box due to its poor result for fluids):
Refraction distorts what's behind the object, which requires to get whatever is behind the refractive object into a texture. You can't do refraction any other way (except raytracing, which is very costly). However refraction accounts for the object's thickness, which enables absorption (making thicker regions of the object less transparent, giving an important visual cue of the volume occupied by the fluid) and distortion (altering the view of what's behind, based on surface thickness and orientation which gives your eye information about the orientation of the fluid's surface). Here's the same fluid, with refraction enabled:
Note how you can immediately tell areas where the fluid is thicker, and clearly see its surface. For your reference, here's an in-depth technical explanation of how to make a simple plane look like liquid, instead of just a transparent layer: https://catlikecoding.com/unity/tutorial...ugh-water/