use tinting metadata in vert/frag
This commit is contained in:
@@ -25,6 +25,10 @@ uint faceHasAlphaCuttoutOverride(uint faceData) {
|
|||||||
return (faceData>>23)&1u;
|
return (faceData>>23)&1u;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint faceTintState(uint faceData) {
|
||||||
|
return (faceData>>24)&3u;
|
||||||
|
}
|
||||||
|
|
||||||
bool modelHasBiomeLUT(BlockModel model) {
|
bool modelHasBiomeLUT(BlockModel model) {
|
||||||
return ((model.flagsA)&2u) != 0;
|
return ((model.flagsA)&2u) != 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,8 +39,8 @@ bool useMipmaps() {
|
|||||||
return (interData.x&2u)==0u;
|
return (interData.x&2u)==0u;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool useTinting() {
|
uint tintingState() {
|
||||||
return (interData.x&4u)!=0u;
|
return (interData.x>>2)&3u;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool useCutout() {
|
bool useCutout() {
|
||||||
@@ -91,13 +91,19 @@ void voxy_emitFragment(VoxyFragmentParameters parameters);
|
|||||||
#else
|
#else
|
||||||
|
|
||||||
vec4 computeColour(vec2 texturePos, vec4 colour) {
|
vec4 computeColour(vec2 texturePos, vec4 colour) {
|
||||||
//Conditional tinting, TODO: FIXME: REPLACE WITH MASK OR SOMETHING, like encode data into the top bit of alpha
|
//Conditional tinting, TODO: FIXME: this is better but still not great, try encode data into the top bit of alpha so its per pixel
|
||||||
if (useTinting()) {
|
|
||||||
|
uint tintingFunction = tintingState();
|
||||||
|
bool doTint = tintingFunction==2;//Always tint if function == 2
|
||||||
|
if (tintingFunction == 1) {//partial tint
|
||||||
vec4 tintTest = textureLod(blockModelAtlas, texturePos, 0);
|
vec4 tintTest = textureLod(blockModelAtlas, texturePos, 0);
|
||||||
if (abs(tintTest.r-tintTest.g) < 0.02f && abs(tintTest.g-tintTest.b) < 0.02f) {
|
if (abs(tintTest.r-tintTest.g) < 0.02f && abs(tintTest.g-tintTest.b) < 0.02f) {
|
||||||
colour *= uint2vec4RGBA(interData.z).yzwx;
|
doTint = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (doTint) {
|
||||||
|
colour *= uint2vec4RGBA(interData.z).yzwx;
|
||||||
|
}
|
||||||
return (colour * uint2vec4RGBA(interData.y)) + vec4(0,0,0,float(interData.w&0xFFu)/255);
|
return (colour * uint2vec4RGBA(interData.y)) + vec4(0,0,0,float(interData.w&0xFFu)/255);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,13 +181,18 @@ void main() {
|
|||||||
#else
|
#else
|
||||||
uint modelId = getModelId();
|
uint modelId = getModelId();
|
||||||
BlockModel model = modelData[modelId];
|
BlockModel model = modelData[modelId];
|
||||||
vec4 tint = vec4(1);
|
uint tintingFunction = tintingState();
|
||||||
if (useTinting()) {
|
bool doTint = tintingFunction==2;//Always tint if function == 2
|
||||||
|
if (tintingFunction==1) {//Partial tint
|
||||||
vec4 tintTest = texture(blockModelAtlas, texPos, -2);
|
vec4 tintTest = texture(blockModelAtlas, texPos, -2);
|
||||||
if (abs(tintTest.r-tintTest.g) < 0.02f && abs(tintTest.g-tintTest.b) < 0.02f) {
|
if (abs(tintTest.r-tintTest.g) < 0.02f && abs(tintTest.g-tintTest.b) < 0.02f) {
|
||||||
tint = uint2vec4RGBA(interData.z).yzwx;
|
doTint = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
vec4 tint = vec4(1);
|
||||||
|
if (doTint) {
|
||||||
|
tint = uint2vec4RGBA(interData.z).yzwx;
|
||||||
|
}
|
||||||
|
|
||||||
voxy_emitFragment(VoxyFragmentParameters(colour, tile, texPos, getFace(), modelId, getLightmap().yx, tint, model.customId));
|
voxy_emitFragment(VoxyFragmentParameters(colour, tile, texPos, getFace(), modelId, getLightmap().yx, tint, model.customId));
|
||||||
|
|
||||||
|
|||||||
@@ -139,13 +139,16 @@ void main() {
|
|||||||
|
|
||||||
//Apply model colour tinting
|
//Apply model colour tinting
|
||||||
uint tintColour = model.colourTint;
|
uint tintColour = model.colourTint;
|
||||||
|
|
||||||
if (modelHasBiomeLUT(model)) {
|
if (modelHasBiomeLUT(model)) {
|
||||||
tintColour = colourData[tintColour + extractBiomeId(quad)];
|
tintColour = colourData[tintColour + extractBiomeId(quad)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint tintState = faceTintState(faceData);
|
||||||
|
|
||||||
uint conditionalTinting = 0;
|
uint conditionalTinting = 0;
|
||||||
if (tintColour != uint(-1)) {
|
if (tintColour != uint(-1)) {
|
||||||
flags |= 1u<<2;
|
flags |= tintState<<2;
|
||||||
conditionalTinting = tintColour;
|
conditionalTinting = tintColour;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user