If I rotate the model around, the alphaIndex (not sure how to call it) on the meshes change as I move around.
What I’m trying to achieve is, as I look from one side to the other, to see everything in the correct order, without having these artifacts.
What I have here is 3 meshes, cylindrical in shape.
outside is red, cup is black and underprint is inside.
Looking from the side for example, I want to sort the meshes this way:
red
black
green
green
black
red
But because 1 = 6, and 2 = 3, I can’t manually assign alphaIndex values to them, as 6 would be rendered in front or 5, 5 in front of 4 and so on.
My questions are:
Am I doing something wrong here? Is there something obvious that I’m not seeing?
Is it possible to sort depth for each individual face? I know of Facet Depth Sorting, I have tried to apply it, but the meshes must be updatable (as far as I know), and I’m not sure that’s possible with imported meshes (or is it?).
Hi there !
I haven’t worked with this specific case, but it seems right up the alley of PBR materials. What I would try to do is use one single mesh for you glass instead of three, and create a glass material with apparent backfaces (it would probably look more realistic as well !). I can’t fix it in your playground right now, but @PatrickRyan has made an awesome tutorial on babylon’s youtube channel, explaining how to achieve this using the node material editor :
If you’re having trouble with it, I’ll be glad to look further into and try to reproduce the effect on your glass over the weekend.
@jhn11, there are a few things you can do here to render correctly. There are two threads that can help you with this. The first is one that dealt directly with a drinking glass where one of the best solutions was to split the inner faces from the exterior faces which allows you to make use of backface culling to manage some of the sorting issues.
Another example of something like this is the soda bottle demo we created for the last release which also uses a label on glass. In this example, the label uses alpha and transmission values from texture to create the opacity for the label separate from the refraction of the glass.
Let me know if you have any questions about any of these methods, but I think a combination of these examples should get you rolling in the right direction.
I will go through each one individually and see what works best for me and I will eventually post results once it’s finished…or further questions if I have any