mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-26 15:13:01 +00:00
Pass mc_Entity like upstream does (#1627)
This commit is contained in:
1 parent
4acb83be6a
commit
465abf889a
4 files changed
+57
-12
No files matched your search
@@ -428,6 +428,7 @@ public class ShaderTransformer {
|
||||
// Handle mc_midTexCoord for Celeritas
|
||||
patchMultiTexCoord3(transformer, parameters);
|
||||
replaceMidTexCoord(transformer, IrisExtendedChunkVertexType.MID_TEX_SCALE);
|
||||
replaceMCEntity(transformer, parameters);
|
||||
applyIntelHd4000Workaround(transformer);
|
||||
break;
|
||||
case COMPOSITE:
|
||||
@@ -494,6 +495,55 @@ public class ShaderTransformer {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces shader-declared mc_Entity (vec2/ivec2/float/int/etc.) with upstream-compatible unpacking
|
||||
* from a single uint attribute. The uint is packed as ((blockId + 1) << 1) | (renderType & 1).
|
||||
*/
|
||||
public static void replaceMCEntity(Transformer transformer, Parameters parameters) {
|
||||
if (parameters.type != ShaderType.VERTEX) return;
|
||||
|
||||
final int type = transformer.findType("mc_Entity");
|
||||
if (type != 0) {
|
||||
transformer.removeVariable("mc_Entity");
|
||||
}
|
||||
transformer.replaceExpression("mc_Entity", "iris_Entity");
|
||||
switch (type) {
|
||||
case 0:
|
||||
case GLSLLexer.BOOL:
|
||||
return;
|
||||
case GLSLLexer.FLOAT:
|
||||
transformer.injectFunction("float iris_Entity = float(int(mc_Entity >> 1u) - 1);");
|
||||
break;
|
||||
case GLSLLexer.VEC2:
|
||||
transformer.injectFunction("vec2 iris_Entity = vec2(int(mc_Entity >> 1u) - 1, mc_Entity & 1u);");
|
||||
break;
|
||||
case GLSLLexer.VEC3:
|
||||
transformer.injectFunction("vec3 iris_Entity = vec3(int(mc_Entity >> 1u) - 1, mc_Entity & 1u, 0.0);");
|
||||
break;
|
||||
case GLSLLexer.VEC4:
|
||||
transformer.injectFunction("vec4 iris_Entity = vec4(int(mc_Entity >> 1u) - 1, mc_Entity & 1u, 0.0, 1.0);");
|
||||
break;
|
||||
case GLSLLexer.UINT:
|
||||
transformer.injectFunction("uint iris_Entity = uint(int(mc_Entity >> 1u) - 1);");
|
||||
break;
|
||||
case GLSLLexer.INT:
|
||||
transformer.injectFunction("int iris_Entity = int(mc_Entity >> 1u) - 1;");
|
||||
break;
|
||||
case GLSLLexer.IVEC2:
|
||||
transformer.injectFunction("ivec2 iris_Entity = ivec2(int(mc_Entity >> 1u) - 1, mc_Entity & 1u);");
|
||||
break;
|
||||
case GLSLLexer.IVEC3:
|
||||
transformer.injectFunction("ivec3 iris_Entity = ivec3(int(mc_Entity >> 1u) - 1, mc_Entity & 1u, 0);");
|
||||
break;
|
||||
case GLSLLexer.IVEC4:
|
||||
transformer.injectFunction("ivec4 iris_Entity = ivec4(int(mc_Entity >> 1u) - 1, mc_Entity & 1u, 0, 1);");
|
||||
break;
|
||||
default:
|
||||
throw new IllegalStateException("Got an invalid format mc_Entity (type token " + type + ").");
|
||||
}
|
||||
transformer.injectVariable("in uint mc_Entity;");
|
||||
}
|
||||
|
||||
public static void addIfNotExists(Transformer transformer, String name, String code) {
|
||||
if (!transformer.hasVariable(name)) {
|
||||
transformer.injectVariable(code);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package net.coderbot.iris.vertices;
|
||||
|
||||
public final class ExtendedDataHelper {
|
||||
// TODO: Resolve render types for normal blocks?
|
||||
public static final short BLOCK_RENDER_TYPE = -1;
|
||||
// Packed mc_Entity only preserves one terrain/fluid bit, so normal blocks must encode as 0.
|
||||
public static final short BLOCK_RENDER_TYPE = 0;
|
||||
/** All fluids have a ShadersMod render type of 1, to match behavior of Minecraft 1.7 and earlier. */
|
||||
public static final short FLUID_RENDER_TYPE = 1;
|
||||
|
||||
|
||||
Reference in new issue
Block a user