0

I have several transparent cubes in a row close to each other. How to make final frame do not sum colors of Front cube with Back cube?

enter image description here

Which blend mode should I use? Or maybe another solution?

Dmitriy L
  • 120
  • 2
  • 9
  • Well, you shouldn't render those faces if you don't want to see them. – derhass Mar 08 '15 at 20:02
  • Do you mean do not render using some openGl mode or should I build mesh without this faces before render? – Dmitriy L Mar 08 '15 at 20:08
  • There is no general opengl mode which would remove these faces. – derhass Mar 08 '15 at 20:20
  • 1
    If you do this in two passes and use the depth buffer, you can reject those interior faces. Only the outer-most faces will be blended. You'll have to mess around with color writes between passes, but the basic procedure is outlined in an answer I wrote [here](http://stackoverflow.com/questions/19942407/why-is-opengl-gldepthfunc-not-working). _Ignore the parts about drawing with line/fill mode though, that's irrelevant._ – Andon M. Coleman Mar 08 '15 at 22:57
  • @AndonM.Coleman, thanks! Theoretically, will these 2 passes cost like 2 "common" passes (like pass used for default solid render)? – Dmitriy L Mar 10 '15 at 10:52
  • 1
    A depth-only pass is pretty quick on modern hardware, so the first pass (depth enabled, color disabled) should be less expensive than a regular render pass (depth enabled, color enabled). In fact, you can turn depth writes off on the second pass, and that might also improve performance. – Andon M. Coleman Mar 10 '15 at 16:14
  • You might want to try out GL20.glBlendEquationSeparate(); – ByteBit Mar 15 '15 at 17:21

0 Answers0