How does Minecraft sort semitransparent blocks?

For people working on the C++ code.
Post Reply
User avatar
wes
Member
Posts: 45
Joined: Fri Jul 07, 2017 12:00
GitHub: wesofx
In-game: wes

How does Minecraft sort semitransparent blocks?

by wes » Post

I know Minetest does not support semitransparent textures. AFAIK semitransparency is difficult because everything with a semitransparent textures needs to be sorted by distance when it's drawn. Does anyone know how Minecraft sorts its semitransparent blocks? The only solution I can imagine is recreating the VBO for the chunk (block) model as the player moves around it. i.e. if you're standing at the northeast corner of the chunk, it creates the VBO from southwest to northeast so the southwestern blocks are drawn first. (EDIT: That wouldn't even work because it doesn't consider being in the middle of the chunk) Am I over-thinking it? Does anyone know? What do you think?

Code: Select all

#include <iostream>
int main(){while(true) std::cout << "nyan ";}

User avatar
Fixer
Member
Posts: 904
Joined: Sun Jul 31, 2011 11:23
IRC: Fixer
In-game: Fixer
Location: Ukraine

Re: How does Minecraft sort semitransparent blocks?

by Fixer » Post

Try googling, for example, I found this
https://www.reddit.com/r/opengl/comment ... h_sorting/

User avatar
TumeniNodes
Member
Posts: 2941
Joined: Fri Feb 26, 2016 19:49
GitHub: TumeniNodes
IRC: tumeninodes
In-game: TumeniNodes
Location: in the dark recesses of the mind
Contact:

Re: How does Minecraft sort semitransparent blocks?

by TumeniNodes » Post

A Wonderful World

User avatar
wes
Member
Posts: 45
Joined: Fri Jul 07, 2017 12:00
GitHub: wesofx
In-game: wes

Re: How does Minecraft sort semitransparent blocks?

by wes » Post

Fixerol wrote:Try googling, for example, I found this
https://www.reddit.com/r/opengl/comment ... h_sorting/
You did a better job googling than me. I only found "how to make transparent skins" and "sorting machines" lol

EDIT:
For water and clouds, the traditional methods of handling transparency (e.g. a sort on the object, and separate draw call) are probably your best bet. (but maybe not. profile). The other stuff (ice and the like) is rare enough that this might be good enough for it as well, but it's hard to say with certainty.
Thanks, I think that's the answer
Last edited by wes on Wed Jul 12, 2017 07:24, edited 1 time in total.

Code: Select all

#include <iostream>
int main(){while(true) std::cout << "nyan ";}

User avatar
wes
Member
Posts: 45
Joined: Fri Jul 07, 2017 12:00
GitHub: wesofx
In-game: wes

Re: How does Minecraft sort semitransparent blocks?

by wes » Post

Interesting, thanks. There's two rendering passes. Still doesn't explain how the semitransparent blocks are sorted, but because there are less of them there's more options.

Code: Select all

#include <iostream>
int main(){while(true) std::cout << "nyan ";}

juhdanad
New member
Posts: 6
Joined: Tue Jan 03, 2017 21:42
GitHub: juhdanad
IRC: juhdanad
In-game: juhdanad

Re: How does Minecraft sort semitransparent blocks?

by juhdanad » Post


Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests