mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-12 16:37:49 +00:00
* Make shader based clouds work with iris shaderpacks, and port optimizations from #1685 Co-Authored-By: Eclipse-Sol <Eclipse-Sol@users.noreply.github.com> * Yeet GL_QUADS * Optimize a little more --------- Co-authored-by: Eclipse-Sol <Eclipse-Sol@users.noreply.github.com> Co-authored-by: Logan Phillips <phillips-l@outlook.com>
This commit is contained in:
19 files changed
+1008
-357
No files matched your search
@@ -11,6 +11,7 @@ public class StateUpdateNotifiers {
|
||||
public static ValueUpdateNotifier alphaFuncNotifier;
|
||||
public static ValueUpdateNotifier alphaTestNotifier;
|
||||
public static ValueUpdateNotifier blendFuncNotifier;
|
||||
public static ValueUpdateNotifier colorModulatorNotifier;
|
||||
public static ValueUpdateNotifier bindTextureNotifier;
|
||||
public static ValueUpdateNotifier normalTextureChangeNotifier;
|
||||
public static ValueUpdateNotifier specularTextureChangeNotifier;
|
||||
|
||||
@@ -34,7 +34,7 @@ class AttributeTransformer {
|
||||
transformer.injectVariable("layout(location = 4) in vec3 iris_Normal;");
|
||||
|
||||
transformer.rename("gl_Vertex", "iris_Vertex");
|
||||
transformer.rename("gl_Color", "iris_Color");
|
||||
transformer.replaceExpression("gl_Color", "(iris_Color * iris_ColorModulator)");
|
||||
transformer.rename("gl_Normal", "iris_Normal");
|
||||
|
||||
// ftransform() = gl_ModelViewProjectionMatrix * gl_Vertex
|
||||
|
||||
@@ -34,6 +34,7 @@ class CeleritasTransformer {
|
||||
transformer.injectFunction(
|
||||
"void _celeritas_init() { " +
|
||||
"_vert_init(); " +
|
||||
"_vert_color = _vert_color * iris_ColorModulator; " +
|
||||
"iris_LightTexCoord = vec4(vec2(_vert_tex_light_coord), 0.0, 1.0); }");
|
||||
transformer.prependMain("_celeritas_init();");
|
||||
transformShared(transformer, parameters);
|
||||
|
||||
@@ -20,9 +20,10 @@ public class CommonTransformer {
|
||||
}
|
||||
|
||||
if (parameters.type == ShaderType.VERTEX) {
|
||||
root.injectVariable("uniform vec4 iris_ColorModulator;");
|
||||
root.injectVariable("out vec4 iris_FrontColor;");
|
||||
root.rename("gl_FrontColor", "iris_FrontColor");
|
||||
root.prependMain("iris_FrontColor = vec4(1.0);");
|
||||
root.prependMain("iris_FrontColor = iris_ColorModulator;");
|
||||
} else if (parameters.type == ShaderType.FRAGMENT) {
|
||||
root.injectVariable("in vec4 iris_FrontColor;");
|
||||
root.rename("gl_Color", "iris_FrontColor");
|
||||
|
||||
@@ -94,7 +94,7 @@ public class DHGenericTransformer {
|
||||
+ " float skyLight = (float(uSkyLight) + 0.5) / 16.0;"
|
||||
+ " _vert_tex_light_coord = vec2(blockLight, skyLight);"
|
||||
+ " dhMaterialId = aMaterial;"
|
||||
+ " _vert_color = iris_color;"
|
||||
+ " _vert_color = iris_color * iris_ColorModulator;"
|
||||
+ " }"
|
||||
);
|
||||
transformer.prependMain("_vert_init();");
|
||||
|
||||
@@ -86,7 +86,7 @@ public class DHTerrainTransformer {
|
||||
+ " _vert_normal = irisNormals[int(irisExtra.y)];"
|
||||
+ " dhMaterialId = int(irisExtra.x);"
|
||||
+ " _vert_tex_light_coord = vec2((float(lights / 16u) + 0.5) / 16.0, (mod(float(lights), 16.0) + 0.5) / 16.0);"
|
||||
+ " _vert_color = iris_color;"
|
||||
+ " _vert_color = iris_color * iris_ColorModulator;"
|
||||
+ " }"
|
||||
);
|
||||
transformer.prependMain("_vert_init();");
|
||||
|
||||
@@ -23,7 +23,7 @@ public enum ProgramId {
|
||||
TexturedLit(ProgramGroup.Gbuffers, "textured_lit", Textured),
|
||||
SkyBasic(ProgramGroup.Gbuffers, "skybasic", Basic),
|
||||
SkyTextured(ProgramGroup.Gbuffers, "skytextured", Textured),
|
||||
Clouds(ProgramGroup.Gbuffers, "clouds", Textured),
|
||||
Clouds(ProgramGroup.Gbuffers, "clouds", Textured, null, new AlphaTestOverride(new AlphaTest(AlphaTestFunction.GREATER, 0.1F))),
|
||||
|
||||
Terrain(ProgramGroup.Gbuffers, "terrain", TexturedLit),
|
||||
TerrainSolid(ProgramGroup.Gbuffers, "terrain_solid", Terrain),
|
||||
|
||||
@@ -2,6 +2,7 @@ package net.coderbot.iris.uniforms;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.mojang.Camera;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.GameModeUtil;
|
||||
import com.gtnewhorizons.angelica.render.CloudRenderer;
|
||||
import net.coderbot.iris.gl.uniform.UniformHolder;
|
||||
import net.coderbot.iris.gl.uniform.UniformUpdateFrequency;
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -40,6 +41,16 @@ public class IrisExclusiveUniforms {
|
||||
uniforms.uniform3d(UniformUpdateFrequency.PER_FRAME, "eyePosition", IrisExclusiveUniforms::getEyePosition);
|
||||
uniforms.uniform3d(UniformUpdateFrequency.PER_FRAME, "relativeEyePosition", IrisExclusiveUniforms::getRelativeEyePosition);
|
||||
uniforms.uniform4f(UniformUpdateFrequency.PER_TICK, "lightningBoltPosition", IrisExclusiveUniforms::getLightningBoltPosition);
|
||||
uniforms.uniform1f(UniformUpdateFrequency.PER_FRAME, "cloudTime", IrisExclusiveUniforms::getCloudTime);
|
||||
}
|
||||
|
||||
private static float getCloudTime() {
|
||||
final WorldClient level = Minecraft.getMinecraft().theWorld;
|
||||
if (level == null) return 0f;
|
||||
final long cycle = (long) CloudRenderer.getCloudTextureWidth() * 400L * CloudRenderer.getScaleMult();
|
||||
final long t = level.getTotalWorldTime() % cycle;
|
||||
final float partial = Minecraft.getMinecraft().timer.renderPartialTicks;
|
||||
return (t + partial) * 0.03F;
|
||||
}
|
||||
|
||||
private static float getThunderStrength() {
|
||||
|
||||
@@ -12,10 +12,19 @@ import static net.coderbot.iris.gl.uniform.UniformUpdateFrequency.PER_FRAME;
|
||||
|
||||
public class IrisInternalUniforms {
|
||||
private static final Vector4f FOG_COLOR = new Vector4f();
|
||||
private static final Vector4f COLOR_MODULATOR = new Vector4f(1f, 1f, 1f, 1f);
|
||||
|
||||
private IrisInternalUniforms() {
|
||||
}
|
||||
|
||||
private static Vector4f getColorModulator() {
|
||||
return COLOR_MODULATOR.set(
|
||||
GLStateManager.getShaderColorR(),
|
||||
GLStateManager.getShaderColorG(),
|
||||
GLStateManager.getShaderColorB(),
|
||||
GLStateManager.getShaderColorA());
|
||||
}
|
||||
|
||||
private static float getEffectiveAlphaRef() {
|
||||
if (!GLStateManager.getAlphaTest().isEnabled() || GLStateManager.getAlphaState().getFunction() == GL11.GL_ALWAYS) {
|
||||
return -1.0f;
|
||||
@@ -44,5 +53,7 @@ public class IrisInternalUniforms {
|
||||
.uniform1f("iris_currentAlphaTest", IrisInternalUniforms::getEffectiveAlphaRef, StateUpdateNotifiers.alphaTestNotifier)
|
||||
.uniform1f("alphaTestRef", IrisInternalUniforms::getEffectiveAlphaRef, StateUpdateNotifiers.alphaTestNotifier)
|
||||
.uniform1i("iris_currentAlphaFunc", IrisInternalUniforms::getEffectiveAlphaFunc, StateUpdateNotifiers.alphaFuncNotifier);
|
||||
|
||||
uniforms.uniform4f("iris_ColorModulator", IrisInternalUniforms::getColorModulator, StateUpdateNotifiers.colorModulatorNotifier);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user