Began work on biome colouring

This commit is contained in:
mcrcortex
2024-01-30 21:51:33 +10:00
parent a3f043a577
commit 8860feb58a
7 changed files with 68 additions and 10 deletions

View File

@@ -71,7 +71,11 @@ layout(binding = 6, std430) readonly restrict buffer ModelBuffer {
BlockModel modelData[];
};
layout(binding = 7, std430) readonly restrict buffer LightingBuffer {
layout(binding = 7, std430) readonly restrict buffer ModelColourBuffer {
uint colourData[];
};
layout(binding = 8, std430) readonly restrict buffer LightingBuffer {
uint lightData[];
};

View File

@@ -14,4 +14,8 @@ uint faceHasAlphaCuttout(uint faceData) {
uint faceHasAlphaCuttoutOverride(uint faceData) {
return (faceData>>23)&1;
}
bool modelHasBiomeLUT(BlockModel model) {
return ((model.flagsA)&2) != 0;
}

View File

@@ -66,25 +66,25 @@ void main() {
vec3 offset = vec3(size, (float(face&1) + getDepthOffset(faceData, face)) * (1<<lodLevel));
if ((face>>1) == 0) {//Up/down
if ((face>>1) == 0) { //Up/down
offset = offset.xzy;
}
//Not needed, here for readability
//if ((face>>1) == 1) {//north/south
// offset = offset.xyz;
//}
if ((face>>1) == 2) {//west/east
if ((face>>1) == 2) { //west/east
offset = offset.zxy;
}
gl_Position = MVP * vec4(corner + offset,1);
gl_Position = MVP * vec4(corner + offset, 1);
//Compute the uv coordinates
vec2 modelUV = vec2(modelId&0xFF, (modelId>>8)&0xFF)*(1f/(256f));
//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(3,2)*256f)));
baseUV = modelUV + (vec2(face%3, face/3) * (1f/(vec2(3, 2)*256f)));
uv = respectiveQuadSize + faceOffset;//Add in the face offset for 0,0 uv
discardAlpha = faceHasAlphaCuttout(faceData);
@@ -96,7 +96,11 @@ void main() {
colourTinting = getLighting(extractLightId(quad));
//Apply model colour tinting
colourTinting *= uint2vec4RGBA(model.colourTint).yzwx;
uint tintColour = model.colourTint;
if (modelHasBiomeLUT(model)) {
tintColour = colourData[tintColour + extractBiomeId(quad)];
}
colourTinting *= uint2vec4RGBA(tintColour).yzwx;
//Apply face tint
if (face == 0) {