womp womp
This commit is contained in:
@@ -70,6 +70,9 @@ public class ModelTextureBakery {
|
||||
|
||||
|
||||
public ModelTextureBakery(int width, int height) {
|
||||
//TODO: Make this run in a seperate opengl context so that it can run in a seperate thread
|
||||
|
||||
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.colourTex = new GlTexture().store(GL_RGBA8, 1, width, height);
|
||||
|
||||
@@ -2,19 +2,19 @@
|
||||
//TODO: FIXME: this isnt actually correct cause depending on the face (i think) it could be 1/64 th of a position off
|
||||
// but im going to assume that since we are dealing with huge render distances, this shouldent matter that much
|
||||
float extractFaceIndentation(uint faceData) {
|
||||
return float((faceData>>16)&63)/63.0;
|
||||
return float((faceData>>16)&63u)/63.0;
|
||||
}
|
||||
|
||||
vec4 extractFaceSizes(uint faceData) {
|
||||
return (vec4(faceData&0xF, (faceData>>4)&0xF, (faceData>>8)&0xF, (faceData>>12)&0xF)/16.0)+vec4(0.0,1.0/16.0,0.0,1.0/16.0);
|
||||
return (vec4(faceData&0xFu, (faceData>>4)&0xFu, (faceData>>8)&0xFu, (faceData>>12)&0xFu)/16.0)+vec4(0.0,1.0/16.0,0.0,1.0/16.0);
|
||||
}
|
||||
|
||||
uint faceHasAlphaCuttout(uint faceData) {
|
||||
return (faceData>>22)&1;
|
||||
return (faceData>>22)&1u;
|
||||
}
|
||||
|
||||
uint faceHasAlphaCuttoutOverride(uint faceData) {
|
||||
return (faceData>>23)&1;
|
||||
return (faceData>>23)&1u;
|
||||
}
|
||||
|
||||
bool modelHasBiomeLUT(BlockModel model) {
|
||||
|
||||
@@ -24,7 +24,7 @@ layout(local_size_x = 128, local_size_y = 1, local_size_x = 1) in;
|
||||
|
||||
uint encodeLocalLodPos(uint detail, ivec3 pos) {
|
||||
uvec3 detla = (pos - (baseSectionPos >> detail))&((1<<9)-1);
|
||||
return (detail<<29)|(detla.x<<20)|(detla.y<<11)|(detla.z<<2);
|
||||
return (detail<<27)|(detla.x<<18)|(detla.y<<9)|(detla.z);
|
||||
}
|
||||
|
||||
|
||||
@@ -100,42 +100,42 @@ void main() {
|
||||
|
||||
//Down
|
||||
count = (meta.cntB)&0xFFFF;
|
||||
if (((msk&(1<<0))!=0)) {
|
||||
if (((msk&(1u<<0))!=0)) {
|
||||
writeCmd(cmdPtr++, encodedPos, ptr, count);
|
||||
}
|
||||
ptr += count;
|
||||
|
||||
//Up
|
||||
count = (meta.cntB>>16)&0xFFFF;
|
||||
if ((msk&(1<<1))!=0) {
|
||||
if ((msk&(1u<<1))!=0) {
|
||||
writeCmd(cmdPtr++, encodedPos, ptr, count);
|
||||
}
|
||||
ptr += count;
|
||||
|
||||
//North
|
||||
count = (meta.cntC)&0xFFFF;
|
||||
if ((msk&(1<<2))!=0) {
|
||||
if ((msk&(1u<<2))!=0) {
|
||||
writeCmd(cmdPtr++, encodedPos, ptr, count);
|
||||
}
|
||||
ptr += count;
|
||||
|
||||
//South
|
||||
count = (meta.cntC>>16)&0xFFFF;
|
||||
if ((msk&(1<<3))!=0) {
|
||||
if ((msk&(1u<<3))!=0) {
|
||||
writeCmd(cmdPtr++, encodedPos, ptr, count);
|
||||
}
|
||||
ptr += count;
|
||||
|
||||
//West
|
||||
count = (meta.cntD)&0xFFFF;
|
||||
if ((msk&(1<<4))!=0) {
|
||||
if ((msk&(1u<<4))!=0) {
|
||||
writeCmd(cmdPtr++, encodedPos, ptr, count);
|
||||
}
|
||||
ptr += count;
|
||||
|
||||
//East
|
||||
count = (meta.cntD>>16)&0xFFFF;
|
||||
if ((msk&(1<<5))!=0) {
|
||||
if ((msk&(1u<<5))!=0) {
|
||||
writeCmd(cmdPtr++, encodedPos, ptr, count);
|
||||
}
|
||||
ptr += count;
|
||||
|
||||
@@ -10,5 +10,5 @@ out vec4 colour;
|
||||
|
||||
void main() {
|
||||
visibilityData[id] = value;
|
||||
colour = vec4(float(id&7)/7, float((id>>3)&7)/7, float((id>>6)&7)/7, 1);
|
||||
colour = vec4(float(id&7u)/7, float((id>>3)&7u)/7, float((id>>6)&7u)/7, 1);
|
||||
}
|
||||
@@ -14,13 +14,13 @@ layout(location = 5) in flat vec4 conditionalTinting;
|
||||
layout(location = 0) out vec4 outColour;
|
||||
void main() {
|
||||
vec2 uv = mod(uv, vec2(1.0))*(1.0/(vec2(3.0,2.0)*256.0));
|
||||
vec4 colour = texture(blockModelAtlas, uv + baseUV, ((flags>>1)&1)*-4.0);
|
||||
if ((flags&1) == 1 && colour.a <= 0.25f) {
|
||||
vec4 colour = texture(blockModelAtlas, uv + baseUV, ((flags>>1)&1u)*-4.0);
|
||||
if ((flags&1u) == 1 && colour.a <= 0.25f) {
|
||||
discard;
|
||||
}
|
||||
|
||||
//Conditional tinting, TODO: FIXME: REPLACE WITH MASK OR SOMETHING, like encode data into the top bit of alpha
|
||||
if ((flags&(1<<2)) != 0 && abs(colour.r-colour.g) < 0.02f && abs(colour.g-colour.b) < 0.02f) {
|
||||
if ((flags&(1u<<2)) != 0 && abs(colour.r-colour.g) < 0.02f && abs(colour.g-colour.b) < 0.02f) {
|
||||
colour *= conditionalTinting;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,13 +14,13 @@ layout(location = 4) out flat uint flags;
|
||||
layout(location = 5) out flat vec4 conditionalTinting;
|
||||
|
||||
uint extractLodLevel() {
|
||||
return uint(gl_BaseInstance)>>29;
|
||||
return uint(gl_BaseInstance)>>27;
|
||||
}
|
||||
|
||||
//Note the last 2 bits of gl_BaseInstance are unused
|
||||
//Gives a relative position of +-255 relative to the player center in its respective lod
|
||||
ivec3 extractRelativeLodPos() {
|
||||
return (ivec3(gl_BaseInstance)<<ivec3(3,12,21))>>ivec3(23);
|
||||
return (ivec3(gl_BaseInstance)<<ivec3(5,14,23))>>ivec3(23);
|
||||
}
|
||||
|
||||
vec4 uint2vec4RGBA(uint colour) {
|
||||
@@ -35,7 +35,7 @@ float getDepthOffset(uint faceData, uint face) {
|
||||
|
||||
vec2 getFaceSizeOffset(uint faceData, uint corner) {
|
||||
vec4 faceOffsetsSizes = extractFaceSizes(faceData);
|
||||
return mix(faceOffsetsSizes.xz, -(1.0-faceOffsetsSizes.yw), bvec2(((corner>>1)&1)==1, (corner&1)==1));
|
||||
return mix(faceOffsetsSizes.xz, -(1.0-faceOffsetsSizes.yw), bvec2(((corner>>1)&1u)==1, (corner&1u)==1));
|
||||
}
|
||||
|
||||
//TODO: add a mechanism so that some quads can ignore backface culling
|
||||
@@ -66,7 +66,7 @@ void main() {
|
||||
vec2 respectiveQuadSize = vec2(quadSize * ivec2((cornerIdx>>1)&1, cornerIdx&1));
|
||||
vec2 size = (respectiveQuadSize + faceOffset) * (1<<lodLevel);
|
||||
|
||||
vec3 offset = vec3(size, (float(face&1) + getDepthOffset(faceData, face)) * (1<<lodLevel));
|
||||
vec3 offset = vec3(size, (float(face&1u) + getDepthOffset(faceData, face)) * (1<<lodLevel));
|
||||
|
||||
if ((face>>1) == 0) { //Up/down
|
||||
offset = offset.xzy;
|
||||
@@ -83,10 +83,10 @@ void main() {
|
||||
|
||||
|
||||
//Compute the uv coordinates
|
||||
vec2 modelUV = vec2(modelId&0xFF, (modelId>>8)&0xFF)*(1.0/(256.0));
|
||||
vec2 modelUV = vec2(modelId&0xFFu, (modelId>>8)&0xFFu)*(1.0/(256.0));
|
||||
//TODO: make the face orientated by 2x3 so that division is not a integer div and modulo isnt needed
|
||||
// as these are very slow ops
|
||||
baseUV = modelUV + (vec2(face>>1, face&1) * (1.0/(vec2(3.0, 2.0)*256.0)));
|
||||
baseUV = modelUV + (vec2(face>>1, face&1u) * (1.0/(vec2(3.0, 2.0)*256.0)));
|
||||
//TODO: add an option to scale the quad size by the lod level so that
|
||||
// e.g. at lod level 2 a face will have 2x2
|
||||
uv = respectiveQuadSize + faceOffset;//Add in the face offset for 0,0 uv
|
||||
|
||||
@@ -39,8 +39,8 @@ void main() {
|
||||
}
|
||||
vec4 colour = imageLoad(colourTex, ivec2(gl_GlobalInvocationID.xy));
|
||||
uint metadata = uint(colour.w*255.0f);
|
||||
uint face = metadata&7;
|
||||
uint lod = (metadata>>3)&7;
|
||||
uint face = metadata&7u;
|
||||
uint lod = (metadata>>3)&7u;
|
||||
bool hasAO = (metadata>>6)!=0;
|
||||
vec3 pos = rev3d(vec3(point, depth));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user