fixes and work on ao, shading, tinting and lighting
This commit is contained in:
@@ -39,6 +39,6 @@ bool modelIsTranslucent(BlockModel model) {
|
||||
return ((model.flagsA)&4u) != 0;
|
||||
}
|
||||
|
||||
bool modelHasMipmaps(BlockModel model) {
|
||||
bool modelIsShaded(BlockModel model) {
|
||||
return ((model.flagsA)&8u) != 0;
|
||||
}
|
||||
@@ -98,7 +98,7 @@ layout(binding = LIGHTING_SAMPLER_BINDING) uniform sampler2D lightSampler;
|
||||
|
||||
vec4 getLighting(uint index) {
|
||||
int i2 = int(index);
|
||||
return texture(lightSampler, clamp((vec2((i2>>4)&0xF, i2&0xF))/16, vec2(8.0f/256), vec2(248.0f/256)));
|
||||
return texture(lightSampler, clamp((vec2((i2>>4)&0xF, i2&0xF))/15, vec2(8.0f/256), vec2(248.0f/256)));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -43,15 +43,15 @@ vec4 uint2vec4RGBA(uint colour) {
|
||||
return vec4((uvec4(colour)>>uvec4(24,16,8,0))&uvec4(0xFF))/255.0;
|
||||
}
|
||||
|
||||
bool useMipmaps() {
|
||||
return (interData.x&2u)==0u;
|
||||
}
|
||||
//bool useMipmaps() {
|
||||
// return (interData.x&2u)==0u;
|
||||
//}
|
||||
|
||||
uint tintingState() {
|
||||
return (interData.x>>2)&3u;
|
||||
}
|
||||
|
||||
bool useCutout() {
|
||||
bool useDiscard() {
|
||||
return (interData.x&1u)==1u;
|
||||
}
|
||||
|
||||
@@ -129,14 +129,16 @@ void main() {
|
||||
vec2 uv2 = modf(uv, tile)*(1.0/(vec2(3.0,2.0)*256.0));
|
||||
vec4 colour;
|
||||
vec2 texPos = uv2 + getBaseUV();
|
||||
if (useMipmaps()) {
|
||||
//This is deprecated, TODO: remove the non mip code path
|
||||
//if (useMipmaps())
|
||||
{
|
||||
vec2 uvSmol = uv*(1.0/(vec2(3.0,2.0)*256.0));
|
||||
vec2 dx = dFdx(uvSmol);//vec2(lDx, dDx);
|
||||
vec2 dy = dFdy(uvSmol);//vec2(lDy, dDy);
|
||||
colour = textureGrad(blockModelAtlas, texPos, dx, dy);
|
||||
} else {
|
||||
colour = textureLod(blockModelAtlas, texPos, 0);
|
||||
}
|
||||
}// else {
|
||||
// colour = textureLod(blockModelAtlas, texPos, 0);
|
||||
//}
|
||||
|
||||
//If we are in shaders and are a helper invocation, just exit, as it enables extra performance gains for small sized
|
||||
// fragments, we do this here after derivative computation
|
||||
@@ -162,7 +164,11 @@ void main() {
|
||||
|
||||
|
||||
//Also, small quad is really fking over the mipping level somehow
|
||||
if (useCutout() && (textureLod(blockModelAtlas, texPos, 0).a <= 0.1f)) {
|
||||
#ifndef TRANSLUCENT
|
||||
if (useDiscard() && (textureLod(blockModelAtlas, texPos, 0).a <= 0.1f)) {
|
||||
#else
|
||||
if (textureLod(blockModelAtlas, texPos, 0).a == 0.0f) {
|
||||
#endif
|
||||
//This is stupidly stupidly bad for divergence
|
||||
//TODO: FIXME, basicly what this do is sample the exact pixel (no lod) for discarding, this stops mipmapping fucking it over
|
||||
#ifndef DEBUG_RENDER
|
||||
|
||||
@@ -58,7 +58,8 @@ uint makeQuadFlags(uint faceData, uint modelId, ivec2 quadSize, const in BlockMo
|
||||
flags |= uint(any(greaterThan(quadSize, ivec2(1)))) & faceHasAlphaCuttoutOverride(faceData);
|
||||
}
|
||||
|
||||
flags |= uint(!modelHasMipmaps(model))<<1;//Not mipmaps
|
||||
//TODO: remove, there is no non mip code path anymore
|
||||
//flags |= uint(!modelHasMipmaps(model))<<1;//Not mipmaps
|
||||
|
||||
flags |= faceTintState(faceData)<<2;
|
||||
flags |= face<<4;//Face
|
||||
@@ -71,6 +72,11 @@ uint packVec4(vec4 vec) {
|
||||
return vec_.x|vec_.y|vec_.z|vec_.w;
|
||||
}
|
||||
|
||||
|
||||
#ifndef PATCHED_SHADER
|
||||
float computeDirectionalFaceTint(bool isShaded, uint face);
|
||||
#endif
|
||||
|
||||
uvec3 makeRemainingAttributes(const in BlockModel model, const in Quad quad, uint lodLevel, uint face) {
|
||||
uvec3 attributes = uvec3(0);
|
||||
|
||||
@@ -88,8 +94,10 @@ uvec3 makeRemainingAttributes(const in BlockModel model, const in Quad quad, uin
|
||||
attributes.y = tintColour;
|
||||
#else
|
||||
bool isTranslucent = modelIsTranslucent(model);
|
||||
bool hasAO = modelHasMipmaps(model);//TODO: replace with per face AO flag
|
||||
bool isShaded = hasAO;//TODO: make this a per face flag
|
||||
|
||||
//afak, these are the same variable in vanilla, (i.e. shaded == ao)
|
||||
bool isShaded = modelIsShaded(model);
|
||||
bool hasAO = isShaded;
|
||||
|
||||
vec4 tinting = getLighting(lighting);
|
||||
|
||||
@@ -202,4 +210,5 @@ float computeDirectionalFaceTint(bool isShaded, uint face) {
|
||||
}
|
||||
#endif
|
||||
return 1.0f;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user