painn
This commit is contained in:
@@ -2,7 +2,8 @@ struct BlockModel {
|
||||
uint faceData[6];
|
||||
uint flagsA;
|
||||
uint colourTint;
|
||||
uint _pad[8];
|
||||
uint customId;
|
||||
uint _pad[7];
|
||||
};
|
||||
|
||||
//TODO: FIXME: this isnt actually correct cause depending on the face (i think) it could be 1/64 th of a position off
|
||||
|
||||
@@ -17,9 +17,18 @@ layout(location = 1) in flat uvec4 interData;
|
||||
#ifdef DEBUG_RENDER
|
||||
layout(location = 7) in flat uint quadDebug;
|
||||
#endif
|
||||
layout(location = 0) out vec4 outColour;
|
||||
|
||||
|
||||
#ifndef PATCHED_SHADER
|
||||
layout(location = 0) out vec4 outColour;
|
||||
#else
|
||||
|
||||
//Bind the model buffer and import the model system as we need it
|
||||
#define MODEL_BUFFER_BINDING 3
|
||||
#import <voxy:lod/block_model.glsl>
|
||||
|
||||
#endif
|
||||
|
||||
#import <voxy:lod/gl46/bindings.glsl>
|
||||
|
||||
vec4 uint2vec4RGBA(uint colour) {
|
||||
@@ -38,17 +47,23 @@ bool useCutout() {
|
||||
return (interData.x&1u)==1u;
|
||||
}
|
||||
|
||||
vec4 computeColour(vec4 colour) {
|
||||
//Conditional tinting, TODO: FIXME: REPLACE WITH MASK OR SOMETHING, like encode data into the top bit of alpha
|
||||
if (useTinting() && abs(colour.r-colour.g) < 0.02f && abs(colour.g-colour.b) < 0.02f) {
|
||||
colour *= uint2vec4RGBA(interData.z).yzwx;
|
||||
}
|
||||
return (colour * uint2vec4RGBA(interData.y)) + vec4(0,0,0,float(interData.w&0xFFu)/255);
|
||||
uint getFace() {
|
||||
#ifndef PATCHED_SHADER
|
||||
return (interData.w>>8)&7u;
|
||||
#else
|
||||
return (interData.y>>8)&7u;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef PATCHED_SHADER
|
||||
vec2 getLightmap() {
|
||||
//return clamp(vec2(interData.y&0xFu, (interData.y>>4)&0xFu)/16, vec2(4.0f/255), vec2(252.0f/255));
|
||||
return vec2(interData.y&0xFu, (interData.y>>4)&0xFu)/15;
|
||||
}
|
||||
#endif
|
||||
|
||||
uint getFace() {
|
||||
return (interData.w>>8)&7u;
|
||||
uint getModelId() {
|
||||
return interData.x>>16;
|
||||
}
|
||||
|
||||
vec2 getBaseUV() {
|
||||
@@ -58,6 +73,37 @@ vec2 getBaseUV() {
|
||||
return modelUV + (vec2(face>>1, face&1u) * (1.0/(vec2(3.0, 2.0)*256.0)));
|
||||
}
|
||||
|
||||
|
||||
#ifdef PATCHED_SHADER
|
||||
struct VoxyFragmentParameters {
|
||||
//TODO: pass in derivative data
|
||||
vec4 sampledColour;
|
||||
vec2 tile;
|
||||
vec2 uv;
|
||||
uint face;
|
||||
uint modelId;
|
||||
vec2 lightMap;
|
||||
vec4 tinting;
|
||||
uint customId;//Same as iris's modelId
|
||||
};
|
||||
|
||||
void voxy_emitFragment(VoxyFragmentParameters parameters);
|
||||
#else
|
||||
|
||||
vec4 computeColour(vec2 texturePos, vec4 colour) {
|
||||
//Conditional tinting, TODO: FIXME: REPLACE WITH MASK OR SOMETHING, like encode data into the top bit of alpha
|
||||
if (useTinting()) {
|
||||
vec4 tintTest = texture(blockModelAtlas, texturePos, -2);
|
||||
if (abs(tintTest.r-tintTest.g) < 0.02f && abs(tintTest.g-tintTest.b) < 0.02f) {
|
||||
colour *= uint2vec4RGBA(interData.z).yzwx;
|
||||
}
|
||||
}
|
||||
return (colour * uint2vec4RGBA(interData.y)) + vec4(0,0,0,float(interData.w&0xFFu)/255);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
void main() {
|
||||
//Tile is the tile we are in
|
||||
vec2 tile;
|
||||
@@ -92,11 +138,10 @@ void main() {
|
||||
#endif
|
||||
}
|
||||
|
||||
colour = computeColour(colour);
|
||||
|
||||
#ifndef PATCHED_SHADER
|
||||
colour = computeColour(texPos, colour);
|
||||
outColour = colour;
|
||||
|
||||
|
||||
#ifdef DEBUG_RENDER
|
||||
uint hash = quadDebug*1231421+123141;
|
||||
hash ^= hash>>16;
|
||||
@@ -105,6 +150,21 @@ void main() {
|
||||
hash = hash * 1827364925 + 123325621;
|
||||
outColour = vec4(float(hash&15u)/15, float((hash>>4)&15u)/15, float((hash>>8)&15u)/15, 1);
|
||||
#endif
|
||||
|
||||
#else
|
||||
uint modelId = getModelId();
|
||||
BlockModel model = modelData[modelId];
|
||||
vec4 tint = vec4(1);
|
||||
if (useTinting()) {
|
||||
vec4 tintTest = texture(blockModelAtlas, texPos, -2);
|
||||
if (abs(tintTest.r-tintTest.g) < 0.02f && abs(tintTest.g-tintTest.b) < 0.02f) {
|
||||
tint = uint2vec4RGBA(interData.z).yzwx;
|
||||
}
|
||||
}
|
||||
|
||||
voxy_emitFragment(VoxyFragmentParameters(colour, tile, texPos, getFace(), modelId, getLightmap().yx, tint, model.customId));
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -131,4 +191,5 @@ colour = textureGrad(blockModelAtlas, texPos, dx, dy);
|
||||
*/
|
||||
//#else
|
||||
//colour = texture(blockModelAtlas, texPos);
|
||||
//#endif
|
||||
//#endif
|
||||
|
||||
|
||||
@@ -129,6 +129,7 @@ void main() {
|
||||
flags |= uint(!modelHasMipmaps(model))<<1;
|
||||
|
||||
//Compute lighting
|
||||
uint lighting = extractLightId(quad);
|
||||
vec4 tinting = getLighting(extractLightId(quad));
|
||||
|
||||
//Apply model colour tinting
|
||||
@@ -143,6 +144,9 @@ void main() {
|
||||
conditionalTinting = tintColour;
|
||||
}
|
||||
|
||||
setSizeAndFlags(modelId, flags, quadSize);
|
||||
|
||||
#ifndef PATCHED_SHADER
|
||||
uint addin = 0;
|
||||
if (!isTranslucent) {
|
||||
tinting.w = 0.0;
|
||||
@@ -167,8 +171,11 @@ void main() {
|
||||
}
|
||||
}
|
||||
|
||||
setSizeAndFlags(modelId, flags, quadSize);
|
||||
setTintingAndExtra(tinting, conditionalTinting, addin|(face<<8));
|
||||
#else
|
||||
interData.y = lighting|(face<<8);
|
||||
interData.z = tintColour;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -3,6 +3,14 @@
|
||||
"package": "me.cortex.voxy.client.mixin",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"client": [
|
||||
"iris.CustomUniformsAccessor",
|
||||
"iris.IrisRenderingPipelineAccessor",
|
||||
"iris.MixinIrisRenderingPipeline",
|
||||
"iris.MixinIrisSamplers",
|
||||
"iris.MixinMatrixUniforms",
|
||||
"iris.MixinProgramSet",
|
||||
"iris.MixinShaderPackSourceNames",
|
||||
"iris.MixinStandardMacros",
|
||||
"minecraft.MixinClientChunkManager",
|
||||
"minecraft.MixinClientCommonNetworkHandler",
|
||||
"minecraft.MixinClientLoginNetworkHandler",
|
||||
@@ -10,6 +18,7 @@
|
||||
"minecraft.MixinFogRenderer",
|
||||
"minecraft.MixinGlDebug",
|
||||
"minecraft.MixinMinecraftClient",
|
||||
"minecraft.MixinRenderSystem",
|
||||
"minecraft.MixinThreadExecutor",
|
||||
"minecraft.MixinWindow",
|
||||
"minecraft.MixinWorldRenderer",
|
||||
@@ -20,7 +29,5 @@
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
},
|
||||
"mixins": [
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user