0
\$\begingroup\$

I am using C++ glew/glfw to make a game, and I currently have different areas of the map and different entity classes using their own VBO's. So far this decision has been informed from a large part of the map being static, lots of the entity's being dynamic, and being calculated independently. The problem is trying to render textures that are largely transparent with some opaque features, in any given VBO correctly.

In this current arrangement, I cannot easily depth sort every transparent face in the C++ realm, because they are being computed individually and being sent in different VBO's.

I have tried changing glDepthFunc to always and greater, but this results in the opaque features of some of the transparent faces being rendered ontop of things closer, which is incorrect.

I have tried disabling glDepthMask, which seems to render them in the order they are sorted in, which aforementioned is an issue, and results in some far opaque features being rendered ontop of where they should be, seemily as a result of how far back in the vertex array they were.

Any ways of solving this is appreciated. Thank you.

\$\endgroup\$
5
  • \$\begingroup\$ You may be interested in Self-occluding object and alpha blending. Correctly ordering translucency is one of the hard problems in rasterization, so if you want it cheap you need to sacrifice some correctness or translucency. If you want correctness with nice feathered edges then it will be expensive. \$\endgroup\$
    – DMGregory
    Dec 27, 2022 at 12:43
  • \$\begingroup\$ @DMGregory I have looked into this, and i run into issues where i have semi transparent textures, such as water and stained glass. I do not mind compromising small correctivity, but it should still look good. Having glass atop water, and having the background water render ontop of the opaque featues of the glass sticks out like a sore thumb. 'glAlphaFunc' has similar issues where the glass doesnt get rendered from the water being more opaque. Perhaps i am misunderstanding? \$\endgroup\$ Dec 28, 2022 at 4:24
  • \$\begingroup\$ You could look into approximate order independent transparent rendering, but these algorithms have their own inaccuracies to grapple with. \$\endgroup\$
    – DMGregory
    Dec 28, 2022 at 6:50
  • \$\begingroup\$ @DMGregory Thanks for your replies! I think I have found partial success in doing 2 draws of transparent textures; i draw all my opaque features as normal, and then I do one run of the transparent textures with the alpha func greater than 0.8, and then finally once more, reversed, for transparent. Is this the method you were advising before? I start to understand the trade off between "it works", and it being a very scary solution; because the 0.8 feels like an arbitrary number that determines how its rendered. I am comfortable.. for now,, but please let me know if this is bad or wrong :) \$\endgroup\$ Dec 28, 2022 at 12:34
  • \$\begingroup\$ If you've solved your problem, please post your solution as an Answer below. I'm not the arbiter of whether an approach is "bad or wrong" — that's determined by whether it serves your players' needs in the context of the game you're making. \$\endgroup\$
    – DMGregory
    Dec 28, 2022 at 14:36

0

You must log in to answer this question.

Browse other questions tagged .