mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-27 15:43:02 +00:00
Uniform Additions and fixes (#1102)
This commit is contained in:
1 parent
e6e230e270
commit
72ca675c93
22 files changed
+846
-156
No files matched your search
@@ -203,43 +203,45 @@ public class ProgramUniforms {
|
||||
final int size = sizeType.get(0);
|
||||
final int type = sizeType.get(1);
|
||||
|
||||
UniformType provided = uniformNames.get(name);
|
||||
final UniformType provided = uniformNames.get(name);
|
||||
final UniformType expected = getExpectedType(type);
|
||||
|
||||
if (provided == null && !name.startsWith("gl_")) {
|
||||
final String typeName = getTypeName(type);
|
||||
if(AngelicaConfig.enableHardcodedCustomUniforms) {
|
||||
// Legacy Checks from hardcoded custom uniforms
|
||||
if (provided == null && !name.startsWith("gl_")) {
|
||||
final String typeName = getTypeName(type);
|
||||
|
||||
if (isSampler(type) || isImage(type)) {
|
||||
// don't print a warning, samplers and images are managed elsewhere.
|
||||
// TODO: Detect unsupported samplers/images?
|
||||
continue;
|
||||
}
|
||||
if (isSampler(type) || isImage(type)) {
|
||||
// don't print a warning, samplers and images are managed elsewhere.
|
||||
continue;
|
||||
}
|
||||
|
||||
final UniformType externalProvided = externalUniformNames.get(name);
|
||||
final UniformType externalProvided = externalUniformNames.get(name);
|
||||
|
||||
if (externalProvided != null) {
|
||||
if (externalProvided != expected) {
|
||||
String expectedName;
|
||||
if (externalProvided != null) {
|
||||
if (externalProvided != expected) {
|
||||
final String expectedName;
|
||||
|
||||
if (expected != null) {
|
||||
expectedName = expected.toString();
|
||||
} else {
|
||||
expectedName = "(unsupported type: " + getTypeName(type) + ")";
|
||||
if (expected != null) {
|
||||
expectedName = expected.toString();
|
||||
} else {
|
||||
expectedName = "(unsupported type: " + getTypeName(type) + ")";
|
||||
}
|
||||
|
||||
Iris.logger.error("[" + this.name + "] Wrong uniform type for externally-managed uniform " + name + ": " + externalProvided + " is provided but the program expects " + expectedName + ".");
|
||||
}
|
||||
|
||||
Iris.logger.error("[" + this.name + "] Wrong uniform type for externally-managed uniform " + name + ": " + externalProvided + " is provided but the program expects " + expectedName + ".");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (size == 1) {
|
||||
Iris.logger.warn("[" + this.name + "] Unsupported uniform: " + typeName + " " + name);
|
||||
} else {
|
||||
Iris.logger.warn("[" + this.name + "] Unsupported uniform: " + name + " of size " + size + " and type " + typeName);
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (size == 1) {
|
||||
Iris.logger.warn("[" + this.name + "] Unsupported uniform: " + typeName + " " + name);
|
||||
} else {
|
||||
Iris.logger.warn("[" + this.name + "] Unsupported uniform: " + name + " of size " + size + " and type " + typeName);
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (provided != null && provided != expected) {
|
||||
@@ -291,6 +293,7 @@ public class ProgramUniforms {
|
||||
return switch(type) {
|
||||
case GL11.GL_FLOAT -> "float";
|
||||
case GL11.GL_INT -> "int";
|
||||
case GL20.GL_BOOL -> "bool";
|
||||
case GL20.GL_FLOAT_MAT4 -> "mat4";
|
||||
case GL20.GL_FLOAT_VEC4 -> "vec4";
|
||||
case GL20.GL_FLOAT_MAT3 -> "mat3";
|
||||
@@ -316,12 +319,13 @@ public class ProgramUniforms {
|
||||
return switch (type) {
|
||||
case GL11.GL_FLOAT -> UniformType.FLOAT;
|
||||
case GL11.GL_INT -> UniformType.INT;
|
||||
case GL20.GL_BOOL -> UniformType.INT;
|
||||
case GL20.GL_FLOAT_MAT4 -> UniformType.MAT4;
|
||||
case GL20.GL_FLOAT_VEC4 -> UniformType.VEC4;
|
||||
case GL20.GL_INT_VEC4 -> UniformType.VEC4I;
|
||||
case GL20.GL_FLOAT_VEC3 -> UniformType.VEC3;
|
||||
case GL20.GL_FLOAT_MAT3 -> null;
|
||||
case GL20.GL_INT_VEC3 -> null;
|
||||
case GL20.GL_FLOAT_MAT3 -> UniformType.MAT3;
|
||||
case GL20.GL_INT_VEC3 -> UniformType.VEC3I;
|
||||
case GL20.GL_FLOAT_MAT2 -> null;
|
||||
case GL20.GL_FLOAT_VEC2 -> UniformType.VEC2;
|
||||
case GL20.GL_INT_VEC2 -> UniformType.VEC2I;
|
||||
|
||||
@@ -3,11 +3,13 @@ package net.coderbot.iris.gl.shader;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.gtnewhorizons.angelica.Tags;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import net.coderbot.iris.parsing.BiomeCategories;
|
||||
import net.coderbot.iris.pipeline.HandRenderer;
|
||||
import net.coderbot.iris.pipeline.WorldRenderingPhase;
|
||||
import net.coderbot.iris.shaderpack.StringPair;
|
||||
import net.coderbot.iris.texture.format.TextureFormat;
|
||||
import net.coderbot.iris.texture.format.TextureFormatLoader;
|
||||
import net.coderbot.iris.uniforms.VanillaBiomeList;
|
||||
import org.lwjgl.LWJGLUtil;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL20;
|
||||
@@ -88,6 +90,9 @@ public class StandardMacros {
|
||||
define(standardDefines, irisDefine);
|
||||
}
|
||||
|
||||
getBiomeCategoryDefines().forEach((category, ordinal) -> define(standardDefines, category, ordinal));
|
||||
getVanillaBiomeDefines().forEach((biome, id) -> define(standardDefines, biome, id));
|
||||
|
||||
return ImmutableList.copyOf(standardDefines);
|
||||
}
|
||||
|
||||
@@ -98,7 +103,7 @@ public class StandardMacros {
|
||||
* @see <a href="https://github.com/sp614x/optifine/blob/9c6a5b5326558ccc57c6490b66b3be3b2dc8cbef/OptiFineDoc/doc/shaders.txt#L696-L699">Optifine Doc</a>
|
||||
*/
|
||||
public static String getMcVersion() {
|
||||
final String version = Loader.MC_VERSION;;
|
||||
final String version = Loader.MC_VERSION;
|
||||
|
||||
String[] splitVersion = version.split("\\.");
|
||||
|
||||
@@ -117,10 +122,10 @@ public class StandardMacros {
|
||||
}
|
||||
|
||||
if (minor.length() == 1) {
|
||||
minor = 0 + minor;
|
||||
minor = "0" + minor;
|
||||
}
|
||||
if (bugfix.length() == 1) {
|
||||
bugfix = 0 + bugfix;
|
||||
bugfix = "0" + bugfix;
|
||||
}
|
||||
|
||||
return major + minor + bugfix;
|
||||
@@ -283,4 +288,47 @@ public class StandardMacros {
|
||||
|
||||
return defines;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns biome category defines for use in shaders.
|
||||
* Generates #define CAT_<CATEGORY_NAME> <ordinal> for each BiomeCategories enum value.
|
||||
*
|
||||
* @return Map of biome category defines and their ordinal values
|
||||
*/
|
||||
public static Map<String, String> getBiomeCategoryDefines() {
|
||||
Map<String, String> defines = new HashMap<>();
|
||||
for (BiomeCategories category : BiomeCategories.values()) {
|
||||
defines.put("CAT_" + category.name(), String.valueOf(category.ordinal()));
|
||||
}
|
||||
return defines;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns vanilla biome ID defines for use in shaders.
|
||||
* Generates #define BIOME_<BIOME_NAME> <biomeID> for all vanilla biomes.
|
||||
*
|
||||
* @return Map of vanilla biome defines and their IDs
|
||||
*/
|
||||
public static Map<String, String> getVanillaBiomeDefines() {
|
||||
final Map<String, String> defines = new HashMap<>();
|
||||
|
||||
for (VanillaBiomeList.BiomeEntry entry : VanillaBiomeList.getVanillaBiomes()) {
|
||||
if (entry.biome != null) {
|
||||
defines.put("BIOME_" + entry.name, String.valueOf(entry.biome.biomeID));
|
||||
}
|
||||
}
|
||||
|
||||
// Modern biomes that don't exist in 1.7.10 - add dummy IDs that will never match
|
||||
// This allows shader expressions to parse without errors while always evaluating to false/0
|
||||
// Using negative IDs to avoid conflicts with actual biome IDs
|
||||
defines.put("BIOME_NETHER_WASTES", "-1000");
|
||||
defines.put("BIOME_SOUL_SAND_VALLEY", "-1001");
|
||||
defines.put("BIOME_CRIMSON_FOREST", "-1002");
|
||||
defines.put("BIOME_WARPED_FOREST", "-1003");
|
||||
defines.put("BIOME_BASALT_DELTAS", "-1004");
|
||||
defines.put("BIOME_LUSH_CAVES", "-1005");
|
||||
defines.put("BIOME_PALE_GARDEN", "-1006");
|
||||
|
||||
return defines;
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,9 @@ package net.coderbot.iris.gl.uniform;
|
||||
|
||||
public enum UniformType {
|
||||
INT,
|
||||
BOOL,
|
||||
FLOAT,
|
||||
MAT3,
|
||||
MAT4,
|
||||
VEC2,
|
||||
VEC2I,
|
||||
|
||||
Reference in new issue
Block a user