Skip to content

Commit

Permalink
Make translucency sorting work with full-precision vertex format
Browse files Browse the repository at this point in the history
  • Loading branch information
embeddedt committed Oct 9, 2023
1 parent e685a7e commit 6589b64
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,21 @@ struct DrawParameters {

//Define packed vertex data
struct Packed {
#if defined(USE_VERTEX_COMPRESSION)
uint a_Pos1; //ushort[2] //x,y //The position of the vertex around the model origin
uint a_Pos2; //ushort[2] //z,w
uint a_Color; //The color of the vertex
uint a_TexCoord; // The block texture coordinate of the vertex
uint a_LightCoord; // The light texture coordinate of the vertex
#else
float a_PosX;
float a_PosY;
float a_PosZ;
uint a_Color;
uint a_TexCoord;
uint a_ChunkId;
uint a_LightCoord;
#endif
};

struct IndexGroup {
Expand Down Expand Up @@ -117,11 +127,15 @@ ChunkMultiDrawRange getSubInfo() {
}

vec4 unpackPos(Packed p) {
#if defined(USE_VERTEX_COMPRESSION)
uint x = p.a_Pos1 & uint(0xFFFF);
uint y = (p.a_Pos1 >> 16);
uint z = p.a_Pos2 & uint(0xFFFF);
uint w = (p.a_Pos2 >> 16);
return vec4(x,y,z,w);
#else
return vec4(p.a_PosX, p.a_PosY, p.a_PosZ, (p.a_ChunkId & 0xFFFFu));
#endif
}

float getAverageDistance(IndexGroup indexGroup) {
Expand Down

0 comments on commit 6589b64

Please sign in to comment.