-
-
Notifications
You must be signed in to change notification settings - Fork 641
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
153 additions
and
8 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ public enum UniformType { | |
VEC2, | ||
VEC2I, | ||
VEC3, | ||
VEC3I, | ||
VEC4, | ||
VEC4I | ||
} |
46 changes: 46 additions & 0 deletions
46
src/main/java/net/coderbot/iris/gl/uniform/Vector3IntegerUniform.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,46 @@ | ||
package net.coderbot.iris.gl.uniform; | ||
|
||
import net.coderbot.iris.gl.IrisRenderSystem; | ||
import net.coderbot.iris.gl.state.ValueUpdateNotifier; | ||
import org.joml.Vector3d; | ||
import org.joml.Vector3f; | ||
import org.joml.Vector3i; | ||
import org.joml.Vector4f; | ||
|
||
import java.util.function.Supplier; | ||
|
||
public class Vector3IntegerUniform extends Uniform { | ||
private final Vector3i cachedValue; | ||
private final Supplier<Vector3i> value; | ||
|
||
Vector3IntegerUniform(int location, Supplier<Vector3i> value) { | ||
super(location); | ||
|
||
this.cachedValue = new Vector3i(); | ||
this.value = value; | ||
} | ||
|
||
Vector3IntegerUniform(int location, Supplier<Vector3i> value, ValueUpdateNotifier notifier) { | ||
super(location, notifier); | ||
|
||
this.cachedValue = new Vector3i(); | ||
this.value = value; | ||
} | ||
@Override | ||
public void update() { | ||
updateValue(); | ||
|
||
if (notifier != null) { | ||
notifier.setListener(this::updateValue); | ||
} | ||
} | ||
|
||
private void updateValue() { | ||
Vector3i newValue = value.get(); | ||
|
||
if (!newValue.equals(cachedValue)) { | ||
cachedValue.set(newValue.x(), newValue.y(), newValue.z()); | ||
IrisRenderSystem.uniform3i(location, cachedValue.x(), cachedValue.y(), cachedValue.z()); | ||
} | ||
} | ||
} |
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
35 changes: 35 additions & 0 deletions
35
src/main/java/net/coderbot/iris/uniforms/IrisTimeUniforms.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,35 @@ | ||
package net.coderbot.iris.uniforms; | ||
|
||
import net.coderbot.iris.Iris; | ||
import net.coderbot.iris.gl.uniform.UniformHolder; | ||
import net.coderbot.iris.gl.uniform.UniformUpdateFrequency; | ||
import org.joml.Vector2i; | ||
import org.joml.Vector3i; | ||
|
||
import java.time.LocalDateTime; | ||
import java.time.temporal.ChronoField; | ||
import java.time.temporal.TemporalField; | ||
import java.util.GregorianCalendar; | ||
|
||
public class IrisTimeUniforms { | ||
private static LocalDateTime dateTime; | ||
|
||
public static void updateTime() { | ||
dateTime = LocalDateTime.now(); | ||
} | ||
|
||
public static void addTimeUniforms(UniformHolder uniforms) { | ||
Vector3i date = new Vector3i(); | ||
Vector3i time = new Vector3i(); | ||
Vector2i yearTime = new Vector2i(); | ||
uniforms.uniform3i(UniformUpdateFrequency.PER_TICK, "currentDate", () -> date.set(dateTime.getYear(), dateTime.getMonthValue(), dateTime.getDayOfMonth())); | ||
uniforms.uniform3i(UniformUpdateFrequency.PER_TICK, "currentTime", () -> time.set(dateTime.getHour(), dateTime.getMinute(), dateTime.getSecond())); | ||
uniforms.uniform2i(UniformUpdateFrequency.PER_TICK, "currentYearTime", () -> yearTime.set( | ||
((dateTime.getDayOfYear() - 1) * 86400) + (dateTime.getHour() * 3600) + (dateTime.getMinute() * 60) + dateTime.getSecond(), | ||
(dateTime.toLocalDate().lengthOfYear() * 86400) - (((dateTime.getDayOfYear() - 1) * 86400) + (dateTime.getHour() * 3600) + (dateTime.getMinute() * 60) + dateTime.getSecond()) | ||
)); | ||
} | ||
|
||
static { | ||
} | ||
} |
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
31 changes: 31 additions & 0 deletions
31
src/main/java/net/coderbot/iris/uniforms/custom/cached/Int3VectorCachedUniform.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,31 @@ | ||
package net.coderbot.iris.uniforms.custom.cached; | ||
|
||
import net.coderbot.iris.gl.uniform.UniformUpdateFrequency; | ||
import net.coderbot.iris.parsing.VectorType; | ||
import org.joml.Vector3f; | ||
import org.joml.Vector3i; | ||
import org.lwjgl.opengl.GL21; | ||
|
||
import java.util.function.Supplier; | ||
|
||
public class Int3VectorCachedUniform extends VectorCachedUniform<Vector3i> { | ||
|
||
public Int3VectorCachedUniform(String name, UniformUpdateFrequency updateFrequency, Supplier<Vector3i> supplier) { | ||
super(name, updateFrequency, new Vector3i(), supplier); | ||
} | ||
|
||
@Override | ||
protected void setFrom(Vector3i other) { | ||
this.cached.set(other); | ||
} | ||
|
||
@Override | ||
public void push(int location) { | ||
GL21.glUniform3i(location, this.cached.x, this.cached.y, this.cached.z); | ||
} | ||
|
||
@Override | ||
public VectorType getType() { | ||
return VectorType.I_VEC3; | ||
} | ||
} |