mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-10-26 14:24:30 +00:00
Fix map rendering issue in xaero's map mods (#1880)
This commit is contained in:
1 parent
0decc515e4
commit
dd68c64239
3 files changed
+24
-4
No files matched your search
@@ -187,6 +187,14 @@ public class GLStateManager {
|
|||||||
private static boolean dirtyTexCoordAttrib;
|
private static boolean dirtyTexCoordAttrib;
|
||||||
private static boolean dirtyLightmapAttrib = true;
|
private static boolean dirtyLightmapAttrib = true;
|
||||||
|
|
||||||
|
private static boolean unit23TexCoordSetDuringDraw = false;
|
||||||
|
|
||||||
|
public static boolean consumeUnit23TexCoordSetDuringDraw() {
|
||||||
|
boolean v = unit23TexCoordSetDuringDraw;
|
||||||
|
unit23TexCoordSetDuringDraw = false;
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
// vertexFlags bits mark attribs the VBO already supplies; FFP supplies the rest via u_Current* uniforms.
|
// vertexFlags bits mark attribs the VBO already supplies; FFP supplies the rest via u_Current* uniforms.
|
||||||
// Skip the backend vertexAttrib call in either case.
|
// Skip the backend vertexAttrib call in either case.
|
||||||
public static void flushDeferredVertexAttribs(boolean hasColor, boolean hasNormal, boolean hasTexCoord, boolean hasLightmap) {
|
public static void flushDeferredVertexAttribs(boolean hasColor, boolean hasNormal, boolean hasTexCoord, boolean hasLightmap) {
|
||||||
@@ -2158,6 +2166,7 @@ public class GLStateManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void glBegin(int mode) {
|
public static void glBegin(int mode) {
|
||||||
|
unit23TexCoordSetDuringDraw = false;
|
||||||
if (DisplayListManager.isRecording()) {
|
if (DisplayListManager.isRecording()) {
|
||||||
ImmediateModeRecorder.begin(mode);
|
ImmediateModeRecorder.begin(mode);
|
||||||
return;
|
return;
|
||||||
@@ -5325,6 +5334,9 @@ public class GLStateManager {
|
|||||||
} else {
|
} else {
|
||||||
final int unit = target - GL13.GL_TEXTURE0;
|
final int unit = target - GL13.GL_TEXTURE0;
|
||||||
if (unit >= 2 && unit < 4) {
|
if (unit >= 2 && unit < 4) {
|
||||||
|
if (DisplayListManager.isRecording() || ImmediateModeRecorder.isDrawing()) {
|
||||||
|
unit23TexCoordSetDuringDraw = true;
|
||||||
|
}
|
||||||
ShaderManager.setCurrentTexCoord(unit, s, t, 0.0f, 1.0f);
|
ShaderManager.setCurrentTexCoord(unit, s, t, 0.0f, 1.0f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ public final class VertexKey {
|
|||||||
private static final int BIT_WIDE_LINE = 36;
|
private static final int BIT_WIDE_LINE = 36;
|
||||||
// Per-unit texmat enable: bits 37-40 (unit 0..3). Unit 1 is the lightmap matrix.
|
// Per-unit texmat enable: bits 37-40 (unit 0..3). Unit 1 is the lightmap matrix.
|
||||||
private static final int BIT_UNIT_TEXMAT_BASE = 37;
|
private static final int BIT_UNIT_TEXMAT_BASE = 37;
|
||||||
|
private static final int BIT_UNIT23_UV_FROM_UNIT0 = 41;
|
||||||
|
|
||||||
public static final int TG_NONE = 0;
|
public static final int TG_NONE = 0;
|
||||||
public static final int TG_OBJ_LINEAR = 1;
|
public static final int TG_OBJ_LINEAR = 1;
|
||||||
@@ -85,6 +86,7 @@ public final class VertexKey {
|
|||||||
public boolean hasVertexNormal() { return bit(BIT_HAS_VERTEX_NORMAL); }
|
public boolean hasVertexNormal() { return bit(BIT_HAS_VERTEX_NORMAL); }
|
||||||
public boolean hasVertexTexCoord() { return bit(BIT_HAS_VERTEX_TEX); }
|
public boolean hasVertexTexCoord() { return bit(BIT_HAS_VERTEX_TEX); }
|
||||||
public boolean hasVertexLightmap() { return bit(BIT_HAS_VERTEX_LIGHTMAP); }
|
public boolean hasVertexLightmap() { return bit(BIT_HAS_VERTEX_LIGHTMAP); }
|
||||||
|
public boolean unit23UvFromUnit0() { return bit(BIT_UNIT23_UV_FROM_UNIT0); }
|
||||||
/** Color material mode (CM_AMBIENT, CM_DIFFUSE, CM_SPECULAR, CM_EMISSION, CM_AMBIENT_AND_DIFFUSE). Only meaningful when colorMaterialEnabled(). */
|
/** Color material mode (CM_AMBIENT, CM_DIFFUSE, CM_SPECULAR, CM_EMISSION, CM_AMBIENT_AND_DIFFUSE). Only meaningful when colorMaterialEnabled(). */
|
||||||
public int colorMaterialMode() { return (int)((packed >> BIT_COLOR_MAT_MODE) & 0x7); }
|
public int colorMaterialMode() { return (int)((packed >> BIT_COLOR_MAT_MODE) & 0x7); }
|
||||||
|
|
||||||
@@ -213,6 +215,10 @@ public final class VertexKey {
|
|||||||
if (hasTexCoord) bits |= (1L << BIT_HAS_VERTEX_TEX);
|
if (hasTexCoord) bits |= (1L << BIT_HAS_VERTEX_TEX);
|
||||||
if (hasLightmap) bits |= (1L << BIT_HAS_VERTEX_LIGHTMAP);
|
if (hasLightmap) bits |= (1L << BIT_HAS_VERTEX_LIGHTMAP);
|
||||||
|
|
||||||
|
if (GLStateManager.consumeUnit23TexCoordSetDuringDraw() && hasTexCoord) {
|
||||||
|
bits |= (1L << BIT_UNIT23_UV_FROM_UNIT0);
|
||||||
|
}
|
||||||
|
|
||||||
if (GLStateManager.anyClipPlaneEnabled()) {
|
if (GLStateManager.anyClipPlaneEnabled()) {
|
||||||
bits |= (1L << BIT_CLIP_PLANES);
|
bits |= (1L << BIT_CLIP_PLANES);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -106,8 +106,8 @@ public final class VertexShaderGenerator {
|
|||||||
if (key.unitTexCoordEnabled(0) && !key.hasVertexTexCoord()) {
|
if (key.unitTexCoordEnabled(0) && !key.hasVertexTexCoord()) {
|
||||||
sb.append("uniform vec4 u_CurrentTexCoord0;\n");
|
sb.append("uniform vec4 u_CurrentTexCoord0;\n");
|
||||||
}
|
}
|
||||||
if (key.unitTexCoordEnabled(2)) sb.append("uniform vec4 u_CurrentTexCoord2;\n");
|
if (key.unitTexCoordEnabled(2) && !key.unit23UvFromUnit0()) sb.append("uniform vec4 u_CurrentTexCoord2;\n");
|
||||||
if (key.unitTexCoordEnabled(3)) sb.append("uniform vec4 u_CurrentTexCoord3;\n");
|
if (key.unitTexCoordEnabled(3) && !key.unit23UvFromUnit0()) sb.append("uniform vec4 u_CurrentTexCoord3;\n");
|
||||||
|
|
||||||
if (key.lightmapEnabled() && !key.hasVertexLightmap()) {
|
if (key.lightmapEnabled() && !key.hasVertexLightmap()) {
|
||||||
sb.append("uniform vec2 u_CurrentLightmapCoord;\n");
|
sb.append("uniform vec2 u_CurrentLightmapCoord;\n");
|
||||||
@@ -363,8 +363,10 @@ public final class VertexShaderGenerator {
|
|||||||
|
|
||||||
for (int i = 2; i < VertexKey.MAX_UNITS; i++) {
|
for (int i = 2; i < VertexKey.MAX_UNITS; i++) {
|
||||||
if (!key.unitTexCoordEnabled(i)) continue;
|
if (!key.unitTexCoordEnabled(i)) continue;
|
||||||
final String src = "u_CurrentTexCoord" + i;
|
final String src = key.unit23UvFromUnit0()
|
||||||
if (key.unitTexMatEnabled(i)) {
|
? "vec4(a_TexCoord0, 0.0, 1.0)"
|
||||||
|
: "u_CurrentTexCoord" + i;
|
||||||
|
if (!key.unit23UvFromUnit0() && key.unitTexMatEnabled(i)) {
|
||||||
sb.append(" v_TexCoord").append(i).append(" = u_TextureMatrix").append(i).append(" * ").append(src).append(";\n");
|
sb.append(" v_TexCoord").append(i).append(" = u_TextureMatrix").append(i).append(" * ").append(src).append(";\n");
|
||||||
} else {
|
} else {
|
||||||
sb.append(" v_TexCoord").append(i).append(" = ").append(src).append(";\n");
|
sb.append(" v_TexCoord").append(i).append(" = ").append(src).append(";\n");
|
||||||
|
|||||||
Reference in new issue
Block a user