forked from IrisShaders/Iris
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support fogMode and fogDensity through a new dynamic uniform system
This new dynamic uniform system allows Iris to handle uniforms that change many times per frame, and opens the door to proper support for uniforms like entityColor, entityId, blendMode, and more.
- Loading branch information
1 parent
526c450
commit 425c19d
Showing
21 changed files
with
294 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/main/java/net/coderbot/iris/gl/state/StateUpdateNotifiers.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package net.coderbot.iris.gl.state; | ||
|
||
import net.coderbot.iris.gl.uniform.ValueUpdateNotifier; | ||
|
||
/** | ||
* Holds some standard update notifiers for various elements of GL state. Currently, this class has a few listeners for | ||
* fog-related values. | ||
*/ | ||
public class StateUpdateNotifiers { | ||
public static ValueUpdateNotifier fogToggleNotifier; | ||
public static ValueUpdateNotifier fogModeNotifier; | ||
public static ValueUpdateNotifier fogDensityNotifier; | ||
} |
32 changes: 32 additions & 0 deletions
32
src/main/java/net/coderbot/iris/gl/uniform/DynamicLocationalUniformHolder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package net.coderbot.iris.gl.uniform; | ||
|
||
import java.util.function.DoubleSupplier; | ||
import java.util.function.IntSupplier; | ||
|
||
public interface DynamicLocationalUniformHolder extends LocationalUniformHolder, DynamicUniformHolder { | ||
DynamicLocationalUniformHolder addDynamicUniform(Uniform uniform, ValueUpdateNotifier notifier); | ||
|
||
default DynamicLocationalUniformHolder uniform1f(String name, FloatSupplier value, ValueUpdateNotifier notifier) { | ||
location(name, UniformType.FLOAT).ifPresent(id -> addDynamicUniform(new FloatUniform(id, value, notifier), notifier)); | ||
|
||
return this; | ||
} | ||
|
||
default DynamicLocationalUniformHolder uniform1f(String name, IntSupplier value, ValueUpdateNotifier notifier) { | ||
location(name, UniformType.FLOAT).ifPresent(id -> addDynamicUniform(new FloatUniform(id, () -> (float) value.getAsInt(), notifier), notifier)); | ||
|
||
return this; | ||
} | ||
|
||
default DynamicLocationalUniformHolder uniform1f(String name, DoubleSupplier value, ValueUpdateNotifier notifier) { | ||
location(name, UniformType.FLOAT).ifPresent(id -> addDynamicUniform(new FloatUniform(id, () -> (float) value.getAsDouble(), notifier), notifier)); | ||
|
||
return this; | ||
} | ||
|
||
default DynamicLocationalUniformHolder uniform1i(String name, IntSupplier value, ValueUpdateNotifier notifier) { | ||
location(name, UniformType.INT).ifPresent(id -> addDynamicUniform(new IntUniform(id, value, notifier), notifier)); | ||
|
||
return this; | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/net/coderbot/iris/gl/uniform/DynamicUniformHolder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package net.coderbot.iris.gl.uniform; | ||
|
||
import java.util.function.DoubleSupplier; | ||
import java.util.function.IntSupplier; | ||
|
||
public interface DynamicUniformHolder extends UniformHolder { | ||
DynamicUniformHolder uniform1f(String name, FloatSupplier value, ValueUpdateNotifier notifier); | ||
DynamicUniformHolder uniform1f(String name, IntSupplier value, ValueUpdateNotifier notifier); | ||
DynamicUniformHolder uniform1f(String name, DoubleSupplier value, ValueUpdateNotifier notifier); | ||
DynamicUniformHolder uniform1i(String name, IntSupplier value, ValueUpdateNotifier notifier); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
src/main/java/net/coderbot/iris/gl/uniform/ValueUpdateNotifier.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package net.coderbot.iris.gl.uniform; | ||
|
||
/** | ||
* A | ||
*/ | ||
public interface ValueUpdateNotifier { | ||
/** | ||
* Sets up a listener with this notifier. Whenever the underlying value of | ||
* @param listener | ||
*/ | ||
void setListener(Runnable listener); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
src/main/java/net/coderbot/iris/mixin/statelisteners/CapabilityTrackerAccessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package net.coderbot.iris.mixin.statelisteners; | ||
|
||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.gen.Accessor; | ||
|
||
@Mixin(targets = "com/mojang/blaze3d/platform/GlStateManager$CapabilityTracker") | ||
public interface CapabilityTrackerAccessor { | ||
@Accessor("state") | ||
boolean getState(); | ||
} |
13 changes: 13 additions & 0 deletions
13
src/main/java/net/coderbot/iris/mixin/statelisteners/GlStateManagerAccessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package net.coderbot.iris.mixin.statelisteners; | ||
|
||
import com.mojang.blaze3d.platform.GlStateManager; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.gen.Accessor; | ||
|
||
@Mixin(GlStateManager.class) | ||
public interface GlStateManagerAccessor { | ||
@Accessor("FOG") | ||
static GlStateManager.FogState getFOG() { | ||
throw new AssertionError(); | ||
} | ||
} |
Oops, something went wrong.