Common Shaders #14
No files matched your search
@@ -55,6 +55,8 @@ public interface RenderSystemService {
|
|||||||
Matrix4f getProjectionMatrix();
|
Matrix4f getProjectionMatrix();
|
||||||
void setProjectionMatrixOrth(Matrix4f projectionMatrix);
|
void setProjectionMatrixOrth(Matrix4f projectionMatrix);
|
||||||
void setProjectionMatrixOrigin(Matrix4f projectionMatrix);
|
void setProjectionMatrixOrigin(Matrix4f projectionMatrix);
|
||||||
|
|
||||||
|
default void setPositionShader() {};
|
||||||
// TODO: Figure out VertexSorting type
|
// TODO: Figure out VertexSorting type
|
||||||
// void setProjectionMatrix(Matrix4f projectionMatrix, VertexSorting vertexSorting)
|
// void setProjectionMatrix(Matrix4f projectionMatrix, VertexSorting vertexSorting)
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -7,6 +7,7 @@ import java.util.function.IntSupplier;
|
|||||||
|
|
||||||
import static com.mitchej123.glsm.GLStateManagerService.GL_STATE_MANAGER;
|
import static com.mitchej123.glsm.GLStateManagerService.GL_STATE_MANAGER;
|
||||||
import static com.mitchej123.glsm.RenderSystemService.RENDER_SYSTEM;
|
import static com.mitchej123.glsm.RenderSystemService.RENDER_SYSTEM;
|
||||||
|
import static org.embeddedt.embeddium.compat.mc.MinecraftVersionShimService.MINECRAFT_SHIM;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import net.irisshaders.iris.gl.IrisRenderSystem;
|
import net.irisshaders.iris.gl.IrisRenderSystem;
|
||||||
@@ -20,7 +21,6 @@ import net.irisshaders.iris.gl.texture.InternalTextureFormat;
|
|||||||
import net.irisshaders.iris.gl.texture.PixelType;
|
import net.irisshaders.iris.gl.texture.PixelType;
|
||||||
import net.irisshaders.iris.gl.uniform.UniformUpdateFrequency;
|
import net.irisshaders.iris.gl.uniform.UniformUpdateFrequency;
|
||||||
import net.irisshaders.iris.uniforms.SystemTimeUniforms;
|
import net.irisshaders.iris.uniforms.SystemTimeUniforms;
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.joml.Matrix4f;
|
import org.joml.Matrix4f;
|
||||||
import org.lwjgl.opengl.GL21C;
|
import org.lwjgl.opengl.GL21C;
|
||||||
@@ -89,7 +89,7 @@ public class CenterDepthSampler {
|
|||||||
DepthCopyStrategy.fastest(false).copy(this.framebuffer, texture, null, altTexture, 1, 1);
|
DepthCopyStrategy.fastest(false).copy(this.framebuffer, texture, null, altTexture, 1, 1);
|
||||||
|
|
||||||
//Reset viewport
|
//Reset viewport
|
||||||
Minecraft.getInstance().getMainRenderTarget().bindWrite(true);
|
MINECRAFT_SHIM.bindMainFramebuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setupColorTexture(int texture, InternalTextureFormat format) {
|
public void setupColorTexture(int texture, InternalTextureFormat format) {
|
||||||
File renamed without changes.
-15
@@ -1,15 +0,0 @@
|
|||||||
package net.irisshaders.iris.pipeline;
|
|
||||||
|
|
||||||
import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
|
|
||||||
import net.irisshaders.iris.gl.texture.TextureAccess;
|
|
||||||
import net.irisshaders.iris.shaderpack.texture.TextureStage;
|
|
||||||
|
|
||||||
import java.util.EnumMap;
|
|
||||||
|
|
||||||
public abstract class CommonCustomTextureManager {
|
|
||||||
public abstract TextureAccess getNoiseTexture();
|
|
||||||
public abstract EnumMap<TextureStage, Object2ObjectMap<String, TextureAccess>> getCustomTextureIdMap();
|
|
||||||
public abstract Object2ObjectMap<String, TextureAccess> getCustomTextureIdMap(TextureStage stage);
|
|
||||||
public abstract Object2ObjectMap<String, TextureAccess> getIrisCustomTextures();
|
|
||||||
public abstract void destroy();
|
|
||||||
}
|
|
||||||
+1295
-30
File diff suppressed because it is too large.
Load diff
+6
-6
@@ -8,6 +8,7 @@ import java.util.function.Supplier;
|
|||||||
|
|
||||||
import static com.mitchej123.glsm.GLStateManagerService.GL_STATE_MANAGER;
|
import static com.mitchej123.glsm.GLStateManagerService.GL_STATE_MANAGER;
|
||||||
import static com.mitchej123.glsm.RenderSystemService.RENDER_SYSTEM;
|
import static com.mitchej123.glsm.RenderSystemService.RENDER_SYSTEM;
|
||||||
|
import static org.embeddedt.embeddium.compat.mc.MinecraftVersionShimService.MINECRAFT_SHIM;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
@@ -25,7 +26,6 @@ import net.irisshaders.iris.gl.sampler.SamplerLimits;
|
|||||||
import net.irisshaders.iris.gl.shader.ShaderCompileException;
|
import net.irisshaders.iris.gl.shader.ShaderCompileException;
|
||||||
import net.irisshaders.iris.gl.state.FogMode;
|
import net.irisshaders.iris.gl.state.FogMode;
|
||||||
import net.irisshaders.iris.gl.texture.TextureAccess;
|
import net.irisshaders.iris.gl.texture.TextureAccess;
|
||||||
import net.irisshaders.iris.mixin.GlStateManagerAccessor;
|
|
||||||
import net.irisshaders.iris.pathways.CenterDepthSampler;
|
import net.irisshaders.iris.pathways.CenterDepthSampler;
|
||||||
import net.irisshaders.iris.pathways.FullScreenQuadRenderer;
|
import net.irisshaders.iris.pathways.FullScreenQuadRenderer;
|
||||||
import net.irisshaders.iris.pipeline.foss_transform.TransformPatcherBridge;
|
import net.irisshaders.iris.pipeline.foss_transform.TransformPatcherBridge;
|
||||||
@@ -47,7 +47,6 @@ import net.irisshaders.iris.targets.RenderTargets;
|
|||||||
import net.irisshaders.iris.uniforms.CommonUniforms;
|
import net.irisshaders.iris.uniforms.CommonUniforms;
|
||||||
import net.irisshaders.iris.uniforms.FrameUpdateNotifier;
|
import net.irisshaders.iris.uniforms.FrameUpdateNotifier;
|
||||||
import net.irisshaders.iris.uniforms.custom.CustomUniforms;
|
import net.irisshaders.iris.uniforms.custom.CustomUniforms;
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import org.lwjgl.opengl.GL15C;
|
import org.lwjgl.opengl.GL15C;
|
||||||
import org.lwjgl.opengl.GL20C;
|
import org.lwjgl.opengl.GL20C;
|
||||||
import org.lwjgl.opengl.GL30C;
|
import org.lwjgl.opengl.GL30C;
|
||||||
@@ -226,7 +225,8 @@ public class CompositeRenderer {
|
|||||||
RENDER_SYSTEM.disableBlend();
|
RENDER_SYSTEM.disableBlend();
|
||||||
|
|
||||||
FullScreenQuadRenderer.INSTANCE.begin();
|
FullScreenQuadRenderer.INSTANCE.begin();
|
||||||
com.mojang.blaze3d.pipeline.RenderTarget main = Minecraft.getInstance().getMainRenderTarget();
|
final int mcWidth = MINECRAFT_SHIM.getMainFramebufferWidth();
|
||||||
|
final int mcHeight = MINECRAFT_SHIM.getMainFramebufferHeight();
|
||||||
|
|
||||||
for (Pass renderPass : passes) {
|
for (Pass renderPass : passes) {
|
||||||
boolean ranCompute = false;
|
boolean ranCompute = false;
|
||||||
@@ -235,7 +235,7 @@ public class CompositeRenderer {
|
|||||||
ranCompute = true;
|
ranCompute = true;
|
||||||
computeProgram.use();
|
computeProgram.use();
|
||||||
this.customUniforms.push(computeProgram);
|
this.customUniforms.push(computeProgram);
|
||||||
computeProgram.dispatch(main.width, main.height);
|
computeProgram.dispatch(mcWidth, mcHeight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -283,7 +283,7 @@ public class CompositeRenderer {
|
|||||||
|
|
||||||
// Make sure to reset the viewport to how it was before... Otherwise weird issues could occur.
|
// Make sure to reset the viewport to how it was before... Otherwise weird issues could occur.
|
||||||
// Also bind the "main" framebuffer if it isn't already bound.
|
// Also bind the "main" framebuffer if it isn't already bound.
|
||||||
Minecraft.getInstance().getMainRenderTarget().bindWrite(true);
|
MINECRAFT_SHIM.bindMainFramebuffer();
|
||||||
ProgramUniforms.clearActiveUniforms();
|
ProgramUniforms.clearActiveUniforms();
|
||||||
ProgramSamplers.clearActiveSamplers();
|
ProgramSamplers.clearActiveSamplers();
|
||||||
GL_STATE_MANAGER.glUseProgram(0);
|
GL_STATE_MANAGER.glUseProgram(0);
|
||||||
@@ -292,7 +292,7 @@ public class CompositeRenderer {
|
|||||||
for (int i = 0; i < SamplerLimits.get().getMaxTextureUnits(); i++) {
|
for (int i = 0; i < SamplerLimits.get().getMaxTextureUnits(); i++) {
|
||||||
// Unbind all textures that we may have used.
|
// Unbind all textures that we may have used.
|
||||||
// NB: This is necessary for shader pack reloading to work propely
|
// NB: This is necessary for shader pack reloading to work propely
|
||||||
if (GlStateManagerAccessor.getTEXTURES()[i].binding != 0) {
|
if (GL_STATE_MANAGER.getBoundTexture(i) != 0) { // GlStateManagerAccessor.getTEXTURES()[i].binding
|
||||||
RENDER_SYSTEM.glActiveTexture(GL15C.GL_TEXTURE0 + i);
|
RENDER_SYSTEM.glActiveTexture(GL15C.GL_TEXTURE0 + i);
|
||||||
RENDER_SYSTEM.bindTexture(0);
|
RENDER_SYSTEM.bindTexture(0);
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,204 @@
|
|||||||
|
package net.irisshaders.iris.pipeline;
|
||||||
|
|
||||||
|
import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
|
||||||
|
import it.unimi.dsi.fastutil.objects.Object2ObjectMaps;
|
||||||
|
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||||
|
import net.irisshaders.iris.gl.texture.GlTexture;
|
||||||
|
import net.irisshaders.iris.gl.texture.TextureAccess;
|
||||||
|
import net.irisshaders.iris.gl.texture.TextureType;
|
||||||
|
import net.irisshaders.iris.gl.texture.TextureWrapper;
|
||||||
|
import net.irisshaders.iris.shaderpack.properties.PackDirectives;
|
||||||
|
import net.irisshaders.iris.shaderpack.texture.CustomTextureData;
|
||||||
|
import net.irisshaders.iris.shaderpack.texture.TextureStage;
|
||||||
|
import net.irisshaders.iris.targets.backed.NativeImageBackedCustomTexture;
|
||||||
|
import net.irisshaders.iris.targets.backed.NativeImageBackedNoiseTexture;
|
||||||
|
import net.irisshaders.iris.texture.format.TextureFormat;
|
||||||
|
import net.irisshaders.iris.texture.format.TextureFormatLoader;
|
||||||
|
import net.irisshaders.iris.texture.pbr.PBRTextureHolder;
|
||||||
|
import net.irisshaders.iris.texture.pbr.PBRTextureManager;
|
||||||
|
import net.irisshaders.iris.texture.pbr.PBRType;
|
||||||
|
import org.apache.commons.io.FilenameUtils;
|
||||||
|
import org.embeddedt.embeddium.compat.mc.MCAbstractTexture;
|
||||||
|
import org.embeddedt.embeddium.compat.mc.MCResourceLocation;
|
||||||
|
import org.embeddedt.embeddium.compat.mc.MCTextureManager;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.EnumMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import static com.mitchej123.glsm.GLStateManagerService.GL_STATE_MANAGER;
|
||||||
|
import static net.irisshaders.iris.IrisLogging.IRIS_LOGGER;
|
||||||
|
import static org.embeddedt.embeddium.compat.mc.MinecraftVersionShimService.MINECRAFT_SHIM;
|
||||||
|
|
||||||
|
public class CustomTextureManager {
|
||||||
|
protected final EnumMap<TextureStage, Object2ObjectMap<String, TextureAccess>> customTextureIdMap = new EnumMap<>(TextureStage.class);
|
||||||
|
protected final Object2ObjectMap<String, TextureAccess> irisCustomTextures = new Object2ObjectOpenHashMap<>();
|
||||||
|
protected final TextureAccess noise;
|
||||||
|
protected final List<GlTexture> ownedRawTextures = new ArrayList<>();
|
||||||
|
/**
|
||||||
|
* List of all OpenGL texture objects owned by this CustomTextureManager that need to be deleted in order to avoid
|
||||||
|
* leaks.
|
||||||
|
* Make sure any textures added to this list call releaseId from the close method.
|
||||||
|
*/
|
||||||
|
protected final List<MCAbstractTexture> ownedTextures = new ArrayList<>();
|
||||||
|
|
||||||
|
public TextureAccess getNoiseTexture() {
|
||||||
|
return noise;
|
||||||
|
}
|
||||||
|
|
||||||
|
private TextureAccess createCustomTexture(CustomTextureData textureData) throws IOException, RuntimeException/*ResourceLocationException*/ {
|
||||||
|
if (textureData instanceof CustomTextureData.PngData) {
|
||||||
|
NativeImageBackedCustomTexture texture = new NativeImageBackedCustomTexture((CustomTextureData.PngData) textureData);
|
||||||
|
ownedTextures.add(texture);
|
||||||
|
|
||||||
|
return texture;
|
||||||
|
} else if (textureData instanceof CustomTextureData.LightmapMarker) {
|
||||||
|
// Special code path for the light texture. While shader packs hardcode the primary light texture, it's
|
||||||
|
// possible that a mod will create a different light texture, so this code path is robust to that.
|
||||||
|
return new TextureWrapper(MINECRAFT_SHIM::getLightTextureId, TextureType.TEXTURE_2D);
|
||||||
|
} else if (textureData instanceof CustomTextureData.RawData1D rawData1D) {
|
||||||
|
GlTexture texture = new GlTexture(TextureType.TEXTURE_1D, rawData1D.getSizeX(), 0, 0, rawData1D.getInternalFormat().getGlFormat(), rawData1D.getPixelFormat().getGlFormat(), rawData1D.getPixelType().getGlFormat(), rawData1D.getContent(), rawData1D.getFilteringData());
|
||||||
|
ownedRawTextures.add(texture);
|
||||||
|
|
||||||
|
return texture;
|
||||||
|
} else if (textureData instanceof CustomTextureData.RawDataRect rawDataRect) {
|
||||||
|
GlTexture texture = new GlTexture(TextureType.TEXTURE_RECTANGLE, rawDataRect.getSizeX(), rawDataRect.getSizeY(), 0, rawDataRect.getInternalFormat().getGlFormat(), rawDataRect.getPixelFormat().getGlFormat(), rawDataRect.getPixelType().getGlFormat(), rawDataRect.getContent(), rawDataRect.getFilteringData());
|
||||||
|
ownedRawTextures.add(texture);
|
||||||
|
|
||||||
|
return texture;
|
||||||
|
} else if (textureData instanceof CustomTextureData.RawData2D rawData2D) {
|
||||||
|
GlTexture texture = new GlTexture(TextureType.TEXTURE_2D, rawData2D.getSizeX(), rawData2D.getSizeY(), 0, rawData2D.getInternalFormat().getGlFormat(), rawData2D.getPixelFormat().getGlFormat(), rawData2D.getPixelType().getGlFormat(), rawData2D.getContent(), rawData2D.getFilteringData());
|
||||||
|
ownedRawTextures.add(texture);
|
||||||
|
|
||||||
|
return texture;
|
||||||
|
} else if (textureData instanceof CustomTextureData.RawData3D rawData3D) {
|
||||||
|
GlTexture texture = new GlTexture(TextureType.TEXTURE_3D, rawData3D.getSizeX(), rawData3D.getSizeY(), rawData3D.getSizeZ(), rawData3D.getInternalFormat().getGlFormat(), rawData3D.getPixelFormat().getGlFormat(), rawData3D.getPixelType().getGlFormat(), rawData3D.getContent(), rawData3D.getFilteringData());
|
||||||
|
ownedRawTextures.add(texture);
|
||||||
|
|
||||||
|
return texture;
|
||||||
|
} else if (textureData instanceof CustomTextureData.ResourceData resourceData) {
|
||||||
|
String namespace = resourceData.getNamespace();
|
||||||
|
String location = resourceData.getLocation();
|
||||||
|
|
||||||
|
String withoutExtension;
|
||||||
|
int extensionIndex = FilenameUtils.indexOfExtension(location);
|
||||||
|
if (extensionIndex != -1) {
|
||||||
|
withoutExtension = location.substring(0, extensionIndex);
|
||||||
|
} else {
|
||||||
|
withoutExtension = location;
|
||||||
|
}
|
||||||
|
PBRType pbrType = PBRType.fromFileLocation(withoutExtension);
|
||||||
|
|
||||||
|
MCTextureManager textureManager = MINECRAFT_SHIM.getTextureManager();
|
||||||
|
|
||||||
|
if (pbrType == null) {
|
||||||
|
MCResourceLocation textureLocation = MINECRAFT_SHIM.makeResourceLocation(namespace, location);
|
||||||
|
|
||||||
|
// NB: We have to re-query the TextureManager for the texture object every time. This is because the
|
||||||
|
// AbstractTexture object could be removed / deleted from the TextureManager on resource reloads,
|
||||||
|
// and we could end up holding on to a deleted texture unless we added special code to handle resource
|
||||||
|
// reloads. Re-fetching the texture from the TextureManager every time is the most robust approach for
|
||||||
|
// now.
|
||||||
|
return new TextureWrapper(() -> {
|
||||||
|
MCAbstractTexture texture = textureManager.getTexture(textureLocation);
|
||||||
|
return texture != null ? texture.getId() : MINECRAFT_SHIM.getMissingTextureId();
|
||||||
|
}, TextureType.TEXTURE_2D);
|
||||||
|
} else {
|
||||||
|
location = location.substring(0, extensionIndex - pbrType.getSuffix().length()) + location.substring(extensionIndex);
|
||||||
|
MCResourceLocation textureLocation = MINECRAFT_SHIM.makeResourceLocation(namespace, location);
|
||||||
|
|
||||||
|
return new TextureWrapper(() -> {
|
||||||
|
MCAbstractTexture texture = textureManager.getTexture(textureLocation);
|
||||||
|
|
||||||
|
if (texture != null) {
|
||||||
|
int id = texture.getId();
|
||||||
|
PBRTextureHolder pbrHolder = PBRTextureManager.INSTANCE.getOrLoadHolder(id);
|
||||||
|
MCAbstractTexture pbrTexture = switch (pbrType) {
|
||||||
|
case NORMAL -> pbrHolder.normalTexture();
|
||||||
|
case SPECULAR -> pbrHolder.specularTexture();
|
||||||
|
default -> throw new IllegalArgumentException("Unknown PBRType '" + pbrType + "'");
|
||||||
|
};
|
||||||
|
|
||||||
|
TextureFormat textureFormat = TextureFormatLoader.getFormat();
|
||||||
|
if (textureFormat != null) {
|
||||||
|
int previousBinding = GL_STATE_MANAGER.getBoundTexture(GL_STATE_MANAGER.getActiveTexture());
|
||||||
|
GL_STATE_MANAGER.bindTexture(pbrTexture.getId());
|
||||||
|
textureFormat.setupTextureParameters(pbrType, (MCAbstractTexture)pbrTexture);
|
||||||
|
GL_STATE_MANAGER.bindTexture(previousBinding);
|
||||||
|
}
|
||||||
|
|
||||||
|
return pbrTexture.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
return MINECRAFT_SHIM.getMissingTextureId();
|
||||||
|
}, TextureType.TEXTURE_2D);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new IllegalArgumentException("Don't know texture type!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public EnumMap<TextureStage, Object2ObjectMap<String, TextureAccess>> getCustomTextureIdMap() {
|
||||||
|
return customTextureIdMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object2ObjectMap<String, TextureAccess> getCustomTextureIdMap(TextureStage stage) {
|
||||||
|
return customTextureIdMap.getOrDefault(stage, Object2ObjectMaps.emptyMap());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object2ObjectMap<String, TextureAccess> getIrisCustomTextures() {
|
||||||
|
return irisCustomTextures;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void destroy() {
|
||||||
|
ownedTextures.forEach(MCAbstractTexture::close);
|
||||||
|
ownedRawTextures.forEach(GlTexture::destroy);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CustomTextureManager(PackDirectives packDirectives,
|
||||||
|
EnumMap<TextureStage, Object2ObjectMap<String, CustomTextureData>> customTextureDataMap,
|
||||||
|
Object2ObjectMap<String, CustomTextureData> irisCustomTextureDataMap, Optional<CustomTextureData> customNoiseTextureData) {
|
||||||
|
|
||||||
|
customTextureDataMap.forEach((textureStage, customTextureStageDataMap) -> {
|
||||||
|
Object2ObjectMap<String, TextureAccess> customTextureIds = new Object2ObjectOpenHashMap<>();
|
||||||
|
|
||||||
|
customTextureStageDataMap.forEach((samplerName, textureData) -> {
|
||||||
|
try {
|
||||||
|
customTextureIds.put(samplerName, createCustomTexture(textureData));
|
||||||
|
} catch (IOException | RuntimeException/*ResourceLocationException*/ e) {
|
||||||
|
IRIS_LOGGER.error("Unable to parse the image data for the custom texture on stage "
|
||||||
|
+ textureStage + ", sampler " + samplerName, e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
customTextureIdMap.put(textureStage, customTextureIds);
|
||||||
|
});
|
||||||
|
|
||||||
|
irisCustomTextureDataMap.forEach((name, texture) -> {
|
||||||
|
try {
|
||||||
|
irisCustomTextures.put(name, createCustomTexture(texture));
|
||||||
|
} catch (IOException e) {
|
||||||
|
IRIS_LOGGER.error("Unable to parse the image data for the custom texture on sampler " + name, e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
noise = customNoiseTextureData.flatMap(textureData -> {
|
||||||
|
try {
|
||||||
|
return Optional.of(createCustomTexture(textureData));
|
||||||
|
} catch (IOException | RuntimeException/*ResourceLocationException*/ e) {
|
||||||
|
IRIS_LOGGER.error("Unable to parse the image data for the custom noise texture", e);
|
||||||
|
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
}).orElseGet(() -> {
|
||||||
|
final int noiseTextureResolution = packDirectives.getNoiseTextureResolution();
|
||||||
|
|
||||||
|
NativeImageBackedNoiseTexture texture = new NativeImageBackedNoiseTexture(noiseTextureResolution);
|
||||||
|
ownedTextures.add(texture);
|
||||||
|
|
||||||
|
return texture;
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
+11
-14
@@ -7,6 +7,7 @@ import java.util.function.Supplier;
|
|||||||
|
|
||||||
import static com.mitchej123.glsm.GLStateManagerService.GL_STATE_MANAGER;
|
import static com.mitchej123.glsm.GLStateManagerService.GL_STATE_MANAGER;
|
||||||
import static com.mitchej123.glsm.RenderSystemService.RENDER_SYSTEM;
|
import static com.mitchej123.glsm.RenderSystemService.RENDER_SYSTEM;
|
||||||
|
import static org.embeddedt.embeddium.compat.mc.MinecraftVersionShimService.MINECRAFT_SHIM;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
@@ -22,7 +23,6 @@ import net.irisshaders.iris.gl.sampler.SamplerLimits;
|
|||||||
import net.irisshaders.iris.gl.shader.ShaderCompileException;
|
import net.irisshaders.iris.gl.shader.ShaderCompileException;
|
||||||
import net.irisshaders.iris.gl.state.FogMode;
|
import net.irisshaders.iris.gl.state.FogMode;
|
||||||
import net.irisshaders.iris.gl.texture.TextureAccess;
|
import net.irisshaders.iris.gl.texture.TextureAccess;
|
||||||
import net.irisshaders.iris.mixin.GlStateManagerAccessor;
|
|
||||||
import net.irisshaders.iris.pathways.CenterDepthSampler;
|
import net.irisshaders.iris.pathways.CenterDepthSampler;
|
||||||
import net.irisshaders.iris.pathways.FullScreenQuadRenderer;
|
import net.irisshaders.iris.pathways.FullScreenQuadRenderer;
|
||||||
import net.irisshaders.iris.pipeline.foss_transform.TransformPatcherBridge;
|
import net.irisshaders.iris.pipeline.foss_transform.TransformPatcherBridge;
|
||||||
@@ -38,13 +38,11 @@ import net.irisshaders.iris.shaderpack.properties.PackRenderTargetDirectives;
|
|||||||
import net.irisshaders.iris.shaderpack.properties.ProgramDirectives;
|
import net.irisshaders.iris.shaderpack.properties.ProgramDirectives;
|
||||||
import net.irisshaders.iris.shaderpack.texture.TextureStage;
|
import net.irisshaders.iris.shaderpack.texture.TextureStage;
|
||||||
import net.irisshaders.iris.shadows.ShadowRenderTargets;
|
import net.irisshaders.iris.shadows.ShadowRenderTargets;
|
||||||
import net.irisshaders.iris.targets.Blaze3dRenderTargetExt;
|
|
||||||
import net.irisshaders.iris.targets.RenderTarget;
|
import net.irisshaders.iris.targets.RenderTarget;
|
||||||
import net.irisshaders.iris.targets.RenderTargets;
|
import net.irisshaders.iris.targets.RenderTargets;
|
||||||
import net.irisshaders.iris.uniforms.CommonUniforms;
|
import net.irisshaders.iris.uniforms.CommonUniforms;
|
||||||
import net.irisshaders.iris.uniforms.FrameUpdateNotifier;
|
import net.irisshaders.iris.uniforms.FrameUpdateNotifier;
|
||||||
import net.irisshaders.iris.uniforms.custom.CustomUniforms;
|
import net.irisshaders.iris.uniforms.custom.CustomUniforms;
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import org.embeddedt.embeddium.impl.gl.debug.GLDebug;
|
import org.embeddedt.embeddium.impl.gl.debug.GLDebug;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.lwjgl.opengl.*;
|
import org.lwjgl.opengl.*;
|
||||||
@@ -110,8 +108,8 @@ public class FinalPassRenderer {
|
|||||||
// passes that write to framebuffers).
|
// passes that write to framebuffers).
|
||||||
this.baseline = renderTargets.createGbufferFramebuffer(flippedBuffers, new int[]{0});
|
this.baseline = renderTargets.createGbufferFramebuffer(flippedBuffers, new int[]{0});
|
||||||
this.colorHolder = new GlFramebuffer();
|
this.colorHolder = new GlFramebuffer();
|
||||||
this.lastColorTextureId = Minecraft.getInstance().getMainRenderTarget().getColorTextureId();
|
this.lastColorTextureId = MINECRAFT_SHIM.getColorTextureId();
|
||||||
this.lastColorTextureVersion = ((Blaze3dRenderTargetExt) Minecraft.getInstance().getMainRenderTarget()).iris$getColorBufferVersion();
|
this.lastColorTextureVersion = MINECRAFT_SHIM.getColorBufferVersion();
|
||||||
this.colorHolder.addColorAttachment(0, lastColorTextureId);
|
this.colorHolder.addColorAttachment(0, lastColorTextureId);
|
||||||
|
|
||||||
// TODO: We don't actually fully swap the content, we merely copy it from alt to main
|
// TODO: We don't actually fully swap the content, we merely copy it from alt to main
|
||||||
@@ -189,9 +187,8 @@ public class FinalPassRenderer {
|
|||||||
RENDER_SYSTEM.disableBlend();
|
RENDER_SYSTEM.disableBlend();
|
||||||
RENDER_SYSTEM.depthMask(false);
|
RENDER_SYSTEM.depthMask(false);
|
||||||
|
|
||||||
final com.mojang.blaze3d.pipeline.RenderTarget main = Minecraft.getInstance().getMainRenderTarget();
|
final int baseWidth = MINECRAFT_SHIM.getMainFramebufferWidth();
|
||||||
final int baseWidth = main.width;
|
final int baseHeight = MINECRAFT_SHIM.getMainFramebufferHeight();
|
||||||
final int baseHeight = main.height;
|
|
||||||
|
|
||||||
// Note that since DeferredWorldRenderingPipeline uses the depth texture of the main Minecraft framebuffer,
|
// Note that since DeferredWorldRenderingPipeline uses the depth texture of the main Minecraft framebuffer,
|
||||||
// we'll be writing to that depth buffer directly automatically and won't need to futz around with copying
|
// we'll be writing to that depth buffer directly automatically and won't need to futz around with copying
|
||||||
@@ -206,9 +203,9 @@ public class FinalPassRenderer {
|
|||||||
//
|
//
|
||||||
// This is not a concern for depthtex1 / depthtex2 since the copy call extracts the depth values, and the
|
// This is not a concern for depthtex1 / depthtex2 since the copy call extracts the depth values, and the
|
||||||
// shader pack only ever uses them to read the depth values.
|
// shader pack only ever uses them to read the depth values.
|
||||||
if (((Blaze3dRenderTargetExt) main).iris$getColorBufferVersion() != lastColorTextureVersion || main.getColorTextureId() != lastColorTextureId) {
|
if (MINECRAFT_SHIM.getColorBufferVersion() != lastColorTextureVersion || MINECRAFT_SHIM.getColorTextureId() != lastColorTextureId) {
|
||||||
lastColorTextureVersion = ((Blaze3dRenderTargetExt) main).iris$getColorBufferVersion();
|
lastColorTextureVersion = MINECRAFT_SHIM.getColorBufferVersion();
|
||||||
this.lastColorTextureId = main.getColorTextureId();
|
this.lastColorTextureId = MINECRAFT_SHIM.getColorTextureId();
|
||||||
colorHolder.addColorAttachment(0, lastColorTextureId);
|
colorHolder.addColorAttachment(0, lastColorTextureId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -261,7 +258,7 @@ public class FinalPassRenderer {
|
|||||||
// https://stackoverflow.com/a/23994979/18166885
|
// https://stackoverflow.com/a/23994979/18166885
|
||||||
this.baseline.bindAsReadBuffer();
|
this.baseline.bindAsReadBuffer();
|
||||||
|
|
||||||
IrisRenderSystem.copyTexSubImage2D(main.getColorTextureId(), GL11C.GL_TEXTURE_2D, 0, 0, 0, 0, 0, baseWidth, baseHeight);
|
IrisRenderSystem.copyTexSubImage2D(MINECRAFT_SHIM.getColorTextureId(), GL11C.GL_TEXTURE_2D, 0, 0, 0, 0, 0, baseWidth, baseHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
RENDER_SYSTEM.glActiveTexture(GL15C.GL_TEXTURE0);
|
RENDER_SYSTEM.glActiveTexture(GL15C.GL_TEXTURE0);
|
||||||
@@ -288,7 +285,7 @@ public class FinalPassRenderer {
|
|||||||
|
|
||||||
// Make sure to reset the viewport to how it was before... Otherwise weird issues could occur.
|
// Make sure to reset the viewport to how it was before... Otherwise weird issues could occur.
|
||||||
// Also bind the "main" framebuffer if it isn't already bound.
|
// Also bind the "main" framebuffer if it isn't already bound.
|
||||||
main.bindWrite(true);
|
MINECRAFT_SHIM.bindMainFramebuffer();
|
||||||
ProgramUniforms.clearActiveUniforms();
|
ProgramUniforms.clearActiveUniforms();
|
||||||
ProgramSamplers.clearActiveSamplers();
|
ProgramSamplers.clearActiveSamplers();
|
||||||
GL_STATE_MANAGER.glUseProgram(0);
|
GL_STATE_MANAGER.glUseProgram(0);
|
||||||
@@ -296,7 +293,7 @@ public class FinalPassRenderer {
|
|||||||
for (int i = 0; i < SamplerLimits.get().getMaxTextureUnits(); i++) {
|
for (int i = 0; i < SamplerLimits.get().getMaxTextureUnits(); i++) {
|
||||||
// Unbind all textures that we may have used.
|
// Unbind all textures that we may have used.
|
||||||
// NB: This is necessary for shader pack reloading to work properly
|
// NB: This is necessary for shader pack reloading to work properly
|
||||||
if (GlStateManagerAccessor.getTEXTURES()[i].binding != 0) {
|
if (GL_STATE_MANAGER.getBoundTexture(i) != 0) {
|
||||||
RENDER_SYSTEM.glActiveTexture(GL15C.GL_TEXTURE0 + i);
|
RENDER_SYSTEM.glActiveTexture(GL15C.GL_TEXTURE0 + i);
|
||||||
RENDER_SYSTEM.bindTexture(0);
|
RENDER_SYSTEM.bindTexture(0);
|
||||||
}
|
}
|
||||||
File renamed without changes.
+2
-2
@@ -2,7 +2,7 @@ package net.irisshaders.iris.pipeline;
|
|||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.primitives.Ints;
|
import com.google.common.primitives.Ints;
|
||||||
import org.embeddedt.embeddium.compat.mc.IResourceLocation;
|
import org.embeddedt.embeddium.compat.mc.MCResourceLocation;
|
||||||
import org.embeddedt.embeddium.impl.render.chunk.RenderPassConfiguration;
|
import org.embeddedt.embeddium.impl.render.chunk.RenderPassConfiguration;
|
||||||
import net.irisshaders.iris.gl.blending.AlphaTest;
|
import net.irisshaders.iris.gl.blending.AlphaTest;
|
||||||
import net.irisshaders.iris.gl.blending.AlphaTests;
|
import net.irisshaders.iris.gl.blending.AlphaTests;
|
||||||
@@ -295,7 +295,7 @@ public class SodiumTerrainPipeline {
|
|||||||
String namespace = matcher.group("namespace");
|
String namespace = matcher.group("namespace");
|
||||||
String path = matcher.group("path");
|
String path = matcher.group("path");
|
||||||
|
|
||||||
IResourceLocation identifier = MINECRAFT_SHIM.makeResourceLocation(namespace, path);
|
MCResourceLocation identifier = MINECRAFT_SHIM.makeResourceLocation(namespace, path);
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -18,8 +18,8 @@ import net.irisshaders.iris.shaderpack.texture.TextureStage;
|
|||||||
import net.irisshaders.iris.targets.RenderTargetStateListener;
|
import net.irisshaders.iris.targets.RenderTargetStateListener;
|
||||||
import net.irisshaders.iris.uniforms.FrameUpdateNotifier;
|
import net.irisshaders.iris.uniforms.FrameUpdateNotifier;
|
||||||
|
|
||||||
import org.embeddedt.embeddium.compat.mc.ICamera;
|
import org.embeddedt.embeddium.compat.mc.MCCamera;
|
||||||
import org.embeddedt.embeddium.compat.mc.ILevelRenderer;
|
import org.embeddedt.embeddium.compat.mc.MCLevelRenderer;
|
||||||
|
|
||||||
public abstract class VanillaRenderingPipeline implements WorldRenderingPipeline {
|
public abstract class VanillaRenderingPipeline implements WorldRenderingPipeline {
|
||||||
public VanillaRenderingPipeline() {
|
public VanillaRenderingPipeline() {
|
||||||
@@ -35,12 +35,12 @@ public abstract class VanillaRenderingPipeline implements WorldRenderingPipeline
|
|||||||
@Override
|
@Override
|
||||||
public void beginLevelRendering() {
|
public void beginLevelRendering() {
|
||||||
// Use the default Minecraft framebuffer and ensure that no programs are in use
|
// Use the default Minecraft framebuffer and ensure that no programs are in use
|
||||||
MINECRAFT_SHIM.bindFramebuffer();
|
MINECRAFT_SHIM.bindMainFramebuffer();
|
||||||
GL_STATE_MANAGER.glUseProgram(0);
|
GL_STATE_MANAGER.glUseProgram(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderShadows(ILevelRenderer worldRenderer, ICamera camera) {
|
public void renderShadows(MCLevelRenderer worldRenderer, MCCamera camera) {
|
||||||
// stub: nothing to do here
|
// stub: nothing to do here
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -10,8 +10,8 @@ import net.irisshaders.iris.shaderpack.properties.ParticleRenderingSettings;
|
|||||||
import net.irisshaders.iris.shaderpack.texture.TextureStage;
|
import net.irisshaders.iris.shaderpack.texture.TextureStage;
|
||||||
import net.irisshaders.iris.targets.RenderTargetStateListener;
|
import net.irisshaders.iris.targets.RenderTargetStateListener;
|
||||||
import net.irisshaders.iris.uniforms.FrameUpdateNotifier;
|
import net.irisshaders.iris.uniforms.FrameUpdateNotifier;
|
||||||
import org.embeddedt.embeddium.compat.mc.ICamera;
|
import org.embeddedt.embeddium.compat.mc.MCCamera;
|
||||||
import org.embeddedt.embeddium.compat.mc.ILevelRenderer;
|
import org.embeddedt.embeddium.compat.mc.MCLevelRenderer;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.OptionalInt;
|
import java.util.OptionalInt;
|
||||||
@@ -19,7 +19,7 @@ import java.util.OptionalInt;
|
|||||||
public interface WorldRenderingPipeline {
|
public interface WorldRenderingPipeline {
|
||||||
void beginLevelRendering();
|
void beginLevelRendering();
|
||||||
|
|
||||||
void renderShadows(ILevelRenderer worldRenderer, ICamera camera);
|
void renderShadows(MCLevelRenderer worldRenderer, MCCamera camera);
|
||||||
|
|
||||||
void addDebugText(List<String> messages);
|
void addDebugText(List<String> messages);
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package net.irisshaders.iris.pipeline.programs;
|
||||||
|
|
||||||
|
import net.irisshaders.iris.gl.blending.AlphaTest;
|
||||||
|
import net.irisshaders.iris.gl.state.FogMode;
|
||||||
|
import net.irisshaders.iris.shaderpack.loading.ProgramId;
|
||||||
|
import org.embeddedt.embeddium.compat.mc.MCVertexFormat;
|
||||||
|
|
||||||
|
public interface ShaderKey {
|
||||||
|
int ordinal();
|
||||||
|
ProgramId getProgram();
|
||||||
|
AlphaTest getAlphaTest();
|
||||||
|
MCVertexFormat getVertexFormat();
|
||||||
|
FogMode getFogMode();
|
||||||
|
boolean isIntensity();
|
||||||
|
String getName();
|
||||||
|
boolean isShadow();
|
||||||
|
boolean hasDiffuseLighting();
|
||||||
|
boolean shouldIgnoreLightmap();
|
||||||
|
boolean isGlint();
|
||||||
|
boolean isText();
|
||||||
|
}
|
||||||
+8
-10
@@ -1,32 +1,30 @@
|
|||||||
package net.irisshaders.iris.pipeline.programs;
|
package net.irisshaders.iris.pipeline.programs;
|
||||||
|
|
||||||
import net.minecraft.client.renderer.ShaderInstance;
|
import org.embeddedt.embeddium.compat.mc.MCShaderInstance;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.concurrent.*;
|
import java.util.concurrent.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A specialized map mapping {@link ShaderKey} to {@link ShaderInstance}.
|
* A specialized map mapping {@link ShaderKey} to {@link MCShaderInstance}.
|
||||||
* Avoids much of the complexity / overhead of an EnumMap while ultimately
|
* Avoids much of the complexity / overhead of an EnumMap while ultimately
|
||||||
* fulfilling the same function.
|
* fulfilling the same function.
|
||||||
*/
|
*/
|
||||||
public class ShaderMap {
|
public class ShaderMap {
|
||||||
private final ShaderInstance[] shaders;
|
private final MCShaderInstance[] shaders;
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private static <E extends Throwable> void sneakyThrow(Throwable e) throws E {
|
private static <E extends Throwable> void sneakyThrow(Throwable e) throws E {
|
||||||
throw (E) e;
|
throw (E) e;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ShaderMap(ShaderFactory factory) throws IOException {
|
public ShaderMap(ShaderFactory factory, ShaderKey[] ids) throws IOException {
|
||||||
ShaderKey[] ids = ShaderKey.values();
|
this.shaders = new MCShaderInstance[ids.length];
|
||||||
|
|
||||||
this.shaders = new ShaderInstance[ids.length];
|
|
||||||
|
|
||||||
LinkedBlockingQueue<Runnable> renderThreadTasks = new LinkedBlockingQueue<>();
|
LinkedBlockingQueue<Runnable> renderThreadTasks = new LinkedBlockingQueue<>();
|
||||||
Executor syncExecutor = renderThreadTasks::add;
|
Executor syncExecutor = renderThreadTasks::add;
|
||||||
|
|
||||||
CompletableFuture<ShaderInstance>[] futures = new CompletableFuture[ids.length];
|
CompletableFuture<MCShaderInstance>[] futures = new CompletableFuture[ids.length];
|
||||||
|
|
||||||
for (int i = 0; i < ids.length; i++) {
|
for (int i = 0; i < ids.length; i++) {
|
||||||
futures[i] = factory.create(ids[i], syncExecutor);
|
futures[i] = factory.create(ids[i], syncExecutor);
|
||||||
@@ -60,10 +58,10 @@ public class ShaderMap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public interface ShaderFactory {
|
public interface ShaderFactory {
|
||||||
CompletableFuture<ShaderInstance> create(ShaderKey key, Executor syncExecutor) throws IOException;
|
CompletableFuture<MCShaderInstance> create(ShaderKey key, Executor syncExecutor) throws IOException;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ShaderInstance getShader(ShaderKey id) {
|
public MCShaderInstance getShader(ShaderKey id) {
|
||||||
return shaders[id.ordinal()];
|
return shaders[id.ordinal()];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -23,6 +23,7 @@ import java.util.function.Supplier;
|
|||||||
|
|
||||||
public class IrisSamplers {
|
public class IrisSamplers {
|
||||||
public static final int ALBEDO_TEXTURE_UNIT = 0;
|
public static final int ALBEDO_TEXTURE_UNIT = 0;
|
||||||
|
// TODO(1.7.10): light map is 1 in 1.7.10, and there is no overlay
|
||||||
public static final int OVERLAY_TEXTURE_UNIT = 1;
|
public static final int OVERLAY_TEXTURE_UNIT = 1;
|
||||||
public static final int LIGHTMAP_TEXTURE_UNIT = 2;
|
public static final int LIGHTMAP_TEXTURE_UNIT = 2;
|
||||||
|
|
||||||
|
|||||||
File renamed without changes.
@@ -12,6 +12,8 @@ import net.irisshaders.iris.shaderpack.properties.PackShadowDirectives;
|
|||||||
import net.irisshaders.iris.shaderpack.properties.ShadowCullState;
|
import net.irisshaders.iris.shaderpack.properties.ShadowCullState;
|
||||||
import net.irisshaders.iris.shadows.frustum.CommonFrustumHolder;
|
import net.irisshaders.iris.shadows.frustum.CommonFrustumHolder;
|
||||||
import net.irisshaders.iris.uniforms.CelestialUniforms;
|
import net.irisshaders.iris.uniforms.CelestialUniforms;
|
||||||
|
import org.embeddedt.embeddium.compat.mc.MCCamera;
|
||||||
|
import org.embeddedt.embeddium.compat.mc.MCLevelRenderer;
|
||||||
import org.joml.Matrix4f;
|
import org.joml.Matrix4f;
|
||||||
import org.lwjgl.opengl.ARBTextureSwizzle;
|
import org.lwjgl.opengl.ARBTextureSwizzle;
|
||||||
import org.lwjgl.opengl.GL20C;
|
import org.lwjgl.opengl.GL20C;
|
||||||
@@ -218,12 +220,14 @@ public abstract class CommonShadowRenderer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public abstract void destroy();
|
||||||
|
|
||||||
protected abstract String getEntitiesDebugString();
|
protected abstract String getEntitiesDebugString();
|
||||||
protected abstract String getBlockEntitiesDebugString();
|
protected abstract String getBlockEntitiesDebugString();
|
||||||
protected abstract void addBuffersDebugText(List<String> messages);
|
protected abstract void addBuffersDebugText(List<String> messages);
|
||||||
|
public abstract void renderShadows(MCLevelRenderer levelRendererIn, MCCamera playerCamera);
|
||||||
|
|
||||||
protected record MipmapPass(int texture, int targetFilteringMode) {
|
protected record MipmapPass(int texture, int targetFilteringMode) {
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
+3
-4
@@ -6,6 +6,7 @@ import java.util.Set;
|
|||||||
|
|
||||||
import static com.mitchej123.glsm.GLStateManagerService.GL_STATE_MANAGER;
|
import static com.mitchej123.glsm.GLStateManagerService.GL_STATE_MANAGER;
|
||||||
import static com.mitchej123.glsm.RenderSystemService.RENDER_SYSTEM;
|
import static com.mitchej123.glsm.RenderSystemService.RENDER_SYSTEM;
|
||||||
|
import static org.embeddedt.embeddium.compat.mc.MinecraftVersionShimService.MINECRAFT_SHIM;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
@@ -38,13 +39,12 @@ import net.irisshaders.iris.targets.RenderTarget;
|
|||||||
import net.irisshaders.iris.uniforms.CommonUniforms;
|
import net.irisshaders.iris.uniforms.CommonUniforms;
|
||||||
import net.irisshaders.iris.uniforms.FrameUpdateNotifier;
|
import net.irisshaders.iris.uniforms.FrameUpdateNotifier;
|
||||||
import net.irisshaders.iris.uniforms.custom.CustomUniforms;
|
import net.irisshaders.iris.uniforms.custom.CustomUniforms;
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import org.lwjgl.opengl.GL15C;
|
import org.lwjgl.opengl.GL15C;
|
||||||
import org.lwjgl.opengl.GL20C;
|
import org.lwjgl.opengl.GL20C;
|
||||||
import org.lwjgl.opengl.GL30C;
|
import org.lwjgl.opengl.GL30C;
|
||||||
import org.lwjgl.opengl.GL43C;
|
import org.lwjgl.opengl.GL43C;
|
||||||
|
|
||||||
public class ShadowCompositeRenderer extends CommonShadowCompositeRenderer {
|
public class ShadowCompositeRenderer {
|
||||||
private final ShadowRenderTargets renderTargets;
|
private final ShadowRenderTargets renderTargets;
|
||||||
|
|
||||||
private final ImmutableList<Pass> passes;
|
private final ImmutableList<Pass> passes;
|
||||||
@@ -189,8 +189,7 @@ public class ShadowCompositeRenderer extends CommonShadowCompositeRenderer {
|
|||||||
ranCompute = true;
|
ranCompute = true;
|
||||||
computeProgram.use();
|
computeProgram.use();
|
||||||
this.customUniforms.push(computeProgram);
|
this.customUniforms.push(computeProgram);
|
||||||
com.mojang.blaze3d.pipeline.RenderTarget main = Minecraft.getInstance().getMainRenderTarget();
|
computeProgram.dispatch(MINECRAFT_SHIM.getMainFramebufferWidth(), MINECRAFT_SHIM.getMainFramebufferHeight());
|
||||||
computeProgram.dispatch(main.width, main.height);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
+10
-7
@@ -1,11 +1,11 @@
|
|||||||
package net.irisshaders.iris.targets.backed;
|
package net.irisshaders.iris.targets.backed;
|
||||||
|
|
||||||
import com.mojang.blaze3d.platform.NativeImage;
|
|
||||||
import net.irisshaders.iris.gl.IrisRenderSystem;
|
import net.irisshaders.iris.gl.IrisRenderSystem;
|
||||||
import net.irisshaders.iris.gl.texture.TextureAccess;
|
import net.irisshaders.iris.gl.texture.TextureAccess;
|
||||||
import net.irisshaders.iris.gl.texture.TextureType;
|
import net.irisshaders.iris.gl.texture.TextureType;
|
||||||
import net.irisshaders.iris.shaderpack.texture.CustomTextureData;
|
import net.irisshaders.iris.shaderpack.texture.CustomTextureData;
|
||||||
import net.minecraft.client.renderer.texture.DynamicTexture;
|
import org.embeddedt.embeddium.compat.mc.CommonDynamicTexture;
|
||||||
|
import org.embeddedt.embeddium.compat.mc.MCNativeImage;
|
||||||
import org.lwjgl.opengl.GL11C;
|
import org.lwjgl.opengl.GL11C;
|
||||||
import org.lwjgl.opengl.GL13C;
|
import org.lwjgl.opengl.GL13C;
|
||||||
|
|
||||||
@@ -14,10 +14,11 @@ import java.nio.ByteBuffer;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.function.IntSupplier;
|
import java.util.function.IntSupplier;
|
||||||
|
|
||||||
public class NativeImageBackedCustomTexture extends DynamicTexture implements TextureAccess {
|
import static org.embeddedt.embeddium.compat.mc.MinecraftVersionShimService.MINECRAFT_SHIM;
|
||||||
|
|
||||||
|
public class NativeImageBackedCustomTexture extends CommonDynamicTexture implements TextureAccess {
|
||||||
public NativeImageBackedCustomTexture(CustomTextureData.PngData textureData) throws IOException {
|
public NativeImageBackedCustomTexture(CustomTextureData.PngData textureData) throws IOException {
|
||||||
super(create(textureData.getContent()));
|
super(create(textureData.getContent()));
|
||||||
|
|
||||||
// By default, images are unblurred and not clamped.
|
// By default, images are unblurred and not clamped.
|
||||||
|
|
||||||
if (textureData.getFilteringData().shouldBlur()) {
|
if (textureData.getFilteringData().shouldBlur()) {
|
||||||
@@ -31,22 +32,23 @@ public class NativeImageBackedCustomTexture extends DynamicTexture implements Te
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static NativeImage create(byte[] content) throws IOException {
|
private static MCNativeImage create(byte[] content) throws IOException {
|
||||||
ByteBuffer buffer = ByteBuffer.allocateDirect(content.length);
|
ByteBuffer buffer = ByteBuffer.allocateDirect(content.length);
|
||||||
buffer.put(content);
|
buffer.put(content);
|
||||||
buffer.flip();
|
buffer.flip();
|
||||||
|
|
||||||
return NativeImage.read(buffer);
|
return MINECRAFT_SHIM.readNativeImage(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void upload() {
|
public void upload() {
|
||||||
NativeImage image = Objects.requireNonNull(getPixels());
|
MCNativeImage image = Objects.requireNonNull(getPixels());
|
||||||
|
|
||||||
bind();
|
bind();
|
||||||
image.upload(0, 0, 0, 0, 0, image.getWidth(), image.getHeight(), false, false, false, false);
|
image.upload(0, 0, 0, 0, 0, image.getWidth(), image.getHeight(), false, false, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TextureType getType() {
|
public TextureType getType() {
|
||||||
return TextureType.TEXTURE_2D;
|
return TextureType.TEXTURE_2D;
|
||||||
@@ -56,4 +58,5 @@ public class NativeImageBackedCustomTexture extends DynamicTexture implements Te
|
|||||||
public IntSupplier getTextureId() {
|
public IntSupplier getTextureId() {
|
||||||
return this::getId;
|
return this::getId;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
+8
-6
@@ -1,21 +1,23 @@
|
|||||||
package net.irisshaders.iris.targets.backed;
|
package net.irisshaders.iris.targets.backed;
|
||||||
|
|
||||||
import com.mojang.blaze3d.platform.NativeImage;
|
|
||||||
import net.irisshaders.iris.gl.texture.TextureAccess;
|
import net.irisshaders.iris.gl.texture.TextureAccess;
|
||||||
import net.irisshaders.iris.gl.texture.TextureType;
|
import net.irisshaders.iris.gl.texture.TextureType;
|
||||||
import net.minecraft.client.renderer.texture.DynamicTexture;
|
import org.embeddedt.embeddium.compat.mc.CommonDynamicTexture;
|
||||||
|
import org.embeddedt.embeddium.compat.mc.MCNativeImage;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.function.IntSupplier;
|
import java.util.function.IntSupplier;
|
||||||
|
|
||||||
public class NativeImageBackedNoiseTexture extends DynamicTexture implements TextureAccess {
|
import static org.embeddedt.embeddium.compat.mc.MinecraftVersionShimService.MINECRAFT_SHIM;
|
||||||
|
|
||||||
|
public class NativeImageBackedNoiseTexture extends CommonDynamicTexture implements TextureAccess {
|
||||||
public NativeImageBackedNoiseTexture(int size) {
|
public NativeImageBackedNoiseTexture(int size) {
|
||||||
super(create(size));
|
super(create(size));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static NativeImage create(int size) {
|
private static MCNativeImage create(int size) {
|
||||||
NativeImage image = new NativeImage(NativeImage.Format.RGBA, size, size, false);
|
MCNativeImage image = MINECRAFT_SHIM.createNativeImage(size, size, false);
|
||||||
Random random = new Random(0);
|
Random random = new Random(0);
|
||||||
|
|
||||||
for (int x = 0; x < size; x++) {
|
for (int x = 0; x < size; x++) {
|
||||||
@@ -31,7 +33,7 @@ public class NativeImageBackedNoiseTexture extends DynamicTexture implements Tex
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void upload() {
|
public void upload() {
|
||||||
NativeImage image = Objects.requireNonNull(getPixels());
|
MCNativeImage image = Objects.requireNonNull(getPixels());
|
||||||
|
|
||||||
bind();
|
bind();
|
||||||
image.upload(0, 0, 0, 0, 0, image.getWidth(), image.getHeight(), true, false, false, false);
|
image.upload(0, 0, 0, 0, 0, image.getWidth(), image.getHeight(), true, false, false, false);
|
||||||
+7
-5
@@ -1,10 +1,12 @@
|
|||||||
package net.irisshaders.iris.targets.backed;
|
package net.irisshaders.iris.targets.backed;
|
||||||
|
|
||||||
import com.mojang.blaze3d.platform.NativeImage;
|
|
||||||
import net.minecraft.client.renderer.texture.DynamicTexture;
|
|
||||||
import org.embeddedt.embeddium.api.util.ColorABGR;
|
import org.embeddedt.embeddium.api.util.ColorABGR;
|
||||||
|
import org.embeddedt.embeddium.compat.mc.CommonDynamicTexture;
|
||||||
|
import org.embeddedt.embeddium.compat.mc.MCNativeImage;
|
||||||
|
|
||||||
public class NativeImageBackedSingleColorTexture extends DynamicTexture {
|
import static org.embeddedt.embeddium.compat.mc.MinecraftVersionShimService.MINECRAFT_SHIM;
|
||||||
|
|
||||||
|
public class NativeImageBackedSingleColorTexture extends CommonDynamicTexture {
|
||||||
public NativeImageBackedSingleColorTexture(int red, int green, int blue, int alpha) {
|
public NativeImageBackedSingleColorTexture(int red, int green, int blue, int alpha) {
|
||||||
super(create(ColorABGR.pack(red, green, blue, alpha)));
|
super(create(ColorABGR.pack(red, green, blue, alpha)));
|
||||||
}
|
}
|
||||||
@@ -13,8 +15,8 @@ public class NativeImageBackedSingleColorTexture extends DynamicTexture {
|
|||||||
this(rgba >> 24 & 0xFF, rgba >> 16 & 0xFF, rgba >> 8 & 0xFF, rgba & 0xFF);
|
this(rgba >> 24 & 0xFF, rgba >> 16 & 0xFF, rgba >> 8 & 0xFF, rgba & 0xFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static NativeImage create(int color) {
|
private static MCNativeImage create(int color) {
|
||||||
NativeImage image = new NativeImage(NativeImage.Format.RGBA, 1, 1, false);
|
MCNativeImage image = MINECRAFT_SHIM.createNativeImage(1, 1, false);
|
||||||
|
|
||||||
image.setPixelRGBA(0, 0, color);
|
image.setPixelRGBA(0, 0, color);
|
||||||
|
|
||||||
File renamed without changes.
File renamed without changes.
+7
-7
@@ -1,8 +1,8 @@
|
|||||||
package net.irisshaders.iris.texture.format;
|
package net.irisshaders.iris.texture.format;
|
||||||
|
|
||||||
import org.embeddedt.embeddium.compat.mc.IResource;
|
import org.embeddedt.embeddium.compat.mc.MCResource;
|
||||||
import org.embeddedt.embeddium.compat.mc.IResourceLocation;
|
import org.embeddedt.embeddium.compat.mc.MCResourceLocation;
|
||||||
import org.embeddedt.embeddium.compat.mc.IResourceProvider;
|
import org.embeddedt.embeddium.compat.mc.MCResourceProvider;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.taumc.celeritas.CeleritasShaderVersionService;
|
import org.taumc.celeritas.CeleritasShaderVersionService;
|
||||||
|
|
||||||
@@ -17,7 +17,7 @@ import static net.irisshaders.iris.IrisLogging.IRIS_LOGGER;
|
|||||||
import static org.embeddedt.embeddium.compat.mc.MinecraftVersionShimService.MINECRAFT_SHIM;
|
import static org.embeddedt.embeddium.compat.mc.MinecraftVersionShimService.MINECRAFT_SHIM;
|
||||||
|
|
||||||
public class TextureFormatLoader {
|
public class TextureFormatLoader {
|
||||||
public static final IResourceLocation LOCATION = MINECRAFT_SHIM.makeResourceLocation("optifine/texture.properties");
|
public static final MCResourceLocation LOCATION = MINECRAFT_SHIM.makeResourceLocation("optifine/texture.properties");
|
||||||
|
|
||||||
private static TextureFormat format;
|
private static TextureFormat format;
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@ public class TextureFormatLoader {
|
|||||||
return format;
|
return format;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void reload(IResourceProvider resourceManager) {
|
public static void reload(MCResourceProvider resourceManager) {
|
||||||
TextureFormat newFormat = loadFormat(resourceManager);
|
TextureFormat newFormat = loadFormat(resourceManager);
|
||||||
boolean didFormatChange = !Objects.equals(format, newFormat);
|
boolean didFormatChange = !Objects.equals(format, newFormat);
|
||||||
format = newFormat;
|
format = newFormat;
|
||||||
@@ -36,8 +36,8 @@ public class TextureFormatLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private static TextureFormat loadFormat(IResourceProvider resourceManager) {
|
private static TextureFormat loadFormat(MCResourceProvider resourceManager) {
|
||||||
Optional<IResource> resource = resourceManager.getResource((IResourceLocation)(Object)LOCATION);
|
Optional<MCResource> resource = resourceManager.getResource((MCResourceLocation)(Object)LOCATION);
|
||||||
if (resource.isPresent()) {
|
if (resource.isPresent()) {
|
||||||
try (InputStream stream = resource.get().open()) {
|
try (InputStream stream = resource.get().open()) {
|
||||||
Properties properties = new Properties();
|
Properties properties = new Properties();
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package net.irisshaders.iris.texture.pbr;
|
||||||
|
|
||||||
|
import org.embeddedt.embeddium.compat.mc.MCDumpable;
|
||||||
|
import org.embeddedt.embeddium.compat.mc.MCResourceLocation;
|
||||||
|
|
||||||
|
public interface PBRDumpable extends MCDumpable {
|
||||||
|
MCResourceLocation getDefaultDumpLocation();
|
||||||
|
}
|
||||||
File renamed without changes.
+8
-10
@@ -5,21 +5,19 @@ import java.nio.file.Path;
|
|||||||
|
|
||||||
import static com.mitchej123.glsm.GLStateManagerService.GL_STATE_MANAGER;
|
import static com.mitchej123.glsm.GLStateManagerService.GL_STATE_MANAGER;
|
||||||
import static net.irisshaders.iris.IrisLogging.IRIS_LOGGER;
|
import static net.irisshaders.iris.IrisLogging.IRIS_LOGGER;
|
||||||
|
import static org.embeddedt.embeddium.compat.mc.MinecraftVersionShimService.MINECRAFT_SHIM;
|
||||||
|
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||||
import net.irisshaders.iris.gl.state.StateUpdateNotifiers;
|
import net.irisshaders.iris.gl.state.StateUpdateNotifiers;
|
||||||
import net.irisshaders.iris.mixin.GlStateManagerAccessor;
|
|
||||||
import net.irisshaders.iris.targets.backed.NativeImageBackedSingleColorTexture;
|
import net.irisshaders.iris.targets.backed.NativeImageBackedSingleColorTexture;
|
||||||
import net.irisshaders.iris.texture.TextureTracker;
|
import net.irisshaders.iris.texture.TextureTracker;
|
||||||
import net.irisshaders.iris.texture.pbr.loader.PBRTextureLoader;
|
import net.irisshaders.iris.texture.pbr.loader.PBRTextureLoader;
|
||||||
import net.irisshaders.iris.texture.pbr.loader.PBRTextureLoader.PBRTextureConsumer;
|
import net.irisshaders.iris.texture.pbr.loader.PBRTextureLoader.PBRTextureConsumer;
|
||||||
import net.irisshaders.iris.texture.pbr.loader.PBRTextureLoaderRegistry;
|
import net.irisshaders.iris.texture.pbr.loader.PBRTextureLoaderRegistry;
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.renderer.texture.AbstractTexture;
|
|
||||||
import net.minecraft.client.renderer.texture.Dumpable;
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
import org.embeddedt.embeddium.compat.mc.MCAbstractTexture;
|
import org.embeddedt.embeddium.compat.mc.MCAbstractTexture;
|
||||||
|
import org.embeddedt.embeddium.compat.mc.MCDumpable;
|
||||||
|
import org.embeddedt.embeddium.compat.mc.MCResourceLocation;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class PBRTextureManager {
|
public class PBRTextureManager {
|
||||||
@@ -55,7 +53,7 @@ public class PBRTextureManager {
|
|||||||
private PBRTextureManager() {
|
private PBRTextureManager() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void dumpTexture(Dumpable dumpable, ResourceLocation id, Path path) {
|
private static void dumpTexture(MCDumpable dumpable, MCResourceLocation id, Path path) {
|
||||||
try {
|
try {
|
||||||
dumpable.dumpContents(id, path);
|
dumpable.dumpContents(id, path);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@@ -106,15 +104,15 @@ public class PBRTextureManager {
|
|||||||
|
|
||||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||||
private PBRTextureHolder loadHolder(int id) {
|
private PBRTextureHolder loadHolder(int id) {
|
||||||
AbstractTexture texture = (AbstractTexture) TextureTracker.INSTANCE.getTexture(id);
|
MCAbstractTexture texture = TextureTracker.INSTANCE.getTexture(id);
|
||||||
if (texture != null) {
|
if (texture != null) {
|
||||||
Class<? extends AbstractTexture> clazz = texture.getClass();
|
Class<? extends MCAbstractTexture> clazz = texture.getClass();
|
||||||
PBRTextureLoader loader = PBRTextureLoaderRegistry.INSTANCE.getLoader(clazz);
|
PBRTextureLoader loader = PBRTextureLoaderRegistry.INSTANCE.getLoader(clazz);
|
||||||
if (loader != null) {
|
if (loader != null) {
|
||||||
int previousTextureBinding = GlStateManagerAccessor.getTEXTURES()[GlStateManagerAccessor.getActiveTexture()].binding;
|
int previousTextureBinding = GL_STATE_MANAGER.getActiveBoundTexture();
|
||||||
consumer.clear();
|
consumer.clear();
|
||||||
try {
|
try {
|
||||||
loader.load(texture, Minecraft.getInstance().getResourceManager(), consumer);
|
loader.load(texture, MINECRAFT_SHIM.getResourceManager(), consumer);
|
||||||
return consumer.toHolder();
|
return consumer.toHolder();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
IRIS_LOGGER.debug("Failed to load PBR textures for texture " + id, e);
|
IRIS_LOGGER.debug("Failed to load PBR textures for texture " + id, e);
|
||||||
+3
-4
@@ -1,11 +1,10 @@
|
|||||||
package net.irisshaders.iris.texture.pbr.loader;
|
package net.irisshaders.iris.texture.pbr.loader;
|
||||||
|
|
||||||
import net.minecraft.client.renderer.texture.AbstractTexture;
|
|
||||||
import net.minecraft.server.packs.resources.ResourceManager;
|
|
||||||
import org.embeddedt.embeddium.compat.mc.MCAbstractTexture;
|
import org.embeddedt.embeddium.compat.mc.MCAbstractTexture;
|
||||||
|
import org.embeddedt.embeddium.compat.mc.MCResourceManager;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public interface PBRTextureLoader<T extends AbstractTexture> {
|
public interface PBRTextureLoader<T> {
|
||||||
/**
|
/**
|
||||||
* This method must not modify global GL state except the texture binding for {@code GL_TEXTURE_2D}.
|
* This method must not modify global GL state except the texture binding for {@code GL_TEXTURE_2D}.
|
||||||
*
|
*
|
||||||
@@ -13,7 +12,7 @@ public interface PBRTextureLoader<T extends AbstractTexture> {
|
|||||||
* @param resourceManager The resource manager.
|
* @param resourceManager The resource manager.
|
||||||
* @param pbrTextureConsumer The consumer that accepts resulting PBR textures.
|
* @param pbrTextureConsumer The consumer that accepts resulting PBR textures.
|
||||||
*/
|
*/
|
||||||
void load(T texture, ResourceManager resourceManager, PBRTextureConsumer pbrTextureConsumer);
|
void load(T texture, MCResourceManager resourceManager, PBRTextureConsumer pbrTextureConsumer);
|
||||||
|
|
||||||
interface PBRTextureConsumer {
|
interface PBRTextureConsumer {
|
||||||
void acceptNormalTexture(@NotNull MCAbstractTexture texture);
|
void acceptNormalTexture(@NotNull MCAbstractTexture texture);
|
||||||
+17
@@ -0,0 +1,17 @@
|
|||||||
|
package net.irisshaders.iris.texture.pbr.loader;
|
||||||
|
|
||||||
|
import org.embeddedt.embeddium.compat.mc.MCAbstractTexture;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.ServiceLoader;
|
||||||
|
|
||||||
|
public interface PBRTextureLoaderRegistry {
|
||||||
|
PBRTextureLoaderRegistry INSTANCE = ServiceLoader.load(PBRTextureLoaderRegistry.class).findFirst().orElseThrow();
|
||||||
|
|
||||||
|
|
||||||
|
<T> void register(Class<? extends T> clazz, PBRTextureLoader<T> loader);
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Nullable
|
||||||
|
<T> PBRTextureLoader<T> getLoader(Class<? extends T> clazz);
|
||||||
|
}
|
||||||
+37
@@ -0,0 +1,37 @@
|
|||||||
|
package org.embeddedt.embeddium.compat.mc;
|
||||||
|
|
||||||
|
import static org.embeddedt.embeddium.compat.mc.MinecraftVersionShimService.MINECRAFT_SHIM;
|
||||||
|
|
||||||
|
public class CommonDynamicTexture implements MCDynamicTexture {
|
||||||
|
MCDynamicTexture dynamicTexture;
|
||||||
|
|
||||||
|
public CommonDynamicTexture(MCNativeImage mcNativeImage) {
|
||||||
|
dynamicTexture = MINECRAFT_SHIM.createDynamicTexture(mcNativeImage);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public MCNativeImage getPixels() {
|
||||||
|
return dynamicTexture.getPixels();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void upload() {
|
||||||
|
dynamicTexture.upload();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return dynamicTexture.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void releaseId() {
|
||||||
|
dynamicTexture.releaseId();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void bind() {
|
||||||
|
dynamicTexture.bind();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void close() {
|
||||||
|
dynamicTexture.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package org.embeddedt.embeddium.compat.mc;
|
|
||||||
|
|
||||||
public interface IResourceLocation {
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
package org.embeddedt.embeddium.compat.mc;
|
|
||||||
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
public interface IResourceProvider {
|
|
||||||
Optional<IResource> getResource(IResourceLocation location);
|
|
||||||
}
|
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package org.embeddedt.embeddium.compat.mc;
|
package org.embeddedt.embeddium.compat.mc;
|
||||||
|
|
||||||
public interface ICamera {
|
public interface MCCamera {
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package org.embeddedt.embeddium.compat.mc;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
|
||||||
|
public interface MCDumpable {
|
||||||
|
void dumpContents(MCResourceLocation resourceLocation, Path path) throws IOException;
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package org.embeddedt.embeddium.compat.mc;
|
||||||
|
|
||||||
|
public interface MCDynamicTexture extends MCAbstractTexture {
|
||||||
|
MCNativeImage getPixels();
|
||||||
|
void upload();
|
||||||
|
}
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package org.embeddedt.embeddium.compat.mc;
|
package org.embeddedt.embeddium.compat.mc;
|
||||||
|
|
||||||
public interface ILevelRenderer {
|
public interface MCLevelRenderer {
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,14 @@
|
|||||||
package org.embeddedt.embeddium.compat.mc;
|
package org.embeddedt.embeddium.compat.mc;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
public interface MCNativeImage {
|
public interface MCNativeImage {
|
||||||
int getWidth();
|
int getWidth();
|
||||||
int getHeight();
|
int getHeight();
|
||||||
void setPixelRGBA(int x, int y, int color);
|
void setPixelRGBA(int x, int y, int color);
|
||||||
int getPixelRGBA(int x, int y);
|
int getPixelRGBA(int x, int y);
|
||||||
long getPointer();
|
// long getPointer();
|
||||||
|
|
||||||
|
void upload(int level, int xOffset, int yOffset, int unpackSkipPixels, int unpackSkipRows, int width, int height, boolean blur, boolean clamp, boolean mipmap, boolean autoClose);
|
||||||
}
|
}
|
||||||
+1
-1
@@ -3,6 +3,6 @@ package org.embeddedt.embeddium.compat.mc;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
public interface IResource {
|
public interface MCResource {
|
||||||
InputStream open() throws IOException;
|
InputStream open() throws IOException;
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package org.embeddedt.embeddium.compat.mc;
|
||||||
|
|
||||||
|
public interface MCResourceLocation {
|
||||||
|
String getPath();
|
||||||
|
String getNamespace();
|
||||||
|
String toDebugFileName();
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package org.embeddedt.embeddium.compat.mc;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
public interface MCResourceManager {
|
||||||
|
Optional<MCResource> getResource(MCResourceLocation location);
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package org.embeddedt.embeddium.compat.mc;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
public interface MCResourceProvider {
|
||||||
|
Optional<MCResource> getResource(MCResourceLocation location);
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package org.embeddedt.embeddium.compat.mc;
|
||||||
|
|
||||||
|
public interface MCShaderInstance {
|
||||||
|
String getName();
|
||||||
|
void clear();
|
||||||
|
void close();
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package org.embeddedt.embeddium.compat.mc;
|
||||||
|
|
||||||
|
public interface MCTextureManager {
|
||||||
|
|
||||||
|
MCAbstractTexture getTexture(MCResourceLocation path);
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package org.embeddedt.embeddium.compat.mc;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
|
public interface MCVertexFormat {
|
||||||
|
ImmutableList<String> getElementAttributeNames();
|
||||||
|
}
|
||||||
+32
-3
@@ -1,10 +1,14 @@
|
|||||||
package org.embeddedt.embeddium.compat.mc;
|
package org.embeddedt.embeddium.compat.mc;
|
||||||
|
|
||||||
|
import net.irisshaders.iris.shaderpack.ShaderPack;
|
||||||
import org.joml.Matrix4f;
|
import org.joml.Matrix4f;
|
||||||
import org.joml.Vector2i;
|
import org.joml.Vector2i;
|
||||||
import org.joml.Vector3d;
|
import org.joml.Vector3d;
|
||||||
import org.joml.Vector4f;
|
import org.joml.Vector4f;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.nio.ByteBuffer;
|
||||||
import java.util.ServiceLoader;
|
import java.util.ServiceLoader;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -97,10 +101,13 @@ public interface MinecraftVersionShimService {
|
|||||||
Vector2i getTextureSize();
|
Vector2i getTextureSize();
|
||||||
|
|
||||||
MCNativeImage createNativeImage(int width, int height, boolean useCalloc);
|
MCNativeImage createNativeImage(int width, int height, boolean useCalloc);
|
||||||
|
MCNativeImage readNativeImage(InputStream textureStream) throws IOException;
|
||||||
|
MCNativeImage readNativeImage(ByteBuffer textureData) throws IOException;
|
||||||
MCNativeImage[] createNativeImageArray(int size);
|
MCNativeImage[] createNativeImageArray(int size);
|
||||||
|
|
||||||
IResourceLocation makeResourceLocation(String namespace, String path);
|
|
||||||
IResourceLocation makeResourceLocation(String str);
|
MCResourceLocation makeResourceLocation(String namespace, String path);
|
||||||
|
MCResourceLocation makeResourceLocation(String str);
|
||||||
|
|
||||||
String getOsString();
|
String getOsString();
|
||||||
|
|
||||||
@@ -115,5 +122,27 @@ public interface MinecraftVersionShimService {
|
|||||||
Matrix4f getShadowModelView(float sunPathRotation, float intervalSize);
|
Matrix4f getShadowModelView(float sunPathRotation, float intervalSize);
|
||||||
Matrix4f getShadowProjection(float shadowDistance, float nearPlane, float farPlane);
|
Matrix4f getShadowProjection(float shadowDistance, float nearPlane, float farPlane);
|
||||||
|
|
||||||
void bindFramebuffer();
|
void bindMainFramebuffer();
|
||||||
|
void unbindMainFramebuffer();
|
||||||
|
int getMainFramebufferWidth();
|
||||||
|
int getMainFramebufferHeight();
|
||||||
|
|
||||||
|
|
||||||
|
int getColorTextureId();
|
||||||
|
int getColorBufferVersion();
|
||||||
|
int getLightTextureId();
|
||||||
|
int getMissingTextureId();
|
||||||
|
|
||||||
|
|
||||||
|
MCDynamicTexture createDynamicTexture(MCNativeImage image);
|
||||||
|
|
||||||
|
MCTextureManager getTextureManager();
|
||||||
|
|
||||||
|
MCResourceManager getResourceManager();
|
||||||
|
|
||||||
|
void populateBlockIds(ShaderPack pack);
|
||||||
|
|
||||||
|
default boolean isSkyTypeNormal() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -5,14 +5,14 @@ import lombok.Getter;
|
|||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
import net.minecraft.util.MathHelper;
|
import net.minecraft.util.MathHelper;
|
||||||
import org.embeddedt.embeddium.compat.mc.ICamera;
|
import org.embeddedt.embeddium.compat.mc.MCCamera;
|
||||||
import org.joml.Matrix4f;
|
import org.joml.Matrix4f;
|
||||||
import org.joml.Vector3d;
|
import org.joml.Vector3d;
|
||||||
import org.joml.Vector4f;
|
import org.joml.Vector4f;
|
||||||
import org.taumc.celeritas.state.MatrixRenderingState;
|
import org.taumc.celeritas.state.MatrixRenderingState;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
public class Camera implements ICamera {
|
public class Camera implements MCCamera {
|
||||||
final Vector3d pos = new Vector3d();
|
final Vector3d pos = new Vector3d();
|
||||||
final BlockPos blockPos = new BlockPos();
|
final BlockPos blockPos = new BlockPos();
|
||||||
float pitch;
|
float pitch;
|
||||||
|
|||||||
+94
-8
@@ -4,31 +4,60 @@ import com.google.common.collect.ImmutableList;
|
|||||||
import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
|
import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
|
||||||
import net.irisshaders.iris.compat.dh.DHCompat;
|
import net.irisshaders.iris.compat.dh.DHCompat;
|
||||||
import net.irisshaders.iris.features.FeatureFlags;
|
import net.irisshaders.iris.features.FeatureFlags;
|
||||||
|
import net.irisshaders.iris.gl.blending.AlphaTest;
|
||||||
|
import net.irisshaders.iris.gl.state.FogMode;
|
||||||
import net.irisshaders.iris.gl.texture.TextureType;
|
import net.irisshaders.iris.gl.texture.TextureType;
|
||||||
import net.irisshaders.iris.helpers.OptionalBoolean;
|
import net.irisshaders.iris.helpers.OptionalBoolean;
|
||||||
import net.irisshaders.iris.helpers.Tri;
|
import net.irisshaders.iris.helpers.Tri;
|
||||||
|
import net.irisshaders.iris.pipeline.programs.ShaderKey;
|
||||||
|
import net.irisshaders.iris.pipeline.programs.ShaderMap;
|
||||||
|
import net.irisshaders.iris.shaderpack.loading.ProgramId;
|
||||||
import net.irisshaders.iris.shaderpack.programs.ProgramSet;
|
import net.irisshaders.iris.shaderpack.programs.ProgramSet;
|
||||||
|
import net.irisshaders.iris.shaderpack.programs.ProgramSource;
|
||||||
import net.irisshaders.iris.shaderpack.properties.CloudSetting;
|
import net.irisshaders.iris.shaderpack.properties.CloudSetting;
|
||||||
|
import net.irisshaders.iris.shaderpack.properties.PackDirectives;
|
||||||
import net.irisshaders.iris.shaderpack.properties.ParticleRenderingSettings;
|
import net.irisshaders.iris.shaderpack.properties.ParticleRenderingSettings;
|
||||||
import net.irisshaders.iris.shaderpack.texture.TextureStage;
|
import net.irisshaders.iris.shaderpack.texture.TextureStage;
|
||||||
|
import net.irisshaders.iris.shadows.CommonShadowRenderer;
|
||||||
import net.irisshaders.iris.shadows.ShadowCompositeRenderer;
|
import net.irisshaders.iris.shadows.ShadowCompositeRenderer;
|
||||||
import net.irisshaders.iris.shadows.ShadowRenderTargets;
|
import net.irisshaders.iris.shadows.ShadowRenderTargets;
|
||||||
import net.irisshaders.iris.shadows.ArchaicShadowRenderer;
|
import net.irisshaders.iris.shadows.ArchaicShadowRenderer;
|
||||||
import net.irisshaders.iris.targets.ClearPassCreator;
|
import net.irisshaders.iris.targets.ClearPassCreator;
|
||||||
import net.irisshaders.iris.targets.RenderTargetStateListener;
|
import net.irisshaders.iris.targets.RenderTargetStateListener;
|
||||||
import net.irisshaders.iris.uniforms.FrameUpdateNotifier;
|
import net.irisshaders.iris.uniforms.FrameUpdateNotifier;
|
||||||
import org.embeddedt.embeddium.compat.mc.ICamera;
|
import net.irisshaders.iris.uniforms.custom.CustomUniforms;
|
||||||
import org.embeddedt.embeddium.compat.mc.ILevelRenderer;
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.shader.Framebuffer;
|
||||||
|
import org.embeddedt.embeddium.compat.mc.MCCamera;
|
||||||
|
import org.embeddedt.embeddium.compat.mc.MCLevelRenderer;
|
||||||
|
import org.embeddedt.embeddium.compat.mc.MCShaderInstance;
|
||||||
|
import org.embeddedt.embeddium.compat.mc.MCVertexFormat;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.taumc.celeritas.interfaces.IRenderTargetExt;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.OptionalInt;
|
import java.util.OptionalInt;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
public class ArchaicIrisRenderingPipeline extends CommonIrisRenderingPipeline implements IrisRenderingPipeline, WorldRenderingPipeline, /*ShaderRenderingPipeline,*/ RenderTargetStateListener {
|
public class ArchaicIrisRenderingPipeline extends CommonIrisRenderingPipeline implements IrisRenderingPipeline, WorldRenderingPipeline, ShaderRenderingPipeline, RenderTargetStateListener {
|
||||||
@Nullable private final ArchaicShadowRenderer shadowRenderer;
|
@Nullable private final ArchaicShadowRenderer shadowRenderer;
|
||||||
private final ShadowCompositeRenderer shadowCompositeRenderer;
|
private final ShadowCompositeRenderer shadowCompositeRenderer;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void updateMCFBInfo() {
|
||||||
|
final Framebuffer main = Minecraft.getMinecraft().getFramebuffer();
|
||||||
|
|
||||||
|
this.mainFBHeight = main.framebufferHeight;
|
||||||
|
this.mainFBWidth = main.framebufferWidth;
|
||||||
|
this.mainFBDepthTextureId = ((IRenderTargetExt)main).getIris$depthTextureId();
|
||||||
|
this.mainFBDepthBufferVersion = ((IRenderTargetExt)main).iris$getDepthBufferVersion();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public ArchaicIrisRenderingPipeline(ProgramSet programSet) {
|
public ArchaicIrisRenderingPipeline(ProgramSet programSet) {
|
||||||
super(programSet);
|
super(programSet);
|
||||||
|
|
||||||
@@ -36,7 +65,7 @@ public class ArchaicIrisRenderingPipeline extends CommonIrisRenderingPipeline im
|
|||||||
shadowRenderTargets = new ShadowRenderTargets(this, shadowMapResolution, shadowDirectives);
|
shadowRenderTargets = new ShadowRenderTargets(this, shadowMapResolution, shadowDirectives);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shadowRenderTargets != null) {
|
if (hasShadowRenderTargets()) {
|
||||||
// ShaderInstance shader = shaderMap.getShader(ShaderKey.SHADOW_TERRAIN_CUTOUT);
|
// ShaderInstance shader = shaderMap.getShader(ShaderKey.SHADOW_TERRAIN_CUTOUT);
|
||||||
boolean shadowUsesImages = false;
|
boolean shadowUsesImages = false;
|
||||||
|
|
||||||
@@ -69,13 +98,14 @@ public class ArchaicIrisRenderingPipeline extends CommonIrisRenderingPipeline im
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void beginLevelRendering() {
|
protected boolean checkShadowUsesImages() {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderShadows(ILevelRenderer worldRenderer, ICamera camera) {
|
protected void renderHorizon() {
|
||||||
|
// TODO
|
||||||
|
throw new UnsupportedOperationException("renderHorizon");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -129,6 +159,35 @@ public class ArchaicIrisRenderingPipeline extends CommonIrisRenderingPipeline im
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected CompletableFuture<MCShaderInstance> createShader(String name, Executor syncExecutor, ProgramSource source, ProgramId programId,
|
||||||
|
AlphaTest fallbackAlpha, MCVertexFormat vertexFormat, FogMode fogMode, boolean isIntensity, boolean isFullbright, boolean isGlint, boolean isText)
|
||||||
|
throws IOException {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected MCShaderInstance createFallbackShader(String name, ShaderKey key) throws IOException {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected CompletableFuture<MCShaderInstance> createShadowShader(String name, Optional<ProgramSource> source, ShaderKey key, Executor syncExecutor)
|
||||||
|
throws IOException {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected MCShaderInstance createFallbackShadowShader(String name, ShaderKey key) throws IOException {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected CompletableFuture<MCShaderInstance> createShadowShader(String name, Executor syncExecutor, ProgramSource source, ProgramId programId,
|
||||||
|
AlphaTest fallbackAlpha, MCVertexFormat vertexFormat, boolean isIntensity, boolean isFullbright, boolean isText) throws IOException {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSetShaderTexture(int id) {
|
public void onSetShaderTexture(int id) {
|
||||||
|
|
||||||
@@ -159,16 +218,43 @@ public class ArchaicIrisRenderingPipeline extends CommonIrisRenderingPipeline im
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void destroyHorizonRenderer() {
|
||||||
|
throw new UnsupportedOperationException("destroyHorizonRenderer");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected @Nullable CommonShadowRenderer createShadowRenderer(CommonIrisRenderingPipeline commonIrisRenderingPipeline, ProgramSource programSource,
|
||||||
|
PackDirectives packDirectives, ShadowRenderTargets shadowRenderTargets, ShadowCompositeRenderer shadowCompositeRenderer,
|
||||||
|
CustomUniforms customUniforms, boolean b) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ShaderKey[] getShaderKeyValues() {
|
||||||
|
return new ShaderKey[0];
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SodiumTerrainPipeline getSodiumTerrainPipeline() {
|
public SodiumTerrainPipeline getSodiumTerrainPipeline() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ShaderMap getShaderMap() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FrameUpdateNotifier getFrameUpdateNotifier() {
|
public FrameUpdateNotifier getFrameUpdateNotifier() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean shouldOverrideShaders() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldDisableVanillaEntityShadows() {
|
public boolean shouldDisableVanillaEntityShadows() {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
package net.irisshaders.iris.pipeline;
|
|
||||||
|
|
||||||
public abstract class CustomTextureManager extends CommonCustomTextureManager {
|
|
||||||
}
|
|
||||||
@@ -4,6 +4,8 @@ import net.irisshaders.iris.shaderpack.programs.ProgramSource;
|
|||||||
import net.irisshaders.iris.shaderpack.properties.PackDirectives;
|
import net.irisshaders.iris.shaderpack.properties.PackDirectives;
|
||||||
import net.irisshaders.iris.shadows.frustum.ArchaicFrustumHolder;
|
import net.irisshaders.iris.shadows.frustum.ArchaicFrustumHolder;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
import org.embeddedt.embeddium.compat.mc.MCCamera;
|
||||||
|
import org.embeddedt.embeddium.compat.mc.MCLevelRenderer;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -21,6 +23,11 @@ public class ArchaicShadowRenderer extends CommonShadowRenderer {
|
|||||||
this.entityFrustumHolder = new ArchaicFrustumHolder();
|
this.entityFrustumHolder = new ArchaicFrustumHolder();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void destroy() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getEntitiesDebugString() {
|
protected String getEntitiesDebugString() {
|
||||||
return (shouldRenderEntities || shouldRenderPlayer) ? (renderedShadowEntities + "/" + Minecraft.getMinecraft().theWorld.loadedEntityList.size()) : "disabled by pack";
|
return (shouldRenderEntities || shouldRenderPlayer) ? (renderedShadowEntities + "/" + Minecraft.getMinecraft().theWorld.loadedEntityList.size()) : "disabled by pack";
|
||||||
@@ -35,4 +42,9 @@ public class ArchaicShadowRenderer extends CommonShadowRenderer {
|
|||||||
protected void addBuffersDebugText(List<String> messages) {
|
protected void addBuffersDebugText(List<String> messages) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void renderShadows(MCLevelRenderer levelRendererIn, MCCamera playerCamera) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package net.irisshaders.iris.shadows;
|
|
||||||
|
|
||||||
public class ShadowCompositeRenderer extends CommonShadowCompositeRenderer {
|
|
||||||
}
|
|
||||||
+36
@@ -0,0 +1,36 @@
|
|||||||
|
package org.embeddedt.embeddium.compat.mc;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.nio.ByteBuffer;
|
||||||
|
|
||||||
|
|
||||||
|
public class ByteBufferBackedInputStream extends InputStream {
|
||||||
|
|
||||||
|
ByteBuffer buf;
|
||||||
|
|
||||||
|
public ByteBufferBackedInputStream(ByteBuffer buf) {
|
||||||
|
this.buf = buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int read() throws IOException {
|
||||||
|
if (!buf.hasRemaining()) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return buf.get() & 0xFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int read(byte @NotNull [] bytes, int off, int len) throws IOException {
|
||||||
|
if (!buf.hasRemaining()) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
len = Math.min(len, buf.remaining());
|
||||||
|
buf.get(bytes, off, len);
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,133 @@
|
|||||||
|
package org.embeddedt.embeddium.compat.mc;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.lwjgl.opengl.GL11;
|
||||||
|
import org.lwjgl.opengl.GL12;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.nio.ByteBuffer;
|
||||||
|
import java.nio.IntBuffer;
|
||||||
|
|
||||||
|
import static org.lwjgl.system.MemoryUtil.memAllocInt;
|
||||||
|
import static org.lwjgl.system.MemoryUtil.memFree;
|
||||||
|
|
||||||
|
public class NativeImage extends BufferedImage implements MCNativeImage {
|
||||||
|
private static final Logger LOGGER = LoggerFactory.getLogger("NativeImage");
|
||||||
|
|
||||||
|
@Getter private final Format format;
|
||||||
|
@Getter private final int width;
|
||||||
|
@Getter private final int height;
|
||||||
|
@Getter private final int size;
|
||||||
|
|
||||||
|
public NativeImage(int width, int height, boolean useStb) {
|
||||||
|
this(Format.RGBA, width, height, useStb);
|
||||||
|
}
|
||||||
|
|
||||||
|
public NativeImage(Format format, int width, int height, boolean useStb) {
|
||||||
|
super(width, height, BufferedImage.TYPE_INT_ARGB);
|
||||||
|
this.format = format;
|
||||||
|
this.width = width;
|
||||||
|
this.height = height;
|
||||||
|
this.size = width * height * format.components;
|
||||||
|
}
|
||||||
|
public NativeImage(Format format, int width, int height, BufferedImage image) {
|
||||||
|
super(image.getColorModel(), image.getRaster(), image.isAlphaPremultiplied(), null);
|
||||||
|
this.format = format;
|
||||||
|
this.width = width;
|
||||||
|
this.height = height;
|
||||||
|
this.size = width * height * format.components;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static NativeImage read(ByteBuffer buf) throws IOException {
|
||||||
|
return read(new ByteBufferBackedInputStream(buf));
|
||||||
|
}
|
||||||
|
public static NativeImage read(InputStream inputStream) throws IOException {
|
||||||
|
BufferedImage image = ImageIO.read(inputStream);
|
||||||
|
return new NativeImage(Format.RGBA, image.getWidth(), image.getHeight(), image);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void downloadTexture(int level, boolean bl) {
|
||||||
|
// this.checkAllocated();
|
||||||
|
GL11.glPixelStorei(GL11.GL_PACK_ALIGNMENT, format.components);
|
||||||
|
// GlStateManager._getTexImage(3553, level, format.glFormat, GL11.GL_UNSIGNED_BYTE, this.pixels);
|
||||||
|
|
||||||
|
// final int width = GL11.glGetTexLevelParameteri(GL11.GL_TEXTURE_2D, level, GL11.GL_TEXTURE_WIDTH);
|
||||||
|
// final int height = GL11.glGetTexLevelParameteri(GL11.GL_TEXTURE_2D, level, GL11.GL_TEXTURE_HEIGHT);
|
||||||
|
|
||||||
|
final IntBuffer buffer = memAllocInt(size);
|
||||||
|
|
||||||
|
try {
|
||||||
|
GL11.glGetTexImage(GL11.GL_TEXTURE_2D, level, format.glFormat, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, buffer);
|
||||||
|
|
||||||
|
int[] data = new int[size];
|
||||||
|
buffer.get(data);
|
||||||
|
setRGB(0, 0, width, height, data, 0, width);
|
||||||
|
} finally {
|
||||||
|
memFree(buffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void writeToFile(File file) throws IOException{
|
||||||
|
try {
|
||||||
|
ImageIO.write(this, "png", file);
|
||||||
|
} catch(IOException ioexception) {
|
||||||
|
LOGGER.info("[TextureDump] Unable to write: ", ioexception);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static int combine(int i, int j, int k, int l) {
|
||||||
|
return (i & 255) << 24 | (j & 255) << 16 | (k & 255) << 8 | (l & 255);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getA(int i) {
|
||||||
|
return i >> 24 & 255;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getR(int i) {
|
||||||
|
return i >> 0 & 255;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getG(int i) {
|
||||||
|
return i >> 8 & 255;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getB(int i) {
|
||||||
|
return i >> 16 & 255;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPixelRGBA(int x, int y) {
|
||||||
|
return getRGB(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void upload(int level, int xOffset, int yOffset, int unpackSkipPixels, int unpackSkipRows, int width, int height, boolean blur, boolean clamp, boolean mipmap, boolean autoClose) {
|
||||||
|
// TODO Implement this method if needed
|
||||||
|
throw new UnsupportedOperationException("Upload method not implemented for NativeImage");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPixelRGBA(int x, int y, int rgb) {
|
||||||
|
setRGB(x, y, rgb);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public enum Format {
|
||||||
|
RGBA(4, GL11.GL_RGBA),
|
||||||
|
RGB(3, GL11.GL_RGB);
|
||||||
|
|
||||||
|
private final int components;
|
||||||
|
private final int glFormat;
|
||||||
|
|
||||||
|
Format(int components, int glFormat) {
|
||||||
|
this.components = components;
|
||||||
|
this.glFormat = glFormat;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+90
-7
@@ -2,10 +2,14 @@ package org.embeddedt.embeddium.impl;
|
|||||||
|
|
||||||
import cpw.mods.fml.common.Loader;
|
import cpw.mods.fml.common.Loader;
|
||||||
import net.irisshaders.iris.IrisCommon;
|
import net.irisshaders.iris.IrisCommon;
|
||||||
|
import net.irisshaders.iris.shaderpack.ShaderPack;
|
||||||
import net.irisshaders.iris.uniforms.CapturedRenderingState;
|
import net.irisshaders.iris.uniforms.CapturedRenderingState;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.multiplayer.WorldClient;
|
import net.minecraft.client.multiplayer.WorldClient;
|
||||||
|
import net.minecraft.client.renderer.texture.DynamicTexture;
|
||||||
|
import net.minecraft.client.renderer.texture.TextureUtil;
|
||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.client.resources.I18n;
|
||||||
|
import net.minecraft.client.shader.Framebuffer;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.EntityLiving;
|
import net.minecraft.entity.EntityLiving;
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
@@ -17,15 +21,25 @@ import net.minecraft.util.ResourceLocation;
|
|||||||
import net.minecraft.util.Vec3;
|
import net.minecraft.util.Vec3;
|
||||||
import net.minecraft.world.WorldProviderEnd;
|
import net.minecraft.world.WorldProviderEnd;
|
||||||
import net.minecraft.world.WorldProviderHell;
|
import net.minecraft.world.WorldProviderHell;
|
||||||
import org.embeddedt.embeddium.compat.mc.IResourceLocation;
|
import org.embeddedt.embeddium.compat.mc.MCDynamicTexture;
|
||||||
import org.embeddedt.embeddium.compat.mc.MCNativeImage;
|
import org.embeddedt.embeddium.compat.mc.MCNativeImage;
|
||||||
|
import org.embeddedt.embeddium.compat.mc.MCResourceLocation;
|
||||||
|
import org.embeddedt.embeddium.compat.mc.MCResourceManager;
|
||||||
|
import org.embeddedt.embeddium.compat.mc.MCTextureManager;
|
||||||
import org.embeddedt.embeddium.compat.mc.MinecraftVersionShimService;
|
import org.embeddedt.embeddium.compat.mc.MinecraftVersionShimService;
|
||||||
|
import org.embeddedt.embeddium.compat.mc.NativeImage;
|
||||||
import org.embeddedt.embeddium.compat.mc.PlatformUtilService;
|
import org.embeddedt.embeddium.compat.mc.PlatformUtilService;
|
||||||
import org.joml.*;
|
|
||||||
import org.joml.Math;
|
import org.joml.Math;
|
||||||
|
import org.joml.Matrix4f;
|
||||||
|
import org.joml.Vector2i;
|
||||||
|
import org.joml.Vector3d;
|
||||||
|
import org.joml.Vector4f;
|
||||||
import org.lwjgl.system.Platform;
|
import org.lwjgl.system.Platform;
|
||||||
|
import org.taumc.celeritas.interfaces.IRenderTargetExt;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
|
||||||
public class MinecraftArchaicVersionShimImpl implements MinecraftVersionShimService, PlatformUtilService {
|
public class MinecraftArchaicVersionShimImpl implements MinecraftVersionShimService, PlatformUtilService {
|
||||||
@@ -433,13 +447,13 @@ public class MinecraftArchaicVersionShimImpl implements MinecraftVersionShimServ
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IResourceLocation makeResourceLocation(String namespace, String path) {
|
public MCResourceLocation makeResourceLocation(String namespace, String path) {
|
||||||
return (IResourceLocation)(Object) new ResourceLocation(namespace, path);
|
return (MCResourceLocation)(Object) new ResourceLocation(namespace, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IResourceLocation makeResourceLocation(String str) {
|
public MCResourceLocation makeResourceLocation(String str) {
|
||||||
return (IResourceLocation)(Object)new ResourceLocation(str);
|
return (MCResourceLocation)(Object)new ResourceLocation(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -483,10 +497,79 @@ public class MinecraftArchaicVersionShimImpl implements MinecraftVersionShimServ
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void bindFramebuffer() {
|
public void bindMainFramebuffer() {
|
||||||
Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(true);
|
Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void unbindMainFramebuffer() {
|
||||||
|
Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMainFramebufferWidth() {
|
||||||
|
return Minecraft.getMinecraft().getFramebuffer().framebufferWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMainFramebufferHeight() {
|
||||||
|
return Minecraft.getMinecraft().getFramebuffer().framebufferHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getColorTextureId() {
|
||||||
|
final Framebuffer main = Minecraft.getMinecraft().getFramebuffer();
|
||||||
|
return main.framebufferTexture;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getColorBufferVersion() {
|
||||||
|
final Framebuffer main = Minecraft.getMinecraft().getFramebuffer();
|
||||||
|
return ((IRenderTargetExt)main).iris$getColorBufferVersion();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getLightTextureId() {
|
||||||
|
// TODO
|
||||||
|
throw new UnsupportedOperationException("getLightTextureId is not implemented in MinecraftArchaicVersionShimImpl");
|
||||||
|
// return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMissingTextureId() {
|
||||||
|
return TextureUtil.missingTexture.getGlTextureId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MCNativeImage readNativeImage(InputStream textureStream) throws IOException {
|
||||||
|
return (MCNativeImage) NativeImage.read(textureStream);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MCNativeImage readNativeImage(ByteBuffer textureData) throws IOException {
|
||||||
|
return (MCNativeImage) NativeImage.read(textureData);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MCDynamicTexture createDynamicTexture(MCNativeImage image) {
|
||||||
|
return (MCDynamicTexture) new DynamicTexture((NativeImage) image);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MCTextureManager getTextureManager() {
|
||||||
|
return (MCTextureManager) Minecraft.getMinecraft().getTextureManager();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MCResourceManager getResourceManager() {
|
||||||
|
return (MCResourceManager) Minecraft.getMinecraft().getResourceManager();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void populateBlockIds(ShaderPack pack) {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isLoadValid() {
|
public boolean isLoadValid() {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
+2
-2
@@ -20,7 +20,7 @@ import net.minecraft.client.renderer.RenderGlobal;
|
|||||||
import net.minecraft.client.renderer.Tessellator;
|
import net.minecraft.client.renderer.Tessellator;
|
||||||
import net.minecraft.client.settings.GameSettings;
|
import net.minecraft.client.settings.GameSettings;
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
import org.embeddedt.embeddium.compat.mc.ILevelRenderer;
|
import org.embeddedt.embeddium.compat.mc.MCLevelRenderer;
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
import org.lwjgl.opengl.GL43C;
|
import org.lwjgl.opengl.GL43C;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
@@ -35,7 +35,7 @@ import org.taumc.celeritas.api.v0.CeleritasShadersApi;
|
|||||||
import org.taumc.celeritas.compat.Camera;
|
import org.taumc.celeritas.compat.Camera;
|
||||||
|
|
||||||
@Mixin(EntityRenderer.class)
|
@Mixin(EntityRenderer.class)
|
||||||
public class MixinEntityRenderer_Shaders implements ILevelRenderer {
|
public class MixinEntityRenderer_Shaders implements MCLevelRenderer {
|
||||||
@Shadow public Minecraft mc;
|
@Shadow public Minecraft mc;
|
||||||
|
|
||||||
@Unique
|
@Unique
|
||||||
|
|||||||
+10
@@ -0,0 +1,10 @@
|
|||||||
|
package org.taumc.celeritas.mixin.shaders;
|
||||||
|
|
||||||
|
import net.minecraft.client.resources.IResourceManager;
|
||||||
|
import org.embeddedt.embeddium.compat.mc.MCResourceManager;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
|
||||||
|
@Mixin(IResourceManager.class)
|
||||||
|
public interface MixinIResourceManager_Shaders extends MCResourceManager {
|
||||||
|
// Interface injection
|
||||||
|
}
|
||||||
+24
@@ -0,0 +1,24 @@
|
|||||||
|
package org.taumc.celeritas.mixin.shaders;
|
||||||
|
|
||||||
|
import net.minecraft.client.renderer.texture.ITextureObject;
|
||||||
|
import net.minecraft.client.renderer.texture.TextureManager;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import org.embeddedt.embeddium.compat.mc.MCAbstractTexture;
|
||||||
|
import org.embeddedt.embeddium.compat.mc.MCResourceLocation;
|
||||||
|
import org.embeddedt.embeddium.compat.mc.MCTextureManager;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
|
||||||
|
@Mixin(TextureManager.class)
|
||||||
|
public class MixinTextureManager_Shaders implements MCTextureManager {
|
||||||
|
@Shadow
|
||||||
|
public ITextureObject getTexture(ResourceLocation path) {
|
||||||
|
throw new IllegalStateException("Mixin shadow method should not be called");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MCAbstractTexture getTexture(MCResourceLocation path) {
|
||||||
|
return (MCAbstractTexture) getTexture((ResourceLocation) path);
|
||||||
|
}
|
||||||
|
// Interface Injection
|
||||||
|
}
|
||||||
@@ -45,6 +45,16 @@ project.ext["loom.platform"] = configuredModLoader.friendlyName
|
|||||||
project.ext["cur_mc_ver"] = ModLoader.getMinecraftVersion(project)
|
project.ext["cur_mc_ver"] = ModLoader.getMinecraftVersion(project)
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
|
// Fix issue with lwjgl-freetype not being found on macOS / ForgeGradle issue
|
||||||
|
//
|
||||||
|
// Could not resolve all files for configuration ':_compileJava_1'.
|
||||||
|
// Could not find lwjgl-freetype-3.3.3-natives-macos-patch.jar (org.lwjgl:lwjgl-freetype:3.3.3).
|
||||||
|
maven {
|
||||||
|
url "https://libraries.minecraft.net"
|
||||||
|
content {
|
||||||
|
includeModule("org.lwjgl", "lwjgl-freetype")
|
||||||
|
}
|
||||||
|
}
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
// for Mod Menu
|
// for Mod Menu
|
||||||
maven {
|
maven {
|
||||||
|
|||||||
+4
-3
@@ -3,11 +3,12 @@ package net.irisshaders.iris.compat.sodium.mixin.clouds;
|
|||||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||||
import com.mojang.blaze3d.vertex.VertexBuffer;
|
import com.mojang.blaze3d.vertex.VertexBuffer;
|
||||||
|
import net.minecraft.client.renderer.ShaderInstance;
|
||||||
import org.embeddedt.embeddium.impl.render.immediate.CloudRenderer;
|
import org.embeddedt.embeddium.impl.render.immediate.CloudRenderer;
|
||||||
import net.irisshaders.iris.Iris;
|
import net.irisshaders.iris.Iris;
|
||||||
import net.irisshaders.iris.pipeline.ShaderRenderingPipeline;
|
import net.irisshaders.iris.pipeline.ShaderRenderingPipeline;
|
||||||
import net.irisshaders.iris.pipeline.WorldRenderingPipeline;
|
import net.irisshaders.iris.pipeline.WorldRenderingPipeline;
|
||||||
import net.irisshaders.iris.pipeline.programs.ShaderKey;
|
import net.irisshaders.iris.pipeline.programs.ModernShaderKey;
|
||||||
import org.embeddedt.embeddium.impl.render.immediate.CloudShader;
|
import org.embeddedt.embeddium.impl.render.immediate.CloudShader;
|
||||||
import org.joml.Matrix4f;
|
import org.joml.Matrix4f;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
@@ -29,9 +30,9 @@ public abstract class MixinCloudRenderer {
|
|||||||
WorldRenderingPipeline pipeline = Iris.getPipelineManager().getPipelineNullable();
|
WorldRenderingPipeline pipeline = Iris.getPipelineManager().getPipelineNullable();
|
||||||
|
|
||||||
if (pipeline instanceof ShaderRenderingPipeline) {
|
if (pipeline instanceof ShaderRenderingPipeline) {
|
||||||
var irisShader = ((ShaderRenderingPipeline) pipeline).getShaderMap().getShader(ShaderKey.CLOUDS_SODIUM);
|
var irisShader = ((ShaderRenderingPipeline) pipeline).getShaderMap().getShader(ModernShaderKey.CLOUDS_SODIUM);
|
||||||
|
|
||||||
this.vertexBuffer.drawWithShader(modelViewMatrix, projectionMatrix, irisShader);
|
this.vertexBuffer.drawWithShader(modelViewMatrix, projectionMatrix, (ShaderInstance) irisShader);
|
||||||
} else {
|
} else {
|
||||||
original.call(instance, modelViewMatrix, projectionMatrix, r, g, b, a);
|
original.call(instance, modelViewMatrix, projectionMatrix, r, g, b, a);
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
package net.irisshaders.iris.gl.state;
|
package net.irisshaders.iris.gl.state;
|
||||||
|
|
||||||
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
|
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
|
||||||
import com.mojang.blaze3d.vertex.VertexFormat;
|
import org.embeddedt.embeddium.compat.mc.MCVertexFormat;
|
||||||
|
|
||||||
public class ShaderAttributeInputsBuilder {
|
public class ShaderAttributeInputsBuilder {
|
||||||
private boolean color;
|
private boolean color;
|
||||||
@@ -13,7 +13,7 @@ public class ShaderAttributeInputsBuilder {
|
|||||||
private boolean glint;
|
private boolean glint;
|
||||||
private boolean text;
|
private boolean text;
|
||||||
|
|
||||||
public ShaderAttributeInputsBuilder(VertexFormat format, boolean isFullbright, boolean isLines, boolean glint, boolean text) {
|
public ShaderAttributeInputsBuilder(MCVertexFormat format, boolean isFullbright, boolean isLines, boolean glint, boolean text) {
|
||||||
if (format == DefaultVertexFormat.POSITION_COLOR_NORMAL && !isLines) {
|
if (format == DefaultVertexFormat.POSITION_COLOR_NORMAL && !isLines) {
|
||||||
newLines = true;
|
newLines = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package net.irisshaders.iris.mixin;
|
package net.irisshaders.iris.mixin;
|
||||||
|
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import it.unimi.dsi.fastutil.objects.ObjectList;
|
|
||||||
import net.minecraft.client.Camera;
|
import net.minecraft.client.Camera;
|
||||||
import net.minecraft.client.multiplayer.ClientLevel;
|
import net.minecraft.client.multiplayer.ClientLevel;
|
||||||
import net.minecraft.client.renderer.LevelRenderer;
|
import net.minecraft.client.renderer.LevelRenderer;
|
||||||
@@ -11,14 +10,14 @@ import net.minecraft.client.renderer.RenderType;
|
|||||||
import net.minecraft.client.renderer.culling.Frustum;
|
import net.minecraft.client.renderer.culling.Frustum;
|
||||||
import net.minecraft.client.renderer.entity.EntityRenderDispatcher;
|
import net.minecraft.client.renderer.entity.EntityRenderDispatcher;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import org.embeddedt.embeddium.compat.mc.ILevelRenderer;
|
import org.embeddedt.embeddium.compat.mc.MCLevelRenderer;
|
||||||
import org.joml.Matrix4f;
|
import org.joml.Matrix4f;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||||
|
|
||||||
@Mixin(LevelRenderer.class)
|
@Mixin(LevelRenderer.class)
|
||||||
public interface LevelRendererAccessor extends ILevelRenderer {
|
public interface LevelRendererAccessor extends MCLevelRenderer {
|
||||||
@Accessor("entityRenderDispatcher")
|
@Accessor("entityRenderDispatcher")
|
||||||
EntityRenderDispatcher getEntityRenderDispatcher();
|
EntityRenderDispatcher getEntityRenderDispatcher();
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package net.irisshaders.iris.mixin;
|
package net.irisshaders.iris.mixin;
|
||||||
|
|
||||||
import net.minecraft.client.Camera;
|
import net.minecraft.client.Camera;
|
||||||
import org.embeddedt.embeddium.compat.mc.ICamera;
|
import org.embeddedt.embeddium.compat.mc.MCCamera;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
|
||||||
@Mixin(Camera.class)
|
@Mixin(Camera.class)
|
||||||
public class MixinCamera implements ICamera {
|
public class MixinCamera implements MCCamera {
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package net.irisshaders.iris.mixin;
|
||||||
|
|
||||||
|
import net.minecraft.client.renderer.texture.Dumpable;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
import org.embeddedt.embeddium.compat.mc.MCDumpable;
|
||||||
|
import org.embeddedt.embeddium.compat.mc.MCResourceLocation;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
|
||||||
|
@Mixin(Dumpable.class)
|
||||||
|
public interface MixinDumpable extends MCDumpable {
|
||||||
|
@Shadow
|
||||||
|
void dumpContents(ResourceLocation resourceLocation, Path path) throws IOException;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
default void dumpContents(MCResourceLocation resourceLocation, Path path) throws IOException {
|
||||||
|
this.dumpContents((ResourceLocation) (Object)resourceLocation, path);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package net.irisshaders.iris.mixin;
|
||||||
|
|
||||||
|
import net.minecraft.client.renderer.texture.DynamicTexture;
|
||||||
|
import org.embeddedt.embeddium.compat.mc.MCDynamicTexture;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
|
||||||
|
@Mixin(DynamicTexture.class)
|
||||||
|
public abstract class MixinDynamicTexture implements MCDynamicTexture {
|
||||||
|
// Interface Injection
|
||||||
|
}
|
||||||
@@ -24,6 +24,7 @@ import net.minecraft.client.renderer.RenderBuffers;
|
|||||||
//? if <1.21.2
|
//? if <1.21.2
|
||||||
import net.minecraft.client.renderer.ShaderInstance;
|
import net.minecraft.client.renderer.ShaderInstance;
|
||||||
import net.minecraft.server.packs.resources.ResourceManager;
|
import net.minecraft.server.packs.resources.ResourceManager;
|
||||||
|
import org.embeddedt.embeddium.compat.mc.MCShaderInstance;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
@@ -43,7 +44,7 @@ public class MixinGameRenderer {
|
|||||||
|
|
||||||
//? if <1.21.2 {
|
//? if <1.21.2 {
|
||||||
@Inject(method = { "*()Lnet/minecraft/client/renderer/ShaderInstance;" }, at = @At("RETURN"), cancellable = true)
|
@Inject(method = { "*()Lnet/minecraft/client/renderer/ShaderInstance;" }, at = @At("RETURN"), cancellable = true)
|
||||||
private static void iris$overrideShader(CallbackInfoReturnable<ShaderInstance> cir) {
|
private static void iris$overrideShader(CallbackInfoReturnable<MCShaderInstance> cir) {
|
||||||
var shader = cir.getReturnValue();
|
var shader = cir.getReturnValue();
|
||||||
if (shader == null) {
|
if (shader == null) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -16,14 +16,12 @@ import net.irisshaders.iris.pipeline.WorldRenderingPipeline;
|
|||||||
import net.irisshaders.iris.shadows.frustum.fallback.NonCullingFrustum;
|
import net.irisshaders.iris.shadows.frustum.fallback.NonCullingFrustum;
|
||||||
import net.irisshaders.iris.uniforms.CapturedRenderingState;
|
import net.irisshaders.iris.uniforms.CapturedRenderingState;
|
||||||
import net.irisshaders.iris.uniforms.IrisTimeUniforms;
|
import net.irisshaders.iris.uniforms.IrisTimeUniforms;
|
||||||
import net.irisshaders.iris.uniforms.SystemTimeUniforms;
|
|
||||||
import net.minecraft.ChatFormatting;
|
|
||||||
import net.minecraft.client.Camera;
|
import net.minecraft.client.Camera;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.multiplayer.ClientLevel;
|
import net.minecraft.client.multiplayer.ClientLevel;
|
||||||
import net.minecraft.client.renderer.*;
|
import net.minecraft.client.renderer.*;
|
||||||
import net.minecraft.client.renderer.culling.Frustum;
|
import net.minecraft.client.renderer.culling.Frustum;
|
||||||
import org.embeddedt.embeddium.compat.mc.ICamera;
|
import org.embeddedt.embeddium.compat.mc.MCCamera;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.joml.Matrix4f;
|
import org.joml.Matrix4f;
|
||||||
import org.lwjgl.opengl.GL43C;
|
import org.lwjgl.opengl.GL43C;
|
||||||
@@ -175,7 +173,7 @@ public class MixinLevelRenderer {
|
|||||||
// Do this before sky rendering so it's ready before the sky render starts.
|
// Do this before sky rendering so it's ready before the sky render starts.
|
||||||
@Inject(method = "renderLevel", at = @At(value = "INVOKE_STRING", target = "Lnet/minecraft/util/profiling/ProfilerFiller;popPush(Ljava/lang/String;)V", args = "ldc=sky"))
|
@Inject(method = "renderLevel", at = @At(value = "INVOKE_STRING", target = "Lnet/minecraft/util/profiling/ProfilerFiller;popPush(Ljava/lang/String;)V", args = "ldc=sky"))
|
||||||
private void iris$renderTerrainShadows(CallbackInfo ci, @Local(ordinal = 0, argsOnly = true) Camera camera) {
|
private void iris$renderTerrainShadows(CallbackInfo ci, @Local(ordinal = 0, argsOnly = true) Camera camera) {
|
||||||
pipeline.renderShadows((LevelRendererAccessor) this, (ICamera) camera);
|
pipeline.renderShadows((LevelRendererAccessor) this, (MCCamera) camera);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ModifyVariable(method = "renderSky", at = @At(value = "HEAD"), index = 5, argsOnly = true)
|
@ModifyVariable(method = "renderSky", at = @At(value = "HEAD"), index = 5, argsOnly = true)
|
||||||
|
|||||||
@@ -6,4 +6,5 @@ import org.spongepowered.asm.mixin.Mixin;
|
|||||||
|
|
||||||
@Mixin(NativeImage.class)
|
@Mixin(NativeImage.class)
|
||||||
public abstract class MixinNativeImage implements MCNativeImage {
|
public abstract class MixinNativeImage implements MCNativeImage {
|
||||||
|
// Interface injection
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
package net.irisshaders.iris.mixin;
|
package net.irisshaders.iris.mixin;
|
||||||
|
|
||||||
import net.minecraft.server.packs.resources.Resource;
|
import net.minecraft.server.packs.resources.Resource;
|
||||||
import org.embeddedt.embeddium.compat.mc.IResource;
|
import org.embeddedt.embeddium.compat.mc.MCResource;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
|
||||||
@Mixin(Resource.class)
|
@Mixin(Resource.class)
|
||||||
public abstract class MixinResource implements IResource {
|
public abstract class MixinResource implements MCResource {
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
package net.irisshaders.iris.mixin;
|
package net.irisshaders.iris.mixin;
|
||||||
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import org.embeddedt.embeddium.compat.mc.IResourceLocation;
|
import org.embeddedt.embeddium.compat.mc.MCResourceLocation;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
|
||||||
@Mixin(ResourceLocation.class)
|
@Mixin(ResourceLocation.class)
|
||||||
public abstract class MixinResourceLocation implements IResourceLocation {
|
public abstract class MixinResourceLocation implements MCResourceLocation {
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package net.irisshaders.iris.mixin;
|
||||||
|
|
||||||
|
import net.minecraft.server.packs.resources.ResourceManager;
|
||||||
|
import org.embeddedt.embeddium.compat.mc.MCResourceManager;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
|
||||||
|
@Mixin(ResourceManager.class)
|
||||||
|
public abstract interface MixinResourceManager extends MCResourceManager {
|
||||||
|
// Interface injection
|
||||||
|
}
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
package net.irisshaders.iris.mixin;
|
package net.irisshaders.iris.mixin;
|
||||||
|
|
||||||
import net.minecraft.server.packs.resources.ResourceProvider;
|
import net.minecraft.server.packs.resources.ResourceProvider;
|
||||||
import org.embeddedt.embeddium.compat.mc.IResourceProvider;
|
import org.embeddedt.embeddium.compat.mc.MCResourceProvider;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
|
||||||
@Mixin(ResourceProvider.class)
|
@Mixin(ResourceProvider.class)
|
||||||
public interface MixinResourceProvider extends IResourceProvider {
|
public interface MixinResourceProvider extends MCResourceProvider {
|
||||||
}
|
}
|
||||||
@@ -25,6 +25,7 @@ import net.minecraft.client.renderer.ShaderInstance;
|
|||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.server.packs.resources.ResourceProvider;
|
import net.minecraft.server.packs.resources.ResourceProvider;
|
||||||
import net.minecraft.util.GsonHelper;
|
import net.minecraft.util.GsonHelper;
|
||||||
|
import org.embeddedt.embeddium.compat.mc.MCShaderInstance;
|
||||||
import org.embeddedt.embeddium.impl.gl.debug.GLDebug;
|
import org.embeddedt.embeddium.impl.gl.debug.GLDebug;
|
||||||
import org.lwjgl.opengl.KHRDebug;
|
import org.lwjgl.opengl.KHRDebug;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@@ -49,7 +50,7 @@ import static net.irisshaders.iris.IrisLogging.IRIS_LOGGER;
|
|||||||
@Mixin(ShaderInstance.class)
|
@Mixin(ShaderInstance.class)
|
||||||
//? if >=1.21.2
|
//? if >=1.21.2
|
||||||
/*@Mixin(CompiledShaderProgram.class)*/
|
/*@Mixin(CompiledShaderProgram.class)*/
|
||||||
public abstract class MixinShaderInstance implements ShaderInstanceInterface {
|
public abstract class MixinShaderInstance implements ShaderInstanceInterface, MCShaderInstance {
|
||||||
@Unique
|
@Unique
|
||||||
private static final ImmutableSet<String> ATTRIBUTE_LIST = ImmutableSet.of("Position", "Color", "Normal", "UV0", "UV1", "UV2");
|
private static final ImmutableSet<String> ATTRIBUTE_LIST = ImmutableSet.of("Position", "Color", "Normal", "UV0", "UV1", "UV2");
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package net.irisshaders.iris.mixin;
|
||||||
|
|
||||||
|
import net.minecraft.client.renderer.texture.TextureManager;
|
||||||
|
import org.embeddedt.embeddium.compat.mc.MCTextureManager;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
|
||||||
|
@Mixin(TextureManager.class)
|
||||||
|
public abstract class MixinTextureManager implements MCTextureManager {
|
||||||
|
// Interface Injection
|
||||||
|
}
|
||||||
+2
-1
@@ -12,6 +12,7 @@ import net.minecraft.client.particle.Particle;
|
|||||||
import net.minecraft.client.particle.ParticleEngine;
|
import net.minecraft.client.particle.ParticleEngine;
|
||||||
import net.minecraft.client.particle.ParticleRenderType;
|
import net.minecraft.client.particle.ParticleRenderType;
|
||||||
import net.minecraft.client.renderer.ShaderInstance;
|
import net.minecraft.client.renderer.ShaderInstance;
|
||||||
|
import org.embeddedt.embeddium.compat.mc.MCShaderInstance;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Unique;
|
import org.spongepowered.asm.mixin.Unique;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
@@ -63,7 +64,7 @@ public class MixinParticleEngine implements PhasedParticleEngine {
|
|||||||
|
|
||||||
@Redirect(method = InjectionPoints.PARTICLE_ENGINE_RENDER, at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;setShader(Ljava/util/function/Supplier;)V"))
|
@Redirect(method = InjectionPoints.PARTICLE_ENGINE_RENDER, at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;setShader(Ljava/util/function/Supplier;)V"))
|
||||||
private void iris$changeParticleShader(Supplier<ShaderInstance> pSupplier0) {
|
private void iris$changeParticleShader(Supplier<ShaderInstance> pSupplier0) {
|
||||||
RenderSystem.setShader(phase == ParticleRenderingPhase.TRANSLUCENT ? ShaderAccess::getParticleTranslucentShader : pSupplier0);
|
RenderSystem.setShader(phase == ParticleRenderingPhase.TRANSLUCENT ? () -> (ShaderInstance) ShaderAccess.getParticleTranslucentShader() : pSupplier0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ModifyExpressionValue(method = InjectionPoints.PARTICLE_ENGINE_RENDER, at = @At(value = "INVOKE", target = /*? if <1.21 {*/ "Ljava/lang/Iterable;iterator()Ljava/util/Iterator;" /*?} else {*/ /*"Ljava/util/Queue;iterator()Ljava/util/Iterator;" *//*?}*/))
|
@ModifyExpressionValue(method = InjectionPoints.PARTICLE_ENGINE_RENDER, at = @At(value = "INVOKE", target = /*? if <1.21 {*/ "Ljava/lang/Iterable;iterator()Ljava/util/Iterator;" /*?} else {*/ /*"Ljava/util/Queue;iterator()Ljava/util/Iterator;" *//*?}*/))
|
||||||
|
|||||||
+2
-2
@@ -4,7 +4,7 @@ import net.irisshaders.iris.texture.format.TextureFormatLoader;
|
|||||||
import net.irisshaders.iris.texture.pbr.PBRTextureManager;
|
import net.irisshaders.iris.texture.pbr.PBRTextureManager;
|
||||||
import net.minecraft.client.renderer.texture.TextureManager;
|
import net.minecraft.client.renderer.texture.TextureManager;
|
||||||
import net.minecraft.server.packs.resources.ResourceManager;
|
import net.minecraft.server.packs.resources.ResourceManager;
|
||||||
import org.embeddedt.embeddium.compat.mc.IResourceProvider;
|
import org.embeddedt.embeddium.compat.mc.MCResourceProvider;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
@@ -18,7 +18,7 @@ import java.util.concurrent.Executor;
|
|||||||
public class MixinTextureManager {
|
public class MixinTextureManager {
|
||||||
@Inject(method = { "method_18167", "m_244739_", "lambda$reload$5" }, at = @At("TAIL"))
|
@Inject(method = { "method_18167", "m_244739_", "lambda$reload$5" }, at = @At("TAIL"))
|
||||||
private void iris$onTailReloadLambda(ResourceManager resourceManager, Executor applyExecutor, CompletableFuture<?> future, Void void1, CallbackInfo ci) {
|
private void iris$onTailReloadLambda(ResourceManager resourceManager, Executor applyExecutor, CompletableFuture<?> future, Void void1, CallbackInfo ci) {
|
||||||
TextureFormatLoader.reload((IResourceProvider) resourceManager);
|
TextureFormatLoader.reload((MCResourceProvider) resourceManager);
|
||||||
PBRTextureManager.INSTANCE.clear();
|
PBRTextureManager.INSTANCE.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -5,6 +5,7 @@ import com.mojang.blaze3d.vertex.VertexFormat;
|
|||||||
import net.irisshaders.iris.shaderpack.materialmap.WorldRenderingSettings;
|
import net.irisshaders.iris.shaderpack.materialmap.WorldRenderingSettings;
|
||||||
import net.irisshaders.iris.vertices.ImmediateState;
|
import net.irisshaders.iris.vertices.ImmediateState;
|
||||||
import net.irisshaders.iris.vertices.IrisVertexFormats;
|
import net.irisshaders.iris.vertices.IrisVertexFormats;
|
||||||
|
import org.embeddedt.embeddium.compat.mc.MCVertexFormat;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
@@ -14,7 +15,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|||||||
* Ensures that the correct state for the extended vertex format is set up when needed.
|
* Ensures that the correct state for the extended vertex format is set up when needed.
|
||||||
*/
|
*/
|
||||||
@Mixin(VertexFormat.class)
|
@Mixin(VertexFormat.class)
|
||||||
public class MixinVertexFormat {
|
public abstract class MixinVertexFormat implements MCVertexFormat {
|
||||||
@Inject(method = "setupBufferState", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "setupBufferState", at = @At("HEAD"), cancellable = true)
|
||||||
private void iris$onSetupBufferState(CallbackInfo ci) {
|
private void iris$onSetupBufferState(CallbackInfo ci) {
|
||||||
if (WorldRenderingSettings.INSTANCE.shouldUseExtendedVertexFormat() && ImmediateState.renderWithExtendedVertexFormat) {
|
if (WorldRenderingSettings.INSTANCE.shouldUseExtendedVertexFormat() && ImmediateState.renderWithExtendedVertexFormat) {
|
||||||
|
|||||||
@@ -1,217 +0,0 @@
|
|||||||
package net.irisshaders.iris.pipeline;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.EnumMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
import static com.mitchej123.glsm.GLStateManagerService.GL_STATE_MANAGER;
|
|
||||||
import static net.irisshaders.iris.IrisLogging.IRIS_LOGGER;
|
|
||||||
|
|
||||||
import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
|
|
||||||
import it.unimi.dsi.fastutil.objects.Object2ObjectMaps;
|
|
||||||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
|
||||||
import net.irisshaders.iris.Iris;
|
|
||||||
import net.irisshaders.iris.gl.texture.GlTexture;
|
|
||||||
import net.irisshaders.iris.gl.texture.TextureAccess;
|
|
||||||
import net.irisshaders.iris.gl.texture.TextureType;
|
|
||||||
import net.irisshaders.iris.gl.texture.TextureWrapper;
|
|
||||||
import net.irisshaders.iris.mixin.GlStateManagerAccessor;
|
|
||||||
import net.irisshaders.iris.mixin.LightTextureAccessor;
|
|
||||||
import net.irisshaders.iris.shaderpack.properties.PackDirectives;
|
|
||||||
import net.irisshaders.iris.shaderpack.texture.CustomTextureData;
|
|
||||||
import net.irisshaders.iris.shaderpack.texture.TextureStage;
|
|
||||||
import net.irisshaders.iris.targets.backed.NativeImageBackedCustomTexture;
|
|
||||||
import net.irisshaders.iris.targets.backed.NativeImageBackedNoiseTexture;
|
|
||||||
import net.irisshaders.iris.texture.format.TextureFormat;
|
|
||||||
import net.irisshaders.iris.texture.format.TextureFormatLoader;
|
|
||||||
import net.irisshaders.iris.texture.pbr.PBRTextureHolder;
|
|
||||||
import net.irisshaders.iris.texture.pbr.PBRTextureManager;
|
|
||||||
import net.irisshaders.iris.texture.pbr.PBRType;
|
|
||||||
import net.minecraft.ResourceLocationException;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.renderer.texture.AbstractTexture;
|
|
||||||
import net.minecraft.client.renderer.texture.MissingTextureAtlasSprite;
|
|
||||||
import net.minecraft.client.renderer.texture.TextureManager;
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
import org.apache.commons.io.FilenameUtils;
|
|
||||||
import org.embeddedt.embeddium.compat.mc.MCAbstractTexture;
|
|
||||||
import org.embeddedt.embeddium.impl.util.ResourceLocationUtil;
|
|
||||||
|
|
||||||
public class CustomTextureManager extends CommonCustomTextureManager {
|
|
||||||
private final EnumMap<TextureStage, Object2ObjectMap<String, TextureAccess>> customTextureIdMap = new EnumMap<>(TextureStage.class);
|
|
||||||
private final Object2ObjectMap<String, TextureAccess> irisCustomTextures = new Object2ObjectOpenHashMap<>();
|
|
||||||
private final TextureAccess noise;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* List of all OpenGL texture objects owned by this CustomTextureManager that need to be deleted in order to avoid
|
|
||||||
* leaks.
|
|
||||||
* Make sure any textures added to this list call releaseId from the close method.
|
|
||||||
*/
|
|
||||||
private final List<AbstractTexture> ownedTextures = new ArrayList<>();
|
|
||||||
private final List<GlTexture> ownedRawTextures = new ArrayList<>();
|
|
||||||
|
|
||||||
public CustomTextureManager(PackDirectives packDirectives,
|
|
||||||
EnumMap<TextureStage, Object2ObjectMap<String, CustomTextureData>> customTextureDataMap,
|
|
||||||
Object2ObjectMap<String, CustomTextureData> irisCustomTextureDataMap, Optional<CustomTextureData> customNoiseTextureData) {
|
|
||||||
customTextureDataMap.forEach((textureStage, customTextureStageDataMap) -> {
|
|
||||||
Object2ObjectMap<String, TextureAccess> customTextureIds = new Object2ObjectOpenHashMap<>();
|
|
||||||
|
|
||||||
customTextureStageDataMap.forEach((samplerName, textureData) -> {
|
|
||||||
try {
|
|
||||||
customTextureIds.put(samplerName, createCustomTexture(textureData));
|
|
||||||
} catch (IOException | ResourceLocationException e) {
|
|
||||||
IRIS_LOGGER.error("Unable to parse the image data for the custom texture on stage "
|
|
||||||
+ textureStage + ", sampler " + samplerName, e);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
customTextureIdMap.put(textureStage, customTextureIds);
|
|
||||||
});
|
|
||||||
|
|
||||||
irisCustomTextureDataMap.forEach((name, texture) -> {
|
|
||||||
try {
|
|
||||||
irisCustomTextures.put(name, createCustomTexture(texture));
|
|
||||||
} catch (IOException e) {
|
|
||||||
IRIS_LOGGER.error("Unable to parse the image data for the custom texture on sampler " + name, e);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
noise = customNoiseTextureData.flatMap(textureData -> {
|
|
||||||
try {
|
|
||||||
return Optional.of(createCustomTexture(textureData));
|
|
||||||
} catch (IOException | ResourceLocationException e) {
|
|
||||||
IRIS_LOGGER.error("Unable to parse the image data for the custom noise texture", e);
|
|
||||||
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
}).orElseGet(() -> {
|
|
||||||
final int noiseTextureResolution = packDirectives.getNoiseTextureResolution();
|
|
||||||
|
|
||||||
NativeImageBackedNoiseTexture texture = new NativeImageBackedNoiseTexture(noiseTextureResolution);
|
|
||||||
ownedTextures.add(texture);
|
|
||||||
|
|
||||||
return texture;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private TextureAccess createCustomTexture(CustomTextureData textureData) throws IOException, ResourceLocationException {
|
|
||||||
if (textureData instanceof CustomTextureData.PngData) {
|
|
||||||
NativeImageBackedCustomTexture texture = new NativeImageBackedCustomTexture((CustomTextureData.PngData) textureData);
|
|
||||||
ownedTextures.add(texture);
|
|
||||||
|
|
||||||
return texture;
|
|
||||||
} else if (textureData instanceof CustomTextureData.LightmapMarker) {
|
|
||||||
// Special code path for the light texture. While shader packs hardcode the primary light texture, it's
|
|
||||||
// possible that a mod will create a different light texture, so this code path is robust to that.
|
|
||||||
return new TextureWrapper(((LightTextureAccessor) Minecraft.getInstance().gameRenderer.lightTexture())
|
|
||||||
.getLightTexture()::getId, TextureType.TEXTURE_2D);
|
|
||||||
} else if (textureData instanceof CustomTextureData.RawData1D rawData1D) {
|
|
||||||
GlTexture texture = new GlTexture(TextureType.TEXTURE_1D, rawData1D.getSizeX(), 0, 0, rawData1D.getInternalFormat().getGlFormat(), rawData1D.getPixelFormat().getGlFormat(), rawData1D.getPixelType().getGlFormat(), rawData1D.getContent(), rawData1D.getFilteringData());
|
|
||||||
ownedRawTextures.add(texture);
|
|
||||||
|
|
||||||
return texture;
|
|
||||||
} else if (textureData instanceof CustomTextureData.RawDataRect rawDataRect) {
|
|
||||||
GlTexture texture = new GlTexture(TextureType.TEXTURE_RECTANGLE, rawDataRect.getSizeX(), rawDataRect.getSizeY(), 0, rawDataRect.getInternalFormat().getGlFormat(), rawDataRect.getPixelFormat().getGlFormat(), rawDataRect.getPixelType().getGlFormat(), rawDataRect.getContent(), rawDataRect.getFilteringData());
|
|
||||||
ownedRawTextures.add(texture);
|
|
||||||
|
|
||||||
return texture;
|
|
||||||
} else if (textureData instanceof CustomTextureData.RawData2D rawData2D) {
|
|
||||||
GlTexture texture = new GlTexture(TextureType.TEXTURE_2D, rawData2D.getSizeX(), rawData2D.getSizeY(), 0, rawData2D.getInternalFormat().getGlFormat(), rawData2D.getPixelFormat().getGlFormat(), rawData2D.getPixelType().getGlFormat(), rawData2D.getContent(), rawData2D.getFilteringData());
|
|
||||||
ownedRawTextures.add(texture);
|
|
||||||
|
|
||||||
return texture;
|
|
||||||
} else if (textureData instanceof CustomTextureData.RawData3D rawData3D) {
|
|
||||||
GlTexture texture = new GlTexture(TextureType.TEXTURE_3D, rawData3D.getSizeX(), rawData3D.getSizeY(), rawData3D.getSizeZ(), rawData3D.getInternalFormat().getGlFormat(), rawData3D.getPixelFormat().getGlFormat(), rawData3D.getPixelType().getGlFormat(), rawData3D.getContent(), rawData3D.getFilteringData());
|
|
||||||
ownedRawTextures.add(texture);
|
|
||||||
|
|
||||||
return texture;
|
|
||||||
} else if (textureData instanceof CustomTextureData.ResourceData resourceData) {
|
|
||||||
String namespace = resourceData.getNamespace();
|
|
||||||
String location = resourceData.getLocation();
|
|
||||||
|
|
||||||
String withoutExtension;
|
|
||||||
int extensionIndex = FilenameUtils.indexOfExtension(location);
|
|
||||||
if (extensionIndex != -1) {
|
|
||||||
withoutExtension = location.substring(0, extensionIndex);
|
|
||||||
} else {
|
|
||||||
withoutExtension = location;
|
|
||||||
}
|
|
||||||
PBRType pbrType = PBRType.fromFileLocation(withoutExtension);
|
|
||||||
|
|
||||||
TextureManager textureManager = Minecraft.getInstance().getTextureManager();
|
|
||||||
|
|
||||||
if (pbrType == null) {
|
|
||||||
ResourceLocation textureLocation = ResourceLocationUtil.make(namespace, location);
|
|
||||||
|
|
||||||
// NB: We have to re-query the TextureManager for the texture object every time. This is because the
|
|
||||||
// AbstractTexture object could be removed / deleted from the TextureManager on resource reloads,
|
|
||||||
// and we could end up holding on to a deleted texture unless we added special code to handle resource
|
|
||||||
// reloads. Re-fetching the texture from the TextureManager every time is the most robust approach for
|
|
||||||
// now.
|
|
||||||
return new TextureWrapper(() -> {
|
|
||||||
AbstractTexture texture = textureManager.getTexture(textureLocation);
|
|
||||||
return texture != null ? texture.getId() : MissingTextureAtlasSprite.getTexture().getId();
|
|
||||||
}, TextureType.TEXTURE_2D);
|
|
||||||
} else {
|
|
||||||
location = location.substring(0, extensionIndex - pbrType.getSuffix().length()) + location.substring(extensionIndex);
|
|
||||||
ResourceLocation textureLocation = ResourceLocationUtil.make(namespace, location);
|
|
||||||
|
|
||||||
return new TextureWrapper(() -> {
|
|
||||||
AbstractTexture texture = textureManager.getTexture(textureLocation);
|
|
||||||
|
|
||||||
if (texture != null) {
|
|
||||||
int id = texture.getId();
|
|
||||||
PBRTextureHolder pbrHolder = PBRTextureManager.INSTANCE.getOrLoadHolder(id);
|
|
||||||
MCAbstractTexture pbrTexture = switch (pbrType) {
|
|
||||||
case NORMAL -> pbrHolder.normalTexture();
|
|
||||||
case SPECULAR -> pbrHolder.specularTexture();
|
|
||||||
default -> throw new IllegalArgumentException("Unknown PBRType '" + pbrType + "'");
|
|
||||||
};
|
|
||||||
|
|
||||||
TextureFormat textureFormat = TextureFormatLoader.getFormat();
|
|
||||||
if (textureFormat != null) {
|
|
||||||
int previousBinding = GlStateManagerAccessor.getTEXTURES()[GlStateManagerAccessor.getActiveTexture()].binding;
|
|
||||||
GL_STATE_MANAGER.bindTexture(pbrTexture.getId());
|
|
||||||
textureFormat.setupTextureParameters(pbrType, (MCAbstractTexture)pbrTexture);
|
|
||||||
GL_STATE_MANAGER.bindTexture(previousBinding);
|
|
||||||
}
|
|
||||||
|
|
||||||
return pbrTexture.getId();
|
|
||||||
}
|
|
||||||
|
|
||||||
return MissingTextureAtlasSprite.getTexture().getId();
|
|
||||||
}, TextureType.TEXTURE_2D);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
throw new IllegalArgumentException("Don't know texture type!");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public EnumMap<TextureStage, Object2ObjectMap<String, TextureAccess>> getCustomTextureIdMap() {
|
|
||||||
return customTextureIdMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object2ObjectMap<String, TextureAccess> getCustomTextureIdMap(TextureStage stage) {
|
|
||||||
return customTextureIdMap.getOrDefault(stage, Object2ObjectMaps.emptyMap());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object2ObjectMap<String, TextureAccess> getIrisCustomTextures() {
|
|
||||||
return irisCustomTextures;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TextureAccess getNoiseTexture() {
|
|
||||||
return noise;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void destroy() {
|
|
||||||
ownedTextures.forEach(AbstractTexture::close);
|
|
||||||
ownedRawTextures.forEach(GlTexture::destroy);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+61
-1089
File diff suppressed because it is too large.
Load diff
+5
-3
@@ -35,6 +35,8 @@ import net.minecraft.client.Minecraft;
|
|||||||
import net.minecraft.client.renderer.ShaderInstance;
|
import net.minecraft.client.renderer.ShaderInstance;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.server.packs.resources.ResourceProvider;
|
import net.minecraft.server.packs.resources.ResourceProvider;
|
||||||
|
import org.embeddedt.embeddium.compat.mc.MCShaderInstance;
|
||||||
|
import org.embeddedt.embeddium.compat.mc.MCVertexFormat;
|
||||||
import org.embeddedt.embeddium.impl.gl.debug.GLDebug;
|
import org.embeddedt.embeddium.impl.gl.debug.GLDebug;
|
||||||
import org.embeddedt.embeddium.impl.util.ResourceLocationUtil;
|
import org.embeddedt.embeddium.impl.util.ResourceLocationUtil;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
@@ -44,7 +46,7 @@ import org.lwjgl.opengl.ARBTextureSwizzle;
|
|||||||
import org.lwjgl.opengl.GL30C;
|
import org.lwjgl.opengl.GL30C;
|
||||||
import org.lwjgl.opengl.KHRDebug;
|
import org.lwjgl.opengl.KHRDebug;
|
||||||
|
|
||||||
public class ExtendedShader extends ShaderInstance implements ShaderInstanceInterface {
|
public class ExtendedShader extends ShaderInstance implements ShaderInstanceInterface, MCShaderInstance {
|
||||||
private static final Matrix4f identity;
|
private static final Matrix4f identity;
|
||||||
private static ExtendedShader lastApplied;
|
private static ExtendedShader lastApplied;
|
||||||
|
|
||||||
@@ -75,12 +77,12 @@ public class ExtendedShader extends ShaderInstance implements ShaderInstanceInte
|
|||||||
float[] tempFloats2 = new float[9];
|
float[] tempFloats2 = new float[9];
|
||||||
private Program geometry, tessControl, tessEval;
|
private Program geometry, tessControl, tessEval;
|
||||||
|
|
||||||
public ExtendedShader(ResourceProvider resourceFactory, String string, VertexFormat vertexFormat, boolean usesTessellation,
|
public ExtendedShader(ResourceProvider resourceFactory, String string, MCVertexFormat vertexFormat, boolean usesTessellation,
|
||||||
GlFramebuffer writingToBeforeTranslucent, GlFramebuffer writingToAfterTranslucent,
|
GlFramebuffer writingToBeforeTranslucent, GlFramebuffer writingToAfterTranslucent,
|
||||||
BlendModeOverride blendModeOverride, AlphaTest alphaTest,
|
BlendModeOverride blendModeOverride, AlphaTest alphaTest,
|
||||||
Consumer<DynamicLocationalUniformHolder> uniformCreator, BiConsumer<SamplerHolder, ImageHolder> samplerCreator, boolean isIntensity,
|
Consumer<DynamicLocationalUniformHolder> uniformCreator, BiConsumer<SamplerHolder, ImageHolder> samplerCreator, boolean isIntensity,
|
||||||
ModernIrisRenderingPipeline parent, @Nullable List<BufferBlendOverride> bufferBlendOverrides, CustomUniforms customUniforms) throws IOException {
|
ModernIrisRenderingPipeline parent, @Nullable List<BufferBlendOverride> bufferBlendOverrides, CustomUniforms customUniforms) throws IOException {
|
||||||
super(resourceFactory, string, vertexFormat);
|
super(resourceFactory, string, (VertexFormat) vertexFormat);
|
||||||
|
|
||||||
GLDebug.nameObject(KHRDebug.GL_SHADER, this.getVertexProgram().getId(), string + "_vertex.vsh");
|
GLDebug.nameObject(KHRDebug.GL_SHADER, this.getVertexProgram().getId(), string + "_vertex.vsh");
|
||||||
GLDebug.nameObject(KHRDebug.GL_SHADER, this.getFragmentProgram().getId(), string + "_fragment.fsh");
|
GLDebug.nameObject(KHRDebug.GL_SHADER, this.getFragmentProgram().getId(), string + "_fragment.fsh");
|
||||||
|
|||||||
+2
-1
@@ -18,9 +18,10 @@ import net.irisshaders.iris.uniforms.CapturedRenderingState;
|
|||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.ShaderInstance;
|
import net.minecraft.client.renderer.ShaderInstance;
|
||||||
import net.minecraft.server.packs.resources.ResourceProvider;
|
import net.minecraft.server.packs.resources.ResourceProvider;
|
||||||
|
import org.embeddedt.embeddium.compat.mc.MCShaderInstance;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
public class FallbackShader extends ShaderInstance {
|
public class FallbackShader extends ShaderInstance implements MCShaderInstance {
|
||||||
private final ModernIrisRenderingPipeline parent;
|
private final ModernIrisRenderingPipeline parent;
|
||||||
private final BlendModeOverride blendModeOverride;
|
private final BlendModeOverride blendModeOverride;
|
||||||
private final GlFramebuffer writingToBeforeTranslucent;
|
private final GlFramebuffer writingToBeforeTranslucent;
|
||||||
|
|||||||
+16
-4
@@ -7,10 +7,11 @@ import net.irisshaders.iris.gl.blending.AlphaTests;
|
|||||||
import net.irisshaders.iris.gl.state.FogMode;
|
import net.irisshaders.iris.gl.state.FogMode;
|
||||||
import net.irisshaders.iris.shaderpack.loading.ProgramId;
|
import net.irisshaders.iris.shaderpack.loading.ProgramId;
|
||||||
import net.irisshaders.iris.vertices.IrisVertexFormats;
|
import net.irisshaders.iris.vertices.IrisVertexFormats;
|
||||||
|
import org.embeddedt.embeddium.compat.mc.MCVertexFormat;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
public enum ShaderKey {
|
public enum ModernShaderKey implements ShaderKey {
|
||||||
// if you auto-format this and destroy all the manual indentation, I'll steal your kneecaps
|
// if you auto-format this and destroy all the manual indentation, I'll steal your kneecaps
|
||||||
|
|
||||||
BASIC(ProgramId.Basic, AlphaTests.OFF, DefaultVertexFormat.POSITION, FogMode.PER_VERTEX, LightingModel.LIGHTMAP),
|
BASIC(ProgramId.Basic, AlphaTests.OFF, DefaultVertexFormat.POSITION, FogMode.PER_VERTEX, LightingModel.LIGHTMAP),
|
||||||
@@ -86,7 +87,7 @@ public enum ShaderKey {
|
|||||||
private final FogMode fogMode;
|
private final FogMode fogMode;
|
||||||
private final LightingModel lightingModel;
|
private final LightingModel lightingModel;
|
||||||
|
|
||||||
ShaderKey(ProgramId program, AlphaTest alphaTest, VertexFormat vertexFormat, FogMode fogMode, LightingModel lightingModel) {
|
ModernShaderKey(ProgramId program, AlphaTest alphaTest, VertexFormat vertexFormat, FogMode fogMode, LightingModel lightingModel) {
|
||||||
this.program = program;
|
this.program = program;
|
||||||
this.alphaTest = alphaTest;
|
this.alphaTest = alphaTest;
|
||||||
this.vertexFormat = vertexFormat;
|
this.vertexFormat = vertexFormat;
|
||||||
@@ -94,46 +95,57 @@ public enum ShaderKey {
|
|||||||
this.lightingModel = lightingModel;
|
this.lightingModel = lightingModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ProgramId getProgram() {
|
public ProgramId getProgram() {
|
||||||
return program;
|
return program;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public AlphaTest getAlphaTest() {
|
public AlphaTest getAlphaTest() {
|
||||||
return alphaTest;
|
return alphaTest;
|
||||||
}
|
}
|
||||||
|
|
||||||
public VertexFormat getVertexFormat() {
|
@Override
|
||||||
return vertexFormat;
|
public MCVertexFormat getVertexFormat() {
|
||||||
|
return (MCVertexFormat) vertexFormat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public FogMode getFogMode() {
|
public FogMode getFogMode() {
|
||||||
return fogMode;
|
return fogMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isIntensity() {
|
public boolean isIntensity() {
|
||||||
return this == TEXT_INTENSITY || this == TEXT_INTENSITY_BE || this == SHADOW_TEXT_INTENSITY;
|
return this == TEXT_INTENSITY || this == TEXT_INTENSITY_BE || this == SHADOW_TEXT_INTENSITY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return toString().toLowerCase(Locale.ROOT);
|
return toString().toLowerCase(Locale.ROOT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isShadow() {
|
public boolean isShadow() {
|
||||||
return this.getProgram() == ProgramId.Shadow;
|
return this.getProgram() == ProgramId.Shadow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean hasDiffuseLighting() {
|
public boolean hasDiffuseLighting() {
|
||||||
return lightingModel == LightingModel.DIFFUSE || lightingModel == LightingModel.DIFFUSE_LM;
|
return lightingModel == LightingModel.DIFFUSE || lightingModel == LightingModel.DIFFUSE_LM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean shouldIgnoreLightmap() {
|
public boolean shouldIgnoreLightmap() {
|
||||||
return lightingModel == LightingModel.FULLBRIGHT || lightingModel == LightingModel.DIFFUSE;
|
return lightingModel == LightingModel.FULLBRIGHT || lightingModel == LightingModel.DIFFUSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isGlint() {
|
public boolean isGlint() {
|
||||||
return this == GLINT;
|
return this == GLINT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isText() {
|
public boolean isText() {
|
||||||
return this.name().contains("TEXT");
|
return this.name().contains("TEXT");
|
||||||
}
|
}
|
||||||
+4
-4
@@ -4,20 +4,20 @@ import net.irisshaders.iris.Iris;
|
|||||||
import net.irisshaders.iris.pipeline.ShaderRenderingPipeline;
|
import net.irisshaders.iris.pipeline.ShaderRenderingPipeline;
|
||||||
import net.irisshaders.iris.pipeline.WorldRenderingPipeline;
|
import net.irisshaders.iris.pipeline.WorldRenderingPipeline;
|
||||||
import net.minecraft.client.renderer.GameRenderer;
|
import net.minecraft.client.renderer.GameRenderer;
|
||||||
import net.minecraft.client.renderer.ShaderInstance;
|
import org.embeddedt.embeddium.compat.mc.MCShaderInstance;
|
||||||
|
|
||||||
public class ShaderAccess {
|
public class ShaderAccess {
|
||||||
public static ShaderInstance getParticleTranslucentShader() {
|
public static MCShaderInstance getParticleTranslucentShader() {
|
||||||
WorldRenderingPipeline pipeline = Iris.getPipelineManager().getPipelineNullable();
|
WorldRenderingPipeline pipeline = Iris.getPipelineManager().getPipelineNullable();
|
||||||
|
|
||||||
if (pipeline instanceof ShaderRenderingPipeline) {
|
if (pipeline instanceof ShaderRenderingPipeline) {
|
||||||
ShaderInstance override = ((ShaderRenderingPipeline) pipeline).getShaderMap().getShader(ShaderKey.PARTICLES_TRANS);
|
MCShaderInstance override = ((ShaderRenderingPipeline) pipeline).getShaderMap().getShader(ModernShaderKey.PARTICLES_TRANS);
|
||||||
|
|
||||||
if (override != null) {
|
if (override != null) {
|
||||||
return override;
|
return override;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return GameRenderer.getParticleShader();
|
return (MCShaderInstance) GameRenderer.getParticleShader();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+4
-3
@@ -36,6 +36,7 @@ import net.minecraft.server.packs.repository.PackSource;
|
|||||||
import net.minecraft.server.packs.resources.Resource;
|
import net.minecraft.server.packs.resources.Resource;
|
||||||
import net.minecraft.server.packs.resources.ResourceProvider;
|
import net.minecraft.server.packs.resources.ResourceProvider;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
|
import org.embeddedt.embeddium.compat.mc.MCVertexFormat;
|
||||||
import org.embeddedt.embeddium.impl.util.ComponentUtil;
|
import org.embeddedt.embeddium.impl.util.ComponentUtil;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
@@ -55,7 +56,7 @@ import static org.embeddedt.embeddium.compat.mc.PlatformUtilService.PLATFORM_UTI
|
|||||||
public class ShaderCreator {
|
public class ShaderCreator {
|
||||||
public static CompletableFuture<ExtendedShader> create(WorldRenderingPipeline pipeline, Executor syncExecutor, String name, ProgramSource source, ProgramId programId, GlFramebuffer writingToBeforeTranslucent,
|
public static CompletableFuture<ExtendedShader> create(WorldRenderingPipeline pipeline, Executor syncExecutor, String name, ProgramSource source, ProgramId programId, GlFramebuffer writingToBeforeTranslucent,
|
||||||
GlFramebuffer writingToAfterTranslucent, AlphaTest fallbackAlpha,
|
GlFramebuffer writingToAfterTranslucent, AlphaTest fallbackAlpha,
|
||||||
VertexFormat vertexFormat, ShaderAttributeInputs inputs, FrameUpdateNotifier updateNotifier,
|
MCVertexFormat vertexFormat, ShaderAttributeInputs inputs, FrameUpdateNotifier updateNotifier,
|
||||||
ModernIrisRenderingPipeline parent, Supplier<ImmutableSet<Integer>> flipped, FogMode fogMode, boolean isIntensity,
|
ModernIrisRenderingPipeline parent, Supplier<ImmutableSet<Integer>> flipped, FogMode fogMode, boolean isIntensity,
|
||||||
boolean isFullbright, boolean isShadowPass, boolean isLines, CustomUniforms customUniforms) throws IOException {
|
boolean isFullbright, boolean isShadowPass, boolean isLines, CustomUniforms customUniforms) throws IOException {
|
||||||
AlphaTest alpha = source.getDirectives().getAlphaTestOverride().orElse(fallbackAlpha);
|
AlphaTest alpha = source.getDirectives().getAlphaTestOverride().orElse(fallbackAlpha);
|
||||||
@@ -140,7 +141,7 @@ public class ShaderCreator {
|
|||||||
|
|
||||||
public static FallbackShader createFallback(String name, GlFramebuffer writingToBeforeTranslucent,
|
public static FallbackShader createFallback(String name, GlFramebuffer writingToBeforeTranslucent,
|
||||||
GlFramebuffer writingToAfterTranslucent, AlphaTest alpha,
|
GlFramebuffer writingToAfterTranslucent, AlphaTest alpha,
|
||||||
VertexFormat vertexFormat, BlendModeOverride blendModeOverride,
|
MCVertexFormat vertexFormat, BlendModeOverride blendModeOverride,
|
||||||
ModernIrisRenderingPipeline parent, FogMode fogMode, boolean entityLighting,
|
ModernIrisRenderingPipeline parent, FogMode fogMode, boolean entityLighting,
|
||||||
boolean isGlint, boolean isText, boolean intensityTex, boolean isFullbright) throws IOException {
|
boolean isGlint, boolean isText, boolean intensityTex, boolean isFullbright) throws IOException {
|
||||||
ShaderAttributeInputs inputs = new ShaderAttributeInputsBuilder(vertexFormat, isFullbright, false, isGlint, isText).build();
|
ShaderAttributeInputs inputs = new ShaderAttributeInputsBuilder(vertexFormat, isFullbright, false, isGlint, isText).build();
|
||||||
@@ -195,7 +196,7 @@ public class ShaderCreator {
|
|||||||
|
|
||||||
ResourceProvider shaderResourceFactory = new IrisProgramResourceFactory(shaderJsonString, vertex, null, null, null, fragment);
|
ResourceProvider shaderResourceFactory = new IrisProgramResourceFactory(shaderJsonString, vertex, null, null, null, fragment);
|
||||||
|
|
||||||
return new FallbackShader(shaderResourceFactory, name, vertexFormat, writingToBeforeTranslucent,
|
return new FallbackShader(shaderResourceFactory, name, (VertexFormat) vertexFormat, writingToBeforeTranslucent,
|
||||||
writingToAfterTranslucent, blendModeOverride, alpha.reference(), parent);
|
writingToAfterTranslucent, blendModeOverride, alpha.reference(), parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import net.irisshaders.iris.compat.dh.DHCompat;
|
|||||||
import net.irisshaders.iris.gl.IrisRenderSystem;
|
import net.irisshaders.iris.gl.IrisRenderSystem;
|
||||||
import net.irisshaders.iris.gui.option.IrisVideoSettings;
|
import net.irisshaders.iris.gui.option.IrisVideoSettings;
|
||||||
import net.irisshaders.iris.mixin.LevelRendererAccessor;
|
import net.irisshaders.iris.mixin.LevelRendererAccessor;
|
||||||
import net.irisshaders.iris.pipeline.ModernIrisRenderingPipeline;
|
import net.irisshaders.iris.pipeline.CommonIrisRenderingPipeline;
|
||||||
import net.irisshaders.iris.shaderpack.programs.ProgramSource;
|
import net.irisshaders.iris.shaderpack.programs.ProgramSource;
|
||||||
import net.irisshaders.iris.shaderpack.properties.PackDirectives;
|
import net.irisshaders.iris.shaderpack.properties.PackDirectives;
|
||||||
import net.irisshaders.iris.shaderpack.properties.PackShadowDirectives;
|
import net.irisshaders.iris.shaderpack.properties.PackShadowDirectives;
|
||||||
@@ -45,8 +45,8 @@ import net.minecraft.client.renderer.entity.EntityRenderDispatcher;
|
|||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import org.embeddedt.embeddium.compat.mc.ICamera;
|
import org.embeddedt.embeddium.compat.mc.MCCamera;
|
||||||
import org.embeddedt.embeddium.compat.mc.ILevelRenderer;
|
import org.embeddedt.embeddium.compat.mc.MCLevelRenderer;
|
||||||
import org.embeddedt.embeddium.impl.gl.debug.GLDebug;
|
import org.embeddedt.embeddium.impl.gl.debug.GLDebug;
|
||||||
import org.embeddedt.embeddium.impl.render.viewport.ViewportProvider;
|
import org.embeddedt.embeddium.impl.render.viewport.ViewportProvider;
|
||||||
import org.embeddedt.embeddium.impl.util.WorldUtil;
|
import org.embeddedt.embeddium.impl.util.WorldUtil;
|
||||||
@@ -60,11 +60,11 @@ public class ModernShadowRenderer extends CommonShadowRenderer {
|
|||||||
public static List<BlockEntity> visibleBlockEntities;
|
public static List<BlockEntity> visibleBlockEntities;
|
||||||
public static Frustum FRUSTUM;
|
public static Frustum FRUSTUM;
|
||||||
private final ShadowCompositeRenderer compositeRenderer;
|
private final ShadowCompositeRenderer compositeRenderer;
|
||||||
private final ModernIrisRenderingPipeline pipeline;
|
private final CommonIrisRenderingPipeline pipeline;
|
||||||
private final RenderBuffers buffers;
|
private final RenderBuffers buffers;
|
||||||
private final RenderBuffersExt renderBuffersExt;
|
private final RenderBuffersExt renderBuffersExt;
|
||||||
|
|
||||||
public ModernShadowRenderer(ModernIrisRenderingPipeline pipeline, ProgramSource shadow, PackDirectives directives,
|
public ModernShadowRenderer(CommonIrisRenderingPipeline pipeline, ProgramSource shadow, PackDirectives directives,
|
||||||
ShadowRenderTargets shadowRenderTargets, ShadowCompositeRenderer compositeRenderer, CustomUniforms customUniforms, boolean separateHardwareSamplers) {
|
ShadowRenderTargets shadowRenderTargets, ShadowCompositeRenderer compositeRenderer, CustomUniforms customUniforms, boolean separateHardwareSamplers) {
|
||||||
super(shadow, directives, shadowRenderTargets, separateHardwareSamplers);
|
super(shadow, directives, shadowRenderTargets, separateHardwareSamplers);
|
||||||
|
|
||||||
@@ -210,7 +210,7 @@ public class ModernShadowRenderer extends CommonShadowRenderer {
|
|||||||
RENDER_SYSTEM.glViewport(0, 0, resolution, resolution);
|
RENDER_SYSTEM.glViewport(0, 0, resolution, resolution);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void renderShadows(ILevelRenderer levelRendererIn, ICamera playerCamera) {
|
public void renderShadows(MCLevelRenderer levelRendererIn, MCCamera playerCamera) {
|
||||||
if (IrisVideoSettings.getOverriddenShadowDistance(IrisVideoSettings.shadowDistance) == 0) {
|
if (IrisVideoSettings.getOverriddenShadowDistance(IrisVideoSettings.shadowDistance) == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import net.minecraft.client.renderer.texture.TextureAtlas;
|
|||||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.server.packs.resources.ResourceManager;
|
import net.minecraft.server.packs.resources.ResourceManager;
|
||||||
|
import org.embeddedt.embeddium.compat.mc.MCResourceLocation;
|
||||||
import org.embeddedt.embeddium.impl.util.ResourceLocationUtil;
|
import org.embeddedt.embeddium.impl.util.ResourceLocationUtil;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
@@ -36,7 +37,7 @@ import static org.embeddedt.embeddium.compat.mc.MinecraftVersionShimService.MINE
|
|||||||
public class PBRAtlasTexture extends AbstractTexture implements PBRDumpable {
|
public class PBRAtlasTexture extends AbstractTexture implements PBRDumpable {
|
||||||
protected final TextureAtlas atlasTexture;
|
protected final TextureAtlas atlasTexture;
|
||||||
protected final PBRType type;
|
protected final PBRType type;
|
||||||
protected final ResourceLocation id;
|
protected final MCResourceLocation id;
|
||||||
protected final Map<ResourceLocation, PBRTextureAtlasSprite> texturesByName = new HashMap<>();
|
protected final Map<ResourceLocation, PBRTextureAtlasSprite> texturesByName = new HashMap<>();
|
||||||
protected final List<TextureAtlasSprite.Ticker> animatedTextures = new ArrayList<>();
|
protected final List<TextureAtlasSprite.Ticker> animatedTextures = new ArrayList<>();
|
||||||
protected int width;
|
protected int width;
|
||||||
@@ -46,7 +47,7 @@ public class PBRAtlasTexture extends AbstractTexture implements PBRDumpable {
|
|||||||
public PBRAtlasTexture(TextureAtlas atlasTexture, PBRType type) {
|
public PBRAtlasTexture(TextureAtlas atlasTexture, PBRType type) {
|
||||||
this.atlasTexture = atlasTexture;
|
this.atlasTexture = atlasTexture;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
id = ResourceLocationUtil.make(atlasTexture.location().getNamespace(), atlasTexture.location().getPath().replace(".png", "") + type.getSuffix() + ".png");
|
id = (MCResourceLocation)(Object)ResourceLocationUtil.make(atlasTexture.location().getNamespace(), atlasTexture.location().getPath().replace(".png", "") + type.getSuffix() + ".png");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void syncAnimation(SpriteContents.Ticker source, SpriteContents.Ticker target) {
|
public static void syncAnimation(SpriteContents.Ticker source, SpriteContents.Ticker target) {
|
||||||
@@ -99,7 +100,7 @@ public class PBRAtlasTexture extends AbstractTexture implements PBRDumpable {
|
|||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResourceLocation getAtlasId() {
|
public MCResourceLocation getAtlasId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -208,14 +209,14 @@ public class PBRAtlasTexture extends AbstractTexture implements PBRDumpable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dumpContents(ResourceLocation id, Path path) {
|
public void dumpContents(MCResourceLocation id, Path path) {
|
||||||
String fileName = id.toDebugFileName();
|
String fileName = id.toDebugFileName();
|
||||||
TextureUtil.writeAsPNG(path, fileName, getId(), mipLevel, width, height);
|
TextureUtil.writeAsPNG(path, fileName, getId(), mipLevel, width, height);
|
||||||
dumpSpriteNames(path, fileName, texturesByName);
|
dumpSpriteNames(path, fileName, texturesByName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResourceLocation getDefaultDumpLocation() {
|
public MCResourceLocation getDefaultDumpLocation() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
package net.irisshaders.iris.texture.pbr;
|
|
||||||
|
|
||||||
import net.minecraft.client.renderer.texture.Dumpable;
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
|
|
||||||
public interface PBRDumpable extends Dumpable {
|
|
||||||
ResourceLocation getDefaultDumpLocation();
|
|
||||||
}
|
|
||||||
+12
-9
@@ -25,6 +25,9 @@ import net.minecraft.server.packs.resources.ResourceManager;
|
|||||||
import net.minecraft.server.packs.resources.ResourceMetadata;
|
import net.minecraft.server.packs.resources.ResourceMetadata;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
import org.embeddedt.embeddium.compat.mc.MCAbstractTexture;
|
import org.embeddedt.embeddium.compat.mc.MCAbstractTexture;
|
||||||
|
import org.embeddedt.embeddium.compat.mc.MCResource;
|
||||||
|
import org.embeddedt.embeddium.compat.mc.MCResourceLocation;
|
||||||
|
import org.embeddedt.embeddium.compat.mc.MCResourceManager;
|
||||||
import org.embeddedt.embeddium.impl.util.ResourceLocationUtil;
|
import org.embeddedt.embeddium.impl.util.ResourceLocationUtil;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
@@ -44,7 +47,7 @@ public class AtlasPBRLoader implements PBRTextureLoader<TextureAtlas> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load(TextureAtlas atlas, ResourceManager resourceManager, PBRTextureConsumer pbrTextureConsumer) {
|
public void load(TextureAtlas atlas, MCResourceManager resourceManager, PBRTextureConsumer pbrTextureConsumer) {
|
||||||
TextureAtlasAccessor atlasAccessor = (TextureAtlasAccessor) atlas;
|
TextureAtlasAccessor atlasAccessor = (TextureAtlasAccessor) atlas;
|
||||||
int atlasWidth = atlasAccessor.callGetWidth();
|
int atlasWidth = atlasAccessor.callGetWidth();
|
||||||
int atlasHeight = atlasAccessor.callGetHeight();
|
int atlasHeight = atlasAccessor.callGetHeight();
|
||||||
@@ -86,15 +89,15 @@ public class AtlasPBRLoader implements PBRTextureLoader<TextureAtlas> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
protected PBRTextureAtlasSprite createPBRSprite(TextureAtlasSprite sprite, ResourceManager resourceManager, TextureAtlas atlas, int atlasWidth, int atlasHeight, int mipLevel, PBRType pbrType) {
|
protected PBRTextureAtlasSprite createPBRSprite(TextureAtlasSprite sprite, MCResourceManager resourceManager, TextureAtlas atlas, int atlasWidth, int atlasHeight, int mipLevel, PBRType pbrType) {
|
||||||
ResourceLocation spriteName = sprite.contents().name();
|
MCResourceLocation spriteName = (MCResourceLocation)(Object)sprite.contents().name();
|
||||||
ResourceLocation pbrImageLocation = getPBRImageLocation(spriteName, pbrType);
|
MCResourceLocation pbrImageLocation = getPBRImageLocation(spriteName, pbrType);
|
||||||
|
|
||||||
Optional<Resource> optionalResource = resourceManager.getResource(pbrImageLocation);
|
Optional<MCResource> optionalResource = resourceManager.getResource(pbrImageLocation);
|
||||||
if (optionalResource.isEmpty()) {
|
if (optionalResource.isEmpty()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
Resource resource = optionalResource.get();
|
Resource resource = (Resource) optionalResource.get();
|
||||||
|
|
||||||
ResourceMetadata animationMetadata;
|
ResourceMetadata animationMetadata;
|
||||||
try {
|
try {
|
||||||
@@ -168,13 +171,13 @@ public class AtlasPBRLoader implements PBRTextureLoader<TextureAtlas> {
|
|||||||
return new PBRTextureAtlasSprite(pbrSpriteName, pbrSpriteContents, atlasWidth, atlasHeight, sprite.getX(), sprite.getY(), sprite);
|
return new PBRTextureAtlasSprite(pbrSpriteName, pbrSpriteContents, atlasWidth, atlasHeight, sprite.getX(), sprite.getY(), sprite);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ResourceLocation getPBRImageLocation(ResourceLocation spriteName, PBRType pbrType) {
|
protected MCResourceLocation getPBRImageLocation(MCResourceLocation spriteName, PBRType pbrType) {
|
||||||
String path = pbrType.appendSuffix(spriteName.getPath());
|
String path = pbrType.appendSuffix(spriteName.getPath());
|
||||||
// Temporary fix for CIT Resewn. CIT Resewn has sprites that are not in the textures/ folder, so a custom check must be used here to avoid that assumption.
|
// Temporary fix for CIT Resewn. CIT Resewn has sprites that are not in the textures/ folder, so a custom check must be used here to avoid that assumption.
|
||||||
if (path.startsWith("optifine/cit/")) {
|
if (path.startsWith("optifine/cit/")) {
|
||||||
return ResourceLocationUtil.make(spriteName.getNamespace(), path + ".png");
|
return (MCResourceLocation)(Object) ResourceLocationUtil.make(spriteName.getNamespace(), path + ".png");
|
||||||
}
|
}
|
||||||
return ResourceLocationUtil.make(spriteName.getNamespace(), "textures/" + path + ".png");
|
return (MCResourceLocation)(Object) ResourceLocationUtil.make(spriteName.getNamespace(), "textures/" + path + ".png");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static class PBRSpriteContents extends SpriteContents implements CustomMipmapGenerator.Provider {
|
protected static class PBRSpriteContents extends SpriteContents implements CustomMipmapGenerator.Provider {
|
||||||
|
|||||||
+29
@@ -0,0 +1,29 @@
|
|||||||
|
package net.irisshaders.iris.texture.pbr.loader;
|
||||||
|
|
||||||
|
import net.minecraft.client.renderer.texture.SimpleTexture;
|
||||||
|
import net.minecraft.client.renderer.texture.TextureAtlas;
|
||||||
|
import org.embeddedt.embeddium.compat.mc.MCAbstractTexture;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class ModernPBRTextureLoaderRegistry implements PBRTextureLoaderRegistry {
|
||||||
|
public ModernPBRTextureLoaderRegistry() {
|
||||||
|
register(SimpleTexture.class, new SimplePBRLoader());
|
||||||
|
register(TextureAtlas.class, new AtlasPBRLoader());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private final Map<Class<?>, PBRTextureLoader<?>> loaderMap = new HashMap<>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T> void register(Class<? extends T> clazz, PBRTextureLoader<T> loader) {
|
||||||
|
loaderMap.put(clazz, loader);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @Nullable <T> PBRTextureLoader<T> getLoader(Class<? extends T> clazz) {
|
||||||
|
return (PBRTextureLoader<T>) loaderMap.get(clazz);
|
||||||
|
}
|
||||||
|
}
|
||||||
-30
@@ -1,30 +0,0 @@
|
|||||||
package net.irisshaders.iris.texture.pbr.loader;
|
|
||||||
|
|
||||||
import net.minecraft.client.renderer.texture.AbstractTexture;
|
|
||||||
import net.minecraft.client.renderer.texture.SimpleTexture;
|
|
||||||
import net.minecraft.client.renderer.texture.TextureAtlas;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class PBRTextureLoaderRegistry {
|
|
||||||
public static final PBRTextureLoaderRegistry INSTANCE = new PBRTextureLoaderRegistry();
|
|
||||||
|
|
||||||
static {
|
|
||||||
INSTANCE.register(SimpleTexture.class, new SimplePBRLoader());
|
|
||||||
INSTANCE.register(TextureAtlas.class, new AtlasPBRLoader());
|
|
||||||
}
|
|
||||||
|
|
||||||
private final Map<Class<?>, PBRTextureLoader<?>> loaderMap = new HashMap<>();
|
|
||||||
|
|
||||||
public <T extends AbstractTexture> void register(Class<? extends T> clazz, PBRTextureLoader<T> loader) {
|
|
||||||
loaderMap.put(clazz, loader);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Nullable
|
|
||||||
public <T extends AbstractTexture> PBRTextureLoader<T> getLoader(Class<? extends T> clazz) {
|
|
||||||
return (PBRTextureLoader<T>) loaderMap.get(clazz);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+5
-3
@@ -2,17 +2,19 @@ package net.irisshaders.iris.texture.pbr.loader;
|
|||||||
|
|
||||||
import net.irisshaders.iris.mixin.texture.SimpleTextureAccessor;
|
import net.irisshaders.iris.mixin.texture.SimpleTextureAccessor;
|
||||||
import net.irisshaders.iris.texture.pbr.PBRType;
|
import net.irisshaders.iris.texture.pbr.PBRType;
|
||||||
|
import net.minecraft.client.renderer.texture.AbstractTexture;
|
||||||
import net.minecraft.client.renderer.texture.SimpleTexture;
|
import net.minecraft.client.renderer.texture.SimpleTexture;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.server.packs.resources.ResourceManager;
|
import net.minecraft.server.packs.resources.ResourceManager;
|
||||||
import org.embeddedt.embeddium.compat.mc.MCAbstractTexture;
|
import org.embeddedt.embeddium.compat.mc.MCAbstractTexture;
|
||||||
|
import org.embeddedt.embeddium.compat.mc.MCResourceManager;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class SimplePBRLoader implements PBRTextureLoader<SimpleTexture> {
|
public class SimplePBRLoader implements PBRTextureLoader<SimpleTexture> {
|
||||||
@Override
|
@Override
|
||||||
public void load(SimpleTexture texture, ResourceManager resourceManager, PBRTextureConsumer pbrTextureConsumer) {
|
public void load(SimpleTexture texture, MCResourceManager resourceManager, PBRTextureConsumer pbrTextureConsumer) {
|
||||||
ResourceLocation location = ((SimpleTextureAccessor) texture).getLocation();
|
ResourceLocation location = ((SimpleTextureAccessor) texture).getLocation();
|
||||||
|
|
||||||
MCAbstractTexture normalTexture = createPBRTexture(location, resourceManager, PBRType.NORMAL);
|
MCAbstractTexture normalTexture = createPBRTexture(location, resourceManager, PBRType.NORMAL);
|
||||||
@@ -27,12 +29,12 @@ public class SimplePBRLoader implements PBRTextureLoader<SimpleTexture> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
protected MCAbstractTexture createPBRTexture(ResourceLocation imageLocation, ResourceManager resourceManager, PBRType pbrType) {
|
protected MCAbstractTexture createPBRTexture(ResourceLocation imageLocation, MCResourceManager resourceManager, PBRType pbrType) {
|
||||||
ResourceLocation pbrImageLocation = imageLocation.withPath(pbrType::appendSuffix);
|
ResourceLocation pbrImageLocation = imageLocation.withPath(pbrType::appendSuffix);
|
||||||
|
|
||||||
SimpleTexture pbrTexture = new SimpleTexture(pbrImageLocation);
|
SimpleTexture pbrTexture = new SimpleTexture(pbrImageLocation);
|
||||||
try {
|
try {
|
||||||
pbrTexture.load(resourceManager);
|
pbrTexture.load((ResourceManager) resourceManager);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
+92
-92
@@ -7,9 +7,9 @@ import net.irisshaders.iris.pathways.HandRenderer;
|
|||||||
import net.irisshaders.iris.pipeline.ShaderRenderingPipeline;
|
import net.irisshaders.iris.pipeline.ShaderRenderingPipeline;
|
||||||
import net.irisshaders.iris.pipeline.WorldRenderingPhase;
|
import net.irisshaders.iris.pipeline.WorldRenderingPhase;
|
||||||
import net.irisshaders.iris.pipeline.WorldRenderingPipeline;
|
import net.irisshaders.iris.pipeline.WorldRenderingPipeline;
|
||||||
import net.irisshaders.iris.pipeline.programs.ShaderKey;
|
import net.irisshaders.iris.pipeline.programs.ModernShaderKey;
|
||||||
import net.irisshaders.iris.shadows.ModernShadowRenderer;
|
import net.irisshaders.iris.shadows.ModernShadowRenderer;
|
||||||
import net.minecraft.client.renderer.ShaderInstance;
|
import org.embeddedt.embeddium.compat.mc.MCShaderInstance;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -19,10 +19,10 @@ import java.util.function.Supplier;
|
|||||||
import static net.irisshaders.iris.IrisLogging.IRIS_LOGGER;
|
import static net.irisshaders.iris.IrisLogging.IRIS_LOGGER;
|
||||||
|
|
||||||
public class ShaderOverrideEngine {
|
public class ShaderOverrideEngine {
|
||||||
private static final Map<String, Supplier<ShaderInstance>> iris$overrides = new Object2ObjectOpenHashMap<>();
|
private static final Map<String, Supplier<MCShaderInstance>> iris$overrides = new Object2ObjectOpenHashMap<>();
|
||||||
private static final Set<String> missingOverrides = new ObjectOpenHashSet<>();
|
private static final Set<String> missingOverrides = new ObjectOpenHashSet<>();
|
||||||
|
|
||||||
private static @Nullable ShaderInstance iris$findOverride(ShaderKey key) {
|
private static @Nullable MCShaderInstance iris$findOverride(ModernShaderKey key) {
|
||||||
WorldRenderingPipeline pipeline = Iris.getPipelineManager().getPipelineNullable();
|
WorldRenderingPipeline pipeline = Iris.getPipelineManager().getPipelineNullable();
|
||||||
|
|
||||||
if (pipeline instanceof ShaderRenderingPipeline) {
|
if (pipeline instanceof ShaderRenderingPipeline) {
|
||||||
@@ -32,7 +32,7 @@ public class ShaderOverrideEngine {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static @Nullable ShaderInstance getOverride(String name) {
|
public static @Nullable MCShaderInstance getOverride(String name) {
|
||||||
WorldRenderingPipeline pipeline = Iris.getPipelineManager().getPipelineNullable();
|
WorldRenderingPipeline pipeline = Iris.getPipelineManager().getPipelineNullable();
|
||||||
|
|
||||||
if (!(pipeline instanceof ShaderRenderingPipeline)) {
|
if (!(pipeline instanceof ShaderRenderingPipeline)) {
|
||||||
@@ -52,44 +52,44 @@ public class ShaderOverrideEngine {
|
|||||||
static {
|
static {
|
||||||
iris$overrides.put("position", () -> {
|
iris$overrides.put("position", () -> {
|
||||||
if (isSky()) {
|
if (isSky()) {
|
||||||
return iris$findOverride(ShaderKey.SKY_BASIC);
|
return iris$findOverride(ModernShaderKey.SKY_BASIC);
|
||||||
} else if (ModernShadowRenderer.ACTIVE) {
|
} else if (ModernShadowRenderer.ACTIVE) {
|
||||||
return iris$findOverride(ShaderKey.SHADOW_BASIC);
|
return iris$findOverride(ModernShaderKey.SHADOW_BASIC);
|
||||||
} else if (shouldOverrideShaders()) {
|
} else if (shouldOverrideShaders()) {
|
||||||
return iris$findOverride(ShaderKey.BASIC);
|
return iris$findOverride(ModernShaderKey.BASIC);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
iris$overrides.put("position_color", () -> {
|
iris$overrides.put("position_color", () -> {
|
||||||
if (isSky()) {
|
if (isSky()) {
|
||||||
return iris$findOverride(ShaderKey.SKY_BASIC_COLOR);
|
return iris$findOverride(ModernShaderKey.SKY_BASIC_COLOR);
|
||||||
} else if (ModernShadowRenderer.ACTIVE) {
|
} else if (ModernShadowRenderer.ACTIVE) {
|
||||||
return iris$findOverride(ShaderKey.SHADOW_BASIC_COLOR);
|
return iris$findOverride(ModernShaderKey.SHADOW_BASIC_COLOR);
|
||||||
} else if (shouldOverrideShaders()) {
|
} else if (shouldOverrideShaders()) {
|
||||||
return iris$findOverride(ShaderKey.BASIC_COLOR);
|
return iris$findOverride(ModernShaderKey.BASIC_COLOR);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
iris$overrides.put("position_tex", () -> {
|
iris$overrides.put("position_tex", () -> {
|
||||||
if (isSky()) {
|
if (isSky()) {
|
||||||
return iris$findOverride(ShaderKey.SKY_TEXTURED);
|
return iris$findOverride(ModernShaderKey.SKY_TEXTURED);
|
||||||
} else if (ModernShadowRenderer.ACTIVE) {
|
} else if (ModernShadowRenderer.ACTIVE) {
|
||||||
return iris$findOverride(ShaderKey.SHADOW_TEX);
|
return iris$findOverride(ModernShaderKey.SHADOW_TEX);
|
||||||
} else if (shouldOverrideShaders()) {
|
} else if (shouldOverrideShaders()) {
|
||||||
return iris$findOverride(ShaderKey.TEXTURED);
|
return iris$findOverride(ModernShaderKey.TEXTURED);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Supplier<ShaderInstance> positionTexColor = () -> {
|
Supplier<MCShaderInstance> positionTexColor = () -> {
|
||||||
if (isSky()) {
|
if (isSky()) {
|
||||||
return iris$findOverride(ShaderKey.SKY_TEXTURED_COLOR);
|
return iris$findOverride(ModernShaderKey.SKY_TEXTURED_COLOR);
|
||||||
} else if (ModernShadowRenderer.ACTIVE) {
|
} else if (ModernShadowRenderer.ACTIVE) {
|
||||||
return iris$findOverride(ShaderKey.SHADOW_TEX_COLOR);
|
return iris$findOverride(ModernShaderKey.SHADOW_TEX_COLOR);
|
||||||
} else if (shouldOverrideShaders()) {
|
} else if (shouldOverrideShaders()) {
|
||||||
return iris$findOverride(ShaderKey.TEXTURED_COLOR);
|
return iris$findOverride(ModernShaderKey.TEXTURED_COLOR);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -98,20 +98,20 @@ public class ShaderOverrideEngine {
|
|||||||
iris$overrides.put("position_color_tex", positionTexColor);
|
iris$overrides.put("position_color_tex", positionTexColor);
|
||||||
iris$overrides.put("particle", () -> {
|
iris$overrides.put("particle", () -> {
|
||||||
if (isPhase(WorldRenderingPhase.RAIN_SNOW)) {
|
if (isPhase(WorldRenderingPhase.RAIN_SNOW)) {
|
||||||
return iris$findOverride(ShaderKey.WEATHER);
|
return iris$findOverride(ModernShaderKey.WEATHER);
|
||||||
} else if (ModernShadowRenderer.ACTIVE) {
|
} else if (ModernShadowRenderer.ACTIVE) {
|
||||||
return iris$findOverride(ShaderKey.SHADOW_PARTICLES);
|
return iris$findOverride(ModernShaderKey.SHADOW_PARTICLES);
|
||||||
} else if (shouldOverrideShaders()) {
|
} else if (shouldOverrideShaders()) {
|
||||||
return iris$findOverride(ShaderKey.PARTICLES);
|
return iris$findOverride(ModernShaderKey.PARTICLES);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Supplier<ShaderInstance> cloudsShader = () -> {
|
Supplier<MCShaderInstance> cloudsShader = () -> {
|
||||||
if (ModernShadowRenderer.ACTIVE) {
|
if (ModernShadowRenderer.ACTIVE) {
|
||||||
return iris$findOverride(ShaderKey.SHADOW_CLOUDS);
|
return iris$findOverride(ModernShaderKey.SHADOW_CLOUDS);
|
||||||
} else if (shouldOverrideShaders()) {
|
} else if (shouldOverrideShaders()) {
|
||||||
return iris$findOverride(ShaderKey.CLOUDS);
|
return iris$findOverride(ModernShaderKey.CLOUDS);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -120,35 +120,35 @@ public class ShaderOverrideEngine {
|
|||||||
iris$overrides.put("position_tex_color_normal", cloudsShader);
|
iris$overrides.put("position_tex_color_normal", cloudsShader);
|
||||||
iris$overrides.put("rendertype_solid", () -> {
|
iris$overrides.put("rendertype_solid", () -> {
|
||||||
if (ModernShadowRenderer.ACTIVE) {
|
if (ModernShadowRenderer.ACTIVE) {
|
||||||
return iris$findOverride(ShaderKey.SHADOW_TERRAIN_CUTOUT);
|
return iris$findOverride(ModernShaderKey.SHADOW_TERRAIN_CUTOUT);
|
||||||
} else if (isBlockEntities() || isEntities()) {
|
} else if (isBlockEntities() || isEntities()) {
|
||||||
return iris$findOverride(ShaderKey.MOVING_BLOCK);
|
return iris$findOverride(ModernShaderKey.MOVING_BLOCK);
|
||||||
} else if (shouldOverrideShaders()) {
|
} else if (shouldOverrideShaders()) {
|
||||||
return iris$findOverride(ShaderKey.TERRAIN_SOLID);
|
return iris$findOverride(ModernShaderKey.TERRAIN_SOLID);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Supplier<ShaderInstance> cutout = () -> {
|
Supplier<MCShaderInstance> cutout = () -> {
|
||||||
if (ModernShadowRenderer.ACTIVE) {
|
if (ModernShadowRenderer.ACTIVE) {
|
||||||
return iris$findOverride(ShaderKey.SHADOW_TERRAIN_CUTOUT);
|
return iris$findOverride(ModernShaderKey.SHADOW_TERRAIN_CUTOUT);
|
||||||
} else if (isBlockEntities() || isEntities()) {
|
} else if (isBlockEntities() || isEntities()) {
|
||||||
return iris$findOverride(ShaderKey.MOVING_BLOCK);
|
return iris$findOverride(ModernShaderKey.MOVING_BLOCK);
|
||||||
} else if (shouldOverrideShaders()) {
|
} else if (shouldOverrideShaders()) {
|
||||||
return iris$findOverride(ShaderKey.TERRAIN_CUTOUT);
|
return iris$findOverride(ModernShaderKey.TERRAIN_CUTOUT);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
iris$overrides.put("rendertype_cutout", cutout);
|
iris$overrides.put("rendertype_cutout", cutout);
|
||||||
iris$overrides.put("rendertype_cutout_mipped", cutout);
|
iris$overrides.put("rendertype_cutout_mipped", cutout);
|
||||||
Supplier<ShaderInstance> translucentShader = () -> {
|
Supplier<MCShaderInstance> translucentShader = () -> {
|
||||||
if (ModernShadowRenderer.ACTIVE) {
|
if (ModernShadowRenderer.ACTIVE) {
|
||||||
return iris$findOverride(ShaderKey.SHADOW_TERRAIN_CUTOUT);
|
return iris$findOverride(ModernShaderKey.SHADOW_TERRAIN_CUTOUT);
|
||||||
} else if (isBlockEntities() || isEntities()) {
|
} else if (isBlockEntities() || isEntities()) {
|
||||||
return iris$findOverride(ShaderKey.MOVING_BLOCK);
|
return iris$findOverride(ModernShaderKey.MOVING_BLOCK);
|
||||||
} else if (shouldOverrideShaders()) {
|
} else if (shouldOverrideShaders()) {
|
||||||
return iris$findOverride(ShaderKey.TERRAIN_TRANSLUCENT);
|
return iris$findOverride(ModernShaderKey.TERRAIN_TRANSLUCENT);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -157,15 +157,15 @@ public class ShaderOverrideEngine {
|
|||||||
iris$overrides.put("rendertype_translucent_no_crumbling", translucentShader);
|
iris$overrides.put("rendertype_translucent_no_crumbling", translucentShader);
|
||||||
iris$overrides.put("rendertype_translucent_moving_block", translucentShader);
|
iris$overrides.put("rendertype_translucent_moving_block", translucentShader);
|
||||||
iris$overrides.put("rendertype_tripwire", translucentShader);
|
iris$overrides.put("rendertype_tripwire", translucentShader);
|
||||||
Supplier<ShaderInstance> entityCutout = () -> {
|
Supplier<MCShaderInstance> entityCutout = () -> {
|
||||||
if (ModernShadowRenderer.ACTIVE) {
|
if (ModernShadowRenderer.ACTIVE) {
|
||||||
return iris$findOverride(ShaderKey.SHADOW_ENTITIES_CUTOUT);
|
return iris$findOverride(ModernShaderKey.SHADOW_ENTITIES_CUTOUT);
|
||||||
} else if (HandRenderer.INSTANCE.isActive()) {
|
} else if (HandRenderer.INSTANCE.isActive()) {
|
||||||
return iris$findOverride(HandRenderer.INSTANCE.isRenderingSolid() ? ShaderKey.HAND_CUTOUT_DIFFUSE : ShaderKey.HAND_WATER_DIFFUSE);
|
return iris$findOverride(HandRenderer.INSTANCE.isRenderingSolid() ? ModernShaderKey.HAND_CUTOUT_DIFFUSE : ModernShaderKey.HAND_WATER_DIFFUSE);
|
||||||
} else if (isBlockEntities()) {
|
} else if (isBlockEntities()) {
|
||||||
return iris$findOverride(ShaderKey.BLOCK_ENTITY_DIFFUSE);
|
return iris$findOverride(ModernShaderKey.BLOCK_ENTITY_DIFFUSE);
|
||||||
} else if (shouldOverrideShaders()) {
|
} else if (shouldOverrideShaders()) {
|
||||||
return iris$findOverride(ShaderKey.ENTITIES_CUTOUT_DIFFUSE);
|
return iris$findOverride(ModernShaderKey.ENTITIES_CUTOUT_DIFFUSE);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -176,15 +176,15 @@ public class ShaderOverrideEngine {
|
|||||||
iris$overrides.put("rendertype_entity_decal", entityCutout);
|
iris$overrides.put("rendertype_entity_decal", entityCutout);
|
||||||
iris$overrides.put("rendertype_entity_smooth_cutout", entityCutout);
|
iris$overrides.put("rendertype_entity_smooth_cutout", entityCutout);
|
||||||
iris$overrides.put("rendertype_armor_cutout_no_cull", entityCutout);
|
iris$overrides.put("rendertype_armor_cutout_no_cull", entityCutout);
|
||||||
Supplier<ShaderInstance> entityTranslucent = () -> {
|
Supplier<MCShaderInstance> entityTranslucent = () -> {
|
||||||
if (ModernShadowRenderer.ACTIVE) {
|
if (ModernShadowRenderer.ACTIVE) {
|
||||||
return iris$findOverride(ShaderKey.SHADOW_ENTITIES_CUTOUT);
|
return iris$findOverride(ModernShaderKey.SHADOW_ENTITIES_CUTOUT);
|
||||||
} else if (HandRenderer.INSTANCE.isActive()) {
|
} else if (HandRenderer.INSTANCE.isActive()) {
|
||||||
return iris$findOverride(HandRenderer.INSTANCE.isRenderingSolid() ? ShaderKey.HAND_CUTOUT_DIFFUSE : ShaderKey.HAND_WATER_DIFFUSE);
|
return iris$findOverride(HandRenderer.INSTANCE.isRenderingSolid() ? ModernShaderKey.HAND_CUTOUT_DIFFUSE : ModernShaderKey.HAND_WATER_DIFFUSE);
|
||||||
} else if (isBlockEntities()) {
|
} else if (isBlockEntities()) {
|
||||||
return iris$findOverride(ShaderKey.BE_TRANSLUCENT);
|
return iris$findOverride(ModernShaderKey.BE_TRANSLUCENT);
|
||||||
} else if (shouldOverrideShaders()) {
|
} else if (shouldOverrideShaders()) {
|
||||||
return iris$findOverride(ShaderKey.ENTITIES_TRANSLUCENT);
|
return iris$findOverride(ModernShaderKey.ENTITIES_TRANSLUCENT);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -194,24 +194,24 @@ public class ShaderOverrideEngine {
|
|||||||
iris$overrides.put("rendertype_item_entity_translucent_cull", entityTranslucent);
|
iris$overrides.put("rendertype_item_entity_translucent_cull", entityTranslucent);
|
||||||
iris$overrides.put("rendertype_breeze_wind", entityTranslucent);
|
iris$overrides.put("rendertype_breeze_wind", entityTranslucent);
|
||||||
iris$overrides.put("rendertype_entity_no_outline", entityTranslucent);
|
iris$overrides.put("rendertype_entity_no_outline", entityTranslucent);
|
||||||
Supplier<ShaderInstance> energySwirlAndShadow = () -> {
|
Supplier<MCShaderInstance> energySwirlAndShadow = () -> {
|
||||||
if (ModernShadowRenderer.ACTIVE) {
|
if (ModernShadowRenderer.ACTIVE) {
|
||||||
return iris$findOverride(ShaderKey.SHADOW_ENTITIES_CUTOUT);
|
return iris$findOverride(ModernShaderKey.SHADOW_ENTITIES_CUTOUT);
|
||||||
} else if (HandRenderer.INSTANCE.isActive()) {
|
} else if (HandRenderer.INSTANCE.isActive()) {
|
||||||
return iris$findOverride(HandRenderer.INSTANCE.isRenderingSolid() ? ShaderKey.HAND_CUTOUT : ShaderKey.HAND_TRANSLUCENT);
|
return iris$findOverride(HandRenderer.INSTANCE.isRenderingSolid() ? ModernShaderKey.HAND_CUTOUT : ModernShaderKey.HAND_TRANSLUCENT);
|
||||||
} else if (isBlockEntities()) {
|
} else if (isBlockEntities()) {
|
||||||
return iris$findOverride(ShaderKey.BLOCK_ENTITY);
|
return iris$findOverride(ModernShaderKey.BLOCK_ENTITY);
|
||||||
} else if (shouldOverrideShaders()) {
|
} else if (shouldOverrideShaders()) {
|
||||||
return iris$findOverride(ShaderKey.ENTITIES_CUTOUT);
|
return iris$findOverride(ModernShaderKey.ENTITIES_CUTOUT);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
iris$overrides.put("rendertype_energy_swirl", energySwirlAndShadow);
|
iris$overrides.put("rendertype_energy_swirl", energySwirlAndShadow);
|
||||||
iris$overrides.put("rendertype_entity_shadow", energySwirlAndShadow);
|
iris$overrides.put("rendertype_entity_shadow", energySwirlAndShadow);
|
||||||
Supplier<ShaderInstance> glint = () -> {
|
Supplier<MCShaderInstance> glint = () -> {
|
||||||
if (shouldOverrideShaders()) {
|
if (shouldOverrideShaders()) {
|
||||||
return iris$findOverride(ShaderKey.GLINT);
|
return iris$findOverride(ModernShaderKey.GLINT);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -223,29 +223,29 @@ public class ShaderOverrideEngine {
|
|||||||
iris$overrides.put("rendertype_entity_glint_direct", glint);
|
iris$overrides.put("rendertype_entity_glint_direct", glint);
|
||||||
iris$overrides.put("rendertype_entity_glint", glint);
|
iris$overrides.put("rendertype_entity_glint", glint);
|
||||||
iris$overrides.put("rendertype_armor_entity_glint", glint);
|
iris$overrides.put("rendertype_armor_entity_glint", glint);
|
||||||
Supplier<ShaderInstance> entitySolid = () -> {
|
Supplier<MCShaderInstance> entitySolid = () -> {
|
||||||
if (ModernShadowRenderer.ACTIVE) {
|
if (ModernShadowRenderer.ACTIVE) {
|
||||||
return iris$findOverride(ShaderKey.SHADOW_ENTITIES_CUTOUT);
|
return iris$findOverride(ModernShaderKey.SHADOW_ENTITIES_CUTOUT);
|
||||||
} else if (HandRenderer.INSTANCE.isActive()) {
|
} else if (HandRenderer.INSTANCE.isActive()) {
|
||||||
return iris$findOverride(HandRenderer.INSTANCE.isRenderingSolid() ? ShaderKey.HAND_CUTOUT_DIFFUSE : ShaderKey.HAND_WATER_DIFFUSE);
|
return iris$findOverride(HandRenderer.INSTANCE.isRenderingSolid() ? ModernShaderKey.HAND_CUTOUT_DIFFUSE : ModernShaderKey.HAND_WATER_DIFFUSE);
|
||||||
} else if (isBlockEntities()) {
|
} else if (isBlockEntities()) {
|
||||||
return iris$findOverride(ShaderKey.BLOCK_ENTITY_DIFFUSE);
|
return iris$findOverride(ModernShaderKey.BLOCK_ENTITY_DIFFUSE);
|
||||||
} else if (shouldOverrideShaders()) {
|
} else if (shouldOverrideShaders()) {
|
||||||
return iris$findOverride(ShaderKey.ENTITIES_SOLID_DIFFUSE);
|
return iris$findOverride(ModernShaderKey.ENTITIES_SOLID_DIFFUSE);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
iris$overrides.put("rendertype_entity_solid", entitySolid);
|
iris$overrides.put("rendertype_entity_solid", entitySolid);
|
||||||
Supplier<ShaderInstance> waterMask = () -> {
|
Supplier<MCShaderInstance> waterMask = () -> {
|
||||||
if (ModernShadowRenderer.ACTIVE) {
|
if (ModernShadowRenderer.ACTIVE) {
|
||||||
return iris$findOverride(ShaderKey.SHADOW_ENTITIES_CUTOUT);
|
return iris$findOverride(ModernShaderKey.SHADOW_ENTITIES_CUTOUT);
|
||||||
} else if (HandRenderer.INSTANCE.isActive()) {
|
} else if (HandRenderer.INSTANCE.isActive()) {
|
||||||
return iris$findOverride(HandRenderer.INSTANCE.isRenderingSolid() ? ShaderKey.HAND_CUTOUT : ShaderKey.HAND_TRANSLUCENT);
|
return iris$findOverride(HandRenderer.INSTANCE.isRenderingSolid() ? ModernShaderKey.HAND_CUTOUT : ModernShaderKey.HAND_TRANSLUCENT);
|
||||||
} else if (isBlockEntities()) {
|
} else if (isBlockEntities()) {
|
||||||
return iris$findOverride(ShaderKey.BLOCK_ENTITY);
|
return iris$findOverride(ModernShaderKey.BLOCK_ENTITY);
|
||||||
} else if (shouldOverrideShaders()) {
|
} else if (shouldOverrideShaders()) {
|
||||||
return iris$findOverride(ShaderKey.ENTITIES_SOLID);
|
return iris$findOverride(ModernShaderKey.ENTITIES_SOLID);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -253,27 +253,27 @@ public class ShaderOverrideEngine {
|
|||||||
iris$overrides.put("rendertype_water_mask", waterMask);
|
iris$overrides.put("rendertype_water_mask", waterMask);
|
||||||
iris$overrides.put("rendertype_beacon_beam", () -> {
|
iris$overrides.put("rendertype_beacon_beam", () -> {
|
||||||
if (ModernShadowRenderer.ACTIVE) {
|
if (ModernShadowRenderer.ACTIVE) {
|
||||||
return iris$findOverride(ShaderKey.SHADOW_BEACON_BEAM);
|
return iris$findOverride(ModernShaderKey.SHADOW_BEACON_BEAM);
|
||||||
} else if (shouldOverrideShaders()) {
|
} else if (shouldOverrideShaders()) {
|
||||||
return iris$findOverride(ShaderKey.BEACON);
|
return iris$findOverride(ModernShaderKey.BEACON);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
iris$overrides.put("rendertype_entity_alpha", () -> {
|
iris$overrides.put("rendertype_entity_alpha", () -> {
|
||||||
if (!ModernShadowRenderer.ACTIVE) {
|
if (!ModernShadowRenderer.ACTIVE) {
|
||||||
return iris$findOverride(ShaderKey.ENTITIES_ALPHA);
|
return iris$findOverride(ModernShaderKey.ENTITIES_ALPHA);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
iris$overrides.put("rendertype_eyes", () -> {
|
iris$overrides.put("rendertype_eyes", () -> {
|
||||||
if (ModernShadowRenderer.ACTIVE) {
|
if (ModernShadowRenderer.ACTIVE) {
|
||||||
return iris$findOverride(ShaderKey.SHADOW_ENTITIES_CUTOUT);
|
return iris$findOverride(ModernShaderKey.SHADOW_ENTITIES_CUTOUT);
|
||||||
} else if (isBlockEntities()) {
|
} else if (isBlockEntities()) {
|
||||||
return iris$findOverride(ShaderKey.BLOCK_ENTITY);
|
return iris$findOverride(ModernShaderKey.BLOCK_ENTITY);
|
||||||
} else if (shouldOverrideShaders()) {
|
} else if (shouldOverrideShaders()) {
|
||||||
return iris$findOverride(ShaderKey.ENTITIES_EYES);
|
return iris$findOverride(ModernShaderKey.ENTITIES_EYES);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -281,49 +281,49 @@ public class ShaderOverrideEngine {
|
|||||||
iris$overrides.put("rendertype_entity_translucent_emissive", () -> {
|
iris$overrides.put("rendertype_entity_translucent_emissive", () -> {
|
||||||
if (ModernShadowRenderer.ACTIVE) {
|
if (ModernShadowRenderer.ACTIVE) {
|
||||||
// TODO: Wrong program
|
// TODO: Wrong program
|
||||||
return iris$findOverride(ShaderKey.SHADOW_ENTITIES_CUTOUT);
|
return iris$findOverride(ModernShaderKey.SHADOW_ENTITIES_CUTOUT);
|
||||||
} else if (isBlockEntities()) {
|
} else if (isBlockEntities()) {
|
||||||
return iris$findOverride(ShaderKey.BLOCK_ENTITY);
|
return iris$findOverride(ModernShaderKey.BLOCK_ENTITY);
|
||||||
} else if (shouldOverrideShaders()) {
|
} else if (shouldOverrideShaders()) {
|
||||||
return iris$findOverride(ShaderKey.ENTITIES_EYES_TRANS);
|
return iris$findOverride(ModernShaderKey.ENTITIES_EYES_TRANS);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
iris$overrides.put("rendertype_leash", () -> {
|
iris$overrides.put("rendertype_leash", () -> {
|
||||||
if (ModernShadowRenderer.ACTIVE) {
|
if (ModernShadowRenderer.ACTIVE) {
|
||||||
return iris$findOverride(ShaderKey.SHADOW_LEASH);
|
return iris$findOverride(ModernShaderKey.SHADOW_LEASH);
|
||||||
} else if (shouldOverrideShaders()) {
|
} else if (shouldOverrideShaders()) {
|
||||||
return iris$findOverride(ShaderKey.LEASH);
|
return iris$findOverride(ModernShaderKey.LEASH);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
iris$overrides.put("rendertype_lightning", () -> {
|
iris$overrides.put("rendertype_lightning", () -> {
|
||||||
if (ModernShadowRenderer.ACTIVE) {
|
if (ModernShadowRenderer.ACTIVE) {
|
||||||
return iris$findOverride(ShaderKey.SHADOW_LIGHTNING);
|
return iris$findOverride(ModernShaderKey.SHADOW_LIGHTNING);
|
||||||
} else if (shouldOverrideShaders()) {
|
} else if (shouldOverrideShaders()) {
|
||||||
return iris$findOverride(ShaderKey.LIGHTNING);
|
return iris$findOverride(ModernShaderKey.LIGHTNING);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
iris$overrides.put("rendertype_crumbling", () -> {
|
iris$overrides.put("rendertype_crumbling", () -> {
|
||||||
if (shouldOverrideShaders() && !ModernShadowRenderer.ACTIVE) {
|
if (shouldOverrideShaders() && !ModernShadowRenderer.ACTIVE) {
|
||||||
return iris$findOverride(ShaderKey.CRUMBLING);
|
return iris$findOverride(ModernShaderKey.CRUMBLING);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Supplier<ShaderInstance> textShader = () -> {
|
Supplier<MCShaderInstance> textShader = () -> {
|
||||||
if (ModernShadowRenderer.ACTIVE) {
|
if (ModernShadowRenderer.ACTIVE) {
|
||||||
return iris$findOverride(ShaderKey.SHADOW_TEXT);
|
return iris$findOverride(ModernShaderKey.SHADOW_TEXT);
|
||||||
} else if (HandRenderer.INSTANCE.isActive()) {
|
} else if (HandRenderer.INSTANCE.isActive()) {
|
||||||
return iris$findOverride(ShaderKey.HAND_TEXT);
|
return iris$findOverride(ModernShaderKey.HAND_TEXT);
|
||||||
} else if (isBlockEntities()) {
|
} else if (isBlockEntities()) {
|
||||||
return iris$findOverride(ShaderKey.TEXT_BE);
|
return iris$findOverride(ModernShaderKey.TEXT_BE);
|
||||||
} else if (shouldOverrideShaders()) {
|
} else if (shouldOverrideShaders()) {
|
||||||
return iris$findOverride(ShaderKey.TEXT);
|
return iris$findOverride(ModernShaderKey.TEXT);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -331,35 +331,35 @@ public class ShaderOverrideEngine {
|
|||||||
iris$overrides.put("rendertype_text", textShader);
|
iris$overrides.put("rendertype_text", textShader);
|
||||||
iris$overrides.put("rendertype_text_see_through", textShader);
|
iris$overrides.put("rendertype_text_see_through", textShader);
|
||||||
iris$overrides.put("position_color_tex_lightmap", textShader);
|
iris$overrides.put("position_color_tex_lightmap", textShader);
|
||||||
Supplier<ShaderInstance> textBgShader = () -> {
|
Supplier<MCShaderInstance> textBgShader = () -> {
|
||||||
if (ModernShadowRenderer.ACTIVE) {
|
if (ModernShadowRenderer.ACTIVE) {
|
||||||
return iris$findOverride(ShaderKey.SHADOW_TEXT_BG);
|
return iris$findOverride(ModernShaderKey.SHADOW_TEXT_BG);
|
||||||
} else {
|
} else {
|
||||||
return iris$findOverride(ShaderKey.TEXT_BG);
|
return iris$findOverride(ModernShaderKey.TEXT_BG);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
iris$overrides.put("rendertype_text_background", textBgShader);
|
iris$overrides.put("rendertype_text_background", textBgShader);
|
||||||
iris$overrides.put("rendertype_text_background_see_through", textBgShader);
|
iris$overrides.put("rendertype_text_background_see_through", textBgShader);
|
||||||
Supplier<ShaderInstance> textIntensityShader = () -> {
|
Supplier<MCShaderInstance> textIntensityShader = () -> {
|
||||||
if (ModernShadowRenderer.ACTIVE) {
|
if (ModernShadowRenderer.ACTIVE) {
|
||||||
return iris$findOverride(ShaderKey.SHADOW_TEXT_INTENSITY);
|
return iris$findOverride(ModernShaderKey.SHADOW_TEXT_INTENSITY);
|
||||||
} else if (HandRenderer.INSTANCE.isActive()) {
|
} else if (HandRenderer.INSTANCE.isActive()) {
|
||||||
return iris$findOverride(ShaderKey.HAND_TEXT_INTENSITY);
|
return iris$findOverride(ModernShaderKey.HAND_TEXT_INTENSITY);
|
||||||
} else if (isBlockEntities()) {
|
} else if (isBlockEntities()) {
|
||||||
return iris$findOverride(ShaderKey.TEXT_INTENSITY_BE);
|
return iris$findOverride(ModernShaderKey.TEXT_INTENSITY_BE);
|
||||||
} else if (shouldOverrideShaders()) {
|
} else if (shouldOverrideShaders()) {
|
||||||
return iris$findOverride(ShaderKey.TEXT_INTENSITY);
|
return iris$findOverride(ModernShaderKey.TEXT_INTENSITY);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
iris$overrides.put("rendertype_text_intensity", textIntensityShader);
|
iris$overrides.put("rendertype_text_intensity", textIntensityShader);
|
||||||
iris$overrides.put("rendertype_text_intensity_see_through", textIntensityShader);
|
iris$overrides.put("rendertype_text_intensity_see_through", textIntensityShader);
|
||||||
Supplier<ShaderInstance> linesShader = () -> {
|
Supplier<MCShaderInstance> linesShader = () -> {
|
||||||
if (ModernShadowRenderer.ACTIVE) {
|
if (ModernShadowRenderer.ACTIVE) {
|
||||||
return iris$findOverride(ShaderKey.SHADOW_LINES);
|
return iris$findOverride(ModernShaderKey.SHADOW_LINES);
|
||||||
} else if (shouldOverrideShaders()) {
|
} else if (shouldOverrideShaders()) {
|
||||||
return iris$findOverride(ShaderKey.LINES);
|
return iris$findOverride(ModernShaderKey.LINES);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
+103
-9
@@ -4,12 +4,19 @@ package org.embeddedt.embeddium.impl;
|
|||||||
import com.mojang.blaze3d.platform.NativeImage;
|
import com.mojang.blaze3d.platform.NativeImage;
|
||||||
import com.mojang.math.Axis;
|
import com.mojang.math.Axis;
|
||||||
import net.irisshaders.iris.Iris;
|
import net.irisshaders.iris.Iris;
|
||||||
|
import net.irisshaders.iris.IrisCommon;
|
||||||
import net.irisshaders.iris.helpers.JomlConversions;
|
import net.irisshaders.iris.helpers.JomlConversions;
|
||||||
import net.irisshaders.iris.mixin.GlStateManagerAccessor;
|
import net.irisshaders.iris.mixin.GlStateManagerAccessor;
|
||||||
|
import net.irisshaders.iris.mixin.LightTextureAccessor;
|
||||||
import net.irisshaders.iris.mixin.texture.TextureAtlasAccessor;
|
import net.irisshaders.iris.mixin.texture.TextureAtlasAccessor;
|
||||||
import net.irisshaders.iris.shaderpack.DimensionId;
|
import net.irisshaders.iris.shaderpack.DimensionId;
|
||||||
|
import net.irisshaders.iris.shaderpack.ShaderPack;
|
||||||
|
import net.irisshaders.iris.shaderpack.materialmap.BlockMaterialMapping;
|
||||||
|
import net.irisshaders.iris.shaderpack.materialmap.ModelTextureAnalyzer;
|
||||||
|
import net.irisshaders.iris.shaderpack.materialmap.ModernWorldRenderingSettings;
|
||||||
import net.irisshaders.iris.shadows.ShadowMatrices;
|
import net.irisshaders.iris.shadows.ShadowMatrices;
|
||||||
import net.irisshaders.iris.shadows.ModernShadowRenderer;
|
import net.irisshaders.iris.shadows.ModernShadowRenderer;
|
||||||
|
import net.irisshaders.iris.targets.Blaze3dRenderTargetExt;
|
||||||
import net.irisshaders.iris.texture.TextureInfoCache;
|
import net.irisshaders.iris.texture.TextureInfoCache;
|
||||||
import net.irisshaders.iris.texture.TextureTracker;
|
import net.irisshaders.iris.texture.TextureTracker;
|
||||||
import net.irisshaders.iris.uniforms.CameraUniforms;
|
import net.irisshaders.iris.uniforms.CameraUniforms;
|
||||||
@@ -17,7 +24,10 @@ import net.irisshaders.iris.uniforms.CapturedRenderingState;
|
|||||||
import net.minecraft.Util;
|
import net.minecraft.Util;
|
||||||
import net.minecraft.client.multiplayer.ClientLevel;
|
import net.minecraft.client.multiplayer.ClientLevel;
|
||||||
import net.minecraft.client.player.LocalPlayer;
|
import net.minecraft.client.player.LocalPlayer;
|
||||||
|
import net.minecraft.client.renderer.DimensionSpecialEffects;
|
||||||
import net.minecraft.client.renderer.GameRenderer;
|
import net.minecraft.client.renderer.GameRenderer;
|
||||||
|
import net.minecraft.client.renderer.texture.DynamicTexture;
|
||||||
|
import net.minecraft.client.renderer.texture.MissingTextureAtlasSprite;
|
||||||
import net.minecraft.client.renderer.texture.TextureAtlas;
|
import net.minecraft.client.renderer.texture.TextureAtlas;
|
||||||
import net.minecraft.client.resources.language.I18n;
|
import net.minecraft.client.resources.language.I18n;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
@@ -32,15 +42,21 @@ import net.minecraft.world.level.GameType;
|
|||||||
import net.minecraft.world.level.LightLayer;
|
import net.minecraft.world.level.LightLayer;
|
||||||
import net.minecraft.world.level.material.FogType;
|
import net.minecraft.world.level.material.FogType;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
import org.embeddedt.embeddium.compat.mc.IResourceLocation;
|
|
||||||
import org.embeddedt.embeddium.compat.mc.MCAbstractTexture;
|
import org.embeddedt.embeddium.compat.mc.MCAbstractTexture;
|
||||||
|
import org.embeddedt.embeddium.compat.mc.MCDynamicTexture;
|
||||||
import org.embeddedt.embeddium.compat.mc.MCNativeImage;
|
import org.embeddedt.embeddium.compat.mc.MCNativeImage;
|
||||||
|
import org.embeddedt.embeddium.compat.mc.MCResourceLocation;
|
||||||
|
import org.embeddedt.embeddium.compat.mc.MCResourceManager;
|
||||||
|
import org.embeddedt.embeddium.compat.mc.MCTextureManager;
|
||||||
import org.embeddedt.embeddium.compat.mc.MinecraftVersionShimService;
|
import org.embeddedt.embeddium.compat.mc.MinecraftVersionShimService;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import org.embeddedt.embeddium.impl.loader.common.EarlyLoaderServices;
|
import org.embeddedt.embeddium.impl.loader.common.EarlyLoaderServices;
|
||||||
import org.joml.*;
|
import org.joml.*;
|
||||||
import org.joml.Math;
|
import org.joml.Math;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.nio.ByteBuffer;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.stream.StreamSupport;
|
import java.util.stream.StreamSupport;
|
||||||
|
|
||||||
@@ -590,22 +606,22 @@ public class MinecraftModernVersionShimImpl implements MinecraftVersionShimServi
|
|||||||
return (MCNativeImage[])(Object[])new NativeImage[size];
|
return (MCNativeImage[])(Object[])new NativeImage[size];
|
||||||
}
|
}
|
||||||
|
|
||||||
public IResourceLocation makeResourceLocation(String namespace, String path) {
|
public MCResourceLocation makeResourceLocation(String namespace, String path) {
|
||||||
//? if >=1.21
|
//? if >=1.21
|
||||||
/*return (IResourceLocation)(Object) ResourceLocation.fromNamespaceAndPath(namespace, path);*/
|
/*return (MCResourceLocation)(Object) ResourceLocation.fromNamespaceAndPath(namespace, path);*/
|
||||||
//? if <1.21
|
//? if <1.21
|
||||||
return (IResourceLocation)(Object) new ResourceLocation(namespace, path);
|
return (MCResourceLocation)(Object) new ResourceLocation(namespace, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IResourceLocation makeResourceLocation(String str) {
|
public MCResourceLocation makeResourceLocation(String str) {
|
||||||
//? if >=1.21 {
|
//? if >=1.21 {
|
||||||
/*if(str.contains(":")) {
|
/*if(str.contains(":")) {
|
||||||
return (IResourceLocation)(Object) ResourceLocation.parse(str);
|
return (MCResourceLocation)(Object) ResourceLocation.parse(str);
|
||||||
} else {
|
} else {
|
||||||
return (IResourceLocation)(Object) ResourceLocation.withDefaultNamespace(str);
|
return (MCResourceLocation)(Object) ResourceLocation.withDefaultNamespace(str);
|
||||||
}
|
}
|
||||||
*///?} else
|
*///?} else
|
||||||
return (IResourceLocation)(Object)new ResourceLocation(str);
|
return (MCResourceLocation)(Object)new ResourceLocation(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -653,8 +669,86 @@ public class MinecraftModernVersionShimImpl implements MinecraftVersionShimServi
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void bindFramebuffer() {
|
public void bindMainFramebuffer() {
|
||||||
Minecraft.getInstance().getMainRenderTarget().bindWrite(true);
|
Minecraft.getInstance().getMainRenderTarget().bindWrite(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void unbindMainFramebuffer() {
|
||||||
|
Minecraft.getInstance().getMainRenderTarget().bindWrite(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMainFramebufferWidth() {
|
||||||
|
return Minecraft.getInstance().getMainRenderTarget().width;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMainFramebufferHeight() {
|
||||||
|
return Minecraft.getInstance().getMainRenderTarget().height;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getColorTextureId() {
|
||||||
|
return Minecraft.getInstance().getMainRenderTarget().getColorTextureId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getColorBufferVersion() {
|
||||||
|
return ((Blaze3dRenderTargetExt) Minecraft.getInstance().getMainRenderTarget()).iris$getColorBufferVersion();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getLightTextureId() {
|
||||||
|
return ((LightTextureAccessor) Minecraft.getInstance().gameRenderer.lightTexture()).getLightTexture().getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMissingTextureId() {
|
||||||
|
return MissingTextureAtlasSprite.getTexture().getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MCNativeImage readNativeImage(InputStream textureStream) throws IOException {
|
||||||
|
return (MCNativeImage) (Object) NativeImage.read(textureStream);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MCNativeImage readNativeImage(ByteBuffer textureData) throws IOException {
|
||||||
|
return (MCNativeImage) (Object) NativeImage.read(textureData);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MCDynamicTexture createDynamicTexture(MCNativeImage image) {
|
||||||
|
return (MCDynamicTexture) new DynamicTexture((NativeImage) (Object)image);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MCTextureManager getTextureManager() {
|
||||||
|
return (MCTextureManager) Minecraft.getInstance().getTextureManager();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MCResourceManager getResourceManager() {
|
||||||
|
return (MCResourceManager) Minecraft.getInstance().getResourceManager();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void populateBlockIds(ShaderPack pack) {
|
||||||
|
ModernWorldRenderingSettings.INSTANCE.setBlockStateIds(BlockMaterialMapping.createBlockStateIdMap(pack.getIdMap().getBlockProperties()));
|
||||||
|
ModernWorldRenderingSettings.INSTANCE.setBlockTypeIds(BlockMaterialMapping.createBlockTypeMap(pack.getIdMap().getBlockRenderTypeMap()));
|
||||||
|
if (IrisCommon.getIrisConfig().isEnableTextureMaterialFallback()) {
|
||||||
|
ModernWorldRenderingSettings.INSTANCE.setFallbackTextureMaterialMapping(ModelTextureAnalyzer.runAnalysisSync(ModernWorldRenderingSettings.INSTANCE.getBlockStateIds()));
|
||||||
|
} else {
|
||||||
|
ModernWorldRenderingSettings.INSTANCE.setFallbackTextureMaterialMapping(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isSkyTypeNormal() {
|
||||||
|
DimensionSpecialEffects.SkyType skyType = Minecraft.getInstance().level.effects().skyType();
|
||||||
|
return skyType == DimensionSpecialEffects.SkyType.NORMAL;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -6,6 +6,7 @@ import com.mitchej123.glsm.RenderSystemService;
|
|||||||
import com.mojang.blaze3d.shaders.FogShape;
|
import com.mojang.blaze3d.shaders.FogShape;
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import net.irisshaders.iris.mixin.GlStateManagerAccessor;
|
import net.irisshaders.iris.mixin.GlStateManagerAccessor;
|
||||||
|
import net.minecraft.client.renderer.GameRenderer;
|
||||||
import org.embeddedt.embeddium.compat.BooleanStateExtended;
|
import org.embeddedt.embeddium.compat.BooleanStateExtended;
|
||||||
import org.joml.Matrix4f;
|
import org.joml.Matrix4f;
|
||||||
|
|
||||||
@@ -159,4 +160,9 @@ public class RenderSystemImpl implements RenderSystemService {
|
|||||||
public void setProjectionMatrixOrigin(Matrix4f projectionMatrix) {
|
public void setProjectionMatrixOrigin(Matrix4f projectionMatrix) {
|
||||||
RenderSystem.setProjectionMatrix(projectionMatrix/*? if >=1.20 {*/, com.mojang.blaze3d.vertex.VertexSorting.DISTANCE_TO_ORIGIN/*?}*/);
|
RenderSystem.setProjectionMatrix(projectionMatrix/*? if >=1.20 {*/, com.mojang.blaze3d.vertex.VertexSorting.DISTANCE_TO_ORIGIN/*?}*/);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setPositionShader() {
|
||||||
|
RenderSystem.setShader(GameRenderer::getPositionShader);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user