Home Game Development opengl – How can I implement semi-transparent/semi-opaque voxels in a voxel sport?

opengl – How can I implement semi-transparent/semi-opaque voxels in a voxel sport?

0
opengl – How can I implement semi-transparent/semi-opaque voxels in a voxel sport?

[ad_1]

I’m making a voxel sport with OpenGL, and I wish to implement water. My voxel world is split into chunks of 16x256x16 cubes (or voxels). Each chunk has its personal VAO with two VBOs, the primary one containing a dice, and the second getting used to retailer the mannequin matrices and the feel coordinates of the seen cubes. I exploit the Instancing technique from OpenGL to render each dice (or voxels) in a piece with a single draw name.

Recently I’ve needed to implement water. For the sake of simplicity, water in my sport is just a dice with a blueish translucent texture. However, the truth that the feel shouldn’t be fully opaque nor fully clear causes points with the depth buffer. With fully clear cubes, I can use the discard; technique within the fragment shader. However right here, I am unable to, or my water texture can be fully clear.

I’ve regarded for options to my downside on Internet, and a technique I discovered to realize correct semi-transparency can be to render the cubes from again to entrance. But rebuilding the second VBO each body would completely destroy my sport’s efficiency. Another resolution I discovered was to first render all of the opaque cubes on this planet, then render all of the translucent cubes. While this resolution sounds good on paper, it means I must create a second VAO containing solely the translucent cubes for each chunk, which once more, can be horrible for the efficiency.

So, what can be one of the simplest ways to implement water in my voxel sport ?

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here