mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-24 22:24:27 +00:00
Various fixes (#1652)
This commit is contained in:
1 parent
9f0f6a6232
commit
fd2a14a000
8 files changed
+38
-19
No files matched your search
@@ -36,9 +36,10 @@ public class GlslTransformUtils {
|
||||
/** Reserved words added in later GLSL versions that may appear as identifiers in older shaders. */
|
||||
private record ReservedWordRename(Pattern pattern, String replacement) {}
|
||||
private static final Map<Integer, List<ReservedWordRename>> VERSIONED_RESERVED_WORDS = Map.of(
|
||||
// Always rename sample, glsl-transformation-lib doesn't like it
|
||||
// Some reserved words to always rename
|
||||
0, List.of(
|
||||
new ReservedWordRename(Pattern.compile("\\bsample\\b"), RENAMED_PREFIX + "sample")
|
||||
new ReservedWordRename(Pattern.compile("\\bsample\\b"), RENAMED_PREFIX + "sample"),
|
||||
new ReservedWordRename(Pattern.compile("\\bnew\\b"), RENAMED_PREFIX + "new")
|
||||
),
|
||||
400, List.of(
|
||||
new ReservedWordRename(Pattern.compile("\\bsampler\\b(?!\\d)"), RENAMED_PREFIX + "sampler")
|
||||
|
||||
@@ -18,5 +18,5 @@ public interface ITessellatorData {
|
||||
boolean hasColor();
|
||||
boolean hasNormals();
|
||||
boolean hasBrightness();
|
||||
void reset();
|
||||
void angelica$reset();
|
||||
}
|
||||
+2
-2
@@ -79,7 +79,7 @@ public class TessellatorStreamingDrawer {
|
||||
final int vertexCount = tess.getVertexCount();
|
||||
if (vertexCount == 0) {
|
||||
final int result = tess.getRawBufferIndex() * 4;
|
||||
tess.reset();
|
||||
tess.angelica$reset();
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ public class TessellatorStreamingDrawer {
|
||||
}
|
||||
|
||||
final int result = tess.getRawBufferIndex() * 4;
|
||||
tess.reset();
|
||||
tess.angelica$reset();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -596,4 +596,21 @@ class CompatShaderTransformerTest {
|
||||
assertFalse(fragResult.contains("varying"), "no 'varying' keyword in fragment");
|
||||
assertTrue(fragResult.contains("in vec2 v_TexCoord"), "varying → in in fragment");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testReservedWordNewIsRenamed() {
|
||||
String src = """
|
||||
#version 120
|
||||
uniform sampler2D tex;
|
||||
void main() {
|
||||
vec4 color = texture2D(tex, vec2(0.5));
|
||||
float new = color.r > 0.5 ? 1.0 : 0.0;
|
||||
gl_FragColor = vec4(new, new, new, 1.0);
|
||||
}
|
||||
""";
|
||||
|
||||
String result = CompatShaderTransformer.transform(src, true);
|
||||
assertFalse(result.matches("(?s).*\\bnew\\b(?!\\s*\\().*"), "'new' as identifier must be renamed in core profile output\n\n" + result);
|
||||
assertTrue(result.contains("angelica_renamed_new"), "'new' should be renamed to angelica_renamed_new\n\n" + result);
|
||||
}
|
||||
}
|
||||
+5
-2
@@ -29,8 +29,11 @@ public class MixinTessellator_CoreProfile implements ITessellatorData {
|
||||
@Shadow public boolean hasNormals;
|
||||
@Shadow public boolean hasBrightness;
|
||||
|
||||
@Intrinsic
|
||||
@Override public void reset() {}
|
||||
@Shadow public void reset() {}
|
||||
|
||||
public void angelica$reset() {
|
||||
reset();
|
||||
}
|
||||
|
||||
@Inject(method = "draw", at = @At("HEAD"), cancellable = true)
|
||||
private void angelica$coreProfileDraw(CallbackInfoReturnable<Integer> cir) {
|
||||
|
||||
-6
@@ -10,12 +10,6 @@ import org.spongepowered.asm.mixin.injection.ModifyConstant;
|
||||
|
||||
@Mixin(value = EntityRenderer.class, priority = 990)
|
||||
public abstract class MixinEntityRenderer {
|
||||
|
||||
@ModifyConstant(method = "renderWorld", constant = @Constant(doubleValue = 128.0D), expect = 2)
|
||||
double notFine$modifyCloudHeightCheck(double original) {
|
||||
return SettingsManager.cloudTranslucencyCheck;
|
||||
}
|
||||
|
||||
@ModifyArg(method = "setupCameraTransform", at = @At(value = "INVOKE", target = "Lorg/lwjgl/util/glu/Project;gluPerspective(FFFF)V", remap = false), index = 3)
|
||||
private float notFine$modifyFarPlane(float original) {
|
||||
return Math.max(original, SettingsManager.minimumFarPlaneDistance);
|
||||
|
||||
+6
-6
@@ -6,7 +6,9 @@ import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||
import com.llamalad7.mixinextras.sugar.Share;
|
||||
import com.llamalad7.mixinextras.sugar.ref.LocalRef;
|
||||
import jss.notfine.core.SettingsManager;
|
||||
import net.coderbot.iris.Iris;
|
||||
import net.coderbot.iris.shaderpack.CloudSetting;
|
||||
import net.coderbot.iris.compat.dh.DHCompat;
|
||||
import net.coderbot.iris.gl.program.Program;
|
||||
import net.coderbot.iris.pipeline.HandRenderer;
|
||||
@@ -84,7 +86,7 @@ public abstract class MixinEntityRenderer implements IResourceManagerReloadListe
|
||||
|
||||
@ModifyConstant(method = "renderWorld(FJ)V", constant = @Constant(doubleValue = 128.0D), expect = 2)
|
||||
private double iris$alwaysRenderCloudsLate(double cloudHeightCheck) {
|
||||
return IrisApi.getInstance().isShaderPackInUse() ? Double.NEGATIVE_INFINITY : cloudHeightCheck;
|
||||
return IrisApi.getInstance().isShaderPackInUse() ? Double.NEGATIVE_INFINITY : SettingsManager.cloudTranslucencyCheck;
|
||||
}
|
||||
|
||||
@Inject(method = "renderWorld(FJ)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/RenderGlobal;renderSky(F)V"))
|
||||
@@ -101,12 +103,10 @@ public abstract class MixinEntityRenderer implements IResourceManagerReloadListe
|
||||
|
||||
@WrapOperation(method = "renderWorld(FJ)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/EntityRenderer;renderCloudsCheck(Lnet/minecraft/client/renderer/RenderGlobal;F)V"))
|
||||
private void iris$clouds(EntityRenderer instance, RenderGlobal rg, float partialTicks, Operation<Void> original, @Share("pipeline") LocalRef<WorldRenderingPipeline> pipeline) {
|
||||
if (IrisApi.getInstance().isShaderPackInUse()) {
|
||||
return;
|
||||
}
|
||||
|
||||
pipeline.get().setPhase(WorldRenderingPhase.CLOUDS);
|
||||
original.call(instance, rg, partialTicks);
|
||||
if (pipeline.get().getCloudSetting() != CloudSetting.OFF) {
|
||||
original.call(instance, rg, partialTicks);
|
||||
}
|
||||
pipeline.get().setPhase(WorldRenderingPhase.NONE);
|
||||
}
|
||||
|
||||
|
||||
+4
@@ -31,6 +31,10 @@ public class MixinTessellator_CoreProfile implements ITessellatorData {
|
||||
|
||||
@Shadow public void reset() {}
|
||||
|
||||
public void angelica$reset() {
|
||||
reset();
|
||||
}
|
||||
|
||||
@Inject(method = "draw", at = @At("HEAD"), cancellable = true)
|
||||
private void umbra$coreProfileDraw(CallbackInfoReturnable<Integer> cir) {
|
||||
if (TessellatorManager.shouldInterceptDraw((Tessellator)(Object)this)) return;
|
||||
|
||||
Reference in new issue
Block a user