0
votes

(Sorry in advance, I'm not at my computer so I can't provide code) I have a voxel based game, and I wanted to add in transparent textures, namely glass. I realized that transparent textures would throw things off (looking through other blocks), so I used my shaders to remove any alpha components lower than the alpha value of the glass texture. Currently, the glass has an alpha of 0.26 (coordinates range from 0 - 1), and it works fine. But, if I want to add some transparency to the glass instead of removing all transparency, I run into my old issue where you can see through the blocks behind the glass.

I read in a few places that I would need to sort my geometry from front to back. Does this still pertain to my situation even after using shaders? I use display lists, for each chunk in my world, should I keep two lists, one for opaque blocks and one for transparent? So when I render, I would do one pass and render the opaque lists, and then do another render pass, and render the chunks inversely and render the transparent list?

Or is there a better way to do this?

1

1 Answers

0
votes

looking through blocks behind transparent geometry means you still have depth checking enabled meaning the blocks behind the glass didn't get rendered.

I read in a few places that I would need to sort my geometry from front to back. Does this still pertain to my situation even after using shaders?

yes you still need to sort, geometry shaders don't solve that issue

however you only need to sort the transparent geometry when you render them after the opaque geometry (after turning on alpha blending)