Nested transparency appears to be impossible.
I have seen a similar example in URP though.
Anyone done it using HDRP?
That doesn’t really need to be more than one shader though.
(and if you’re fine with it looking a bit frosted, you can get away with just using cubemaps instead of transparency).
Not sure how to do this in HDRP.
I never said it needs 2 shaders. Just mentioned that nested transparency does not seem to work out of the box. One easy way to approach it could be a texture map with 2 different transmission colors but would look very fake
I just found out about a solution that will at some point come in the asset store.
No idea if it will work with HDRP though.
Looks like the author replicated the liquid effect from Alyx.
In general, realistic transparent objects can be a bit of a problem.
These glasses are solid modelled. But they only appear as cylinders.
Yes, after Alyx did the bottle shader update, there were a lot of fan implementation that were similar (I’m pretty sure you can still find code around if you look), none of them involved “nested transparencies”.
The Alyx implementation specifically doesn’t involve transparency at all AFAIK.
The base logic is : calculate the liquid level in world space (easiest thing is to get the middle of the bottle in object space and translate it to world space), then above that level use show the cubemap with a tiny bit of refraction, then below that level show the cubemap with a color tint, a lot of refraction, and maybe a lower cubemap mip so it appears blurrier, then also use the same cubemap for reflection… and you’re done.
That’s the basis of it, you can do a lot more bells and whistles on top of that, but that’s the starting point.
Here’s a super hacky implementation I made. I’ve cut a lot of corners since it’s for a mobile game, but it’s the start of all these types of shaders.
This can also serve as a basis, just do a bit fancier shading than the examples.
You seem to be fixated with the mentioned nested transparency although I never really asked for help with such solution.
In any case, it is the simplest and fastest way to visualize such an object in 3D especially if it is static. i.e. a bottle or a glass of wine. Set two transparent objects one inside the other and you are done. That is why it is important to have experienced graphics people with you when developing a new graphics system for them. Unity has the nasty habit to, make first and ask opinions later, when they already have done things in a way that is not easy to deviate from the cliff.
Thanks for giving it a try and providing such helpful tips and links. (Your attempt came out nice despite being a hack.) The link is the URP version I mentioned in my first post. I understand the logic of it and what is required, just not a programmer Let alone a graphics programmer. I will give the Shader Graph solution a try.
I think Unity should provide such a basic shader in its HDRP samples. It is used a lot in visualization. Unfortunately, it took them a year to provide a simple particle shader and two years for hair.