Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Transparent fluid when using Meta quest passthrough
#11
(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):

[Image: SRMZC1Z.png]

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:

[Image: yNdbaRZ.png]

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/
Reply
#12
(09-11-2023, 01:48 PM)josemendez Wrote: 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):

[Image: SRMZC1Z.png]

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:

[Image: yNdbaRZ.png]

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/
Do you have the fluid shader that is modified to only work with Alpha blending for me?
Reply
#13
(17-11-2023, 02:55 PM)413866 Wrote: Do you have the fluid shader that is modified to only work with Alpha blending for me?

Answered your PM regarding this, check it out.

For those users looking at the same problem: the screenshots above were taken by simply removing refractive distortion and absorption from FluidShader.shader, in order to illustrate how simple alpha blending would look.

However it doesn't change the fact that the renderer's structure assumes opaque objects in the scene have been captured to a texture (similar to a GrabPass), and still blends fluid over this texture so it wouldn't work around the limitation of not being able to access Quest's camera feed. Since the texture's contents are the same as the screen frame buffer's, it looks the same as blending against the screen would look and it's enough for my original purpose of illustrating the difference in both techniques.

A proper implementation that works around Quest's issue would require modifying ObiFluidRenderer.cs to not capture the screen contents and instead blit an alpha-blended version of the fluid directly on top of the screen. This is an extensive modification of both the renderer and the shader, up to you to implement for this particular use case.

regards,
Reply