Micro quad size increase + fix boarder outline around ssao

This commit is contained in:
mcrcortex
2024-02-26 14:59:22 +10:00
parent 9df9b6fc89
commit 4426d02fbe
3 changed files with 36 additions and 20 deletions

View File

@@ -10,10 +10,12 @@ layout(location = 2) in flat vec4 tinting;
layout(location = 3) in flat vec4 addin; layout(location = 3) in flat vec4 addin;
layout(location = 4) in flat uint flags; layout(location = 4) in flat uint flags;
layout(location = 5) in flat vec4 conditionalTinting; layout(location = 5) in flat vec4 conditionalTinting;
//layout(location = 6) in flat vec4 solidColour;
layout(location = 0) out vec4 outColour; layout(location = 0) out vec4 outColour;
void main() { void main() {
vec2 uv = mod(uv, vec2(1.0))*(1.0/(vec2(3.0,2.0)*256.0)); vec2 uv = mod(uv, vec2(1.0))*(1.0/(vec2(3.0,2.0)*256.0));
//vec4 colour = solidColour;
vec4 colour = texture(blockModelAtlas, uv + baseUV, ((flags>>1)&1u)*-4.0); vec4 colour = texture(blockModelAtlas, uv + baseUV, ((flags>>1)&1u)*-4.0);
if ((flags&1u) == 1 && colour.a <= 0.25f) { if ((flags&1u) == 1 && colour.a <= 0.25f) {
discard; discard;

View File

@@ -12,6 +12,7 @@ layout(location = 2) out flat vec4 tinting;
layout(location = 3) out flat vec4 addin; layout(location = 3) out flat vec4 addin;
layout(location = 4) out flat uint flags; layout(location = 4) out flat uint flags;
layout(location = 5) out flat vec4 conditionalTinting; layout(location = 5) out flat vec4 conditionalTinting;
//layout(location = 6) out flat vec4 solidColour;
uint extractLodLevel() { uint extractLodLevel() {
return uint(gl_BaseInstance)>>27; return uint(gl_BaseInstance)>>27;
@@ -34,8 +35,12 @@ float getDepthOffset(uint faceData, uint face) {
} }
vec2 getFaceSizeOffset(uint faceData, uint corner) { vec2 getFaceSizeOffset(uint faceData, uint corner) {
float EPSILON = 0.001f;
vec4 faceOffsetsSizes = extractFaceSizes(faceData); vec4 faceOffsetsSizes = extractFaceSizes(faceData);
return mix(faceOffsetsSizes.xz, -(1.0-faceOffsetsSizes.yw), bvec2(((corner>>1)&1u)==1, (corner&1u)==1)); //Expand the quads by a very small amount
faceOffsetsSizes.xz -= vec2(EPSILON);
faceOffsetsSizes.yw += vec2(EPSILON);
return mix(faceOffsetsSizes.xz, faceOffsetsSizes.yw-1.0f, bvec2(((corner>>1)&1u)==1, (corner&1u)==1));
} }
//TODO: add a mechanism so that some quads can ignore backface culling //TODO: add a mechanism so that some quads can ignore backface culling
@@ -139,4 +144,7 @@ void main() {
tinting.xyz *= 0.95f; tinting.xyz *= 0.95f;
} }
} }
//solidColour = vec4(vec3(modelId&0xFu, (modelId>>4)&0xFu, (modelId>>8)&0xFu)*(1f/15f),1f);
} }

View File

@@ -48,32 +48,38 @@ void main() {
if (any(lessThanEqual(size, gl_GlobalInvocationID.xy))) { if (any(lessThanEqual(size, gl_GlobalInvocationID.xy))) {
return; return;
} }
vec2 point = vec2(gl_GlobalInvocationID.xy)/size; vec2 scale = vec2(1.0f)/size;
float depth = texture(depthTex, point, -4.0f).r; vec2 point = vec2(gl_GlobalInvocationID.xy)*scale;
point += scale*0.5f;//Offset to the center of the textile
float depth = texture(depthTex, point).r;
vec4 ocolour = vec4(0); vec4 ocolour = vec4(0);
if (depth < 1.0f) { if (depth < 1.0f) {
vec4 colour = texture(colourTex, point); vec4 colour = texture(colourTex, point);
uint metadata = uint(colour.w*255.0f); if (colour == vec4(0.0f, 0.0f, 0.0f, 0.0f)) {
uint face = metadata&7u; ocolour = vec4(1.0f, 0.0f, 0.0f, 1.0f);
uint lod = (metadata>>3)&7u; } else {
bool hasAO = (metadata>>6)!=0; uint metadata = uint(colour.w*255.0f);
vec3 pos = rev3d(vec3(point, depth)); uint face = metadata&7u;
uint lod = (metadata>>3)&7u;
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 //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)) * (float(int(face)&1)*2-1);
//vec3 viewNormal = vec3(uint((face>>1)==2), uint((face>>1)==0), uint((face>>1)==1)) * (-sign(pos)); //vec3 viewNormal = vec3(uint((face>>1)==2), uint((face>>1)==0), uint((face>>1)==1)) * (-sign(pos));
float d = 0.0; float d = 0.0;
if (hasAO) { if (hasAO) {
d = computeAOAngle(pos, 1.0*(1<<lod), viewNormal);//1 d = computeAOAngle(pos, 1.0*(1<<lod), viewNormal);//1
if (d<0.1) { if (d<0.1) {
d = 0.0f; d = 0.0f;
}
} }
}
ocolour = colour; ocolour = colour;
ocolour.xyz *= ((1.0f-d)/3.0f+(2.0f/3.0f)); ocolour.xyz *= ((1.0f-d)/3.0f+(2.0f/3.0f));
ocolour.w = 1.0f; ocolour.w = 1.0f;
}
} }
imageStore(colourTexOut, ivec2(gl_GlobalInvocationID.xy), ocolour); imageStore(colourTexOut, ivec2(gl_GlobalInvocationID.xy), ocolour);
} }