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 = 4) in flat uint flags;
layout(location = 5) in flat vec4 conditionalTinting;
//layout(location = 6) in flat vec4 solidColour;
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 = solidColour;
vec4 colour = texture(blockModelAtlas, uv + baseUV, ((flags>>1)&1u)*-4.0);
if ((flags&1u) == 1 && colour.a <= 0.25f) {
discard;

View File

@@ -12,6 +12,7 @@ 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;
//layout(location = 6) out flat vec4 solidColour;
uint extractLodLevel() {
return uint(gl_BaseInstance)>>27;
@@ -34,8 +35,12 @@ float getDepthOffset(uint faceData, uint face) {
}
vec2 getFaceSizeOffset(uint faceData, uint corner) {
float EPSILON = 0.001f;
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
@@ -139,4 +144,7 @@ void main() {
tinting.xyz *= 0.95f;
}
}
//solidColour = vec4(vec3(modelId&0xFu, (modelId>>4)&0xFu, (modelId>>8)&0xFu)*(1f/15f),1f);
}

View File

@@ -48,11 +48,16 @@ void main() {
if (any(lessThanEqual(size, gl_GlobalInvocationID.xy))) {
return;
}
vec2 point = vec2(gl_GlobalInvocationID.xy)/size;
float depth = texture(depthTex, point, -4.0f).r;
vec2 scale = vec2(1.0f)/size;
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);
if (depth < 1.0f) {
vec4 colour = texture(colourTex, point);
if (colour == vec4(0.0f, 0.0f, 0.0f, 0.0f)) {
ocolour = vec4(1.0f, 0.0f, 0.0f, 1.0f);
} else {
uint metadata = uint(colour.w*255.0f);
uint face = metadata&7u;
uint lod = (metadata>>3)&7u;
@@ -75,6 +80,7 @@ void main() {
ocolour.xyz *= ((1.0f-d)/3.0f+(2.0f/3.0f));
ocolour.w = 1.0f;
}
}
imageStore(colourTexOut, ivec2(gl_GlobalInvocationID.xy), ocolour);
}
//vec4 ocolour = vec4(max(0, d), abs(min(0,d)), 0, 1);