How does Minecraft sort semitransparent blocks?

For people working on the C++ code.
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 » Tue Jul 11, 2017 09:51

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 ";}
 

Fixerol
Member
 
Posts: 724
Joined: Sun Jul 31, 2011 11:23
Location: Ukraine
IRC: Fixer
In-game: Fixer
 

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

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 » Wed Jul 12, 2017 07:06

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 » Wed Jul 12, 2017 07:18

TumeniNodes wrote:http://greyminecraftcoder.blogspot.com/2013/07/rendering-transparent-blocks.html

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: 4
Joined: Tue Jan 03, 2017 21:42
GitHub: juhdanad
IRC: juhdanad
In-game: juhdanad
 


Return to Partly official engine development



Who is online

Users browsing this forum: No registered users and 2 guests