Added no mipping
This commit is contained in:
@@ -2,11 +2,11 @@
|
||||
//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)/63f;
|
||||
return float((faceData>>16)&63)/63.0;
|
||||
}
|
||||
|
||||
vec4 extractFaceSizes(uint faceData) {
|
||||
return (vec4(faceData&0xF, (faceData>>4)&0xF, (faceData>>8)&0xF, (faceData>>12)&0xF)/16f)+vec4(0f,1f/16f,0f,1f/16f);
|
||||
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);
|
||||
}
|
||||
|
||||
uint faceHasAlphaCuttout(uint faceData) {
|
||||
|
||||
@@ -9,14 +9,22 @@ layout(location = 1) in flat vec2 baseUV;
|
||||
layout(location = 2) in flat vec4 tinting;
|
||||
layout(location = 3) in flat vec4 addin;
|
||||
layout(location = 4) in flat uint flags;
|
||||
layout(location = 5) in flat vec4 conditionalTinting;
|
||||
|
||||
layout(location = 0) out vec4 outColour;
|
||||
void main() {
|
||||
vec2 uv = mod(uv, vec2(1f))*(1f/(vec2(3f,2f)*256f));
|
||||
vec4 colour = texture(blockModelAtlas, uv + baseUV, ((flags>>1)&1)*-4f);
|
||||
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) {
|
||||
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) {
|
||||
colour *= conditionalTinting;
|
||||
}
|
||||
|
||||
outColour = (colour * tinting) + addin;
|
||||
|
||||
//outColour = vec4(uv + baseUV, 0, 1);
|
||||
}
|
||||
@@ -11,6 +11,7 @@ layout(location = 1) out flat vec2 baseUV;
|
||||
layout(location = 2) out flat vec4 tinting;
|
||||
layout(location = 3) out flat vec4 addin;
|
||||
layout(location = 4) out flat uint flags;
|
||||
layout(location = 5) out flat vec4 conditionalTinting;
|
||||
|
||||
uint extractLodLevel() {
|
||||
return uint(gl_BaseInstance)>>29;
|
||||
@@ -23,18 +24,18 @@ ivec3 extractRelativeLodPos() {
|
||||
}
|
||||
|
||||
vec4 uint2vec4RGBA(uint colour) {
|
||||
return vec4((uvec4(colour)>>uvec4(24,16,8,0))&uvec4(0xFF))/255f;
|
||||
return vec4((uvec4(colour)>>uvec4(24,16,8,0))&uvec4(0xFF))/255.0;
|
||||
}
|
||||
|
||||
//Gets the face offset with respect to the face direction (e.g. some will be + some will be -)
|
||||
float getDepthOffset(uint faceData, uint face) {
|
||||
float offset = extractFaceIndentation(faceData);
|
||||
return offset * (1f-((int(face)&1)*2f));
|
||||
return offset * (1.0-((int(face)&1)*2.0));
|
||||
}
|
||||
|
||||
vec2 getFaceSizeOffset(uint faceData, uint corner) {
|
||||
vec4 faceOffsetsSizes = extractFaceSizes(faceData);
|
||||
return mix(faceOffsetsSizes.xz, -(1f-faceOffsetsSizes.yw), bvec2(((corner>>1)&1)==1, (corner&1)==1));
|
||||
return mix(faceOffsetsSizes.xz, -(1.0-faceOffsetsSizes.yw), bvec2(((corner>>1)&1)==1, (corner&1)==1));
|
||||
}
|
||||
|
||||
//TODO: add a mechanism so that some quads can ignore backface culling
|
||||
@@ -78,14 +79,16 @@ void main() {
|
||||
offset = offset.zxy;
|
||||
}
|
||||
|
||||
gl_Position = MVP * vec4(corner + offset, 1f);
|
||||
gl_Position = MVP * vec4(corner + offset, 1.0);
|
||||
|
||||
|
||||
//Compute the uv coordinates
|
||||
vec2 modelUV = vec2(modelId&0xFF, (modelId>>8)&0xFF)*(1f/(256f));
|
||||
vec2 modelUV = vec2(modelId&0xFF, (modelId>>8)&0xFF)*(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%3, face/3) * (1f/(vec2(3f, 2f)*256f)));
|
||||
baseUV = modelUV + (vec2(face%3, face/3) * (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
|
||||
|
||||
flags = faceHasAlphaCuttout(faceData);
|
||||
@@ -103,19 +106,30 @@ void main() {
|
||||
if (modelHasBiomeLUT(model)) {
|
||||
tintColour = colourData[tintColour + extractBiomeId(quad)];
|
||||
}
|
||||
tinting *= uint2vec4RGBA(tintColour).yzwx;
|
||||
|
||||
conditionalTinting = vec4(0);
|
||||
if (tintColour != uint(-1)) {
|
||||
flags |= 1u<<2;
|
||||
conditionalTinting = uint2vec4RGBA(tintColour).yzwx;
|
||||
}
|
||||
|
||||
addin = vec4(0.0);
|
||||
if (!modelIsTranslucent(model)) {
|
||||
tinting.w = 0.0;
|
||||
addin.w = float(face|(lodLevel<<3))/255.0;
|
||||
//Encode the face, the lod level and
|
||||
uint encodedData = 0;
|
||||
encodedData |= face;
|
||||
encodedData |= (lodLevel<<3);
|
||||
encodedData |= uint(modelHasMipmaps(model))<<6;//TODO: add if the face has AO as a face property instead of just using if it has mipmaps
|
||||
addin.w = float(encodedData)/255.0;
|
||||
}
|
||||
|
||||
//Apply face tint
|
||||
if (face == 0) {
|
||||
tinting.xyz *= vec3(0.75, 0.75, 0.75);
|
||||
} else if (face != 1) {
|
||||
tinting.xyz *= vec3((float(face-2)/4.0)*0.3 + 0.7);
|
||||
if ((face>>1) == 0) {
|
||||
tinting.xyz *= 1.0;
|
||||
} else if ((face>>1) == 1) {
|
||||
tinting.xyz *= 0.8;
|
||||
} else {
|
||||
tinting.xyz *= 0.6;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -15,7 +15,10 @@ vec3 rev3d(vec3 clip) {
|
||||
vec3 reDeProject(vec3 pos) {
|
||||
vec4 view = MVP * vec4(pos, 1);
|
||||
view.xy /= view.w;
|
||||
view.z = texture(depthTex, clamp(view.xy*0.5+0.5, 0, 1)).x*2-1;
|
||||
vec2 UV = clamp(view.xy*0.5+0.5, 0, 1);
|
||||
//TODO: sample the colour texture and check if the alpha has the hasAO flag
|
||||
|
||||
view.z = texture(depthTex, UV).x*2-1;
|
||||
view.w = 1;
|
||||
view = invMVP * view;
|
||||
return view.xyz/view.w;
|
||||
@@ -38,20 +41,23 @@ void main() {
|
||||
uint metadata = uint(colour.w*255f);
|
||||
uint face = metadata&7;
|
||||
uint lod = (metadata>>3)&7;
|
||||
bool hasAO = (metadata>>6)!=0;
|
||||
vec3 pos = rev3d(vec3(point, depth));
|
||||
|
||||
//TODO: TODO: only encode the axis, then use then it as as a mask along with pos and multiply by the -sign of everything
|
||||
vec3 viewNormal = vec3(uint((face>>1)==2), uint((face>>1)==0), uint((face>>1)==1)) * (float(int(face)&1)*2-1);
|
||||
//vec3 viewNormal = vec3(uint((face>>1)==2), uint((face>>1)==0), uint((face>>1)==1)) * (-sign(pos));
|
||||
|
||||
|
||||
float d = computeAOAngle(pos, 0.75*(1<<lod), viewNormal);//1
|
||||
if (d<0.1) {
|
||||
d = 0f;
|
||||
float d = 0.0;
|
||||
if (hasAO) {
|
||||
d = computeAOAngle(pos, 1*(1<<lod), viewNormal);//1
|
||||
if (d<0.1) {
|
||||
d = 0f;
|
||||
}
|
||||
}
|
||||
|
||||
vec4 ocolour = colour;
|
||||
ocolour.xyz *= ((1f-d)/2f+0.5f);
|
||||
ocolour.xyz *= ((1f-d)/3f+0.666666f);
|
||||
ocolour.w = 1f;
|
||||
imageStore(colourTex, ivec2(gl_GlobalInvocationID.xy), ocolour);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user