0
\$\begingroup\$

I do not know if this question might have been asked before, but which method for rendering transparency is more efficient in terms of less lag?:

  1. Rendering the scene from front to back with respect to the camera
  2. Rendering the all the opaque items then all the transparent items from least transparent to most transparent.

Also another question with method 2 above, would disabling the GL_BLEND func when rendering the opaque items reduce usage of memory, and inturn reduce lag, because the fragment shader would not have to run the blend operations, which saves memory, (right?) or have I got it wrong?

\$\endgroup\$

1 Answer 1

2
\$\begingroup\$

The usual way is:

  1. Render opaque objects first

    • Blending disabled (this does not save memory — the render target still has just as many pixels with just as many bits of colour information — but it does save time spent doing the blending calculation)

    • Sorted front to back (so earlier objects tend to occlude later objects, and you can skip drawing some of the distant objects' pixels entirely thanks to early Z rejection)

  2. Render transparent objects second

    • Blending enabled (obviously)

    • Sorted back to front (so distant objects are already in the frame buffer when you draw a closer translucent object over them, allowing you to see the distant one through the near one, attenuated by the near object's translucency. Doing this front to back would end up layering some distant objects on top of nearer ones, making for strange-looking artifacts)

\$\endgroup\$
1
  • \$\begingroup\$ Ah, Thank you!! \$\endgroup\$
    – Dstarred
    Commented Sep 2, 2021 at 11:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .