Compare commits

...
Author SHA1 Message Date
Jason Mitchell 1ef691ecc8 Beta Release - Shaders sneak preview (Don't submit issues yet)
Beta Release - Shaders sneak preview (Don't submit issues yet)
Latest set of shader fixes and other improvements
2024-07-14 23:24:03 -07:00
Jason Mitchell b242a13fd6 Update README.MD 2024-07-14 23:17:12 -07:00
2274bfabfd Beta (#461)
* Beta, maybe
* Fixes for entityColor uniform in Iris
* Handle Iris Texture input hook properly in GLSM
* Iris Entity Fixes
* Gbuffer progress
* Wire up BlockEntity gbuffer
* Move Entity gbuffer to a more appropriate place to avoid reentrancy
* Wire up ENTITY_EYES and BEACOM_BEAM
* Clean up unused RenderStateShard files
* This seems marginally more correct?
* Fix shadows from showing on sides of blocks
* Remove overlay
* yeet
* More gl debugging
* Grr, fix water textures
* Add missed enable checks
* Workaround for unset depth texture when using apitrace...
   Use a WrapOperation instead of an Inject with local capture - it wasn't working in dev w/ mixin debug set
* update bs
* Fix crosshair rendering with shaders
* more final
* Disable dynamic lights if shaders are in use
* No light when in water
* Add Void Particle Option + Mixin cleanup
* update bs
* less false

---------

Co-authored-by: Darren Eberly <[email protected]>
Co-authored-by: Caedis <[email protected]>
2024-07-14 23:09:03 -07:00
ev chang 7e4292bdba Add HUDCaching FPS (from PolyPatcher) 2024-07-12 10:49:07 -07:00
Darren Eberly f79e112700 More GLSM Lighting Fixes (#554) 2024-07-11 15:16:15 -04:00
Darren Eberly ba46feb20b GLSM Lighting (#553) 2024-07-11 11:10:04 -04:00
Jason Mitchell 33804c67da Use gtnhlib for coordinate packing/unpacking (#550) 2024-07-07 22:48:58 -07:00
Caedis 3c9353e143 Update dynamic lights from beta branch (#534)
* move dynamic lights lang to angelica

* No light when in water

* update bs

* add battlegear2 compat

Can't add backhand compat since it shares api package path with
battlegear2 (mods/battlegear2/api/core/BattlegearUtils)

* Add backhand 1.4.1+ support
2024-06-26 05:39:26 -07:00
JL2210 77eb3ad46a Fix NPE from MineFactory Reloaded during lag spikes (#522)
* Fix NPE from MineFactory Reloaded during lag spikes

This is an ARR mod and hence cannot be forked.
I decided to put the fix here rather than e.g. Hodgepodge as this is only an
issue with Angelica and seems to be due to its thread safety patches.

* Rewrite as injector

IDE go brr
2024-06-24 17:45:37 -07:00
FalsePattern 8a56ab8ca1 fixed crash with EndlessIDs when joining a multiplayer server 2024-06-09 21:24:26 +08:00
Dakotah fe065803aa THIS ADDS FEATURE REQUEST ISSUE TO GITHUB (#514)
* Add feature request template

* Add feature request template

* Add labels to feature request template automatically

* switch labels to enhancement
2024-05-30 16:30:09 -07:00
ah-OOG-ah f94268c384 Add null check to FluidRenderer (#513)
* Add null check to FluidRenderer

* Update FluidRenderer.java
2024-05-30 17:56:32 -04:00
jss2a98aj f7a8b0f3bf Cloud scaling, distance, and some fixes 2024-05-24 22:16:41 -07:00
embeddedt 8893cf2291 Mark chunk graph as dirty when FOV changes (#506) 2024-05-24 15:59:46 -04:00
76 changed files with 1265 additions and 511 deletions

No files matched your search

@@ -0,0 +1,33 @@
name: Feature Request
description: "Request a feature."
labels: ["enhancement"]
body:
- type: markdown
attributes:
value: "Please use this form to request features. We ask you check if it was already requested though"
- type: input
id: discord
attributes:
label: Your GTNH Discord Username
description: Leave empty if you don't have one, but this will make it harder to contact you if we need additional info.
placeholder: "Example: Wumpus#1234"
- type: textarea
id: request
attributes:
label: Feature Request
description: "Relevant information, as well as relevant images"
placeholder: "Example: https://mclo.gs/ OR submit the file to github by dragging it to this textbox."
validations:
required: true
- type: checkboxes
id: final
attributes:
label: Final Checklist
description: Certify that you read things
options:
- label: "I have searched the issues and haven't found a similar issue."
required: true
- label: "I have read the known incompatibilities and this is not related to one of those."
required: true
- label: "This issue is not related to a feature that is disabed by default - Shaders, MCPF, etc. [They'll be enabled when they're ready for testing]"
required: true
+1
View File
@@ -1,6 +1,7 @@
.gradle
.settings
/.idea/
/.vs/
/.vscode/
/run/
/build/
+12 -7
View File
@@ -6,21 +6,26 @@
* Is it obtuse, or accute? -Caedis
* It's a cute angle -mitchej123
**Alpha Quality - Here there be Dragons**
## **Beta Quality - Here there be Dragons**
* Shaders sneak preview - Please don't report issues yet, but please do submit fixes
* Complementary & BSL mostly function, but have some bugs
* Sildurs, Seus, and any other shader probably doesn't work
# Required Dependencies
* [UniMixins](https://github.com/LegacyModdingMC/UniMixins/releases) >= 0.1.14
* [GTNHLib](https://github.com/GTNewHorizons/GTNHLib/releases) >= 0.2.9
* [GTNHLib](https://github.com/GTNewHorizons/GTNHLib/releases) >= 0.3.2
* NOTE: Some mods are not required, but a specific version is required if present - see: `Permanent Incompatibilities` below.
# Known (temporary) Incompatibilities
* Forge Relocation - Currently non Thread Safe; safe if not in use
* ProjectRed Frames - Currently non Thread Safe; safe if not in use
* ProjectRed Frames - Currently non Thread Safe; safe if not in use'
# Known - Incompatibilities
* EndlessIDs - Not currently planned (Looking for volunteers)
* FalseTweaks - Not currently planned (Looking for volunteers)
# Potential Incompatibilities
* EndlessIDs - Compat commits have been made, might work, might not - not fully tested
# Known Incompatibilities
* FalseTweaks - Not currently planned (Looking for volunteers) [Might work if you effectively disable most of the mod]
* SmoothFont - Not currently planned (Looking for volunteers)
* RPLE - Not currently planned (Looking for volunteers)
@@ -31,7 +36,7 @@
* LWJGL3ify 1.5.4 and below - Use the latest version available, 1.5.7+
* ArchaicFix 0.6.2 and below - Use 0.7.0 or above
* Hodgepodge 2.4.3 and below - [Use 2.4.4 or above](https://github.com/GTNewHorizons/Hodgepodge/releases)
* CodeChicken[Core](https://github.com/GTNewHorizons/CodeChickenCore/releases)/[Lib](https://github.com/GTNewHorizons/CodeChickenLib/releases) <1.2.0 - Threading issues, use 1.2.0+
* CodeChicken[Core](https://github.com/GTNewHorizons/CodeChickenCore/releases)/[Lib](https://github.com/GTNewHorizons/CodeChickenLib/releases) <1.2.0 - Threading issues, use 1.3.0+
* Neodymium - Untested, but unlikely to be compatible. (Chunk Meshing is definitely incompatible, other features might work depending on config)
# Credits
+11 -3
View File
@@ -58,7 +58,7 @@ dependencies {
// Iris Shaders
compileOnly('org.jetbrains:annotations:24.0.1')
api("com.github.GTNewHorizons:GTNHLib:0.2.9:dev")
api("com.github.GTNewHorizons:GTNHLib:0.3.2:dev")
shadowImplementation("org.anarres:jcpp:1.4.14") // Apache 2.0
implementation("io.github.douira:glsl-transformer:1.0.0")
shadowImplementation("io.github.douira:glsl-transformer:1.0.0") { // glsl-transformer Noncommercial License 1.0.0
@@ -78,12 +78,20 @@ dependencies {
compileOnly("com.github.GTNewHorizons:TinkersConstruct:1.12.0-GTNH:dev")
compileOnly("com.github.GTNewHorizons:Natura:2.6.1:dev")
compileOnly("com.falsepattern:chunkapi-mc1.7.10:0.5.0:api") { transitive = false }
compileOnly("com.falsepattern:endlessids-mc1.7.10:1.5-beta0002:dev") { transitive = false }
compileOnly("com.github.GTNewHorizons:Battlegear2:1.4.0:dev") { transitive = false }
compileOnly(rfg.deobf('maven.modrinth:backhand:1.4.1')) { transitive = false }
compileOnly("com.github.GTNewHorizons:Battlegear2:1.4.0:dev") { transitive = false }
compileOnly(rfg.deobf('maven.modrinth:backhand:1.4.1')) { transitive = false }
compileOnly("com.falsepattern:chunkapi-mc1.7.10:0.5.1:api") { transitive = false }
compileOnly("com.falsepattern:endlessids-mc1.7.10:1.5-beta0003:dev") { transitive = false }
compileOnly(rfg.deobf("curse.maven:extrautils-225561:2264383"))
compileOnly(rfg.deobf("curse.maven:dynamiclights-227874:2337326"))
compileOnly("curse.maven:minefactory-reloaded-66672:2277486")
compileOnly("com.github.GTNewHorizons:NotEnoughIds:2.0.3:dev") // Mixin Version
compileOnly("com.github.GTNewHorizons:NotEnoughIds-Legacy:1.4.7:dev") // ASM Version
Binary file not shown.
+1 -1
View File
@@ -16,5 +16,5 @@ pluginManagement {
}
plugins {
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.21'
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.23'
}
@@ -15,7 +15,7 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent;
name = "Angelica",
version = Tags.VERSION,
dependencies = " before:lwjgl3ify@[1.5.3,);" + " after:hodgepodge@[2.4.4,);" + " after:CodeChickenCore@[1.2.0,);"
+ " after:archaicfix@[0.7.0,);" + " required-after:gtnhlib@[0.2.9,);",
+ " after:archaicfix@[0.7.0,);" + " required-after:gtnhlib@[0.3.2,);",
acceptedMinecraftVersions = "[1.7.10]",
acceptableRemoteVersions = "*",
guiFactory = "com.gtnewhorizons.angelica.config.AngelicaGuiConfigFactory")
@@ -1,24 +1,10 @@
package com.gtnewhorizons.angelica.api;
import com.gtnewhorizon.gtnhlib.util.CoordinatePacker;
import com.gtnewhorizons.angelica.compat.mojang.BlockPosImpl;
import net.minecraft.util.MathHelper;
import net.minecraftforge.common.util.ForgeDirection;
import java.math.RoundingMode;
import static com.google.common.math.IntMath.log2;
public interface BlockPos {
int SIZE_BITS_X = 1 + log2(MathHelper.roundUpToPowerOfTwo(30000000), RoundingMode.UNNECESSARY);
int SIZE_BITS_Z = SIZE_BITS_X;
int SIZE_BITS_Y = 64 - SIZE_BITS_X - SIZE_BITS_Z;
long BITS_X = (1L << SIZE_BITS_X) - 1L;
long BITS_Y = (1L << SIZE_BITS_Y) - 1L;
long BITS_Z = (1L << SIZE_BITS_Z) - 1L;
int BIT_SHIFT_Z = SIZE_BITS_Y;
int BIT_SHIFT_X = SIZE_BITS_Y + SIZE_BITS_Z;
int getX();
int getY();
int getZ();
@@ -28,22 +14,6 @@ public interface BlockPos {
long asLong();
static long asLong(int x, int y, int z) {
long l = 0L;
l |= ((long) x & BITS_X) << BIT_SHIFT_X;
l |= ((long) y & BITS_Y) << 0;
l |= ((long) z & BITS_Z) << BIT_SHIFT_Z;
return l;
}
public static int unpackLongX(long packedPos) {
return (int)(packedPos << 64 - BIT_SHIFT_X - SIZE_BITS_X >> 64 - SIZE_BITS_X);
}
public static int unpackLongY(long packedPos) {
return (int)(packedPos << 64 - SIZE_BITS_Y >> 64 - SIZE_BITS_Y);
}
public static int unpackLongZ(long packedPos) {
return (int)(packedPos << 64 - BIT_SHIFT_Z - SIZE_BITS_Z >> 64 - SIZE_BITS_Z);
return CoordinatePacker.pack(x, y, z);
}
}
@@ -5,6 +5,7 @@ import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.versioning.ArtifactVersion;
import cpw.mods.fml.common.versioning.DefaultArtifactVersion;
import net.dries007.holoInventory.HoloInventory;
import xonin.backhand.Backhand;
public class ModStatus {
/**
@@ -23,6 +24,8 @@ public class ModStatus {
public static boolean isEIDBiomeLoaded;
public static boolean isXaerosMinimapLoaded;
public static boolean isHoloInventoryLoaded;
public static boolean isBattlegearLoaded;
public static boolean isBackhandLoaded;
public static void preInit(){
isBetterCrashesLoaded = Loader.isModLoaded("bettercrashes");
@@ -33,6 +36,8 @@ public class ModStatus {
isEIDBiomeLoaded = Loader.isModLoaded("endlessids_biome");
isXaerosMinimapLoaded = Loader.isModLoaded("XaeroMinimap");
isHoloInventoryLoaded = Loader.isModLoaded("holoinventory");
isBattlegearLoaded = Loader.isModLoaded("battlegear2");
isBackhandLoaded = Loader.isModLoaded("backhand");
if (isHoloInventoryLoaded){
isHoloInventoryLoaded = new DefaultArtifactVersion("2.4.4-GTNH")
@@ -41,6 +46,13 @@ public class ModStatus {
) <= 0;
}
if (isBackhandLoaded){
isBackhandLoaded = new DefaultArtifactVersion("1.4.1")
.compareTo(
LoadControllerHelper.getOwningMod(Backhand.class).getProcessedVersion()
) <= 0;
}
isNEIDMetadataExtended = false;
if (isNEIDLoaded) {
@@ -0,0 +1,37 @@
package com.gtnewhorizons.angelica.compat.endlessids;
import com.falsepattern.endlessids.mixin.helpers.ChunkBiomeHook;
import lombok.val;
import net.minecraft.world.chunk.Chunk;
import static com.falsepattern.endlessids.constants.ExtendedConstants.biomeIDMask;
import static com.falsepattern.endlessids.constants.ExtendedConstants.biomeIDNull;
public class EndlessIDsCompat {
public static void sodium$populateBiomes(Chunk chunk) {
if (!(chunk instanceof ChunkBiomeHook hook))
return;
val biomes = hook.getBiomeShortArray();
if (biomes == null)
return;
val cX = chunk.xPosition << 4;
val cZ = chunk.zPosition << 4;
val manager = chunk.worldObj.getWorldChunkManager();
for(var z = 0; z < 16; z++) {
for(var x = 0; x < 16; x++) {
val idx = (z << 4) + x;
val biome = biomes[idx] & biomeIDMask;
if(biome == biomeIDNull) {
val generated = manager.getBiomeGenAt(cX + x, cZ + z);
if (generated == null)
continue;
biomes[idx] = (short)(generated.biomeID & biomeIDMask);
}
}
}
}
}
@@ -1,14 +1,11 @@
package com.gtnewhorizons.angelica.compat.mojang;
import com.gtnewhorizons.angelica.api.BlockPos;
import com.gtnewhorizon.gtnhlib.util.CoordinatePacker;
import com.gtnewhorizons.angelica.api.MutableBlockPos;
import net.minecraft.world.ChunkPosition;
import net.minecraftforge.common.util.ForgeDirection;
import org.joml.Vector3i;
import static com.gtnewhorizons.angelica.api.BlockPos.unpackLongX;
import static com.gtnewhorizons.angelica.api.BlockPos.unpackLongY;
import static com.gtnewhorizons.angelica.api.BlockPos.unpackLongZ;
// Should we keep this?
public class BlockPosImpl extends Vector3i implements MutableBlockPos {
@@ -54,7 +51,7 @@ public class BlockPosImpl extends Vector3i implements MutableBlockPos {
@Override
public long asLong() {
return BlockPos.asLong(this.x, this.y, this.z);
return CoordinatePacker.pack(this.x, this.y, this.z);
}
@Override
@@ -65,6 +62,7 @@ public class BlockPosImpl extends Vector3i implements MutableBlockPos {
@Override
public BlockPosImpl set(long packedPos) {
return set(unpackLongX(packedPos), unpackLongY(packedPos), unpackLongZ(packedPos));
CoordinatePacker.unpack(packedPos, this);
return this;
}
}
@@ -1,21 +0,0 @@
package com.gtnewhorizons.angelica.compat.toremove;
import com.gtnewhorizons.angelica.compat.mojang.VertexFormat;
import lombok.Getter;
@Deprecated
public class DrawState {
@Getter
private final VertexFormat format;
@Getter
private final int vertexCount;
@Getter
private final int mode;
public DrawState(VertexFormat format, int vertexCount, int mode) {
this.format = format;
this.vertexCount = vertexCount;
this.mode = mode;
}
}
@@ -1,8 +0,0 @@
package com.gtnewhorizons.angelica.compat.toremove;
@Deprecated
public class OverlayTexture {
// This is definitely wrong
public static final int NO_OVERLAY = 0;
}
@@ -140,7 +140,6 @@ public abstract class RenderLayer extends RenderPhase { // Aka: RenderType (Iris
private final RenderPhase.DepthTest depthTest;
private final RenderPhase.Cull cull;
private final RenderPhase.Lightmap lightmap;
private final RenderPhase.Overlay overlay;
private final RenderPhase.Fog fog;
private final RenderPhase.Layering layering;
private final RenderPhase.Target target;
@@ -150,7 +149,7 @@ public abstract class RenderLayer extends RenderPhase { // Aka: RenderType (Iris
private final OutlineMode outlineMode;
private final ImmutableList<RenderPhase> phases;
private MultiPhaseParameters(RenderPhase.Texture texture, RenderPhase.Transparency transparency, RenderPhase.DiffuseLighting diffuseLighting, RenderPhase.ShadeModel shadeModel, RenderPhase.Alpha alpha, RenderPhase.DepthTest depthTest, RenderPhase.Cull cull, RenderPhase.Lightmap lightmap, RenderPhase.Overlay overlay, RenderPhase.Fog fog, RenderPhase.Layering layering, RenderPhase.Target target, RenderPhase.Texturing texturing, RenderPhase.WriteMaskState writeMaskState, RenderPhase.LineWidth lineWidth, OutlineMode outlineMode) {
private MultiPhaseParameters(RenderPhase.Texture texture, RenderPhase.Transparency transparency, RenderPhase.DiffuseLighting diffuseLighting, RenderPhase.ShadeModel shadeModel, RenderPhase.Alpha alpha, RenderPhase.DepthTest depthTest, RenderPhase.Cull cull, RenderPhase.Lightmap lightmap, RenderPhase.Fog fog, RenderPhase.Layering layering, RenderPhase.Target target, RenderPhase.Texturing texturing, RenderPhase.WriteMaskState writeMaskState, RenderPhase.LineWidth lineWidth, OutlineMode outlineMode) {
this.texture = texture;
this.transparency = transparency;
this.diffuseLighting = diffuseLighting;
@@ -159,7 +158,6 @@ public abstract class RenderLayer extends RenderPhase { // Aka: RenderType (Iris
this.depthTest = depthTest;
this.cull = cull;
this.lightmap = lightmap;
this.overlay = overlay;
this.fog = fog;
this.layering = layering;
this.target = target;
@@ -167,7 +165,7 @@ public abstract class RenderLayer extends RenderPhase { // Aka: RenderType (Iris
this.writeMaskState = writeMaskState;
this.lineWidth = lineWidth;
this.outlineMode = outlineMode;
this.phases = ImmutableList.of(this.texture, this.transparency, this.diffuseLighting, this.shadeModel, this.alpha, this.depthTest, this.cull, this.lightmap, this.overlay, this.fog, this.layering, this.target, new RenderPhase[]{this.texturing, this.writeMaskState, this.lineWidth});
this.phases = ImmutableList.of(this.texture, this.transparency, this.diffuseLighting, this.shadeModel, this.alpha, this.depthTest, this.cull, this.lightmap, this.fog, this.layering, this.target, this.texturing, this.writeMaskState, this.lineWidth);
}
public boolean equals(Object object) {
@@ -202,7 +200,6 @@ public abstract class RenderLayer extends RenderPhase { // Aka: RenderType (Iris
private RenderPhase.DepthTest depthTest;
private RenderPhase.Cull cull;
private RenderPhase.Lightmap lightmap;
private RenderPhase.Overlay overlay;
private RenderPhase.Fog fog;
private RenderPhase.Layering layering;
private RenderPhase.Target target;
@@ -219,7 +216,6 @@ public abstract class RenderLayer extends RenderPhase { // Aka: RenderType (Iris
this.depthTest = RenderPhase.LEQUAL_DEPTH_TEST;
this.cull = RenderPhase.ENABLE_CULLING;
this.lightmap = RenderPhase.DISABLE_LIGHTMAP;
this.overlay = RenderPhase.DISABLE_OVERLAY_COLOR;
this.fog = RenderPhase.FOG;
this.layering = RenderPhase.NO_LAYERING;
this.target = RenderPhase.MAIN_TARGET;
@@ -263,11 +259,6 @@ public abstract class RenderLayer extends RenderPhase { // Aka: RenderType (Iris
return this;
}
public Builder overlay(RenderPhase.Overlay overlay) {
this.overlay = overlay;
return this;
}
public Builder fog(RenderPhase.Fog fog) {
this.fog = fog;
return this;
@@ -288,7 +279,7 @@ public abstract class RenderLayer extends RenderPhase { // Aka: RenderType (Iris
}
public MultiPhaseParameters build(OutlineMode outlineMode) {
return new MultiPhaseParameters(this.texture, this.transparency, this.diffuseLighting, this.shadeModel, this.alpha, this.depthTest, this.cull, this.lightmap, this.overlay, this.fog, this.layering, this.target, this.texturing, this.writeMaskState, this.lineWidth, outlineMode);
return new MultiPhaseParameters(this.texture, this.transparency, this.diffuseLighting, this.shadeModel, this.alpha, this.depthTest, this.cull, this.lightmap, this.fog, this.layering, this.target, this.texturing, this.writeMaskState, this.lineWidth, outlineMode);
}
}
}
@@ -69,8 +69,6 @@ public abstract class RenderPhase {
protected static final Texturing ENTITY_GLINT_TEXTURING;
protected static final Lightmap ENABLE_LIGHTMAP;
protected static final Lightmap DISABLE_LIGHTMAP;
protected static final Overlay ENABLE_OVERLAY_COLOR;
protected static final Overlay DISABLE_OVERLAY_COLOR;
protected static final DiffuseLighting ENABLE_DIFFUSE_LIGHTING;
protected static final DiffuseLighting DISABLE_DIFFUSE_LIGHTING;
protected static final Cull ENABLE_CULLING;
@@ -177,8 +175,6 @@ public abstract class RenderPhase {
});
ENABLE_LIGHTMAP = new Lightmap(true);
DISABLE_LIGHTMAP = new Lightmap(false);
ENABLE_OVERLAY_COLOR = new Overlay(true);
DISABLE_OVERLAY_COLOR = new Overlay(false);
ENABLE_DIFFUSE_LIGHTING = new DiffuseLighting(true);
DISABLE_DIFFUSE_LIGHTING = new DiffuseLighting(false);
ENABLE_CULLING = new Cull(true);
@@ -505,25 +501,6 @@ public abstract class RenderPhase {
}
public static class Overlay extends Toggleable {
public Overlay(boolean overlayColor) {
super("overlay", () -> {
if (overlayColor) {
throw new RuntimeException("Not Implemented Yet");
// MinecraftClient.getInstance().gameRenderer.getOverlayTexture().setupOverlayColor();
}
}, () -> {
if (overlayColor) {
throw new RuntimeException("Not Implemented Yet");
// MinecraftClient.getInstance().gameRenderer.getOverlayTexture().teardownOverlayColor();
}
}, overlayColor);
}
}
public static class Lightmap extends Toggleable {
public Lightmap(boolean lightmap) {
super("lightmap", () -> {
@@ -35,13 +35,11 @@ public class AngelicaConfig {
@Config.Comment("Enable Iris Shaders [Requires Sodium]")
@Config.DefaultBoolean(false)
@Config.RequiresMcRestart
@Config.Ignore()
public static boolean enableIris;
@Config.Comment("Enable MCPatcherForge features, still in Alpha. Individual features are toggled in mcpatcher.json")
@Config.DefaultBoolean(false)
@Config.RequiresMcRestart
@Config.Ignore()
public static boolean enableMCPatcherForgeFeatures;
@Config.Comment("Replace some vanilla render paths with more optimized versions. Disable if you encounter mixin conflicts.")
@@ -70,18 +68,23 @@ public class AngelicaConfig {
@Config.DefaultBoolean(true)
public static boolean showSplashMemoryBar;
@Config.Comment("Renders the HUD elements once per tick and reuses the pixels to improve performance. [Experimental]")
@Config.Comment("Renders the HUD elements once per 20 frames (by default) and reuses the pixels to improve performance. [Experimental]")
@Config.DefaultBoolean(true)
@Config.RequiresMcRestart
public static boolean enableHudCaching;
@Config.Comment("The amount of frames to wait before updating the HUD elements. [Experimental]")
@Config.DefaultInt(20)
@Config.RangeInt(min = 1, max = 60)
public static int hudCachingFPS = 20;
@Config.Comment("Batch drawScreen fonts [Experimental]")
@Config.DefaultBoolean(true)
@Config.RequiresMcRestart
public static boolean enableFontRenderer;
@Config.Comment("Enable Dynamic Lights")
@Config.DefaultBoolean(false)
@Config.DefaultBoolean(true)
@Config.RequiresMcRestart
public static boolean enableDynamicLights;
@@ -110,6 +113,11 @@ public class AngelicaConfig {
@Config.RequiresMcRestart
public static boolean fixExtraUtilsSodiumCompat;
@Config.Comment("Fix thread-safety issues in MineFactory Reloaded")
@Config.DefaultBoolean(true)
@Config.RequiresMcRestart
public static boolean fixMineFactoryReloadedSodiumCompat;
@Config.Comment("Fix RenderBlockFluid reading the block type from the world access multiple times")
@Config.DefaultBoolean(true)
@Config.RequiresMcRestart
@@ -1,15 +1,21 @@
package com.gtnewhorizons.angelica.dynamiclights;
import com.gtnewhorizons.angelica.api.BlockPos;
import com.gtnewhorizon.gtnhlib.util.CoordinatePacker;
import com.gtnewhorizons.angelica.compat.ModStatus;
import com.gtnewhorizons.angelica.compat.mojang.BlockPosImpl;
import com.gtnewhorizons.angelica.config.AngelicaConfig;
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
import me.jellysquid.mods.sodium.client.render.SodiumWorldRenderer;
import mods.battlegear2.api.core.IBattlePlayer;
import mods.battlegear2.api.core.IInventoryPlayerBattle;
import net.irisshaders.iris.api.v0.IrisApi;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
@@ -18,8 +24,9 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.MathHelper;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import xonin.backhand.api.core.BackhandUtils;
import xonin.backhand.api.core.IBackhandPlayer;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.function.Predicate;
@@ -42,7 +49,7 @@ public class DynamicLights {
}
public static boolean isEnabled() {
return Mode.isEnabled() && AngelicaConfig.enableDynamicLights;
return AngelicaConfig.enableDynamicLights && Mode.isEnabled() && !IrisApi.getInstance().isShaderPackInUse();
}
/**
@@ -271,7 +278,7 @@ public class DynamicLights {
* @param chunkPos the packed chunk position
*/
public static void scheduleChunkRebuild(@NotNull SodiumWorldRenderer renderer, long chunkPos) {
scheduleChunkRebuild(renderer, BlockPos.unpackLongX(chunkPos), BlockPos.unpackLongY(chunkPos), BlockPos.unpackLongZ(chunkPos));
scheduleChunkRebuild(renderer, CoordinatePacker.unpackX(chunkPos), CoordinatePacker.unpackY(chunkPos), CoordinatePacker.unpackZ(chunkPos));
}
public static void scheduleChunkRebuild(@NotNull SodiumWorldRenderer renderer, int x, int y, int z) {
@@ -287,7 +294,7 @@ public class DynamicLights {
*/
public static void updateTrackedChunks(@NotNull BlockPosImpl chunkPos, @Nullable LongOpenHashSet old, @Nullable LongOpenHashSet newPos) {
if (old != null || newPos != null) {
long pos = chunkPos.asLong();
final long pos = chunkPos.asLong();
if (old != null)
old.remove(pos);
if (newPos != null)
@@ -319,6 +326,9 @@ public class DynamicLights {
* @return the luminance of the item
*/
public static int getLuminanceFromItemStack(@NotNull ItemStack stack, boolean submergedInWater) {
// TODO only have certain items not glow in water?
if (submergedInWater) return 0;
Item item = stack.getItem();
if (item instanceof ItemBlock itemBlock) {
Block block = itemBlock.field_150939_a;
@@ -337,15 +347,15 @@ public class DynamicLights {
if (entity.fire > 0) return 15;
if (entity instanceof EntityItem item) {
return getLuminanceFromItemStack(item.getEntityItem(), item.isInWater());
return getLuminanceFromItemStack(item.getEntityItem(), item.isInsideOfMaterial(Material.water));
}
if (entity instanceof EntityLivingBase living) {
int luminance = 0;
boolean inWater = living.isInWater();
boolean inWater = living.isInsideOfMaterial(Material.water);
// check equipment + hand for light
// check equipment + hand for light (should work for all entities)
ItemStack itemStack;
for (int i = 0; i < 5; i++) {
if ((itemStack = living.getEquipmentInSlot(i)) != null) {
@@ -353,6 +363,23 @@ public class DynamicLights {
}
}
if (ModStatus.isBattlegearLoaded &&
living instanceof EntityPlayer player &&
player instanceof IBattlePlayer battlePlayer &&
battlePlayer.battlegear2$isBattlemode()
) {
ItemStack offhand = ((IInventoryPlayerBattle) player.inventory).battlegear2$getCurrentOffhandWeapon();
if (offhand != null) {
luminance = Math.max(luminance, getLuminanceFromItemStack(offhand, inWater));
}
}
else if (ModStatus.isBackhandLoaded && living instanceof EntityPlayer player){
ItemStack offhand = BackhandUtils.getOffhandItem(player);
if (offhand != null) {
luminance = Math.max(luminance, getLuminanceFromItemStack(offhand, inWater));
}
}
return luminance;
}
@@ -82,7 +82,14 @@ public class Feature {
, GLStateManager.depthTest // GL_DEPTH_TEST flag
// GL_DITHER flag
, GLStateManager.fogMode // GL_FOG flag
// GL_LIGHTi where 0 <= i < GL_MAX_LIGHTS
, GLStateManager.lightStates[0] // GL_LIGHT0
, GLStateManager.lightStates[1] // GL_LIGHT1
, GLStateManager.lightStates[2] // GL_LIGHT2
, GLStateManager.lightStates[3] // GL_LIGHT3
, GLStateManager.lightStates[4] // GL_LIGHT4
, GLStateManager.lightStates[5] // GL_LIGHT5
, GLStateManager.lightStates[6] // GL_LIGHT6
, GLStateManager.lightStates[7] // GL_LIGHT7
, GLStateManager.lightingState // GL_LIGHTING flag
// GL_LINE_SMOOTH flag
// GL_LINE_STIPPLE flag
@@ -149,9 +156,25 @@ public class Feature {
// GL_LIGHT_MODEL_TWO_SIDE setting
GLStateManager.lightingState // GL_LIGHTING enable bit
// Enable bit for each light
, GLStateManager.lightStates[0] // GL_LIGHT0
, GLStateManager.lightStates[1] // GL_LIGHT1
, GLStateManager.lightStates[2] // GL_LIGHT2
, GLStateManager.lightStates[3] // GL_LIGHT3
, GLStateManager.lightStates[4] // GL_LIGHT4
, GLStateManager.lightStates[5] // GL_LIGHT5
, GLStateManager.lightStates[6] // GL_LIGHT6
, GLStateManager.lightStates[7] // GL_LIGHT7
// Ambient, diffuse, and specular intensity for each light
// Direction, position, exponent, and cutoff angle for each light
// Constant, linear, and quadratic attenuation factors for each light
, GLStateManager.lightDataStates[0]
, GLStateManager.lightDataStates[1]
, GLStateManager.lightDataStates[2]
, GLStateManager.lightDataStates[3]
, GLStateManager.lightDataStates[4]
, GLStateManager.lightDataStates[5]
, GLStateManager.lightDataStates[6]
, GLStateManager.lightDataStates[7]
// Ambient, diffuse, specular, and emissive color for each material
// Ambient, diffuse, and specular color indices for each material
// Specular exponent for each material
@@ -271,17 +271,20 @@ public final class GLDebug {
private static DebugState debugState;
private interface DebugState {
private interface DebugState {
void nameObject(int id, int object, String name);
void pushGroup(String name);
void popGroup();
void debugMessage(String name);
}
String getObjectLabel(int glProgram, int program);
}
private static class KHRDebugState implements DebugState {
private static final int ID = 0;
private int depth = 0;
private static final int maxDepth = GL11.glGetInteger(KHRDebug.GL_MAX_DEBUG_GROUP_STACK_DEPTH);
private static final int maxNameLength = GL11.glGetInteger(KHRDebug.GL_MAX_LABEL_LENGTH);
@Override
public void nameObject(int id, int object, String name) {
@@ -310,6 +313,14 @@ public final class GLDebug {
public void debugMessage(String message) {
KHRDebug.glDebugMessageInsert(KHRDebug.GL_DEBUG_SOURCE_APPLICATION, KHRDebug.GL_DEBUG_TYPE_MARKER, ID, KHRDebug.GL_DEBUG_SEVERITY_NOTIFICATION, message);
}
@Override
public String getObjectLabel(int glProgram, int program) {
if(program == 0)
return "";
return KHRDebug.glGetObjectLabel(glProgram, program, maxNameLength);
}
}
private static class UnsupportedDebugState implements DebugState {
@@ -329,6 +340,11 @@ public final class GLDebug {
public void debugMessage(String name) {
}
@Override
public String getObjectLabel(int glProgram, int program) {
return "";
}
}
public static void initDebugState() {
@@ -359,4 +375,12 @@ public final class GLDebug {
debugState.debugMessage(message);
}
}
public static String getObjectLabel(int glProgram, int program) {
if(debugState != null && Thread.currentThread() == GLStateManager.getMainThread()) {
return debugState.getObjectLabel(glProgram, program);
}
return "";
}
}
@@ -11,6 +11,7 @@ import com.gtnewhorizons.angelica.glsm.stacks.DepthStateStack;
import com.gtnewhorizons.angelica.glsm.stacks.FogStateStack;
import com.gtnewhorizons.angelica.glsm.stacks.IStateStack;
import com.gtnewhorizons.angelica.glsm.stacks.IntegerStateStack;
import com.gtnewhorizons.angelica.glsm.stacks.LightStateStack;
import com.gtnewhorizons.angelica.glsm.stacks.MatrixModeStack;
import com.gtnewhorizons.angelica.glsm.stacks.ViewPortStateStack;
import com.gtnewhorizons.angelica.glsm.states.Color4;
@@ -58,7 +59,9 @@ import org.lwjgl.opengl.GL13;
import org.lwjgl.opengl.GL14;
import org.lwjgl.opengl.GL20;
import org.lwjgl.opengl.GLContext;
import org.lwjgl.opengl.KHRDebug;
import java.lang.Math;
import java.nio.ByteBuffer;
import java.nio.DoubleBuffer;
import java.nio.FloatBuffer;
@@ -121,9 +124,19 @@ public class GLStateManager {
@Getter protected static final Matrix4fStack modelViewMatrix = new Matrix4fStack(MAX_MODELVIEW_STACK_DEPTH);
@Getter protected static final Matrix4fStack projectionMatrix = new Matrix4fStack(MAX_PROJECTION_STACK_DEPTH);
@Getter protected static final BooleanStateStack[] lightStates = new BooleanStateStack[8];
@Getter protected static final LightStateStack[] lightDataStates = new LightStateStack[8];
static {
for (int i = 0; i < lightStates.length; i ++) {
lightStates[i] = new BooleanStateStack(GL11.GL_LIGHT0 + i);
lightDataStates[i] = new LightStateStack(GL11.GL_LIGHT0 + i);
}
}
@Getter protected static final ViewPortStateStack viewportState = new ViewPortStateStack();
@Getter protected static int activeProgram = 0;
public static void reset() {
runningSplash = true;
while(!attribs.isEmpty()) {
@@ -259,6 +272,14 @@ public class GLStateManager {
case GL11.GL_DEPTH_TEST -> enableDepthTest();
case GL11.GL_FOG -> enableFog();
case GL11.GL_LIGHTING -> enableLighting();
case GL11.GL_LIGHT0 -> enableLight(0);
case GL11.GL_LIGHT1 -> enableLight(1);
case GL11.GL_LIGHT2 -> enableLight(2);
case GL11.GL_LIGHT3 -> enableLight(3);
case GL11.GL_LIGHT4 -> enableLight(4);
case GL11.GL_LIGHT5 -> enableLight(5);
case GL11.GL_LIGHT6 -> enableLight(6);
case GL11.GL_LIGHT7 -> enableLight(7);
case GL11.GL_SCISSOR_TEST -> enableScissorTest();
case GL11.GL_TEXTURE_2D -> enableTexture();
case GL12.GL_RESCALE_NORMAL -> enableRescaleNormal();
@@ -274,6 +295,14 @@ public class GLStateManager {
case GL11.GL_DEPTH_TEST -> disableDepthTest();
case GL11.GL_FOG -> disableFog();
case GL11.GL_LIGHTING -> disableLighting();
case GL11.GL_LIGHT0 -> disableLight(0);
case GL11.GL_LIGHT1 -> disableLight(1);
case GL11.GL_LIGHT2 -> disableLight(2);
case GL11.GL_LIGHT3 -> disableLight(3);
case GL11.GL_LIGHT4 -> disableLight(4);
case GL11.GL_LIGHT5 -> disableLight(5);
case GL11.GL_LIGHT6 -> disableLight(6);
case GL11.GL_LIGHT7 -> disableLight(7);
case GL11.GL_SCISSOR_TEST -> disableScissorTest();
case GL11.GL_TEXTURE_2D -> disableTexture();
case GL12.GL_RESCALE_NORMAL -> disableRescaleNormal();
@@ -292,6 +321,14 @@ public class GLStateManager {
case GL11.GL_DEPTH_TEST -> depthTest.isEnabled();
case GL11.GL_FOG -> fogMode.isEnabled();
case GL11.GL_LIGHTING -> lightingState.isEnabled();
case GL11.GL_LIGHT0 -> lightStates[0].isEnabled();
case GL11.GL_LIGHT1 -> lightStates[1].isEnabled();
case GL11.GL_LIGHT2 -> lightStates[2].isEnabled();
case GL11.GL_LIGHT3 -> lightStates[3].isEnabled();
case GL11.GL_LIGHT4 -> lightStates[4].isEnabled();
case GL11.GL_LIGHT5 -> lightStates[5].isEnabled();
case GL11.GL_LIGHT6 -> lightStates[6].isEnabled();
case GL11.GL_LIGHT7 -> lightStates[7].isEnabled();
case GL11.GL_SCISSOR_TEST -> scissorTest.isEnabled();
case GL11.GL_TEXTURE_2D -> textures.getTextureUnitStates(activeTextureUnit.getValue()).isEnabled();
case GL12.GL_RESCALE_NORMAL -> rescaleNormalState.isEnabled();
@@ -311,6 +348,14 @@ public class GLStateManager {
case GL11.GL_DEPTH_WRITEMASK -> depthState.isEnabled();
case GL11.GL_FOG -> fogMode.isEnabled();
case GL11.GL_LIGHTING -> lightingState.isEnabled();
case GL11.GL_LIGHT0 -> lightStates[0].isEnabled();
case GL11.GL_LIGHT1 -> lightStates[1].isEnabled();
case GL11.GL_LIGHT2 -> lightStates[2].isEnabled();
case GL11.GL_LIGHT3 -> lightStates[3].isEnabled();
case GL11.GL_LIGHT4 -> lightStates[4].isEnabled();
case GL11.GL_LIGHT5 -> lightStates[5].isEnabled();
case GL11.GL_LIGHT6 -> lightStates[6].isEnabled();
case GL11.GL_LIGHT7 -> lightStates[7].isEnabled();
case GL11.GL_SCISSOR_TEST -> scissorTest.isEnabled();
case GL11.GL_TEXTURE_2D -> textures.getTextureUnitStates(activeTextureUnit.getValue()).isEnabled();
case GL12.GL_RESCALE_NORMAL -> rescaleNormalState.isEnabled();
@@ -357,6 +402,7 @@ public class GLStateManager {
case GL14.GL_BLEND_DST_RGB -> blendState.getDstRgb();
case GL14.GL_BLEND_SRC_ALPHA -> blendState.getSrcAlpha();
case GL14.GL_BLEND_SRC_RGB -> blendState.getSrcRgb();
case GL20.GL_CURRENT_PROGRAM -> activeProgram;
default -> GL11.glGetInteger(pname);
};
@@ -381,6 +427,24 @@ public class GLStateManager {
}
public static void glGetLight(int light, int pname, FloatBuffer params) {
if (shouldBypassCache()) {
GL11.glGetLight(light, pname, params);
return;
}
LightStateStack state = lightDataStates[light - GL11.GL_LIGHT0];
switch (pname) {
case GL11.GL_AMBIENT -> state.ambient.get(0, params);
case GL11.GL_DIFFUSE -> state.diffuse.get(0, params);
case GL11.GL_SPECULAR -> state.specular.get(0, params);
case GL11.GL_POSITION -> state.position.get(0, params);
case GL11.GL_SPOT_DIRECTION -> state.spotDirection.get(0, params);
case GL11.GL_SPOT_EXPONENT -> params.put(state.spotExponent);
case GL11.GL_SPOT_CUTOFF -> params.put(state.spotCutoff);
case GL11.GL_CONSTANT_ATTENUATION -> params.put(state.constantAttenuation);
case GL11.GL_LINEAR_ATTENUATION -> params.put(state.linearAttenuation);
case GL11.GL_QUADRATIC_ATTENUATION -> params.put(state.quadraticAttenuation);
}
GL11.glGetLight(light, pname, params);
}
@@ -595,6 +659,8 @@ public class GLStateManager {
return ((b - Byte.MIN_VALUE) & 0xFF) / 255.0F;
}
public static float i2f(int i) { return ((i - Integer.MIN_VALUE) & 0xFFFFFF) / 4294967295.0F; }
private static boolean changeColor(float red, float green, float blue, float alpha) {
// Helper function for glColor*
if (shouldBypassCache() || red != color.getRed() || green != color.getGreen() || blue != color.getBlue() || alpha != color.getAlpha()) {
@@ -783,9 +849,6 @@ public class GLStateManager {
} else if (textureUnit == IrisSamplers.LIGHTMAP_TEXTURE_UNIT) {
StateTracker.INSTANCE.lightmapSampler = true;
updatePipeline = true;
} else if (textureUnit == IrisSamplers.OVERLAY_TEXTURE_UNIT) {
StateTracker.INSTANCE.overlaySampler = true;
updatePipeline = true;
}
if (updatePipeline) {
@@ -806,9 +869,6 @@ public class GLStateManager {
} else if (textureUnit == IrisSamplers.LIGHTMAP_TEXTURE_UNIT) {
StateTracker.INSTANCE.lightmapSampler = false;
updatePipeline = true;
} else if (textureUnit == IrisSamplers.OVERLAY_TEXTURE_UNIT) {
StateTracker.INSTANCE.overlaySampler = false;
updatePipeline = true;
}
if (updatePipeline) {
@@ -900,10 +960,18 @@ public class GLStateManager {
lightingState.enable();
}
public static void enableLight(int light) {
lightStates[light].enable();
}
public static void disableLighting() {
lightingState.disable();
}
public static void disableLight(int light) {
lightStates[light].disable();
}
public static void enableRescaleNormal() {
rescaleNormalState.enable();
}
@@ -1147,6 +1215,10 @@ public class GLStateManager {
}
}
public static Matrix4f getModelviewMatrix() {
return modelViewMatrix;
}
public static void glLoadIdentity() {
GL11.glLoadIdentity();
getMatrixStack().identity();
@@ -1418,10 +1490,61 @@ public class GLStateManager {
}
public static void glLight(int light, int pname, FloatBuffer params) {
GL11.glLight(light, pname, params);
LightStateStack lightState = lightDataStates[light - GL11.GL_LIGHT0];
switch (pname) {
case GL11.GL_AMBIENT -> lightState.setAmbient(params);
case GL11.GL_DIFFUSE -> lightState.setDiffuse(params);
case GL11.GL_SPECULAR -> lightState.setSpecular(params);
case GL11.GL_POSITION -> lightState.setPosition(params);
case GL11.GL_SPOT_DIRECTION -> lightState.setSpotDirection(params);
case GL11.GL_SPOT_EXPONENT -> lightState.setSpotExponent(params);
case GL11.GL_SPOT_CUTOFF -> lightState.setSpotCutoff(params);
case GL11.GL_CONSTANT_ATTENUATION -> lightState.setConstantAttenuation(params);
case GL11.GL_LINEAR_ATTENUATION -> lightState.setLinearAttenuation(params);
case GL11.GL_QUADRATIC_ATTENUATION -> lightState.setQuadraticAttenuation(params);
default -> GL11.glLight(light, pname, params);
}
}
public static void glLight(int light, int pname, IntBuffer params) {
GL11.glLight(light, pname, params);
LightStateStack lightState = lightDataStates[light - GL11.GL_LIGHT0];
switch (pname) {
case GL11.GL_AMBIENT -> lightState.setAmbient(params);
case GL11.GL_DIFFUSE -> lightState.setDiffuse(params);
case GL11.GL_SPECULAR -> lightState.setSpecular(params);
case GL11.GL_POSITION -> lightState.setPosition(params);
case GL11.GL_SPOT_DIRECTION -> lightState.setSpotDirection(params);
case GL11.GL_SPOT_EXPONENT -> lightState.setSpotExponent(params);
case GL11.GL_SPOT_CUTOFF -> lightState.setSpotCutoff(params);
case GL11.GL_CONSTANT_ATTENUATION -> lightState.setConstantAttenuation(params);
case GL11.GL_LINEAR_ATTENUATION -> lightState.setLinearAttenuation(params);
case GL11.GL_QUADRATIC_ATTENUATION -> lightState.setQuadraticAttenuation(params);
default -> GL11.glLight(light, pname, params);
}
}
public static void glLightf(int light, int pname, float param) {
LightStateStack lightState = lightDataStates[light - GL11.GL_LIGHT0];
switch (pname) {
case GL11.GL_SPOT_EXPONENT -> lightState.setSpotExponent(param);
case GL11.GL_SPOT_CUTOFF -> lightState.setSpotCutoff(param);
case GL11.GL_CONSTANT_ATTENUATION -> lightState.setConstantAttenuation(param);
case GL11.GL_LINEAR_ATTENUATION -> lightState.setLinearAttenuation(param);
case GL11.GL_QUADRATIC_ATTENUATION -> lightState.setQuadraticAttenuation(param);
default -> GL11.glLightf(light, pname, param);
}
}
public static void glLighti(int light, int pname, int param) {
LightStateStack lightState = lightDataStates[light - GL11.GL_LIGHT0];
switch (pname) {
case GL11.GL_SPOT_EXPONENT -> lightState.setSpotExponent(param);
case GL11.GL_SPOT_CUTOFF -> lightState.setSpotCutoff(param);
case GL11.GL_CONSTANT_ATTENUATION -> lightState.setConstantAttenuation(param);
case GL11.GL_LINEAR_ATTENUATION -> lightState.setLinearAttenuation(param);
case GL11.GL_QUADRATIC_ATTENUATION -> lightState.setQuadraticAttenuation(param);
default -> GL11.glLighti(light, pname, param);
}
}
public static void glLightModel(int pname, FloatBuffer params) {
@@ -1444,4 +1567,18 @@ public class GLStateManager {
public static void glDepthRange(double near, double far) {
GL11.glDepthRange(near, far);
}
public static void glUseProgram(int program) {
if(program != activeProgram || shouldBypassCache()) {
activeProgram = program;
if(AngelicaMod.lwjglDebug) {
final String programName = GLDebug.getObjectLabel(KHRDebug.GL_PROGRAM, program);
GLDebug.debugMessage("Activating Program - " + program + ":" + programName);
}
GL20.glUseProgram(program);
}
}
}
@@ -0,0 +1,39 @@
package com.gtnewhorizons.angelica.glsm.stacks;
import com.gtnewhorizons.angelica.glsm.GLStateManager;
import com.gtnewhorizons.angelica.glsm.states.LightState;
public class LightStateStack extends LightState implements IStateStack<LightStateStack> {
protected final LightState[] stack;
protected int pointer;
public LightStateStack(int light) {
super(light);
stack = new LightState[GLStateManager.MAX_ATTRIB_STACK_DEPTH];
for (int i = 0; i < GLStateManager.MAX_ATTRIB_STACK_DEPTH; i++) {
stack[i] = new LightState(light);
}
}
public LightStateStack push() {
if (pointer == stack.length) {
throw new IllegalStateException("Stack overflow size " + (pointer + 1) + " reached");
}
stack[pointer++].set(this);
return this;
}
public LightStateStack pop() {
if (pointer == 0) {
throw new IllegalStateException("Stack underflow");
}
set(stack[--pointer]);
return this;
}
public boolean isEmpty() { return pointer == 0; }
}
@@ -0,0 +1,291 @@
package com.gtnewhorizons.angelica.glsm.states;
import com.gtnewhorizons.angelica.glsm.GLStateManager;
import org.joml.Matrix3f;
import org.joml.Vector3f;
import org.joml.Vector3i;
import org.joml.Vector4f;
import org.joml.Vector4i;
import org.lwjgl.opengl.GL11;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import static com.gtnewhorizons.angelica.glsm.GLStateManager.i2f;
public class LightState implements ISettableState<LightState> {
private static final Vector4i vector4i = new Vector4i();
private static final Vector4f vector4f = new Vector4f();
private static final Vector3i vector3i = new Vector3i();
private static final Vector3f vector3f = new Vector3f();
private static final Matrix3f matrix3f = new Matrix3f();
public int light;
public final Vector4f ambient;
public final Vector4f diffuse;
public final Vector4f specular;
public final Vector4f position;
public final Vector3f spotDirection;
public float spotExponent;
public float spotCutoff;
public float constantAttenuation;
public float linearAttenuation;
public float quadraticAttenuation;
public LightState(int light) {
this(
light,
new Vector4f(0F, 0F, 0F, 1F),
new Vector4f(0F, 0F, 0F, 1F),
new Vector4f(0F, 0F, 0F, 1F),
new Vector4f(0F, 0F, 1F, 0F),
new Vector3f(0F, 0F, -1F),
0F,
180F,
1.0F,
0.0F,
0.0F
);
if (light == GL11.GL_LIGHT0) {
this.diffuse.set(1F, 1F, 1F, 1F);
this.specular.set(1F, 1F, 1F, 1F);
}
}
public LightState(int light, Vector4f ambient, Vector4f diffuse, Vector4f specular, Vector4f position, Vector3f spotDirection, float spotExponent, float spotCutoff, float constantAttenuation, float linearAttenuation, float quadraticAttenuation) {
this.light = light;
this.ambient = ambient;
this.diffuse = diffuse;
this.specular = specular;
this.spotExponent = spotExponent;
this.spotCutoff = spotCutoff;
this.constantAttenuation = constantAttenuation;
this.linearAttenuation = linearAttenuation;
this.quadraticAttenuation = quadraticAttenuation;
this.position = position;
this.position.mul(GLStateManager.getModelviewMatrix());
this.spotDirection = spotDirection;
GLStateManager.getModelviewMatrix().get3x3(matrix3f);
this.spotDirection.mul(matrix3f);
}
public void setAmbient(FloatBuffer newBuffer) {
vector4f.set(newBuffer);
if (GLStateManager.shouldBypassCache() || !this.ambient.equals(vector4f)) {
this.ambient.set(vector4f);
GL11.glLight(this.light, GL11.GL_AMBIENT, newBuffer);
}
}
public void setAmbient(IntBuffer newBuffer) {
vector4i.set(newBuffer);
vector4f.set(i2f(vector4i.x), i2f(vector4i.y), i2f(vector4i.z), i2f(vector4i.w));
if (GLStateManager.shouldBypassCache() || !this.ambient.equals(vector4f)) {
this.ambient.set(vector4f);
GL11.glLight(this.light, GL11.GL_AMBIENT, newBuffer);
}
}
public void setDiffuse(FloatBuffer newBuffer) {
vector4f.set(newBuffer);
if (GLStateManager.shouldBypassCache() || !this.diffuse.equals(vector4f)) {
this.diffuse.set(vector4f);
GL11.glLight(this.light, GL11.GL_DIFFUSE, newBuffer);
}
}
public void setDiffuse(IntBuffer newBuffer) {
vector4i.set(newBuffer);
vector4f.set(i2f(vector4i.x), i2f(vector4i.y), i2f(vector4i.z), i2f(vector4i.w));
if (GLStateManager.shouldBypassCache() || !this.diffuse.equals(vector4f)) {
this.diffuse.set(vector4f);
GL11.glLight(this.light, GL11.GL_DIFFUSE, newBuffer);
}
}
public void setSpecular(FloatBuffer newBuffer) {
vector4f.set(newBuffer);
if (GLStateManager.shouldBypassCache() || !this.specular.equals(vector4f)) {
this.specular.set(vector4f);
GL11.glLight(this.light, GL11.GL_SPECULAR, newBuffer);
}
}
public void setSpecular(IntBuffer newBuffer) {
vector4i.set(newBuffer);
vector4f.set(i2f(vector4i.x), i2f(vector4i.y), i2f(vector4i.z), i2f(vector4i.w));
if (GLStateManager.shouldBypassCache() || !this.specular.equals(vector4f)) {
this.specular.set(vector4f);
GL11.glLight(this.light, GL11.GL_SPECULAR, newBuffer);
}
}
public void setPosition(FloatBuffer newBuffer) {
// We are bypassing cache everytime for position, because the necessary components to enable tracking the cache
// are big and probably more than just bypassing. We would need to track the modelview matrix it was transformed
// with and the untransformed coordinates in addition to the final transformation.
this.position.set(newBuffer);
this.position.mul(GLStateManager.getModelviewMatrix());
GL11.glLight(this.light, GL11.GL_POSITION, newBuffer);
}
public void setPosition(IntBuffer newBuffer) {
vector4i.set(newBuffer);
this.position.set((float) vector4i.x, (float) vector4i.y, (float) vector4i.z, (float) vector4i.w);
this.position.mul(GLStateManager.getModelviewMatrix());
GL11.glLight(this.light, GL11.GL_POSITION, newBuffer);
}
public void setSpotDirection(FloatBuffer newBuffer) {
// We are bypassing cache everytime for spot direction, because the necessary components to enable tracking the cache
// are big and probably more than just bypassing. We would need to track the modelview matrix it was transformed
// with and the untransformed coordinates in addition to the final transformation.
GLStateManager.getModelviewMatrix().get3x3(matrix3f);
this.spotDirection.set(newBuffer);
this.spotDirection.mul(matrix3f);
GL11.glLight(this.light, GL11.GL_SPOT_DIRECTION, newBuffer);
}
public void setSpotDirection(IntBuffer newBuffer) {
vector3i.set(newBuffer);
GLStateManager.getModelviewMatrix().get3x3(matrix3f);
this.spotDirection.set((float) vector3i.x, (float) vector3i.y, (float) vector3i.z);
this.spotDirection.mul(matrix3f);
GL11.glLight(this.light, GL11.GL_SPOT_DIRECTION, newBuffer);
}
public void setSpotExponent(FloatBuffer newBuffer) {
setSpotExponent(newBuffer.get());
}
public void setSpotExponent(IntBuffer newBuffer) {
setSpotExponent((float) newBuffer.get());
}
public void setSpotExponent(int i) {
setSpotExponent((float) i);
}
public void setSpotExponent(float f) {
if (GLStateManager.shouldBypassCache() || Float.compare(f, this.spotExponent) != 0) {
this.spotExponent = f;
GL11.glLightf(this.light, GL11.GL_SPOT_EXPONENT, f);
}
}
public void setSpotCutoff(FloatBuffer newBuffer) {
setSpotCutoff(newBuffer.get());
}
public void setSpotCutoff(IntBuffer newBuffer) {
setSpotCutoff((float) newBuffer.get());
}
public void setSpotCutoff(int i) {
setSpotCutoff((float) i);
}
public void setSpotCutoff(float f) {
if (GLStateManager.shouldBypassCache() || Float.compare(f, this.spotCutoff) != 0) {
this.spotCutoff = f;
GL11.glLightf(this.light, GL11.GL_SPOT_CUTOFF, f);
}
}
public void setConstantAttenuation(FloatBuffer newBuffer) {
setConstantAttenuation(newBuffer.get());
}
public void setConstantAttenuation(IntBuffer newBuffer) {
setConstantAttenuation((float) newBuffer.get());
}
public void setConstantAttenuation(int i) {
setConstantAttenuation((float) i);
}
public void setConstantAttenuation(float f) {
if (GLStateManager.shouldBypassCache() || Float.compare(f, this.constantAttenuation) != 0) {
this.constantAttenuation = f;
GL11.glLightf(this.light, GL11.GL_CONSTANT_ATTENUATION, f);
}
}
public void setLinearAttenuation(FloatBuffer newBuffer) {
setLinearAttenuation(newBuffer.get());
}
public void setLinearAttenuation(IntBuffer newBuffer) {
setLinearAttenuation((float) newBuffer.get());
}
public void setLinearAttenuation(int i) {
setLinearAttenuation((float) i);
}
public void setLinearAttenuation(float f) {
if (GLStateManager.shouldBypassCache() || Float.compare(f, this.linearAttenuation) != 0) {
this.linearAttenuation = f;
GL11.glLightf(this.light, GL11.GL_LINEAR_ATTENUATION, f);
}
}
public void setQuadraticAttenuation(FloatBuffer newBuffer) {
setQuadraticAttenuation(newBuffer.get());
}
public void setQuadraticAttenuation(IntBuffer newBuffer) {
setQuadraticAttenuation((float) newBuffer.get());
}
public void setQuadraticAttenuation(int i) {
setQuadraticAttenuation((float) i);
}
public void setQuadraticAttenuation(float f) {
if (GLStateManager.shouldBypassCache() || Float.compare(f, this.quadraticAttenuation) != 0) {
this.quadraticAttenuation = f;
GL11.glLightf(this.light, GL11.GL_QUADRATIC_ATTENUATION, f);
}
}
@Override
public LightState set(LightState state) {
this.ambient.set(state.ambient);
this.diffuse.set(state.diffuse);
this.specular.set(state.specular);
this.position.set(state.position);
this.spotDirection.set(state.spotDirection);
this.spotExponent = state.spotExponent;
this.spotCutoff = state.spotCutoff;
this.constantAttenuation = state.constantAttenuation;
this.linearAttenuation = state.linearAttenuation;
this.quadraticAttenuation = state.quadraticAttenuation;
return this;
}
@Override
public boolean sameAs(Object state) {
if (this == state) return true;
if (!(state instanceof LightState lightState)) return false;
return this.ambient.equals(lightState.ambient)
&& this.diffuse.equals(lightState.diffuse)
&& this.specular.equals(lightState.specular)
&& this.position.equals(lightState.position)
&& this.spotDirection.equals(lightState.spotDirection)
&& Float.compare(this.spotCutoff, lightState.spotCutoff) == 0
&& Float.compare(this.spotExponent, lightState.spotExponent) == 0
&& Float.compare(this.linearAttenuation, lightState.linearAttenuation) == 0
&& Float.compare(this.constantAttenuation, lightState.constantAttenuation) == 0
&& Float.compare(this.quadraticAttenuation, lightState.quadraticAttenuation) == 0;
}
@Override
public LightState copy() { return new LightState(this.light).set(this); }
}
@@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.List;
import com.gtnewhorizons.angelica.compat.ModStatus;
import com.gtnewhorizons.angelica.config.AngelicaConfig;
import com.gtnewhorizons.angelica.mixins.early.angelica.hudcaching.RenderGameOverlayEventAccessor;
import cpw.mods.fml.common.eventhandler.EventPriority;
import net.dries007.holoInventory.client.Renderer;
@@ -43,6 +44,7 @@ public class HUDCaching {
private static final Minecraft mc = Minecraft.getMinecraft();
public static Framebuffer framebuffer;
private static boolean dirty = true;
private static long nextHudRefresh;
public static boolean renderingCacheOverride;
@@ -106,13 +108,6 @@ public class HUDCaching {
/* TODO END REMOVE DEBUG STUFF */
@SubscribeEvent
public void onTick(TickEvent.ClientTickEvent event) {
if (event.phase == TickEvent.Phase.END) {
dirty = true;
}
}
// highest so it runs before the GLSM load event
@SubscribeEvent(priority = EventPriority.HIGH)
public void onJoinWorld(WorldEvent.Load event) {
@@ -136,8 +131,13 @@ public class HUDCaching {
return;
}
if (System.currentTimeMillis() > nextHudRefresh) {
dirty = true;
}
if (dirty) {
dirty = false;
nextHudRefresh = System.currentTimeMillis() + (1000 / AngelicaConfig.hudCachingFPS);
resetFramebuffer(mc.displayWidth, mc.displayHeight);
framebuffer.bindFramebuffer(false);
renderingCacheOverride = true;
@@ -48,11 +48,6 @@ public class AngelicaTweaker implements IFMLLoadingPlugin, IEarlyMixinLoader {
}
ctx.updateLoggers();
// Too many bug reports because people refuse to read or just want to try it - so make these only able
// to be enabled by system properties for now.
AngelicaConfig.enableIris = Boolean.parseBoolean(System.getProperty("angelica.enableShaders", "false"));
AngelicaConfig.enableMCPatcherForgeFeatures = Boolean.parseBoolean(System.getProperty("angelica.enableMCPatcherForgeFeatures", "false"));
// Debug features
AngelicaConfig.enableTestBlocks = Boolean.parseBoolean(System.getProperty("angelica.enableTestBlocks", "false"));
@@ -140,13 +140,18 @@ public enum Mixins {
IRIS_RENDERING(new Builder("Iris Shaders").addTargetedMod(TargetedMod.VANILLA).setSide(Side.CLIENT)
.setPhase(Phase.EARLY).setApplyIf(() -> AngelicaConfig.enableIris).addMixinClasses(
"shaders.MixinEntityRenderer"
,"shaders.MixinGuiIngameForge"
,"shaders.MixinFramebuffer"
,"shaders.MixinItem"
,"shaders.MixinLocale"
,"shaders.MixinOpenGlHelper"
,"shaders.MixinRender"
,"shaders.MixinRenderDragon"
,"shaders.MixinRenderEnderman"
,"shaders.MixinRendererLivingEntity"
,"shaders.MixinRenderGlobal"
,"shaders.MixinRenderManager"
,"shaders.MixinRenderSpider"
,"shaders.MixinTileEntityBeaconRenderer"
)
),
@@ -207,6 +212,11 @@ public enum Mixins {
"client.extrautils.MixinRenderBlockConnectedTexturesEthereal",
"client.extrautils.MixinIconConnectedTexture")),
MFR_THREAD_SAFETY(new Builder("Enable thread safety fixes for MineFactory Reloaded").setPhase(Phase.LATE)
.addTargetedMod(TargetedMod.MINEFACTORY_RELOADED).setSide(Side.CLIENT)
.setApplyIf(() -> AngelicaConfig.fixMineFactoryReloadedSodiumCompat)
.addMixinClasses("client.minefactoryreloaded.MixinRedNetCableRenderer")),
SPEEDUP_CAMPFIRE_BACKPORT_ANIMATIONS(new Builder("Add animation speedup support to Campfire Backport").setPhase(Phase.LATE)
.addTargetedMod(TargetedMod.CAMPFIRE_BACKPORT).setSide(Side.CLIENT)
.setApplyIf(() -> AngelicaConfig.speedupAnimations)
@@ -15,6 +15,7 @@ public enum TargetedMod {
, DYNAMIC_SURROUNDINGS_MIST("Dynamic Surroundings", "org.blockartistry.mod.DynSurround.mixinplugin.DynamicSurroundingsEarlyMixins", "dsurround")
, DYNAMIC_SURROUNDINGS_ORIGINAL("Dynamic Surroundings", "org.blockartistry.mod.DynSurround.asm.TransformLoader", "dsurround")
, EXTRAUTILS("ExtraUtilities", null, "ExtraUtilities")
, MINEFACTORY_RELOADED("MineFactory Reloaded", null, "MineFactoryReloaded")
, GTNHLIB("GTNHLib", "com.gtnewhorizon.gtnhlib.core.GTNHLibCore", "gtnhlib")
, IC2("IC2", "ic2.core.coremod.IC2core", "IC2")
, JABBA("JABBA", null, "JABBA")
@@ -7,6 +7,7 @@ import net.minecraft.entity.EntityLivingBase;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyArg;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(EntityRenderer.class)
@@ -23,4 +24,9 @@ public abstract class MixinEntityRenderer {
);
}
@ModifyArg(method = "setupCameraTransform", at = @At(value = "INVOKE", target = "Lorg/lwjgl/util/glu/Project;gluPerspective(FFFF)V", ordinal = 0, remap = false), index = 0)
private float captureFov(float fov) {
RenderingState.INSTANCE.setFov(fov);
return fov;
}
}
@@ -8,7 +8,7 @@ import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(GuiIngameForge.class)
@Mixin(value=GuiIngameForge.class, remap = false)
public class MixinGuiIngameForge {
@Redirect(method = "renderHUDText", at = @At(value = "FIELD", target = "Lnet/minecraft/world/biome/BiomeGenBase;biomeName:Ljava/lang/String;"))
private String getModNameWithBiome(BiomeGenBase biome) {
@@ -510,7 +510,7 @@ public abstract class MixinRenderBlocks {
* @author roadhog360
*/
@SuppressWarnings("UnreachableCode")
@Inject(method = "renderBlockStainedGlassPane", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BlockPane;canPaneConnectTo(Lnet/minecraft/world/IBlockAccess;IIILnet/minecraftforge/common/util/ForgeDirection;)Z", ordinal = 3, shift = At.Shift.BY, by = 2), cancellable = true)
@Inject(method = "renderBlockStainedGlassPane", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BlockPane;canPaneConnectTo(Lnet/minecraft/world/IBlockAccess;IIILnet/minecraftforge/common/util/ForgeDirection;)Z", ordinal = 3, shift = At.Shift.BY, by = 2, remap = false), cancellable = true)
private void tweakStainedPaneRenderer(Block block, int x, int y, int z, CallbackInfoReturnable<Boolean> cir,
@Local(name = "iicon") IIcon iicon,
@Local(name = "d22") double d22, @Local(name = "d0") double d0, @Local(name = "d1") double d1, @Local(name = "d2") double d2,
@@ -52,7 +52,8 @@ abstract public class MixinEntityRenderer {
at = @At(
value = "INVOKE",
target = "Lorg/lwjgl/opengl/GL11;glFogf(IF)V",
ordinal = 14
ordinal = 14,
remap = false
)
)
private void notFine$nearFogDistance(int mode, float value) {
@@ -17,7 +17,7 @@ public abstract class MixinGuiIngame {
target = "Lnet/minecraft/client/Minecraft;isFancyGraphicsEnabled()Z"
)
)
private boolean notFine$toggleVignette(float whyAndHowIsThisAFloat) {
private boolean notFine$toggleVignette() {
return SettingsManager.vignette;
}
@@ -71,6 +71,9 @@ public abstract class MixinFramebuffer implements IRenderTargetExt {
@Inject(method="createFramebuffer(II)V", at=@At(value="FIELD", target="Lnet/minecraft/client/shader/Framebuffer;useDepth:Z", shift=At.Shift.BEFORE, ordinal = 1))
private void iris$createDepthTexture(int width, int height, CallbackInfo ci) {
if(this.iris$useDepth) {
if(this.iris$depthTextureId == -1) {
this.iris$depthTextureId = GL11.glGenTextures();
}
GLStateManager.glBindTexture(GL11.GL_TEXTURE_2D, this.iris$depthTextureId);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
@@ -0,0 +1,17 @@
package com.gtnewhorizons.angelica.mixins.early.shaders;
import net.minecraftforge.client.GuiIngameForge;
import org.lwjgl.opengl.GL11;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(value = GuiIngameForge.class, remap = false)
public class MixinGuiIngameForge {
@Inject(method="renderCrosshairs", at= @At(value = "INVOKE", target = "Lnet/minecraftforge/client/GuiIngameForge;bind(Lnet/minecraft/util/ResourceLocation;)V", shift = At.Shift.AFTER))
private void renderCrosshairs(CallbackInfo ci) {
// Set the same state as vanilla so we don't break with textures that set a color value on transparent pixels for the crosshairs
GL11.glEnable(GL11.GL_ALPHA_TEST);
}
}
@@ -0,0 +1,18 @@
package com.gtnewhorizons.angelica.mixins.early.shaders;
import net.coderbot.iris.gbuffer_overrides.matching.SpecialCondition;
import net.coderbot.iris.layer.GbufferPrograms;
import net.minecraft.client.renderer.entity.RenderDragon;
import net.minecraft.entity.boss.EntityDragon;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(RenderDragon.class)
public class MixinRenderDragon {
@Inject(method = "Lnet/minecraft/client/renderer/entity/RenderDragon;shouldRenderPass(Lnet/minecraft/entity/boss/EntityDragon;IF)I", at = @At(value="RETURN", ordinal = 1))
private void onShouldRenderPass(EntityDragon entity, int pass, float partialTicks, CallbackInfoReturnable<Integer> cir) {
GbufferPrograms.setupSpecialRenderCondition(SpecialCondition.ENTITY_EYES);
}
}
@@ -0,0 +1,19 @@
package com.gtnewhorizons.angelica.mixins.early.shaders;
import net.coderbot.iris.gbuffer_overrides.matching.SpecialCondition;
import net.coderbot.iris.layer.GbufferPrograms;
import net.minecraft.client.renderer.entity.RenderEnderman;
import net.minecraft.entity.monster.EntityEnderman;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(RenderEnderman.class)
public class MixinRenderEnderman {
@Inject(method = "Lnet/minecraft/client/renderer/entity/RenderEnderman;shouldRenderPass(Lnet/minecraft/entity/monster/EntityEnderman;IF)I", at = @At(value="RETURN", ordinal = 1))
private void onShouldRenderPass(EntityEnderman entity, int pass, float partialTicks, CallbackInfoReturnable<Integer> cir) {
GbufferPrograms.setupSpecialRenderCondition(SpecialCondition.ENTITY_EYES);
}
}
@@ -1,30 +0,0 @@
package com.gtnewhorizons.angelica.mixins.early.shaders;
import net.coderbot.iris.layer.GbufferPrograms;
import net.coderbot.iris.uniforms.CapturedRenderingState;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.entity.Entity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(RenderManager.class)
public class MixinRenderManager {
@Unique
private static final String DO_RENDER = "Lnet/minecraft/client/renderer/entity/Render;doRender(Lnet/minecraft/entity/Entity;DDDFF)V";
@Inject(method = "func_147939_a", at = @At(value = "INVOKE", target = DO_RENDER))
private void iris$onRenderEntityPre(Entity entity, double x, double y, double z, float yaw, float partialTicks, boolean rebuild, CallbackInfoReturnable<Boolean> cir) {
CapturedRenderingState.INSTANCE.setCurrentEntity(entity.getEntityId());
GbufferPrograms.beginEntities();
}
@Inject(method = "func_147939_a", at = @At(value = "INVOKE", target = DO_RENDER, shift = At.Shift.AFTER))
private void iris$onRenderEntityPost(Entity entity, double x, double y, double z, float yaw, float partialTicks, boolean rebuild, CallbackInfoReturnable<Boolean> cir) {
CapturedRenderingState.INSTANCE.setCurrentEntity(-1);
GbufferPrograms.endEntities();
}
}
@@ -0,0 +1,19 @@
package com.gtnewhorizons.angelica.mixins.early.shaders;
import net.coderbot.iris.gbuffer_overrides.matching.SpecialCondition;
import net.coderbot.iris.layer.GbufferPrograms;
import net.minecraft.client.renderer.entity.RenderSpider;
import net.minecraft.entity.monster.EntitySpider;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(RenderSpider.class)
public class MixinRenderSpider {
@Inject(method = "Lnet/minecraft/client/renderer/entity/RenderSpider;shouldRenderPass(Lnet/minecraft/entity/monster/EntitySpider;IF)I", at = @At(value="RETURN", ordinal = 1))
private void onShouldRenderPass(EntitySpider entity, int pass, float partialTicks, CallbackInfoReturnable<Integer> cir) {
GbufferPrograms.setupSpecialRenderCondition(SpecialCondition.ENTITY_EYES);
}
}
@@ -0,0 +1,38 @@
package com.gtnewhorizons.angelica.mixins.early.shaders;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import net.coderbot.iris.layer.GbufferPrograms;
import net.coderbot.iris.uniforms.CapturedRenderingState;
import net.minecraft.client.renderer.entity.RendererLivingEntity;
import net.minecraft.entity.EntityLivingBase;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(RendererLivingEntity.class)
public class MixinRendererLivingEntity {
@WrapOperation(
method="doRender",
at=@At(value="INVOKE", target="Lnet/minecraft/client/renderer/entity/RendererLivingEntity;getColorMultiplier(Lnet/minecraft/entity/EntityLivingBase;FF)I")
)
private int iris$setEntityColor(RendererLivingEntity instance, EntityLivingBase elb, float f0, float f1, Operation<Integer> original) {
final int j = original.call(instance, elb, f0, f1);
final float a = (j >> 24 & 255) / 255.0F;
final float r = (j >> 16 & 255) / 255.0F;
final float g = (j >> 8 & 255) / 255.0F;
final float b = (j & 255) / 255.0F;
CapturedRenderingState.INSTANCE.setCurrentEntityColor(r, g, b, 1.0F - a);
return j;
}
@Inject(
method="Lnet/minecraft/client/renderer/entity/RendererLivingEntity;doRender(Lnet/minecraft/entity/EntityLivingBase;DDDFF)V", at=@At(value="INVOKE",
target="Lnet/minecraft/client/renderer/entity/RendererLivingEntity;renderEquippedItems(Lnet/minecraft/entity/EntityLivingBase;F)V", shift=At.Shift.BEFORE)
)
private void iris$teardownSpecialRenderConditions(EntityLivingBase entity, double x, double y, double z, float entityYaw, float partialTicks, CallbackInfo ci) {
GbufferPrograms.teardownSpecialRenderCondition();
}
}
@@ -0,0 +1,26 @@
package com.gtnewhorizons.angelica.mixins.early.shaders;
import net.coderbot.iris.gbuffer_overrides.matching.SpecialCondition;
import net.coderbot.iris.layer.GbufferPrograms;
import net.minecraft.client.renderer.tileentity.TileEntityBeaconRenderer;
import net.minecraft.tileentity.TileEntityBeacon;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(TileEntityBeaconRenderer.class)
public class MixinTileEntityBeaconRenderer {
@Inject(method="Lnet/minecraft/client/renderer/tileentity/TileEntityBeaconRenderer;renderTileEntityAt(Lnet/minecraft/tileentity/TileEntityBeacon;DDDF)V", at=@At("HEAD"))
private void onRenderTileEntityAt(TileEntityBeacon beacon, double x, double y, double z, float partialTicks, CallbackInfo ci) {
GbufferPrograms.setupSpecialRenderCondition(SpecialCondition.BEACON_BEAM);
}
@Inject(method="Lnet/minecraft/client/renderer/tileentity/TileEntityBeaconRenderer;renderTileEntityAt(Lnet/minecraft/tileentity/TileEntityBeacon;DDDF)V", at=@At("RETURN"))
private void afterRenderTileEntityAt(TileEntityBeacon beacon, double x, double y, double z, float partialTicks, CallbackInfo ci) {
GbufferPrograms.teardownSpecialRenderCondition();
}
}
@@ -5,6 +5,9 @@ import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.biome.WorldChunkManager;
import net.minecraft.world.chunk.Chunk;
import com.gtnewhorizons.angelica.compat.ModStatus;
import com.gtnewhorizons.angelica.compat.endlessids.EndlessIDsCompat;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@@ -29,14 +32,18 @@ public abstract class MixinChunk {
if(this.worldObj.isRemote && !Minecraft.getMinecraft().isSingleplayer()) {
// We are in multiplayer, the server might not have sent all biomes to the client.
// Populate them now while we're on the main thread.
WorldChunkManager manager = this.worldObj.getWorldChunkManager();
for(int z = 0; z < 16; z++) {
for(int x = 0; x < 16; x++) {
int idx = (z << 4) + x;
int biome = this.blockBiomeArray[idx] & 255;
if(biome == 255) {
BiomeGenBase generated = manager.getBiomeGenAt((this.xPosition << 4) + x, (this.zPosition << 4) + z);
this.blockBiomeArray[idx] = (byte)(generated.biomeID & 255);
if (ModStatus.isEIDBiomeLoaded) {
EndlessIDsCompat.sodium$populateBiomes((Chunk) (Object) this);
} else {
WorldChunkManager manager = this.worldObj.getWorldChunkManager();
for (int z = 0; z < 16; z++) {
for (int x = 0; x < 16; x++) {
int idx = (z << 4) + x;
int biome = this.blockBiomeArray[idx] & 255;
if (biome == 255) {
BiomeGenBase generated = manager.getBiomeGenAt((this.xPosition << 4) + x, (this.zPosition << 4) + z);
this.blockBiomeArray[idx] = (byte) (generated.biomeID & 255);
}
}
}
}
@@ -6,15 +6,19 @@ import com.gtnewhorizons.angelica.config.AngelicaConfig;
import com.gtnewhorizons.angelica.mixins.interfaces.IRenderGlobalExt;
import com.gtnewhorizons.angelica.rendering.AngelicaRenderQueue;
import com.gtnewhorizons.angelica.rendering.RenderingState;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import lombok.Getter;
import me.jellysquid.mods.sodium.client.gl.device.RenderDevice;
import me.jellysquid.mods.sodium.client.render.SodiumWorldRenderer;
import me.jellysquid.mods.sodium.client.render.chunk.passes.BlockRenderPass;
import net.coderbot.iris.Iris;
import net.coderbot.iris.layer.GbufferPrograms;
import net.coderbot.iris.pipeline.HandRenderer;
import net.coderbot.iris.pipeline.ShadowRenderer;
import net.coderbot.iris.pipeline.WorldRenderingPhase;
import net.coderbot.iris.pipeline.WorldRenderingPipeline;
import net.coderbot.iris.uniforms.CapturedRenderingState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.PlayerControllerMP;
import net.minecraft.client.multiplayer.WorldClient;
@@ -23,10 +27,14 @@ import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.culling.Frustrum;
import net.minecraft.client.renderer.culling.ICamera;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.init.Blocks;
import org.lwjgl.opengl.GL11;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
@@ -49,6 +57,8 @@ public class MixinRenderGlobal implements IRenderGlobalExt {
@Shadow public int renderDistanceChunks;
@Shadow public WorldRenderer[] worldRenderers;
@Shadow public WorldRenderer[] sortedWorldRenderers;
@Shadow @Final private TextureManager renderEngine;
@Getter
@Unique private SodiumWorldRenderer renderer;
@@ -141,9 +151,10 @@ public class MixinRenderGlobal implements IRenderGlobalExt {
pipeline = null;
} else {
pipeline = Iris.getPipelineManager().getPipelineNullable();
pipeline.setPhase(WorldRenderingPhase.TERRAIN_CUTOUT);
if(pass == 1) {
if(pass == 0) {
pipeline.setPhase(WorldRenderingPhase.TERRAIN_CUTOUT);
} else if(pass == 1) {
pipeline.setPhase(WorldRenderingPhase.TERRAIN_TRANSLUCENT);
final Camera camera = new Camera(mc.renderViewEntity, (float) partialTicks);
// iris$beginTranslucents
@@ -151,6 +162,7 @@ public class MixinRenderGlobal implements IRenderGlobalExt {
HandRenderer.INSTANCE.renderSolid(null /*poseStack*/, (float) partialTicks, camera, mc.renderGlobal, pipeline);
mc.mcProfiler.endStartSection("iris_pre_translucent");
pipeline.beginTranslucents();
this.renderEngine.bindTexture(TextureMap.locationBlocksTexture);
}
}
// Handle view distance change
@@ -172,6 +184,7 @@ public class MixinRenderGlobal implements IRenderGlobalExt {
try {
final MatrixStack matrixStack = new MatrixStack(ShadowRenderer.ACTIVE ? ShadowRenderer.MODELVIEW : RenderingState.INSTANCE.getModelViewMatrix());
mc.mcProfiler.endStartSection("draw_chunk_layer_" + pass);
this.renderer.drawChunkLayer(BlockRenderPass.VALUES[pass], matrixStack, x, y, z);
} finally {
RenderDevice.exitManagedCode();
@@ -285,6 +298,19 @@ public class MixinRenderGlobal implements IRenderGlobalExt {
this.renderChunksDeep = 0;
}
@WrapOperation(method="renderEntities", at=@At(value="INVOKE", target="Lnet/minecraft/client/renderer/entity/RenderManager;renderEntitySimple(Lnet/minecraft/entity/Entity;F)Z"))
private boolean angelica$renderEntitySimple(RenderManager instance, Entity entity, float partialTicks, Operation<Boolean> original) {
CapturedRenderingState.INSTANCE.setCurrentEntity(entity.getEntityId());
GbufferPrograms.beginEntities();
try {
return original.call(instance, entity, partialTicks);
} finally {
CapturedRenderingState.INSTANCE.setCurrentEntity(-1);
GbufferPrograms.endEntities();
}
}
@Inject(method="renderEntities", at=@At(value="INVOKE", target="Lnet/minecraft/client/renderer/RenderHelper;enableStandardItemLighting()V", shift = At.Shift.AFTER))
public void sodium$renderTileEntities(EntityLivingBase entity, ICamera camera, float partialTicks, CallbackInfo ci) {
this.renderer.renderTileEntities(entity, camera, partialTicks);
@@ -0,0 +1,31 @@
package com.gtnewhorizons.angelica.mixins.late.client.minefactoryreloaded;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.world.IBlockAccess;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
import powercrystals.minefactoryreloaded.render.block.RedNetCableRenderer;
import powercrystals.minefactoryreloaded.tile.rednet.TileEntityRedNetCable;
@Mixin(value = RedNetCableRenderer.class)
public abstract class MixinRedNetCableRenderer extends TileEntitySpecialRenderer {
/**
* @author JL2210
* @reason Thread safety compat (check result of getTileEntity for null)
*/
@Inject(method = "renderWorldBlock", at = @At(value = "FIELD", target = "Lpowercrystals/minefactoryreloaded/setup/MFRConfig;TESRCables*:Z"), locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true, remap = false)
public void angelica$checkNullBeforeAccess(IBlockAccess world, int x, int y, int z, Block block, int modelId,
RenderBlocks renderer, CallbackInfoReturnable<Boolean> cir, TileEntityRedNetCable _cable) {
if (_cable == null) {
cir.setReturnValue(false);
}
}
}
@@ -64,6 +64,8 @@ public class CloudRenderer implements IResourceManagerReloadListener {
private VertexBuffer vbo;
private int cloudMode = -1;
private int renderDistance = -1;
private int cloudElevation = -1;
private int scaleMult = -1;
private DynamicTexture COLOR_TEX = null;
@@ -82,9 +84,8 @@ public class CloudRenderer implements IResourceManagerReloadListener {
return instance;
}
private int getScale() {
return cloudMode == 2 ? 12 : 8;
return (cloudMode == 2 ? 12 : 8) * scaleMult;
}
private float ceilToScale(float value) {
@@ -139,11 +140,12 @@ public class CloudRenderer implements IResourceManagerReloadListener {
tessellator.pos(sectX0, 0, sectZ1).tex(u0, v1).color(bCol, bCol, bCol, ALPHA).endVertex();
if (fancy) {
final int height = HEIGHT * scaleMult;
// Top
tessellator.pos(sectX0, HEIGHT, sectZ0).tex(u0, v0).color(1, 1, 1, ALPHA).endVertex();
tessellator.pos(sectX0, HEIGHT, sectZ1).tex(u0, v1).color(1, 1, 1, ALPHA).endVertex();
tessellator.pos(sectX1, HEIGHT, sectZ1).tex(u1, v1).color(1, 1, 1, ALPHA).endVertex();
tessellator.pos(sectX1, HEIGHT, sectZ0).tex(u1, v0).color(1, 1, 1, ALPHA).endVertex();
tessellator.pos(sectX0, height, sectZ0).tex(u0, v0).color(1, 1, 1, ALPHA).endVertex();
tessellator.pos(sectX0, height, sectZ1).tex(u0, v1).color(1, 1, 1, ALPHA).endVertex();
tessellator.pos(sectX1, height, sectZ1).tex(u1, v1).color(1, 1, 1, ALPHA).endVertex();
tessellator.pos(sectX1, height, sectZ0).tex(u1, v0).color(1, 1, 1, ALPHA).endVertex();
float slice;
float sliceCoord0;
@@ -157,8 +159,8 @@ public class CloudRenderer implements IResourceManagerReloadListener {
if (slice > -CULL_DIST) {
slice += INSET;
tessellator.pos(slice, 0, sectZ1).tex(sliceCoord0, v1).color(0.9F, 0.9F, 0.9F, ALPHA).endVertex();
tessellator.pos(slice, HEIGHT, sectZ1).tex(sliceCoord1, v1).color(0.9F, 0.9F, 0.9F, ALPHA).endVertex();
tessellator.pos(slice, HEIGHT, sectZ0).tex(sliceCoord1, v0).color(0.9F, 0.9F, 0.9F, ALPHA).endVertex();
tessellator.pos(slice, height, sectZ1).tex(sliceCoord1, v1).color(0.9F, 0.9F, 0.9F, ALPHA).endVertex();
tessellator.pos(slice, height, sectZ0).tex(sliceCoord1, v0).color(0.9F, 0.9F, 0.9F, ALPHA).endVertex();
tessellator.pos(slice, 0, sectZ0).tex(sliceCoord0, v0).color(0.9F, 0.9F, 0.9F, ALPHA).endVertex();
slice -= INSET;
}
@@ -168,8 +170,8 @@ public class CloudRenderer implements IResourceManagerReloadListener {
if (slice <= CULL_DIST) {
slice -= INSET;
tessellator.pos(slice, 0, sectZ0).tex(sliceCoord0, v0).color(0.9F, 0.9F, 0.9F, ALPHA).endVertex();
tessellator.pos(slice, HEIGHT, sectZ0).tex(sliceCoord1, v0).color(0.9F, 0.9F, 0.9F, ALPHA).endVertex();
tessellator.pos(slice, HEIGHT, sectZ1).tex(sliceCoord1, v1).color(0.9F, 0.9F, 0.9F, ALPHA).endVertex();
tessellator.pos(slice, height, sectZ0).tex(sliceCoord1, v0).color(0.9F, 0.9F, 0.9F, ALPHA).endVertex();
tessellator.pos(slice, height, sectZ1).tex(sliceCoord1, v1).color(0.9F, 0.9F, 0.9F, ALPHA).endVertex();
tessellator.pos(slice, 0, sectZ1).tex(sliceCoord0, v1).color(0.9F, 0.9F, 0.9F, ALPHA).endVertex();
slice += INSET;
}
@@ -183,8 +185,8 @@ public class CloudRenderer implements IResourceManagerReloadListener {
if (slice > -CULL_DIST) {
slice += INSET;
tessellator.pos(sectX0, 0, slice).tex(u0, sliceCoord0).color(0.8F, 0.8F, 0.8F, ALPHA).endVertex();
tessellator.pos(sectX0, HEIGHT, slice).tex(u0, sliceCoord1).color(0.8F, 0.8F, 0.8F, ALPHA).endVertex();
tessellator.pos(sectX1, HEIGHT, slice).tex(u1, sliceCoord1).color(0.8F, 0.8F, 0.8F, ALPHA).endVertex();
tessellator.pos(sectX0, height, slice).tex(u0, sliceCoord1).color(0.8F, 0.8F, 0.8F, ALPHA).endVertex();
tessellator.pos(sectX1, height, slice).tex(u1, sliceCoord1).color(0.8F, 0.8F, 0.8F, ALPHA).endVertex();
tessellator.pos(sectX1, 0, slice).tex(u1, sliceCoord0).color(0.8F, 0.8F, 0.8F, ALPHA).endVertex();
slice -= INSET;
}
@@ -194,8 +196,8 @@ public class CloudRenderer implements IResourceManagerReloadListener {
if (slice <= CULL_DIST) {
slice -= INSET;
tessellator.pos(sectX1, 0, slice).tex(u1, sliceCoord0).color(0.8F, 0.8F, 0.8F, ALPHA).endVertex();
tessellator.pos(sectX1, HEIGHT, slice).tex(u1, sliceCoord1).color(0.8F, 0.8F, 0.8F, ALPHA).endVertex();
tessellator.pos(sectX0, HEIGHT, slice).tex(u0, sliceCoord1).color(0.8F, 0.8F, 0.8F, ALPHA).endVertex();
tessellator.pos(sectX1, height, slice).tex(u1, sliceCoord1).color(0.8F, 0.8F, 0.8F, ALPHA).endVertex();
tessellator.pos(sectX0, height, slice).tex(u0, sliceCoord1).color(0.8F, 0.8F, 0.8F, ALPHA).endVertex();
tessellator.pos(sectX0, 0, slice).tex(u0, sliceCoord0).color(0.8F, 0.8F, 0.8F, ALPHA).endVertex();
slice += INSET;
}
@@ -238,21 +240,32 @@ public class CloudRenderer implements IResourceManagerReloadListener {
public void checkSettings() {
GraphicsQualityOff cloudGraphicsQuality = (GraphicsQualityOff)Settings.MODE_CLOUDS.option.getStore();
final int cloudQualitySetting = cloudGraphicsQuality == GraphicsQualityOff.FANCY
final int cloudQualitySetting = cloudGraphicsQuality == GraphicsQualityOff.FANCY
|| cloudGraphicsQuality == GraphicsQualityOff.DEFAULT && mc.gameSettings.fancyGraphics ? 2 : 1;
boolean newEnabled = mc.gameSettings.shouldRenderClouds()
final boolean newEnabled = mc.gameSettings.shouldRenderClouds()
&& mc.theWorld != null
&& mc.theWorld.provider.isSurfaceWorld();
final int targetDistance = Math.max(mc.gameSettings.renderDistanceChunks, (int)Settings.RENDER_DISTANCE_CLOUDS.option.getStore());
final int cloudScaleMult = (int)Settings.CLOUD_SCALE.option.getStore();
if (isBuilt()
&& (!newEnabled
|| cloudQualitySetting != cloudMode
|| mc.gameSettings.renderDistanceChunks != renderDistance)) {
|| targetDistance != renderDistance
|| cloudScaleMult != scaleMult)) {
dispose();
}
cloudMode = cloudQualitySetting;
renderDistance = mc.gameSettings.renderDistanceChunks;
renderDistance = targetDistance;
scaleMult = cloudScaleMult;
cloudElevation = mc.theWorld == null ? 128 : (int)mc.theWorld.provider.getCloudHeight();
//Allows the setting to work with RFG and similar without hardcoding.
//The minimum height check is so stuff like Aether cloud height doesn't get messed up.
if(cloudElevation >= 96) {
cloudElevation = (int)Settings.CLOUD_HEIGHT.option.getStore();
}
if (newEnabled && !isBuilt()) {
build();
@@ -268,7 +281,7 @@ public class CloudRenderer implements IResourceManagerReloadListener {
double totalOffset = cloudTicks + partialTicks;
double x = entity.prevPosX + (entity.posX - entity.prevPosX) * partialTicks + totalOffset * 0.03;
double y = mc.theWorld.provider.getCloudHeight() - (entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * partialTicks) + 0.33;
double y = cloudElevation - (entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * partialTicks) + 0.33;
double z = entity.prevPosZ + (entity.posZ - entity.prevPosZ) * partialTicks;
int scale = getScale();
@@ -2,6 +2,7 @@ package com.gtnewhorizons.angelica.rendering;
import com.gtnewhorizons.angelica.glsm.GLStateManager;
import lombok.Getter;
import lombok.Setter;
import org.joml.Matrix4f;
import org.joml.Vector3d;
import org.lwjgl.BufferUtils;
@@ -21,6 +22,9 @@ public class RenderingState {
private final Matrix4f projectionMatrix = new Matrix4f().identity();
@Getter
private final Matrix4f modelViewMatrix = new Matrix4f().identity();
@Getter
@Setter
private float fov;
public void setCameraPosition(double x, double y, double z) {
@@ -145,6 +145,8 @@ public class RedirectorTransformer implements IClassTransformer {
.add("glGetTexParameteri")
.add("glIsEnabled")
.add("glLight")
.add("glLightf")
.add("glLighti")
.add("glLightModel")
.add("glLightModelf")
.add("glLightModeli")
@@ -202,6 +204,7 @@ public class RedirectorTransformer implements IClassTransformer {
);
methodRedirects.put(GL20, RedirectMap.newMap()
.add("glBlendEquationSeparate")
.add("glUseProgram")
);
methodRedirects.put(OpenGlHelper, RedirectMap.newMap()
.add("glBlendFunc", "tryBlendFuncSeparate")
+3 -4
View File
@@ -40,7 +40,7 @@ public enum Settings {
SettingsManager.cloudsUpdated();
}
},
CLOUD_SCALE(new NotFineOptionSlider(4, 2, 20, 1, null)),
CLOUD_SCALE(new NotFineOptionSlider(1, 1, 3, 1, null)),
DOWNFALL_DISTANCE(new NotFineOptionCycling<>(DownfallQuality.DEFAULT, OptionImpact.MEDIUM)) {
@Override
public void applyChanges() {
@@ -112,7 +112,7 @@ public enum Settings {
},
PARTICLES_ENC_TABLE(new NotFineOptionSlider(1, 0, 16, 1, OptionImpact.LOW)),
PARTICLES_VOID(new NotFineOptionTickBox(true, OptionImpact.LOW)),
RENDER_DISTANCE_CLOUDS(new NotFineOptionSlider(4, 4, 64, 2, OptionImpact.VARIES)) {
RENDER_DISTANCE_CLOUDS(new NotFineOptionSlider(4, 4, 64, 1, OptionImpact.VARIES)) {
@Override
public void applyChanges() {
SettingsManager.cloudsUpdated();
@@ -172,8 +172,7 @@ public enum Settings {
@Override
public Control<Integer> getControl() {
//TODO: Don't hardcode CLOUD_SCALE check.
return new SliderControl(this, min, max, step, setting != Settings.CLOUD_SCALE ? ControlValueFormatter.number() : NotFineControlValueFormatter.multiplied(0.25f));
return new SliderControl(this, min, max, step, ControlValueFormatter.number());
}
@Override
@@ -57,8 +57,8 @@ public class SettingsManager {
public static void cloudsUpdated() {
if(Settings.MODE_CLOUDS.option.getStore() != GraphicsQualityOff.OFF) {
minimumFarPlaneDistance = 32 * (int)Settings.RENDER_DISTANCE_CLOUDS.option.getStore();
minimumFarPlaneDistance += Math.abs((int)Settings.CLOUD_HEIGHT.option.getStore());
minimumFarPlaneDistance = 32 * ((int)Settings.RENDER_DISTANCE_CLOUDS.option.getStore());
minimumFarPlaneDistance += (int)Settings.CLOUD_HEIGHT.option.getStore();
mc.gameSettings.clouds = true;
} else {
minimumFarPlaneDistance = 128;
@@ -206,9 +206,9 @@ public class NotFineGameOptionPages {
.add(Settings.MODE_SKY.option)
.add(Settings.MODE_SUN_MOON.option)
.add(Settings.MODE_CLOUDS.option)
//.add(Settings.RENDER_DISTANCE_CLOUDS.option)
.add(Settings.RENDER_DISTANCE_CLOUDS.option)
.add(Settings.CLOUD_HEIGHT.option)
//.add(Settings.CLOUD_SCALE.option)
.add(Settings.CLOUD_SCALE.option)
.add(Settings.MODE_CLOUD_TRANSLUCENCY.option)
.add(Settings.MODE_STARS.option)
.add(Settings.TOTAL_STARS.option)
@@ -1,5 +1,6 @@
package me.jellysquid.mods.sodium.client.gl.shader;
import com.gtnewhorizons.angelica.glsm.GLDebug;
import me.jellysquid.mods.sodium.client.gl.GlObject;
import me.jellysquid.mods.sodium.client.gl.device.RenderDevice;
import net.minecraft.util.ResourceLocation;
@@ -7,7 +8,7 @@ import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL20;
import org.lwjgl.opengl.KHRDebug;
/**
* An OpenGL shader program.
@@ -47,7 +48,7 @@ public abstract class GlProgram extends GlObject {
* @throws NullPointerException If no uniform exists with the given name
*/
public int getUniformLocation(String name) {
int index = GL20.glGetUniformLocation(this.handle(), name);
final int index = GL20.glGetUniformLocation(this.handle(), name);
if (index < 0) {
throw new NullPointerException("No uniform exists with name: " + name);
@@ -69,6 +70,7 @@ public abstract class GlProgram extends GlObject {
public Builder(ResourceLocation name) {
this.name = name;
this.program = GL20.glCreateProgram();
GLDebug.nameObject(KHRDebug.GL_PROGRAM, program, name.toString());
}
public Builder attachShader(GlShader shader) {
@@ -89,13 +91,13 @@ public abstract class GlProgram extends GlObject {
public <P extends GlProgram> P build(ProgramFactory<P> factory) {
GL20.glLinkProgram(this.program);
String log = GL20.glGetProgramInfoLog(this.program, GL20.GL_INFO_LOG_LENGTH);
final String log = GL20.glGetProgramInfoLog(this.program, GL20.GL_INFO_LOG_LENGTH);
if (!log.isEmpty()) {
LOGGER.warn("Program link log for " + this.name + ": " + log);
}
int result = GL20.glGetProgrami(this.program, GL20.GL_LINK_STATUS);
final int result = GL20.glGetProgrami(this.program, GL20.GL_LINK_STATUS);
if (result != GL11.GL_TRUE) {
throw new RuntimeException("Shader program linking failed, see log for details");
@@ -81,9 +81,9 @@ public class SodiumGameOptionPages {
firstGroupBuilder.add(Settings.MODE_LIGHT_FLICKER.option)
.add(Settings.MODE_SKY.option)
.add(Settings.MODE_SUN_MOON.option)
//.add(Settings.RENDER_DISTANCE_CLOUDS.option)
.add(Settings.RENDER_DISTANCE_CLOUDS.option)
.add(Settings.CLOUD_HEIGHT.option)
//.add(Settings.CLOUD_SCALE.option)
.add(Settings.CLOUD_SCALE.option)
.add(Settings.MODE_CLOUD_TRANSLUCENCY.option)
.add(Settings.MODE_STARS.option)
.add(Settings.TOTAL_STARS.option)
@@ -187,6 +187,7 @@ public class SodiumGameOptionPages {
.setImpact(OptionImpact.LOW)
.build())
.add(Settings.PARTICLES_ENC_TABLE.option)
.add(Settings.PARTICLES_VOID.option)
.add(OptionImpl.createBuilder(GraphicsQuality.class, sodiumOpts)
.setName(I18n.format("sodium.options.grass_quality.name"))
.setTooltip(I18n.format("sodium.options.grass_quality.tooltip"))
@@ -72,7 +72,7 @@ public class SmoothLightPipeline implements LightPipeline {
public void calculate(ModelQuadView quad, BlockPosImpl pos, QuadLightData out, ForgeDirection cullFace, ForgeDirection face, boolean shade) {
this.updateCachedData(pos.asLong());
int flags = quad.getFlags();
final int flags = quad.getFlags();
final AoNeighborInfo neighborInfo = AoNeighborInfo.get(face);
@@ -102,7 +102,7 @@ public class SmoothLightPipeline implements LightPipeline {
* Flags: IS_ALIGNED, !IS_PARTIAL
*/
private void applyAlignedFullFace(AoNeighborInfo neighborInfo, BlockPosImpl pos, ForgeDirection dir, QuadLightData out) {
AoFaceData faceData = this.getCachedFaceData(pos, dir, true);
final AoFaceData faceData = this.getCachedFaceData(pos, dir, true);
neighborInfo.mapCorners(faceData.lm, faceData.ao, out.lm, out.br);
}
@@ -113,11 +113,11 @@ public class SmoothLightPipeline implements LightPipeline {
private void applyAlignedPartialFace(AoNeighborInfo neighborInfo, ModelQuadView quad, BlockPosImpl pos, ForgeDirection dir, QuadLightData out) {
for (int i = 0; i < 4; i++) {
// Clamp the vertex positions to the block's boundaries to prevent weird errors in lighting
float cx = clamp(quad.getX(i));
float cy = clamp(quad.getY(i));
float cz = clamp(quad.getZ(i));
final float cx = clamp(quad.getX(i));
final float cy = clamp(quad.getY(i));
final float cz = clamp(quad.getZ(i));
float[] weights = this.weights;
final float[] weights = this.weights;
neighborInfo.calculateCornerWeights(cx, cy, cz, weights);
this.applyAlignedPartialFaceVertex(pos, dir, weights, i, out, true);
}
@@ -133,14 +133,14 @@ public class SmoothLightPipeline implements LightPipeline {
private void applyParallelFace(AoNeighborInfo neighborInfo, ModelQuadView quad, BlockPosImpl pos, ForgeDirection dir, QuadLightData out) {
for (int i = 0; i < 4; i++) {
// Clamp the vertex positions to the block's boundaries to prevent weird errors in lighting
float cx = clamp(quad.getX(i));
float cy = clamp(quad.getY(i));
float cz = clamp(quad.getZ(i));
final float cx = clamp(quad.getX(i));
final float cy = clamp(quad.getY(i));
final float cz = clamp(quad.getZ(i));
float[] weights = this.weights;
final float[] weights = this.weights;
neighborInfo.calculateCornerWeights(cx, cy, cz, weights);
float depth = neighborInfo.getDepth(cx, cy, cz);
final float depth = neighborInfo.getDepth(cx, cy, cz);
// If the quad is approximately grid-aligned (not inset) to the other side of the block, avoid unnecessary
// computation by treating it is as aligned
@@ -160,14 +160,14 @@ public class SmoothLightPipeline implements LightPipeline {
private void applyNonParallelFace(AoNeighborInfo neighborInfo, ModelQuadView quad, BlockPosImpl pos, ForgeDirection dir, QuadLightData out) {
for (int i = 0; i < 4; i++) {
// Clamp the vertex positions to the block's boundaries to prevent weird errors in lighting
float cx = clamp(quad.getX(i));
float cy = clamp(quad.getY(i));
float cz = clamp(quad.getZ(i));
final float cx = clamp(quad.getX(i));
final float cy = clamp(quad.getY(i));
final float cz = clamp(quad.getZ(i));
float[] weights = this.weights;
final float[] weights = this.weights;
neighborInfo.calculateCornerWeights(cx, cy, cz, weights);
float depth = neighborInfo.getDepth(cx, cy, cz);
final float depth = neighborInfo.getDepth(cx, cy, cz);
// If the quad is approximately grid-aligned (not inset), avoid unnecessary computation by treating it is as aligned
if (DoubleMath.fuzzyEquals(depth, 0.0F, TOLERANCE)) {
@@ -183,22 +183,22 @@ public class SmoothLightPipeline implements LightPipeline {
}
private void applyAlignedPartialFaceVertex(BlockPosImpl pos, ForgeDirection dir, float[] w, int i, QuadLightData out, boolean offset) {
AoFaceData faceData = this.getCachedFaceData(pos, dir, offset);
final AoFaceData faceData = this.getCachedFaceData(pos, dir, offset);
if (!faceData.hasUnpackedLightData()) {
faceData.unpackLightData();
}
float sl = faceData.getBlendedSkyLight(w);
float bl = faceData.getBlendedBlockLight(w);
float ao = faceData.getBlendedShade(w);
final float sl = faceData.getBlendedSkyLight(w);
final float bl = faceData.getBlendedBlockLight(w);
final float ao = faceData.getBlendedShade(w);
out.br[i] = ao;
out.lm[i] = getLightMapCoord(sl, bl);
}
private void applyInsetPartialFaceVertex(BlockPosImpl pos, ForgeDirection dir, float n1d, float n2d, float[] w, int i, QuadLightData out) {
AoFaceData n1 = this.getCachedFaceData(pos, dir, false);
final AoFaceData n1 = this.getCachedFaceData(pos, dir, false);
if (!n1.hasUnpackedLightData()) {
n1.unpackLightData();
@@ -211,9 +211,9 @@ public class SmoothLightPipeline implements LightPipeline {
}
// Blend between the direct neighbors and above based on the passed weights
float ao = (n1.getBlendedShade(w) * n1d) + (n2.getBlendedShade(w) * n2d);
float sl = (n1.getBlendedSkyLight(w) * n1d) + (n2.getBlendedSkyLight(w) * n2d);
float bl = (n1.getBlendedBlockLight(w) * n1d) + (n2.getBlendedBlockLight(w) * n2d);
final float ao = (n1.getBlendedShade(w) * n1d) + (n2.getBlendedShade(w) * n2d);
final float sl = (n1.getBlendedSkyLight(w) * n1d) + (n2.getBlendedSkyLight(w) * n2d);
final float bl = (n1.getBlendedBlockLight(w) * n1d) + (n2.getBlendedBlockLight(w) * n2d);
out.br[i] = ao;
out.lm[i] = getLightMapCoord(sl, bl);
@@ -224,8 +224,8 @@ public class SmoothLightPipeline implements LightPipeline {
return;
}
float brightness = this.lightCache.getWorld().getBrightness(face, shade);
float[] br = out.br;
final float brightness = this.lightCache.getWorld().getBrightness(face, shade);
final float[] br = out.br;
for (int i = 0; i < br.length; i++) {
br[i] *= brightness;
@@ -236,7 +236,7 @@ public class SmoothLightPipeline implements LightPipeline {
* Returns the cached data for a given facing or calculates it if it hasn't been cached.
*/
private AoFaceData getCachedFaceData(BlockPosImpl pos, ForgeDirection face, boolean offset) {
AoFaceData data = this.cachedFaceData[offset ? face.ordinal() : face.ordinal() + 6];
final AoFaceData data = this.cachedFaceData[offset ? face.ordinal() : face.ordinal() + 6];
if (!data.hasLightData()) {
data.initLightData(this.lightCache, pos, face, offset);
@@ -7,6 +7,7 @@ import com.gtnewhorizons.angelica.compat.toremove.RenderLayer;
import com.gtnewhorizons.angelica.config.AngelicaConfig;
import com.gtnewhorizons.angelica.dynamiclights.DynamicLights;
import com.gtnewhorizons.angelica.glsm.GLStateManager;
import com.gtnewhorizons.angelica.rendering.RenderingState;
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
import it.unimi.dsi.fastutil.longs.LongSet;
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
@@ -29,10 +30,13 @@ import me.jellysquid.mods.sodium.client.util.math.FrustumExtended;
import me.jellysquid.mods.sodium.client.world.ChunkStatusListener;
import me.jellysquid.mods.sodium.common.util.ListUtil;
import net.coderbot.iris.block_rendering.BlockRenderingSettings;
import net.coderbot.iris.layer.GbufferPrograms;
import net.coderbot.iris.pipeline.ShadowRenderer;
import net.coderbot.iris.shadows.ShadowRenderingState;
import net.coderbot.iris.sodium.shadow_map.SwappableChunkRenderManager;
import net.coderbot.iris.sodium.vertex_format.IrisModelVertexFormats;
import net.coderbot.iris.uniforms.CapturedRenderingState;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.WorldClient;
import net.minecraft.client.renderer.WorldRenderer;
@@ -64,6 +68,7 @@ public class SodiumWorldRenderer implements ChunkStatusListener {
private int renderDistance;
private double lastCameraX, lastCameraY, lastCameraZ;
private float lastFov;
private double lastCameraPitch, lastCameraYaw;
private float lastFogDistance;
@@ -213,8 +218,10 @@ public class SodiumWorldRenderer implements ChunkStatusListener {
float fogDistance = FogHelper.getFogCutoff();
float fov = RenderingState.INSTANCE.getFov();
boolean dirty = pos.x != this.lastCameraX || pos.y != this.lastCameraY || pos.z != this.lastCameraZ ||
pitch != this.lastCameraPitch || yaw != this.lastCameraYaw || fogDistance != this.lastFogDistance;
pitch != this.lastCameraPitch || yaw != this.lastCameraYaw || fogDistance != this.lastFogDistance || fov != this.lastFov;
if(AngelicaConfig.enableIris) {
iris$ensureStateSwapped();
@@ -232,6 +239,7 @@ public class SodiumWorldRenderer implements ChunkStatusListener {
this.lastCameraPitch = pitch;
this.lastCameraYaw = yaw;
this.lastFogDistance = fogDistance;
this.lastFov = fov;
profiler.endStartSection("chunk_update");
@@ -334,7 +342,13 @@ public class SodiumWorldRenderer implements ChunkStatusListener {
return;
try {
if(AngelicaConfig.enableIris) {
final Block block = tileEntity.getWorldObj().getBlock(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord);
CapturedRenderingState.INSTANCE.setCurrentBlockEntity(Block.getIdFromBlock(block));
GbufferPrograms.beginBlockEntities();
}
TileEntityRendererDispatcher.instance.renderTileEntity(tileEntity, partialTicks);
} catch(RuntimeException e) {
if(tileEntity.isInvalid()) {
SodiumClientMod.logger().error("Suppressing crash from invalid tile entity", e);
@@ -342,10 +356,16 @@ public class SodiumWorldRenderer implements ChunkStatusListener {
throw e;
}
}
finally {
if(AngelicaConfig.enableIris) {
CapturedRenderingState.INSTANCE.setCurrentBlockEntity(-1);
GbufferPrograms.endBlockEntities();
}
}
}
public void renderTileEntities(EntityLivingBase entity, ICamera camera, float partialTicks) {
int pass = MinecraftForgeClient.getRenderPass();
final int pass = MinecraftForgeClient.getRenderPass();
for (TileEntity tileEntity : this.chunkRenderManager.getVisibleTileEntities()) {
renderTE(tileEntity, pass, partialTicks);
}
@@ -45,6 +45,7 @@ public class FluidRenderer {
private final QuadLightData quadLightData = new QuadLightData();
private boolean useSeparateAo;
private final int[] quadColors = new int[4];
private final TextureAtlasSprite missingTex = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite("minecraft:missing");
public FluidRenderer(LightPipelineProvider lpp) {
int normal = Norm3b.pack(0.0f, 1.0f, 0.0f);
@@ -95,7 +96,7 @@ public class FluidRenderer {
int posZ = pos.z;
Fluid fluid = ((IFluidBlock) block).getFluid();
if(fluid == null) return false;
if (fluid == null) return false;
// Check for occluded sides; if everything is occluded, don't render
boolean sfUp = this.isFluidOccluded(world, posX, posY, posZ, ForgeDirection.UP, fluid);
@@ -117,6 +118,11 @@ public class FluidRenderer {
(TextureAtlasSprite) fluid.getFlowingIcon(),
null
};
// Because some mods are wack and return null textures here
sprites[0] = sprites[0] == null ? missingTex : sprites[0];
sprites[1] = sprites[1] == null ? missingTex : sprites[1];
boolean hc = fluid.getColor() != 0xffffffff;
boolean rendered = false;
@@ -1,9 +0,0 @@
package net.coderbot.batchedentityrendering.impl;
import com.gtnewhorizons.angelica.compat.toremove.DrawState;
import java.nio.ByteBuffer;
public interface BufferBuilderExt {
}
@@ -1,6 +1,5 @@
package net.coderbot.batchedentityrendering.impl;
import com.gtnewhorizons.angelica.compat.toremove.DrawState;
import com.gtnewhorizons.angelica.compat.toremove.RenderLayer;
import lombok.Getter;
@@ -9,12 +8,10 @@ import java.nio.ByteBuffer;
public class BufferSegment {
private final ByteBuffer slice;
@Getter
private final DrawState drawState;
private final RenderLayer type;
public BufferSegment(ByteBuffer slice, DrawState drawState, RenderLayer type) {
public BufferSegment(ByteBuffer slice, RenderLayer type) {
this.slice = slice;
this.drawState = drawState;
this.type = type;
}
@@ -5,29 +5,19 @@ public class InputAvailability {
public final boolean texture;
public final boolean lightmap;
public final boolean overlay;
public InputAvailability(boolean texture, boolean lightmap, boolean overlay) {
public InputAvailability(boolean texture, boolean lightmap) {
this.texture = texture;
this.lightmap = lightmap;
this.overlay = overlay;
}
public InputAvailability withoutOverlay() {
return new InputAvailability(texture, lightmap, false);
}
public static InputAvailability unpack(int packed) {
return new InputAvailability((packed & 1) == 1, (packed & 2) == 2, (packed & 4) == 4);
return new InputAvailability((packed & 1) == 1, (packed & 2) == 2);
}
public int pack() {
int packed = 0;
if (overlay) {
packed |= 4;
}
if (lightmap) {
packed |= 2;
}
@@ -44,7 +34,6 @@ public class InputAvailability {
return "InputAvailability{" +
"texture=" + texture +
", lightmap=" + lightmap +
", overlay=" + overlay +
'}';
}
@@ -53,7 +42,6 @@ public class InputAvailability {
final int prime = 31;
int result = 1;
result = prime * result + (lightmap ? 1231 : 1237);
result = prime * result + (overlay ? 1231 : 1237);
result = prime * result + (texture ? 1231 : 1237);
return result;
}
@@ -69,8 +57,6 @@ public class InputAvailability {
InputAvailability other = (InputAvailability) obj;
if (lightmap != other.lightmap)
return false;
if (overlay != other.overlay)
return false;
if (texture != other.texture)
return false;
return true;
@@ -11,12 +11,8 @@ public class StateTracker {
public boolean albedoSampler;
// LightmapStateShard / TextureUnit.LIGHTMAP
public boolean lightmapSampler;
// OverlayStateShard / TextureUnit.OVERLAY
public boolean overlaySampler;
public InputAvailability getInputs() {
return new InputAvailability(albedoSampler,
lightmapSampler,
overlaySampler);
return new InputAvailability(albedoSampler, lightmapSampler);
}
}
@@ -1,42 +0,0 @@
package net.coderbot.iris.layer;
import com.gtnewhorizons.angelica.compat.toremove.RenderPhase;
import net.coderbot.iris.uniforms.CapturedRenderingState;
public final class BlockEntityRenderStateShard extends RenderPhase {
private static final BlockEntityRenderStateShard UNIDENTIFIED = new BlockEntityRenderStateShard(-1);
private final int entityId;
private BlockEntityRenderStateShard(int entityId) {
super("iris:is_block_entity", () -> {
CapturedRenderingState.INSTANCE.setCurrentBlockEntity(entityId);
GbufferPrograms.beginBlockEntities();
}, () -> {
CapturedRenderingState.INSTANCE.setCurrentBlockEntity(-1);
GbufferPrograms.endBlockEntities();
});
this.entityId = entityId;
}
public static BlockEntityRenderStateShard forId(int entityId) {
if (entityId == -1) {
return UNIDENTIFIED;
} else {
// TODO: Cache all created render phases to avoid allocations?
return new BlockEntityRenderStateShard(entityId);
}
}
@Override
public boolean equals(Object object) {
if (object == null || object.getClass() != this.getClass()) {
return false;
}
BlockEntityRenderStateShard other = (BlockEntityRenderStateShard) object;
return this.entityId == other.entityId;
}
}
@@ -1,42 +0,0 @@
package net.coderbot.iris.layer;
import com.gtnewhorizons.angelica.compat.toremove.RenderPhase;
import net.coderbot.iris.uniforms.CapturedRenderingState;
public final class EntityRenderStateShard extends RenderPhase {
private static final EntityRenderStateShard UNIDENTIFIED = new EntityRenderStateShard(-1);
private final int entityId;
private EntityRenderStateShard(int entityId) {
super("iris:is_entity", () -> {
CapturedRenderingState.INSTANCE.setCurrentEntity(entityId);
GbufferPrograms.beginEntities();
}, () -> {
CapturedRenderingState.INSTANCE.setCurrentEntity(-1);
GbufferPrograms.endEntities();
});
this.entityId = entityId;
}
public static EntityRenderStateShard forId(int entityId) {
if (entityId == -1) {
return UNIDENTIFIED;
} else {
// TODO: Cache all created render phases to avoid allocations?
return new EntityRenderStateShard(entityId);
}
}
@Override
public boolean equals(Object object) {
if (object == null || object.getClass() != this.getClass()) {
return false;
}
EntityRenderStateShard other = (EntityRenderStateShard) object;
return this.entityId == other.entityId;
}
}
@@ -65,7 +65,7 @@ public class GbufferPrograms {
}
public static WorldRenderingPhase getCurrentPhase() {
WorldRenderingPipeline pipeline = Iris.getPipelineManager().getPipelineNullable();
final WorldRenderingPipeline pipeline = Iris.getPipelineManager().getPipelineNullable();
if (pipeline != null) {
return pipeline.getPhase();
@@ -75,7 +75,7 @@ public class GbufferPrograms {
}
private static void setPhase(WorldRenderingPhase phase) {
WorldRenderingPipeline pipeline = Iris.getPipelineManager().getPipelineNullable();
final WorldRenderingPipeline pipeline = Iris.getPipelineManager().getPipelineNullable();
if (pipeline != null) {
pipeline.setPhase(phase);
@@ -83,7 +83,7 @@ public class GbufferPrograms {
}
public static void setOverridePhase(WorldRenderingPhase phase) {
WorldRenderingPipeline pipeline = Iris.getPipelineManager().getPipelineNullable();
final WorldRenderingPipeline pipeline = Iris.getPipelineManager().getPipelineNullable();
if (pipeline != null) {
pipeline.setOverridePhase(phase);
@@ -100,7 +100,7 @@ public class GbufferPrograms {
Iris.getPipelineManager().getPipeline().ifPresent(p -> p.setSpecialCondition(override));
}
public static void teardownSpecialRenderCondition(SpecialCondition override) {
public static void teardownSpecialRenderCondition() {
Iris.getPipelineManager().getPipeline().ifPresent(p -> p.setSpecialCondition(null));
}
@@ -1,11 +0,0 @@
package net.coderbot.iris.layer;
import com.gtnewhorizons.angelica.compat.toremove.RenderPhase;
public class IsBlockEntityRenderStateShard extends RenderPhase {
public static final IsBlockEntityRenderStateShard INSTANCE = new IsBlockEntityRenderStateShard();
private IsBlockEntityRenderStateShard() {
super("iris:is_block_entity", GbufferPrograms::beginBlockEntities, GbufferPrograms::endBlockEntities);
}
}
@@ -1,11 +0,0 @@
package net.coderbot.iris.layer;
import com.gtnewhorizons.angelica.compat.toremove.RenderPhase;
public class IsEntityRenderStateShard extends RenderPhase {
public static final IsEntityRenderStateShard INSTANCE = new IsEntityRenderStateShard();
private IsEntityRenderStateShard() {
super("iris:is_entity", GbufferPrograms::beginEntities, GbufferPrograms::endEntities);
}
}
@@ -1,11 +0,0 @@
package net.coderbot.iris.layer;
import com.gtnewhorizons.angelica.compat.toremove.RenderPhase;
public class IsOutlineRenderStateShard extends RenderPhase {
public static final IsOutlineRenderStateShard INSTANCE = new IsOutlineRenderStateShard();
private IsOutlineRenderStateShard() {
super("iris:is_outline", GbufferPrograms::beginOutline, GbufferPrograms::endOutline);
}
}
@@ -145,7 +145,7 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R
private WorldRenderingPhase phase = WorldRenderingPhase.NONE;
private boolean isBeforeTranslucent;
private boolean isRenderingShadow = false;
private InputAvailability inputs = new InputAvailability(false, false, false);
private InputAvailability inputs = new InputAvailability(false, false);
private SpecialCondition special = null;
private boolean shouldBindPBR;
@@ -344,7 +344,7 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R
if (programs.getPackDirectives().getShadowDirectives().isShadowEnabled().orElse(true)) {
this.shadowRenderer = new ShadowRenderer(programs.getShadow().orElse(null),
programs.getPackDirectives(), shadowRenderTargets);
Program shadowProgram = table.match(RenderCondition.SHADOW, new InputAvailability(true, true, true)).getProgram();
Program shadowProgram = table.match(RenderCondition.SHADOW, new InputAvailability(true, true)).getProgram();
shadowRenderer.setUsesImages(shadowProgram != null && shadowProgram.getActiveImages() > 0);
} else {
shadowRenderer = null;
@@ -367,7 +367,7 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R
ProgramSamplers.CustomTextureSamplerInterceptor customTextureSamplerInterceptor = ProgramSamplers.customTextureSamplerInterceptor(builder, customTextureManager.getCustomTextureIdMap(TextureStage.GBUFFERS_AND_SHADOW));
IrisSamplers.addRenderTargetSamplers(customTextureSamplerInterceptor, flipped, renderTargets, false);
IrisSamplers.addLevelSamplers(customTextureSamplerInterceptor, this, whitePixel, new InputAvailability(true, true, false));
IrisSamplers.addLevelSamplers(customTextureSamplerInterceptor, this, whitePixel, new InputAvailability(true, true));
IrisSamplers.addWorldDepthSamplers(customTextureSamplerInterceptor, renderTargets);
IrisSamplers.addNoiseSampler(customTextureSamplerInterceptor, customTextureManager.getNoiseTexture());
@@ -395,7 +395,7 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R
ProgramSamplers.CustomTextureSamplerInterceptor customTextureSamplerInterceptor = ProgramSamplers.customTextureSamplerInterceptor(builder, customTextureManager.getCustomTextureIdMap(TextureStage.GBUFFERS_AND_SHADOW));
IrisSamplers.addRenderTargetSamplers(customTextureSamplerInterceptor, () -> flippedAfterPrepare, renderTargets, false);
IrisSamplers.addLevelSamplers(customTextureSamplerInterceptor, this, whitePixel, new InputAvailability(true, true, false));
IrisSamplers.addLevelSamplers(customTextureSamplerInterceptor, this, whitePixel, new InputAvailability(true, true));
IrisSamplers.addNoiseSampler(customTextureSamplerInterceptor, customTextureManager.getNoiseTexture());
// Only initialize these samplers if the shadow map renderer exists. Otherwise, this program shouldn't be used at all?
@@ -548,7 +548,7 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R
}
if (sodiumTerrainRendering) {
beginPass(table.match(getCondition(getPhase()), new InputAvailability(true, true, false)));
beginPass(table.match(getCondition(getPhase()), new InputAvailability(true, true)));
return;
}
@@ -967,7 +967,7 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R
IrisSamplers.addRenderTargetSamplers(customTextureSamplerInterceptor, flipped, renderTargets, false);
IrisImages.addRenderTargetImages(builder, flipped, renderTargets);
IrisSamplers.addLevelSamplers(customTextureSamplerInterceptor, this, whitePixel, new InputAvailability(true, true, false));
IrisSamplers.addLevelSamplers(customTextureSamplerInterceptor, this, whitePixel, new InputAvailability(true, true));
IrisSamplers.addNoiseSampler(customTextureSamplerInterceptor, customTextureManager.getNoiseTexture());
@@ -36,7 +36,7 @@ class AttributeTransformer {
// lightmap texture coordinate.
// See https://github.com/IrisShaders/Iris/issues/1149
if (parameters.inputs.lightmap) {
root.rename("gl_MultiTexCoord1", "gl_MultiTexCoord2");
root.rename("gl_MultiTexCoord2", "gl_MultiTexCoord1");
}
Stream<Identifier> stream = Stream.empty();
@@ -59,10 +59,6 @@ class AttributeTransformer {
patchTextureMatrices(t, tree, root, parameters.inputs.lightmap);
if (parameters.inputs.overlay) {
patchOverlayColor(t, tree, root, parameters);
}
if (parameters.type.glShaderType == ShaderType.VERTEX
&& root.identifierIndex.has("gl_MultiTexCoord3")
&& !root.identifierIndex.has("mc_midTexCoord")) {
@@ -91,7 +87,7 @@ class AttributeTransformer {
"const float iris_ONE_OVER_32 = iris_ONE_OVER_256 * 8;");
if (hasLightmap) {
tree.parseAndInjectNode(t, ASTInjectionPoint.BEFORE_FUNCTIONS,
"mat4 iris_LightmapTextureMatrix = gl_TextureMatrix[2];");
"mat4 iris_LightmapTextureMatrix = gl_TextureMatrix[1];");
} else {
tree.parseAndInjectNode(t, ASTInjectionPoint.BEFORE_FUNCTIONS, "mat4 iris_LightmapTextureMatrix =" +
"mat4(iris_ONE_OVER_256, 0.0, 0.0, 0.0," +
@@ -112,56 +108,4 @@ class AttributeTransformer {
"mat4(1.0)" +
");");
}
private static final AutoHintedMatcher<ExternalDeclaration> uniformVec4EntityColor = new AutoHintedMatcher<>(
"uniform vec4 entityColor;", Matcher.externalDeclarationPattern);
// Add entity color -> overlay color attribute support.
private static void patchOverlayColor(
ASTParser t,
TranslationUnit tree,
Root root,
AttributeParameters parameters) {
// delete original declaration
root.processMatches(t, uniformVec4EntityColor, ASTNode::detachAndDelete);
if (parameters.type.glShaderType == ShaderType.VERTEX) {
// add our own declarations
// TODO: We're exposing entityColor to this stage even if it isn't declared in
// this stage. But this is needed for the pass-through behavior.
tree.parseAndInjectNodes(t, ASTInjectionPoint.BEFORE_FUNCTIONS,
"uniform sampler2D iris_overlay;",
"varying vec4 entityColor;");
// this is so we can pass through the overlay color at the end to the geometry
// or fragment stage.
tree.prependMain(t,
"vec4 overlayColor = texture2D(iris_overlay, (gl_TextureMatrix[1] * gl_MultiTexCoord1).xy);",
"entityColor = vec4(overlayColor.rgb, 1.0 - overlayColor.a);",
// Workaround for a shader pack bug:
// https://github.com/IrisShaders/Iris/issues/1549
// Some shader packs incorrectly ignore the alpha value, and assume that rgb
// will be
// zero if there is no hit flash, we try to emulate that here
"entityColor.rgb *= float(entityColor.a != 0.0);");
} else if (parameters.type.glShaderType == ShaderType.GEOMETRY) {
// replace read references to grab the color from the first vertex.
root.replaceReferenceExpressions(t, "entityColor", "entityColor[0]");
// TODO: this is passthrough behavior
tree.parseAndInjectNode(t, ASTInjectionPoint.BEFORE_FUNCTIONS,
"out vec4 entityColorGS;");
tree.parseAndInjectNode(t, ASTInjectionPoint.BEFORE_FUNCTIONS,
"in vec4 entityColor[];");
tree.prependMain(t, "entityColorGS = entityColor[0];");
} else if (parameters.type.glShaderType == ShaderType.FRAGMENT) {
tree.parseAndInjectNode(t, ASTInjectionPoint.BEFORE_DECLARATIONS,
"varying vec4 entityColor;");
// Different output name to avoid a name collision in the geometry shader.
if (parameters.hasGeometry) {
root.rename("entityColor", "entityColorGS");
}
}
}
}
@@ -5,6 +5,7 @@ import com.google.common.collect.ImmutableSet;
import net.coderbot.iris.gbuffer_overrides.matching.InputAvailability;
import net.coderbot.iris.gl.sampler.SamplerHolder;
import net.coderbot.iris.gl.state.StateUpdateNotifiers;
import net.coderbot.iris.pipeline.DeferredWorldRenderingPipeline;
import net.coderbot.iris.pipeline.WorldRenderingPipeline;
import net.coderbot.iris.rendertarget.RenderTarget;
import net.coderbot.iris.rendertarget.RenderTargets;
@@ -18,15 +19,13 @@ import java.util.function.Supplier;
public class IrisSamplers {
public static final int ALBEDO_TEXTURE_UNIT = 0;
// TODO: Find equivalent in 1.7.10
public static final int OVERLAY_TEXTURE_UNIT = 1;
public static final int LIGHTMAP_TEXTURE_UNIT = 1;
public static final ImmutableSet<Integer> WORLD_RESERVED_TEXTURE_UNITS = ImmutableSet.of(0, 1, 2);
public static final ImmutableSet<Integer> WORLD_RESERVED_TEXTURE_UNITS = ImmutableSet.of(0, 1);
// TODO: In composite programs, there shouldn't be any reserved textures.
// We need a way to restore these texture bindings.
public static final ImmutableSet<Integer> COMPOSITE_RESERVED_TEXTURE_UNITS = ImmutableSet.of(1, 2);
public static final ImmutableSet<Integer> COMPOSITE_RESERVED_TEXTURE_UNITS = ImmutableSet.of(1);
private IrisSamplers() {
// no construction allowed
@@ -139,14 +138,6 @@ public class IrisSamplers {
samplers.addDynamicSampler(whitePixel::getGlTextureId, "lightmap");
}
if (availability.overlay) {
// TODO: Overlay equivalent in 1.7.10?
// samplers.addExternalSampler(OVERLAY_TEXTURE_UNIT, "iris_overlay");
samplers.addDynamicSampler(whitePixel::getGlTextureId, "iris_overlay");
} else {
samplers.addDynamicSampler(whitePixel::getGlTextureId, "iris_overlay");
}
samplers.addDynamicSampler(pipeline::getCurrentNormalTexture, StateUpdateNotifiers.normalTextureChangeNotifier, "normals");
samplers.addDynamicSampler(pipeline::getCurrentSpecularTexture, StateUpdateNotifiers.specularTextureChangeNotifier, "specular");
}
@@ -158,11 +149,8 @@ public class IrisSamplers {
}
public static void addCompositeSamplers(SamplerHolder samplers, RenderTargets renderTargets) {
samplers.addDynamicSampler(renderTargets::getDepthTexture,
"gdepthtex", "depthtex0");
samplers.addDynamicSampler(renderTargets.getDepthTextureNoTranslucents()::getTextureId,
"depthtex1");
samplers.addDynamicSampler(renderTargets.getDepthTextureNoHand()::getTextureId,
"depthtex2");
samplers.addDynamicSampler(renderTargets::getDepthTexture, "gdepthtex", "depthtex0");
samplers.addDynamicSampler(renderTargets.getDepthTextureNoTranslucents()::getTextureId, "depthtex1");
samplers.addDynamicSampler(renderTargets.getDepthTextureNoHand()::getTextureId, "depthtex2");
}
}
@@ -1,6 +1,5 @@
package net.coderbot.iris.sodium.vertex_format.entity_xhfp;
import com.gtnewhorizons.angelica.compat.toremove.OverlayTexture;
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferView;
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferWriterNio;
import me.jellysquid.mods.sodium.client.model.vertex.formats.glyph.GlyphVertexSink;
@@ -53,7 +52,7 @@ public class EntityVertexBufferWriterNio extends VertexBufferWriterNio implement
@Override
public void writeGlyph(float x, float y, float z, int color, float u, float v, int light) {
writeQuad(x, y, z, color, u, v, light, OverlayTexture.NO_OVERLAY, 0);
writeQuad(x, y, z, color, u, v, light, 0, 0);
}
private void endQuad(int normal) {
@@ -1,7 +1,6 @@
package net.coderbot.iris.sodium.vertex_format.entity_xhfp;
import com.gtnewhorizons.angelica.compat.lwjgl.CompatMemoryUtil;
import com.gtnewhorizons.angelica.compat.toremove.OverlayTexture;
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferView;
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferWriterUnsafe;
import me.jellysquid.mods.sodium.client.model.vertex.formats.glyph.GlyphVertexSink;
@@ -51,7 +50,7 @@ public class EntityVertexBufferWriterUnsafe extends VertexBufferWriterUnsafe imp
@Override
public void writeGlyph(float x, float y, float z, int color, float u, float v, int light) {
writeQuad(x, y, z, color, u, v, light, OverlayTexture.NO_OVERLAY, 0);
writeQuad(x, y, z, color, u, v, light, 0, 0);
}
private void endQuad(int normal) {
@@ -1,6 +1,5 @@
package net.coderbot.iris.sodium.vertex_format.entity_xhfp;
import com.gtnewhorizons.angelica.compat.toremove.OverlayTexture;
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferView;
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferWriterNio;
import me.jellysquid.mods.sodium.client.model.vertex.formats.glyph.GlyphVertexSink;
@@ -52,7 +51,7 @@ public class GlyphVertexBufferWriterNio extends VertexBufferWriterNio implements
@Override
public void writeGlyph(float x, float y, float z, int color, float u, float v, int light) {
writeQuad(x, y, z, color, u, v, light, OverlayTexture.NO_OVERLAY, 0);
writeQuad(x, y, z, color, u, v, light, 0, 0);
}
private void endQuad(int normal) {
@@ -1,7 +1,6 @@
package net.coderbot.iris.sodium.vertex_format.entity_xhfp;
import com.gtnewhorizons.angelica.compat.lwjgl.CompatMemoryUtil;
import com.gtnewhorizons.angelica.compat.toremove.OverlayTexture;
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferView;
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferWriterUnsafe;
import me.jellysquid.mods.sodium.client.model.vertex.formats.glyph.GlyphVertexSink;
@@ -50,7 +49,7 @@ public class GlyphVertexBufferWriterUnsafe extends VertexBufferWriterUnsafe impl
@Override
public void writeGlyph(float x, float y, float z, int color, float u, float v, int light) {
writeQuad(x, y, z, color, u, v, light, OverlayTexture.NO_OVERLAY, 0);
writeQuad(x, y, z, color, u, v, light, 0, 0);
}
private void endQuad(int normal) {
@@ -3,6 +3,8 @@ package net.coderbot.iris.uniforms;
import lombok.Getter;
import net.coderbot.iris.gl.state.ValueUpdateNotifier;
import org.joml.Vector4f;
public class CapturedRenderingState {
public static final CapturedRenderingState INSTANCE = new CapturedRenderingState();
@@ -16,6 +18,10 @@ public class CapturedRenderingState {
private int currentRenderedEntity = -1;
private Runnable entityIdListener = null;
@Getter
private final Vector4f currentEntityColor = new Vector4f();
private Runnable entityColorListener = null;
private CapturedRenderingState() {
}
@@ -39,6 +45,14 @@ public class CapturedRenderingState {
}
}
public void setCurrentEntityColor(float r, float g, float b, float a) {
this.currentEntityColor.set(r, g, b, a);
if (this.entityColorListener != null) {
this.entityColorListener.run();
}
}
public ValueUpdateNotifier getEntityIdNotifier() {
return listener -> this.entityIdListener = listener;
}
@@ -46,4 +60,6 @@ public class CapturedRenderingState {
public ValueUpdateNotifier getBlockEntityIdNotifier() {
return listener -> this.blockEntityIdListener = listener;
}
public ValueUpdateNotifier getEntityColorNotifier() { return listener -> this.entityColorListener = listener; }
}
@@ -91,6 +91,8 @@ public final class CommonUniforms {
uniforms.uniform1i("renderStage", () -> GbufferPrograms.getCurrentPhase().ordinal(), StateUpdateNotifiers.phaseChangeNotifier);
uniforms.uniform4f("entityColor", CapturedRenderingState.INSTANCE::getCurrentEntityColor, CapturedRenderingState.INSTANCE.getEntityColorNotifier());
CommonUniforms.generalCommonUniforms(uniforms, updateNotifier, directives);
}
@@ -115,8 +117,7 @@ public final class CommonUniforms {
.uniform1f(PER_FRAME, "screenBrightness", () -> client.gameSettings.gammaSetting)
// just a dummy value for shaders where entityColor isn't supplied through a vertex attribute (and thus is
// not available) - suppresses warnings. See AttributeShaderTransformer for the actual entityColor code.
.uniform4f(ONCE, "entityColor", Vector4f::new)
.uniform1f(PER_TICK, "playerMood", CommonUniforms::getPlayerMood)
.uniform1f(PER_TICK, "playerMood", CommonUniforms::getPlayerMood)
.uniform2i(PER_FRAME, "eyeBrightness", CommonUniforms::getEyeBrightness)
.uniform2i(PER_FRAME, "eyeBrightnessSmooth", () -> {
final Vector2f smoothed = eyeBrightnessSmooth.get();
@@ -126,6 +126,8 @@ options.iris.shadowDistance.enabled=Allows you to change the maximum distance fo
options.iris.shadowDistance.disabled=Your current shader pack has already set a render distance for shadows; you cannot change it.
options.iris.gui.hide=Hide GUI
options.iris.gui.show=Show GUI
options.dynamic_lights=Dynamic Lights
options.dynamic_lights.tooltip=Enables dynamic lights. Modes: OFF - off, FASTEST - 500ms delay, FAST - 250ms delay, FANCY - no delay. Disabled if shaders are in use.
pack.iris.select.title=Select
pack.iris.configure.title=Configure
label.iris.true=On
@@ -10,7 +10,7 @@ options.graphics.smart=Smart
options.graphics.ultra=Ultra
options.off=Off
options.on=On
options.cloud_height=Cloud Height
options.cloud_height=Cloud Elevation
options.cloud_scale=Cloud Scale
options.gui_background=Background
options.downfall_distance=Weather Effects
@@ -33,7 +33,7 @@ options.mode_water=Water
options.mode_vignette=Vignette
options.particles_enc_table=Enchantment Particles
options.particles_void=Void Particles
options.render_distance_clouds=Cloud Render Distance
options.render_distance_clouds=Minimum Cloud Distance
options.title.detail=Detail Settings
options.title.other=Other Settings
options.title.particle=Particle Settings
@@ -0,0 +1,167 @@
package com.gtnewhorizons.angelica.glsm;
import com.gtnewhorizons.angelica.AngelicaExtension;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.lwjgl.opengl.GL11;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
import static com.gtnewhorizons.angelica.util.GLSMUtil.verifyLightState;
import static com.gtnewhorizons.angelica.util.GLSMUtil.verifyState;
@ExtendWith(AngelicaExtension.class)
public class GLSM_Lighting_UnitTest {
static final FloatBuffer f4b = ByteBuffer.allocateDirect(4 << 2).order(ByteOrder.nativeOrder()).asFloatBuffer();
static final FloatBuffer f3b = ByteBuffer.allocateDirect(3 << 2).order(ByteOrder.nativeOrder()).asFloatBuffer();
@Test
void testLightEnablement() {
verifyState(GL11.GL_LIGHT0, false, "GL_LIGHT0 Initial State");
GLStateManager.glEnable(GL11.GL_LIGHT0);
verifyState(GL11.GL_LIGHT0, true, "GL_LIGHT0 Enabled");
verifyState(GL11.GL_LIGHT1, false, "GL_LIGHT1 Initial State");
GLStateManager.glEnable(GL11.GL_LIGHT1);
verifyState(GL11.GL_LIGHT1, true, "GL_LIGHT1 Enabled State");
GLStateManager.glDisable(GL11.GL_LIGHT0);
GLStateManager.glDisable(GL11.GL_LIGHT1);
}
@Test
void testLightValues() {
GLStateManager.glPushAttrib(GL11.GL_LIGHTING_BIT);
verifyLightState(GL11.GL_LIGHT0, GL11.GL_AMBIENT, new float[]{0F, 0F, 0F, 1F}, "GL_LIGHT0 Initial Ambient");
verifyLightState(GL11.GL_LIGHT0, GL11.GL_DIFFUSE, new float[]{1F, 1F, 1F, 1F}, "GL_LIGHT0 Initial Diffuse");
verifyLightState(GL11.GL_LIGHT0, GL11.GL_SPECULAR, new float[]{1F, 1F, 1F, 1F}, "GL_LIGHT0 Initial Specular");
verifyLightState(GL11.GL_LIGHT0, GL11.GL_POSITION, new float[]{0F, 0F, 1F, 0F}, "GL_LIGHT0 Initial Position");
verifyLightState(GL11.GL_LIGHT1, GL11.GL_AMBIENT, new float[]{0F, 0F, 0F, 1F}, "GL_LIGHT1 Initial Ambient");
verifyLightState(GL11.GL_LIGHT1, GL11.GL_DIFFUSE, new float[]{0F, 0F, 0F, 1F}, "GL_LIGHT1 Initial Diffuse");
verifyLightState(GL11.GL_LIGHT1, GL11.GL_SPECULAR, new float[]{0F, 0F, 0F, 1F}, "GL_LIGHT1 Initial Specular");
verifyLightState(GL11.GL_LIGHT1, GL11.GL_POSITION, new float[]{0F, 0F, 1F, 0F}, "GL_LIGHT1 Initial Position");
newf4b(0.25F, 0.5F, 0.25F, 0.5F);
GLStateManager.glLight(GL11.GL_LIGHT0, GL11.GL_AMBIENT, f4b);
verifyLightState(GL11.GL_LIGHT0, GL11.GL_AMBIENT, new float[]{0.25F, 0.5F, 0.25F, 0.5F}, "GL_LIGHT0 Ambient Changed State");
GLStateManager.glPushAttrib(GL11.GL_LIGHTING_BIT);
newf4b(0.3F, 0.4F, 0.5F, 0.6F);
GLStateManager.glLight(GL11.GL_LIGHT0, GL11.GL_AMBIENT, f4b);
verifyLightState(GL11.GL_LIGHT0, GL11.GL_AMBIENT, new float[]{0.3F, 0.4F, 0.5F, 0.6F}, "GL_LIGHT0 attrib push state changed check");
GLStateManager.glPopAttrib();
verifyLightState(GL11.GL_LIGHT0, GL11.GL_AMBIENT, new float[]{0.25F, 0.5F, 0.25F, 0.5F}, "GL_LIGHT0 attrib pop state check");
// The position is stored in eye coordinates, so we're moving around the modelview matrix before changing them
// That way we can test that the client side transformation of them via GLSM is working and matches the OpenGL
// transformation. This doesn't seem like float precision should break this test, but it may be possible for it
// to need tweaked a bit more.
GLStateManager.glMatrixMode(GL11.GL_MODELVIEW);
GLStateManager.glPushMatrix();
GLStateManager.glTranslatef(25.0F, 25.0F, 25.0F);
GLStateManager.glRotatef(35.0F, 10.0F, 15.0F, 20.0F);
newf4b(0.25F, 0.5F, 0.25F, 0.0F);
GLStateManager.glLight(GL11.GL_LIGHT0, GL11.GL_POSITION, f4b);
verifyLightState(GL11.GL_LIGHT0, GL11.GL_POSITION, new float[]{0.1090F, 0.5189F, 0.3062F, 0.0F}, "GL_LIGHT0 Position Changed State");
GLStateManager.glPushAttrib(GL11.GL_LIGHTING_BIT);
newf4b(0.3F, 0.4F, 0.5F, 0.0F);
GLStateManager.glLight(GL11.GL_LIGHT0, GL11.GL_POSITION, f4b);
verifyLightState(GL11.GL_LIGHT0, GL11.GL_POSITION, new float[]{0.2824F, 0.4200F, 0.4937F, 0.0F}, "GL_LIGHT0 attrib push state changed check");
GLStateManager.glPopAttrib();
verifyLightState(GL11.GL_LIGHT0, GL11.GL_POSITION, new float[]{0.1090F, 0.5189F, 0.3062F, 0.0F}, "GL_LIGHT0 attrib pop state check");
GLStateManager.glPopMatrix();
newf4b(0.25F, 0.5F, 0.25F, 0.5F);
GLStateManager.glLight(GL11.GL_LIGHT0, GL11.GL_DIFFUSE, f4b);
verifyLightState(GL11.GL_LIGHT0, GL11.GL_DIFFUSE, new float[]{0.25F, 0.5F, 0.25F, 0.5F}, "GL_LIGHT0 Diffuse Changed State");
GLStateManager.glPushAttrib(GL11.GL_LIGHTING_BIT);
newf4b(0.3F, 0.4F, 0.5F, 0.6F);
GLStateManager.glLight(GL11.GL_LIGHT0, GL11.GL_DIFFUSE, f4b);
verifyLightState(GL11.GL_LIGHT0, GL11.GL_DIFFUSE, new float[]{0.3F, 0.4F, 0.5F, 0.6F}, "GL_LIGHT0 attrib push state changed check");
GLStateManager.glPopAttrib();
verifyLightState(GL11.GL_LIGHT0, GL11.GL_DIFFUSE, new float[]{0.25F, 0.5F, 0.25F, 0.5F}, "GL_LIGHT0 attrib pop state check");
newf4b(0.25F, 0.5F, 0.25F, 0.5F);
GLStateManager.glLight(GL11.GL_LIGHT0, GL11.GL_SPECULAR, f4b);
verifyLightState(GL11.GL_LIGHT0, GL11.GL_SPECULAR, new float[]{0.25F, 0.5F, 0.25F, 0.5F}, "GL_LIGHT0 Specular Changed State");
GLStateManager.glPushAttrib(GL11.GL_LIGHTING_BIT);
newf4b(0.3F, 0.4F, 0.5F, 0.6F);
GLStateManager.glLight(GL11.GL_LIGHT0, GL11.GL_SPECULAR, f4b);
verifyLightState(GL11.GL_LIGHT0, GL11.GL_SPECULAR, new float[]{0.3F, 0.4F, 0.5F, 0.6F}, "GL_LIGHT0 attrib push state changed check");
GLStateManager.glPopAttrib();
verifyLightState(GL11.GL_LIGHT0, GL11.GL_SPECULAR, new float[]{0.25F, 0.5F, 0.25F, 0.5F}, "GL_LIGHT0 attrib pop state check");
GLStateManager.glMatrixMode(GL11.GL_MODELVIEW);
GLStateManager.glPushMatrix();
GLStateManager.glTranslatef(25.0F, 25.0F, 25.0F);
GLStateManager.glRotatef(35.0F, 10.0F, 15.0F, 20.0F);
newf4b(0.25F, 0.5F, 0.25F, 0.0F);
GLStateManager.glLight(GL11.GL_LIGHT0, GL11.GL_SPOT_DIRECTION, f4b);
verifyLightState(GL11.GL_LIGHT0, GL11.GL_SPOT_DIRECTION, new float[]{0.1090F, 0.5189F, 0.3062F}, "GL_LIGHT0 Spot Direction Changed State");
GLStateManager.glPushAttrib(GL11.GL_LIGHTING_BIT);
newf4b(0.3F, 0.4F, 0.5F, 0.0F);
GLStateManager.glLight(GL11.GL_LIGHT0, GL11.GL_SPOT_DIRECTION, f4b);
verifyLightState(GL11.GL_LIGHT0, GL11.GL_SPOT_DIRECTION, new float[]{0.2824F, 0.4200F, 0.4937F}, "GL_LIGHT0 attrib push state changed check");
GLStateManager.glPopAttrib();
verifyLightState(GL11.GL_LIGHT0, GL11.GL_SPOT_DIRECTION, new float[]{0.1090F, 0.5189F, 0.3062F}, "GL_LIGHT0 attrib pop state check");
GLStateManager.glPopMatrix();
GLStateManager.glLightf(GL11.GL_LIGHT0, GL11.GL_SPOT_EXPONENT, 1.0F);
verifyLightState(GL11.GL_LIGHT0, GL11.GL_SPOT_EXPONENT, new float[]{1.0F}, "GL_LIGHT0 Spot Exponent Changed State");
GLStateManager.glPushAttrib(GL11.GL_LIGHTING_BIT);
GLStateManager.glLightf(GL11.GL_LIGHT0, GL11.GL_SPOT_EXPONENT, 2.0F);
verifyLightState(GL11.GL_LIGHT0, GL11.GL_SPOT_EXPONENT, new float[]{2.0F}, "GL_LIGHT0 attrib push state changed check");
GLStateManager.glPopAttrib();
verifyLightState(GL11.GL_LIGHT0, GL11.GL_SPOT_EXPONENT, new float[]{1.0F}, "GL_LIGHT0 attrib pop state check");
GLStateManager.glLightf(GL11.GL_LIGHT0, GL11.GL_SPOT_CUTOFF, 20.0F);
verifyLightState(GL11.GL_LIGHT0, GL11.GL_SPOT_CUTOFF, new float[]{20.0F}, "GL_LIGHT0 Spot Cutoff Changed State");
GLStateManager.glPushAttrib(GL11.GL_LIGHTING_BIT);
GLStateManager.glLightf(GL11.GL_LIGHT0, GL11.GL_SPOT_CUTOFF, 40.0F);
verifyLightState(GL11.GL_LIGHT0, GL11.GL_SPOT_CUTOFF, new float[]{40.0F}, "GL_LIGHT0 attrib push state changed check");
GLStateManager.glPopAttrib();
verifyLightState(GL11.GL_LIGHT0, GL11.GL_SPOT_CUTOFF, new float[]{20.0F}, "GL_LIGHT0 attrib pop state check");
GLStateManager.glLightf(GL11.GL_LIGHT0, GL11.GL_CONSTANT_ATTENUATION, 10.0F);
verifyLightState(GL11.GL_LIGHT0, GL11.GL_CONSTANT_ATTENUATION, new float[]{10.0F}, "GL_LIGHT0 Constant Attenuation Changed State");
GLStateManager.glPushAttrib(GL11.GL_LIGHTING_BIT);
GLStateManager.glLightf(GL11.GL_LIGHT0, GL11.GL_CONSTANT_ATTENUATION, 20.0F);
verifyLightState(GL11.GL_LIGHT0, GL11.GL_CONSTANT_ATTENUATION, new float[]{20.0F}, "GL_LIGHT0 attrib push state changed check");
GLStateManager.glPopAttrib();
verifyLightState(GL11.GL_LIGHT0, GL11.GL_CONSTANT_ATTENUATION, new float[]{10.0F}, "GL_LIGHT0 attrib pop state check");
GLStateManager.glLightf(GL11.GL_LIGHT0, GL11.GL_LINEAR_ATTENUATION, 10.0F);
verifyLightState(GL11.GL_LIGHT0, GL11.GL_LINEAR_ATTENUATION, new float[]{10.0F}, "GL_LIGHT0 Linear Attenuation Changed State");
GLStateManager.glPushAttrib(GL11.GL_LIGHTING_BIT);
GLStateManager.glLightf(GL11.GL_LIGHT0, GL11.GL_LINEAR_ATTENUATION, 20.0F);
verifyLightState(GL11.GL_LIGHT0, GL11.GL_LINEAR_ATTENUATION, new float[]{20.0F}, "GL_LIGHT0 attrib push state changed check");
GLStateManager.glPopAttrib();
verifyLightState(GL11.GL_LIGHT0, GL11.GL_LINEAR_ATTENUATION, new float[]{10.0F}, "GL_LIGHT0 attrib pop state check");
GLStateManager.glLightf(GL11.GL_LIGHT0, GL11.GL_QUADRATIC_ATTENUATION, 10.0F);
verifyLightState(GL11.GL_LIGHT0, GL11.GL_QUADRATIC_ATTENUATION, new float[]{10.0F}, "GL_LIGHT0 Quadratic Attenuation Changed State");
GLStateManager.glPushAttrib(GL11.GL_LIGHTING_BIT);
GLStateManager.glLightf(GL11.GL_LIGHT0, GL11.GL_QUADRATIC_ATTENUATION, 20.0F);
verifyLightState(GL11.GL_LIGHT0, GL11.GL_QUADRATIC_ATTENUATION, new float[]{20.0F}, "GL_LIGHT0 attrib push state changed check");
GLStateManager.glPopAttrib();
verifyLightState(GL11.GL_LIGHT0, GL11.GL_QUADRATIC_ATTENUATION, new float[]{10.0F}, "GL_LIGHT0 attrib pop state check");
GLStateManager.glPopAttrib();
}
static void newf4b(float x, float y, float z, float w) {
f4b.clear();
f4b.put(x).put(y).put(z).put(w);
f4b.flip();
}
static void newf3b(float x, float y, float z) {
f3b.clear();
f3b.put(x).put(y).put(z);
f3b.flip();
}
}
@@ -133,10 +133,10 @@ class GLSM_PushPop_UnitTest {
GLStateManager.glNormal3f(0.5f, 0.5f, 0.5f);
GLStateManager.glTexCoord4f(0.5f, 0.5f, 0.5f, 0.5f); // Current texture coordinates
GLStateManager.glRasterPos4f(0.5f, 0.5f, 0.5f, 0.5f); // Current raster position
// GL_CURRENT_RASTER_POSITION_VALID flag
// RGBA color associated with current raster position
// Color index associated with current raster position
// Texture coordinates associated with current raster position
// GL_CURRENT_RASTER_POSITION_VALID flag
// RGBA color associated with current raster position
// Color index associated with current raster position
// Texture coordinates associated with current raster position
GLStateManager.glEdgeFlag(false); // GL_EDGE_FLAG flag