wip tinting
This commit is contained in:
@@ -20,6 +20,7 @@ import me.cortex.voxy.client.core.rendering.util.UploadStream;
|
|||||||
import me.cortex.voxy.common.Logger;
|
import me.cortex.voxy.common.Logger;
|
||||||
import me.cortex.voxy.common.world.WorldEngine;
|
import me.cortex.voxy.common.world.WorldEngine;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.core.Direction;
|
||||||
import org.joml.Matrix4f;
|
import org.joml.Matrix4f;
|
||||||
import org.lwjgl.system.MemoryUtil;
|
import org.lwjgl.system.MemoryUtil;
|
||||||
|
|
||||||
@@ -110,10 +111,15 @@ public class MDICSectionRenderer extends AbstractSectionRenderer<MDICViewport, B
|
|||||||
|
|
||||||
//.defineIf("USE_NV_BARRY", Capabilities.INSTANCE.nvBarryCoords)
|
//.defineIf("USE_NV_BARRY", Capabilities.INSTANCE.nvBarryCoords)
|
||||||
|
|
||||||
.defineIf("DARKENED_TINTING", Minecraft.getInstance().level.effects().constantAmbientLight())//TODO: FIXME: this is really jank atm
|
|
||||||
|
|
||||||
.addSource(ShaderType.VERTEX, vertex);
|
.addSource(ShaderType.VERTEX, vertex);
|
||||||
|
|
||||||
|
//Apply per face tinting
|
||||||
|
var CL = Minecraft.getInstance().level;
|
||||||
|
if (CL.effects().constantAmbientLight()) {
|
||||||
|
builder.define("DARKENED_TINTING");
|
||||||
|
//TODO: generate the tinting table here
|
||||||
|
}
|
||||||
|
|
||||||
String frag = ShaderLoader.parse("voxy:lod/gl46/quads.frag");
|
String frag = ShaderLoader.parse("voxy:lod/gl46/quads.frag");
|
||||||
|
|
||||||
String opaqueFrag = pipeline.patchOpaqueShader(this, frag);
|
String opaqueFrag = pipeline.patchOpaqueShader(this, frag);
|
||||||
|
|||||||
@@ -109,34 +109,8 @@ uvec3 makeRemainingAttributes(const in BlockModel model, const in Quad quad, uin
|
|||||||
addin = encodedData;
|
addin = encodedData;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Apply face tint
|
tinting.rgb *= computeDirectionalFaceTint(isShaded, face);
|
||||||
#ifdef DARKENED_TINTING
|
|
||||||
if (isShaded) {
|
|
||||||
//TODO: make branchless, infact apply ahead of time to the texture itself in ModelManager since that is
|
|
||||||
// per face
|
|
||||||
if ((face>>1) == 1) {//NORTH, SOUTH
|
|
||||||
tinting.xyz *= 0.8f;
|
|
||||||
} else if ((face>>1) == 2) {//EAST, WEST
|
|
||||||
tinting.xyz *= 0.6f;
|
|
||||||
} else {//UP DOWN
|
|
||||||
tinting.xyz *= 0.9f;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
tinting.xyz *= 0.9f;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
if (isShaded) {
|
|
||||||
//TODO: make branchless, infact apply ahead of time to the texture itself in ModelManager since that is
|
|
||||||
// per face
|
|
||||||
if ((face>>1) == 1) {//NORTH, SOUTH
|
|
||||||
tinting.xyz *= 0.8f;
|
|
||||||
} else if ((face>>1) == 2) {//EAST, WEST
|
|
||||||
tinting.xyz *= 0.6f;
|
|
||||||
} else if (face == 0) {//DOWN
|
|
||||||
tinting.xyz *= 0.5f;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
attributes.x = packVec4(tinting);
|
attributes.x = packVec4(tinting);
|
||||||
attributes.y = conditionalTinting;
|
attributes.y = conditionalTinting;
|
||||||
attributes.z = addin|(face<<8);
|
attributes.z = addin|(face<<8);
|
||||||
@@ -193,3 +167,39 @@ vec2 getCornerUV(const in QuadData quad, uint cornerId) {
|
|||||||
return quad.uvCorner + quad.quadSizeAddin*vec2((cornerId>>1)&1u, cornerId&1u);
|
return quad.uvCorner + quad.quadSizeAddin*vec2((cornerId>>1)&1u, cornerId&1u);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef PATCHED_SHADER
|
||||||
|
float computeDirectionalFaceTint(bool isShaded, uint face) {
|
||||||
|
//Apply face tint
|
||||||
|
#ifdef DARKENED_TINTING
|
||||||
|
if (isShaded) {
|
||||||
|
//just index on a const array with the face as an index, will be much faster
|
||||||
|
// or use a vector and select/sum
|
||||||
|
// but per face might be easier?
|
||||||
|
//TODO: make branchless, infact apply ahead of time to the texture itself in ModelManager since that is
|
||||||
|
// per face
|
||||||
|
if ((face>>1) == 1) {//NORTH, SOUTH
|
||||||
|
return 0.8f;
|
||||||
|
} else if ((face>>1) == 2) {//EAST, WEST
|
||||||
|
return 0.6f;
|
||||||
|
} else {//UP DOWN
|
||||||
|
return 0.9f;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return 0.9f;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
if (isShaded) {
|
||||||
|
//TODO: make branchless, infact apply ahead of time to the texture itself in ModelManager since that is
|
||||||
|
// per face
|
||||||
|
if ((face>>1) == 1) {//NORTH, SOUTH
|
||||||
|
return 0.8f;
|
||||||
|
} else if ((face>>1) == 2) {//EAST, WEST
|
||||||
|
return 0.6f;
|
||||||
|
} else if (face == 0) {//DOWN
|
||||||
|
return 0.5f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return 1.0f;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user