mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-14 01:14:08 +00:00
Add functionality to fake blockId for shaders
This commit is contained in:
1 parent
1e71b1c4d8
commit
720aaca1b7
13 files changed
+56
-15
No files matched your search
@@ -15,7 +15,7 @@
|
||||
|
||||
# Required Dependencies
|
||||
* [UniMixins](https://github.com/LegacyModdingMC/UniMixins/releases) >= 0.1.19
|
||||
* [GTNHLib](https://github.com/GTNewHorizons/GTNHLib/releases) >= 0.6.6
|
||||
* [GTNHLib](https://github.com/GTNewHorizons/GTNHLib/releases) >= 0.6.20
|
||||
* NOTE: Some mods are not required, but a specific version is required if present - see: `Permanent Incompatibilities` below.
|
||||
|
||||
# Known (temporary) Incompatibilities
|
||||
|
||||
+1
-1
@@ -61,7 +61,7 @@ dependencies {
|
||||
|
||||
// Iris Shaders
|
||||
compileOnly('org.jetbrains:annotations:26.0.2')
|
||||
api("com.github.GTNewHorizons:GTNHLib:0.6.13:dev")
|
||||
api("com.github.GTNewHorizons:GTNHLib:0.6.20:dev")
|
||||
shadowImplementation("org.anarres:jcpp:1.4.14") // Apache 2.0
|
||||
shadowImplementation("org.taumc:glsl-transformation-lib:0.2.0-4.g6b42bca") {
|
||||
exclude module: "antlr4" // we only want to shadow the runtime module
|
||||
|
||||
+2
-2
@@ -17,7 +17,7 @@ public class ChunkModelVertexTransformer extends AbstractVertexTransformer<Model
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeQuad(float x, float y, float z, int color, float u, float v, int light) {
|
||||
this.delegate.writeQuad(x + this.offset.x, y + this.offset.y, z + this.offset.z, color, u, v, light);
|
||||
public void writeQuad(float x, float y, float z, int color, float u, float v, int light, int shaderBlockId) {
|
||||
this.delegate.writeQuad(x + this.offset.x, y + this.offset.y, z + this.offset.z, color, u, v, light, shaderBlockId);
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -12,6 +12,7 @@ public interface ModelVertexSink extends VertexSink {
|
||||
* @param u The u-texture of the vertex
|
||||
* @param v The y-texture of the vertex
|
||||
* @param light The packed light-map coordinates of the vertex
|
||||
* @param shaderBlockId The blockId to be passed to the shader
|
||||
*/
|
||||
void writeQuad(float x, float y, float z, int color, float u, float v, int light);
|
||||
void writeQuad(float x, float y, float z, int color, float u, float v, int light, int shaderBlockId);
|
||||
}
|
||||
+1
-1
@@ -14,7 +14,7 @@ public class HFPModelVertexBufferWriterNio extends VertexBufferWriterNio impleme
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeQuad(float x, float y, float z, int color, float u, float v, int light) {
|
||||
public void writeQuad(float x, float y, float z, int color, float u, float v, int light, int shaderBlockId) {
|
||||
this.writeQuadInternal(
|
||||
ModelVertexUtil.denormalizeVertexPositionFloatAsShort(x),
|
||||
ModelVertexUtil.denormalizeVertexPositionFloatAsShort(y),
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ public class HFPModelVertexBufferWriterUnsafe extends VertexBufferWriterUnsafe i
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeQuad(float x, float y, float z, int color, float u, float v, int light) {
|
||||
public void writeQuad(float x, float y, float z, int color, float u, float v, int light, int shaderBlockId) {
|
||||
this.writeQuadInternal(
|
||||
ModelVertexUtil.denormalizeVertexPositionFloatAsShort(x),
|
||||
ModelVertexUtil.denormalizeVertexPositionFloatAsShort(y),
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ public class SFPModelVertexBufferWriterNio extends VertexBufferWriterNio impleme
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeQuad(float x, float y, float z, int color, float u, float v, int light) {
|
||||
public void writeQuad(float x, float y, float z, int color, float u, float v, int light, int shaderBlockId) {
|
||||
int i = this.writeOffset;
|
||||
|
||||
ByteBuffer buffer = this.byteBuffer;
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ public class SFPModelVertexBufferWriterUnsafe extends VertexBufferWriterUnsafe i
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeQuad(float x, float y, float z, int color, float u, float v, int light) {
|
||||
public void writeQuad(float x, float y, float z, int color, float u, float v, int light, int shaderBlockId) {
|
||||
long i = this.writePointer;
|
||||
|
||||
memPutFloat(i, x);
|
||||
|
||||
@@ -150,6 +150,7 @@ public class BlockRenderer {
|
||||
|
||||
final ModelQuadOrientation order = (useSodiumLight || this.useSeparateAo) ? ModelQuadOrientation.orient(light.br) : ModelQuadOrientation.NORMAL;
|
||||
|
||||
int shaderBlockId = quad.getShaderBlockId();
|
||||
for (int dstIndex = 0; dstIndex < 4; dstIndex++) {
|
||||
final int srcIndex = order.getVertexIndex(dstIndex);
|
||||
|
||||
@@ -173,7 +174,7 @@ public class BlockRenderer {
|
||||
final int lm = (useSeparateAo) ? ModelQuadUtil.mergeBakedLight(quad.getLight(srcIndex), light.lm[srcIndex]) :
|
||||
(useSodiumLight) ? light.lm[srcIndex] : quad.getLight(srcIndex);
|
||||
|
||||
sink.writeQuad(x, y, z, color, u, v, lm);
|
||||
sink.writeQuad(x, y, z, color, u, v, lm, shaderBlockId);
|
||||
}
|
||||
|
||||
final TextureAtlasSprite sprite = quad.rubidium$getSprite();
|
||||
|
||||
@@ -405,7 +405,7 @@ public class FluidRenderer {
|
||||
|
||||
int light = this.quadLightData.lm[vertexIdx];
|
||||
|
||||
sink.writeQuad(x, y, z, color, u, v, light);
|
||||
sink.writeQuad(x, y, z, color, u, v, light, -1);
|
||||
|
||||
vertexIdx += lightOrder;
|
||||
}
|
||||
|
||||
@@ -1,13 +1,18 @@
|
||||
package net.coderbot.iris;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.CapturingTessellator;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.TessellatorManager;
|
||||
import com.gtnewhorizons.angelica.AngelicaMod;
|
||||
import com.gtnewhorizons.angelica.Tags;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import com.mojang.realmsclient.gui.ChatFormatting;
|
||||
import cpw.mods.fml.client.registry.ClientRegistry;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.InputEvent;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import lombok.Getter;
|
||||
import net.coderbot.iris.block_rendering.BlockRenderingSettings;
|
||||
import net.coderbot.iris.config.IrisConfig;
|
||||
import net.coderbot.iris.gl.shader.StandardMacros;
|
||||
import net.coderbot.iris.gui.screen.ShaderPackScreen;
|
||||
@@ -24,7 +29,9 @@ import net.coderbot.iris.shaderpack.option.OptionSet;
|
||||
import net.coderbot.iris.shaderpack.option.Profile;
|
||||
import net.coderbot.iris.shaderpack.option.values.MutableOptionValues;
|
||||
import net.coderbot.iris.shaderpack.option.values.OptionValues;
|
||||
import net.coderbot.iris.sodium.block_context.BlockContextHolder;
|
||||
import net.coderbot.iris.texture.pbr.PBRTextureManager;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.multiplayer.WorldClient;
|
||||
@@ -639,4 +646,36 @@ public class Iris {
|
||||
ClientRegistry.registerKeyBinding(toggleShadersKeybind);
|
||||
ClientRegistry.registerKeyBinding(shaderpackScreenKeybind);
|
||||
}
|
||||
|
||||
static BlockContextHolder contextHolder;
|
||||
|
||||
private static int getShaderMaterialOverrideId(Block block, int meta) {
|
||||
if (contextHolder == null) {
|
||||
final Object2IntMap<Block> blockMatches = BlockRenderingSettings.INSTANCE.getBlockMatches();
|
||||
if (blockMatches == null) {
|
||||
return -1;
|
||||
}
|
||||
contextHolder = new BlockContextHolder(blockMatches);
|
||||
|
||||
}
|
||||
contextHolder.set(block, (short) block.getRenderType());
|
||||
return contextHolder.blockId;
|
||||
}
|
||||
|
||||
public static void setShaderMaterialOverride(Block block, int meta) {
|
||||
if (!AngelicaConfig.enableIris)
|
||||
return;
|
||||
|
||||
int blockId = getShaderMaterialOverrideId(block, meta);
|
||||
|
||||
CapturingTessellator tess = (CapturingTessellator) TessellatorManager.get();
|
||||
tess.setShaderBlockId(blockId);
|
||||
}
|
||||
|
||||
public static void resetShaderMaterialOverride() {
|
||||
if (!AngelicaConfig.enableIris)
|
||||
return;
|
||||
CapturingTessellator tess = (CapturingTessellator) TessellatorManager.get();
|
||||
tess.setShaderBlockId(-1);
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -30,7 +30,7 @@ public class XHFPModelVertexBufferWriterNio extends VertexBufferWriterNio implem
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeQuad(float x, float y, float z, int color, float u, float v, int light) {
|
||||
public void writeQuad(float x, float y, float z, int color, float u, float v, int light, int shaderBlockId) {
|
||||
uSum += u;
|
||||
vSum += v;
|
||||
|
||||
@@ -42,7 +42,7 @@ public class XHFPModelVertexBufferWriterNio extends VertexBufferWriterNio implem
|
||||
ModelVertexUtil.denormalizeVertexTextureFloatAsShort(u),
|
||||
ModelVertexUtil.denormalizeVertexTextureFloatAsShort(v),
|
||||
light,
|
||||
contextHolder.blockId,
|
||||
shaderBlockId != -1 ? (short)shaderBlockId : contextHolder.blockId,
|
||||
contextHolder.renderType,
|
||||
ExtendedDataHelper.computeMidBlock(x, y, z, contextHolder.localPosX, contextHolder.localPosY, contextHolder.localPosZ)
|
||||
);
|
||||
|
||||
+2
-2
@@ -30,7 +30,7 @@ public class XHFPModelVertexBufferWriterUnsafe extends VertexBufferWriterUnsafe
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeQuad(float x, float y, float z, int color, float u, float v, int light) {
|
||||
public void writeQuad(float x, float y, float z, int color, float u, float v, int light, int shaderBlockId) {
|
||||
uSum += u;
|
||||
vSum += v;
|
||||
|
||||
@@ -42,7 +42,7 @@ public class XHFPModelVertexBufferWriterUnsafe extends VertexBufferWriterUnsafe
|
||||
ModelVertexUtil.denormalizeVertexTextureFloatAsShort(u),
|
||||
ModelVertexUtil.denormalizeVertexTextureFloatAsShort(v),
|
||||
light,
|
||||
contextHolder.blockId,
|
||||
shaderBlockId != -1 ? (short)shaderBlockId : contextHolder.blockId,
|
||||
contextHolder.renderType,
|
||||
ExtendedDataHelper.computeMidBlock(x, y, z, contextHolder.localPosX, contextHolder.localPosY, contextHolder.localPosZ)
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user