Translucency Layers and Terrain Split (#2332)

* Replace translucency sorting toggle with an Off/Fast/Fancy setting

* Add premultiplied layer blending to GLSMBlend

* Add translucency layer targets and depth-sorted composite

* Draw translucent terrain and tile entities into composited layers

* Draw particles, weather and clouds into composited layers

* Composite terrain behind block entities under Fancy translucency
This commit is contained in:
Ruling-0 authored and GitHub committed 2026-11-21 22:13:43 -05:00
1 parent ef8648cdc0
commit 586cce1c40
31 files changed
+1199 -146

No files matched your search

@@ -551,6 +551,8 @@ public enum Mixins implements IMixins {
, "shaders.MixinEntityRenderer"
, "shaders.MixinGuiIngameForge"
, "shaders.MixinFramebuffer"
, "angelica.rendering.MixinEntityRenderer_TranslucencyLayers"
, "angelica.rendering.MixinFramebuffer_TranslucencyLayers"
, "shaders.MixinItem"
, "shaders.MixinItemRenderer_ItemId"
, "shaders.MixinLocale"
@@ -103,8 +103,12 @@ public class PanoramaRenderer {
}
public static <T> GlProgram<T> loadProgram(String name, String vertBase, String fragBase, Function<ShaderBindingContext, T> factory) {
return loadProgram(name, vertBase, fragBase, ShaderConstants.EMPTY, factory);
}
public static <T> GlProgram<T> loadProgram(String name, String vertBase, String fragBase, ShaderConstants fragConstants, Function<ShaderBindingContext, T> factory) {
final GlShader vert = ShaderLoader.loadShader(ShaderType.VERTEX, vertBase + ".vert", ShaderConstants.EMPTY);
final GlShader frag = ShaderLoader.loadShader(ShaderType.FRAGMENT, fragBase + ".frag", ShaderConstants.EMPTY);
final GlShader frag = ShaderLoader.loadShader(ShaderType.FRAGMENT, fragBase + ".frag", fragConstants);
try {
final GlProgram<T> program = GlProgram.builder(name).attachShader(vert).attachShader(frag).link(factory);
program.bind();
@@ -13,6 +13,7 @@ import com.gtnewhorizons.angelica.rendering.TextureSamplers;
import com.gtnewhorizons.angelica.rendering.celeritas.api.IrisShaderProvider;
import com.gtnewhorizons.angelica.rendering.celeritas.api.IrisShaderProviderHolder;
import com.gtnewhorizons.angelica.rendering.culling.GpuCulling;
import com.gtnewhorizons.angelica.rendering.translucency.TranslucencyLayers;
import me.jellysquid.mods.sodium.client.gui.SodiumGameOptions;
import me.jellysquid.mods.sodium.client.gui.options.named.MultiDrawMode;
import com.gtnewhorizons.angelica.rendering.voxelization.SdlShadowVoxelizationSink;
@@ -196,6 +197,7 @@ class AngelicaChunkRenderer extends DefaultChunkRenderer {
if (program != null) {
program.bind();
program.getInterface().setupState(pass);
if (pass == AngelicaRenderPassConfiguration.TRANSLUCENT_PASS) TranslucencyLayers.INSTANCE.beginTerrainSplit(program.handle());
}
}
@@ -204,6 +206,7 @@ class AngelicaChunkRenderer extends DefaultChunkRenderer {
if (irisProgram != null) {
endIrisPass(pass);
} else {
if (pass == AngelicaRenderPassConfiguration.TRANSLUCENT_PASS) TranslucencyLayers.INSTANCE.endTerrainSplit();
super.end(pass);
}
}
@@ -80,7 +80,8 @@ public class AngelicaRenderPassConfiguration {
TRANSLUCENT_PASS = builderForRenderType(1, false, translucentCutoff, vertexType)
.name("translucent")
.useReverseOrder(true)
.useTranslucencySorting(ClientProxy.options().performance.translucencySorting)
.useTranslucencySorting(ClientProxy.options().performance.translucencyMode.sorts())
.extraDefine("TRANSLUCENCY_SPLIT", "")
.build();
TRANSLUCENT_MATERIAL = new Material(TRANSLUCENT_PASS, translucentCutoff, true);
@@ -72,6 +72,8 @@ import com.gtnewhorizons.angelica.rendering.celeritas.api.IrisShaderProviderHold
import com.gtnewhorizons.angelica.rendering.tesr.TesrAttribution;
import com.gtnewhorizons.angelica.rendering.tesr.TesrBatchRenderer;
import com.gtnewhorizons.angelica.rendering.tesr.TesrLifecycle;
import com.gtnewhorizons.angelica.rendering.translucency.TranslucencyLayers;
import com.gtnewhorizons.angelica.rendering.translucency.TranslucentLayer;
import net.coderbot.iris.Iris;
import net.coderbot.iris.layer.GbufferPrograms;
import net.coderbot.iris.pipeline.ShadowRenderer;
@@ -395,6 +397,15 @@ public class CeleritasWorldRenderer extends SimpleWorldRenderer<WorldClient, Ang
return camera;
}
public boolean hasVisibleLayer(BlockRenderLayer renderLayer) {
final Collection<TerrainRenderPass> passes = this.renderSectionManager.getRenderPassConfiguration().vanillaRenderStages().get(renderLayer);
if (passes == null) return false;
for (final TerrainRenderPass pass : passes) {
if (this.renderSectionManager.getRenderLists().hasPass(pass)) return true;
}
return false;
}
@Override
public void drawChunkLayer(BlockRenderLayer renderLayer, double x, double y, double z) {
if (DEBUG_WIREFRAME_MODE) {
@@ -421,8 +432,9 @@ public class CeleritasWorldRenderer extends SimpleWorldRenderer<WorldClient, Ang
public void renderBlockEntitiesBeforeTranslucent(float partialTicks) {
if (passOne != PassOne.PENDING) return;
passOne = PassOne.DRAWN_EARLY;
if (frameOverride.isEmpty()) return;
if (!anyRendersInPassOne()) return;
final Minecraft mc = Minecraft.getMinecraft();
final boolean layered = TranslucencyLayers.INSTANCE.active();
final int previousPass = MinecraftForgeClient.getRenderPass();
final int depth = GLSMAttribStack.pushState(StateSet.BLOCK_ENTITY_PASS);
savedTextureMatrix.set(GLSMTextures.getTextures().getTextureUnitMatrix(0));
@@ -434,14 +446,23 @@ public class CeleritasWorldRenderer extends SimpleWorldRenderer<WorldClient, Ang
GLSMTextures.glActiveTexture(GL13.GL_TEXTURE0);
GLSMTextures.enableTexture();
GLSMCurrentAttribs.glColor4f(1f, 1f, 1f, 1f);
if (mc.gameSettings.fancyGraphics) {
// A layer reads its color as premultiplied, which a blend-disabled draw does not write (TranslucencyLayers).
if (layered) {
GLSMBlend.enableBlend();
GLSMBlend.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
} else if (mc.gameSettings.fancyGraphics) {
GLSMBlend.disableBlend();
GLSMRasterizer.glShadeModel(GL11.GL_FLAT);
}
if (mc.gameSettings.fancyGraphics) GLSMRasterizer.glShadeModel(GL11.GL_FLAT);
RenderHelper.enableStandardItemLighting();
mc.entityRenderer.enableLightmap(partialTicks);
ForgeHooksClient.setRenderPass(1);
renderBlockEntitiesInPhase(partialTicks);
if (layered) TranslucencyLayers.INSTANCE.begin(TranslucentLayer.BLOCK_ENTITIES);
try {
renderBlockEntitiesInPhase(partialTicks);
} finally {
if (layered) TranslucencyLayers.INSTANCE.end();
}
} finally {
ForgeHooksClient.setRenderPass(previousPass);
GLSMMatrices.glMatrixMode(GL11.GL_MODELVIEW);
@@ -451,6 +472,13 @@ public class CeleritasWorldRenderer extends SimpleWorldRenderer<WorldClient, Ang
}
}
private boolean anyRendersInPassOne() {
for (int i = 0; i < frameOverride.size(); i++) {
if (frameOverride.get(i).shouldRenderInPass(1)) return true;
}
return false;
}
public boolean takeLatePassOne() {
final boolean late = passOne != PassOne.DRAWN_EARLY;
passOne = PassOne.NONE;
@@ -504,7 +532,7 @@ public class CeleritasWorldRenderer extends SimpleWorldRenderer<WorldClient, Ang
this.teTransform = null;
if (Tracy.ENABLED) Tracy.beginZone(Z_TESR_DISPATCH);
try {
if (ClientProxy.options().performance.translucencySorting) {
if (ClientProxy.options().performance.translucencyMode.sorts()) {
depthOrder.sortBackToFront(frameTEs, teCamX, teCamY, teCamZ);
}
for (int i = 0; i < frameTEs.size(); i++) {
@@ -0,0 +1,391 @@
package com.gtnewhorizons.angelica.rendering.translucency;
import com.gtnewhorizons.angelica.glsm.GLSMAttribStack;
import com.gtnewhorizons.angelica.glsm.GLSMBlend;
import com.gtnewhorizons.angelica.glsm.GLSMDepthStencilAlpha;
import com.gtnewhorizons.angelica.glsm.GLSMDraws;
import com.gtnewhorizons.angelica.glsm.GLSMFramebuffer;
import com.gtnewhorizons.angelica.glsm.GLSMPrograms;
import com.gtnewhorizons.angelica.glsm.GLSMQueries;
import com.gtnewhorizons.angelica.glsm.GLSMRasterizer;
import com.gtnewhorizons.angelica.glsm.GLSMTextures;
import com.gtnewhorizons.angelica.glsm.GLSMVertexInput;
import com.gtnewhorizons.angelica.glsm.RenderSystem;
import com.gtnewhorizons.angelica.glsm.StateSet;
import com.gtnewhorizons.angelica.glsm.hooks.BatchStateGuard;
import com.gtnewhorizons.angelica.glsm.stacks.ColorMaskStack;
import com.gtnewhorizons.angelica.glsm.texture.DepthBufferFormat;
import com.gtnewhorizons.angelica.glsm.texture.TextureInfoCache;
import com.gtnewhorizons.angelica.proxy.ClientProxy;
import com.gtnewhorizons.angelica.render.PanoramaRenderer;
import net.coderbot.iris.Iris;
import net.coderbot.iris.gl.framebuffer.GlFramebuffer;
import net.coderbot.iris.pipeline.FixedFunctionWorldRenderingPipeline;
import net.coderbot.iris.rendertarget.IRenderTargetExt;
import net.minecraft.client.Minecraft;
import net.minecraft.client.shader.Framebuffer;
import org.embeddedt.embeddium.impl.gl.shader.GlProgram;
import org.embeddedt.embeddium.impl.gl.shader.ShaderConstants;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import org.lwjgl.opengl.GL13;
import org.lwjgl.opengl.GL30;
import java.nio.ByteBuffer;
/// Draws each [TranslucentLayer] into its own target, seeded with the main depth, and composites the drawn layers over
/// the main framebuffer per pixel, farthest first. Layers hold premultiplied color with coverage alpha (GLSM layer
/// blending), and the composite writes the nearest layer depth.
///
/// The terrain layer has a second sheet for fragments behind the block-entity layer, so a tile entity inside a
/// block's own translucent model is covered only by the faces in front of it.
public final class TranslucencyLayers {
private static final int LAYERS = TranslucentLayer.values().length;
private static final int FIRST_LAYER_UNIT = 1;
private static final int TERRAIN_BEHIND_UNIT = FIRST_LAYER_UNIT + 2 * LAYERS;
private static final int SPLIT_DEPTH_UNIT = TERRAIN_BEHIND_UNIT + 1;
private static final int[] SINGLE_BUFFER = { 0 };
private static final int[] SPLIT_BUFFERS = { 0, 1 };
private static final int[] BEHIND_BUFFER = { 1 };
public static final TranslucencyLayers INSTANCE = new TranslucencyLayers(new MinecraftTarget());
interface MainTarget {
int framebuffer();
int depthTexture();
int width();
int height();
int depthVersion();
}
private final MainTarget main;
private final Target[] layers = new Target[LAYERS];
private Target depthSnapshot;
private int width;
private int height;
private int depthVersion = -1;
private DepthBufferFormat depthFormat;
private boolean decided;
private boolean active;
private int drawnMask;
private TranslucentLayer open;
private int savedDraw;
private int savedRead;
private boolean alphaMasked;
private boolean splitting;
private boolean behindDrawn;
private CompositeProgram program;
private CompositeProgram behindProgram;
private int vao;
private StateSet prepareState;
private StateSet compositeState;
TranslucencyLayers(MainTarget main) {
this.main = main;
}
/// Whether layering applies is decided on the first [#active] call, once Iris has prepared the frame's pipeline.
public void beginFrame() {
decided = false;
drawnMask = 0;
behindDrawn = false;
}
void beginFrame(boolean active) {
this.active = active;
decided = true;
drawnMask = 0;
behindDrawn = false;
}
public boolean active() {
if (!decided) {
active = ClientProxy.options().performance.translucencyMode.composites() && Iris.enabled
&& Iris.getPipelineManager().getPipelineNullable() instanceof FixedFunctionWorldRenderingPipeline;
decided = true;
}
return active;
}
public boolean beginIfActive(TranslucentLayer layer) {
if (!active()) return false;
begin(layer);
return true;
}
public void begin(TranslucentLayer layer) {
if (open != null) throw new IllegalStateException("Translucency layer " + open + " is still open");
BatchStateGuard.beforeChange();
savedDraw = GLSMFramebuffer.getDrawFramebuffer();
savedRead = GLSMFramebuffer.getReadFramebuffer();
syncSize();
final Target target = layer(layer);
final int bit = 1 << layer.ordinal();
if ((drawnMask & bit) == 0) {
drawnMask |= bit;
prepare(target);
}
target.framebuffer.bind();
open = layer;
GLSMBlend.setLayerBlending(true);
final ColorMaskStack mask = GLSMBlend.getColorMask();
alphaMasked = !mask.alpha;
if (alphaMasked) GLSMBlend.glColorMask(mask.red, mask.green, mask.blue, true);
}
public void end() {
BatchStateGuard.beforeChange();
if (alphaMasked) {
final ColorMaskStack mask = GLSMBlend.getColorMask();
GLSMBlend.glColorMask(mask.red, mask.green, mask.blue, false);
}
GLSMBlend.setLayerBlending(false);
GLSMFramebuffer.glBindFramebuffer(GL30.GL_DRAW_FRAMEBUFFER, savedDraw);
GLSMFramebuffer.glBindFramebuffer(GL30.GL_READ_FRAMEBUFFER, savedRead);
open = null;
}
public boolean redirectsMainBind() {
return open != null;
}
public void bindOpenLayer() {
layers[open.ordinal()].framebuffer.bind();
}
public void beginTerrainSplit(int program) {
splitting = open == TranslucentLayer.TERRAIN && (drawnMask & (1 << TranslucentLayer.BLOCK_ENTITIES.ordinal())) != 0;
GLSMPrograms.glUniform1i(GLSMPrograms.glGetUniformLocation(program, "u_SplitEnabled"), splitting ? 1 : 0);
if (!splitting) return;
GLSMPrograms.glUniform1i(GLSMPrograms.glGetUniformLocation(program, "u_SplitDepth"), SPLIT_DEPTH_UNIT);
final Target terrain = layers[TranslucentLayer.TERRAIN.ordinal()];
if (!behindDrawn) {
behindDrawn = true;
terrain.attachBehind(width, height);
terrain.framebuffer.drawBuffers(BEHIND_BUFFER);
clear(terrain);
}
final int unit = GLSMTextures.getActiveTextureUnit();
bindTexture(SPLIT_DEPTH_UNIT, layers[TranslucentLayer.BLOCK_ENTITIES.ordinal()].depth);
GLSMTextures.glActiveTexture(GL13.GL_TEXTURE0 + unit);
terrain.framebuffer.drawBuffers(SPLIT_BUFFERS);
}
public void endTerrainSplit() {
if (!splitting) return;
splitting = false;
layers[TranslucentLayer.TERRAIN.ordinal()].framebuffer.drawBuffers(SINGLE_BUFFER);
final int unit = GLSMTextures.getActiveTextureUnit();
bindTexture(SPLIT_DEPTH_UNIT, 0);
GLSMTextures.glActiveTexture(GL13.GL_TEXTURE0 + unit);
}
public void composite() {
if (drawnMask == 0) return;
BatchStateGuard.beforeChange();
final int draw = GLSMFramebuffer.getDrawFramebuffer();
final int read = GLSMFramebuffer.getReadFramebuffer();
final int activeProgram = GLSMPrograms.getActiveProgram();
final int activeVao = GLSMQueries.glGetInteger(GL30.GL_VERTEX_ARRAY_BINDING);
if (program == null) initProgram();
syncSize();
if (drawnMask == 0) return;
final Target snapshot = depthSnapshot();
final int depth = GLSMAttribStack.pushState(compositeState);
try {
GLSMRasterizer.disableScissorTest();
blit(main.framebuffer(), snapshot.framebuffer.getId(), GL11.GL_DEPTH_BUFFER_BIT);
GLSMFramebuffer.glBindFramebuffer(GL30.GL_FRAMEBUFFER, main.framebuffer());
GLSMRasterizer.glViewport(0, 0, width, height);
GLSMBlend.enableBlend();
GLSMBlend.tryBlendFuncSeparate(GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ZERO, GL11.GL_ONE);
GLSMRasterizer.disableCull();
GLSMDepthStencilAlpha.enableDepthTest();
GLSMDepthStencilAlpha.glDepthFunc(GL11.GL_ALWAYS);
GLSMDepthStencilAlpha.glDepthMask(true);
bindTexture(0, snapshot.depth);
for (int i = 0; i < LAYERS; i++) {
if ((drawnMask & (1 << i)) == 0) continue;
bindTexture(FIRST_LAYER_UNIT + i, layers[i].color);
bindTexture(FIRST_LAYER_UNIT + LAYERS + i, layers[i].depth);
}
if (behindDrawn) bindTexture(TERRAIN_BEHIND_UNIT, layers[TranslucentLayer.TERRAIN.ordinal()].behind);
final CompositeProgram composite = behindDrawn ? behindProgram : program;
GLSMPrograms.glUseProgram(composite.program.handle());
GLSMPrograms.glUniform1i(composite.maskUniform, drawnMask);
GLSMVertexInput.glBindVertexArray(vao);
GLSMDraws.glDrawArrays(GL11.GL_TRIANGLES, 0, 3);
} finally {
GLSMVertexInput.glBindVertexArray(activeVao);
GLSMPrograms.glUseProgram(activeProgram);
GLSMFramebuffer.glBindFramebuffer(GL30.GL_DRAW_FRAMEBUFFER, draw);
GLSMFramebuffer.glBindFramebuffer(GL30.GL_READ_FRAMEBUFFER, read);
GLSMAttribStack.popStateTo(depth);
drawnMask = 0;
behindDrawn = false;
}
}
public void destroy() {
destroyTargets();
if (program != null) {
program.program.delete();
behindProgram.program.delete();
GLSMVertexInput.glDeleteVertexArrays(vao);
program = null;
behindProgram = null;
}
}
private void initProgram() {
program = new CompositeProgram("angelica:translucency_composite", ShaderConstants.EMPTY);
behindProgram = new CompositeProgram("angelica:translucency_composite_behind", ShaderConstants.builder().add("TERRAIN_BEHIND").build());
vao = GLSMVertexInput.glGenVertexArrays();
compositeState = StateSet.forMask(GL11.GL_ALL_ATTRIB_BITS);
}
private void prepare(Target target) {
clear(target);
blit(main.framebuffer(), target.framebuffer.getId(), depthFormat.isCombinedStencil() ? GL11.GL_DEPTH_BUFFER_BIT | GL11.GL_STENCIL_BUFFER_BIT : GL11.GL_DEPTH_BUFFER_BIT);
}
private void clear(Target target) {
if (prepareState == null) prepareState = StateSet.forMask(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_SCISSOR_BIT);
final int depth = GLSMAttribStack.pushState(prepareState);
try {
GLSMRasterizer.disableScissorTest();
GLSMBlend.glColorMask(true, true, true, true);
target.framebuffer.bind();
GLSMBlend.glClearColor(0f, 0f, 0f, 0f);
GLSMFramebuffer.glClear(GL11.GL_COLOR_BUFFER_BIT);
} finally {
GLSMAttribStack.popStateTo(depth);
}
}
private void blit(int from, int to, int mask) {
GLSMFramebuffer.glBindFramebuffer(GL30.GL_READ_FRAMEBUFFER, from);
GLSMFramebuffer.glBindFramebuffer(GL30.GL_DRAW_FRAMEBUFFER, to);
GLSMFramebuffer.glBlitFramebuffer(0, 0, width, height, 0, 0, width, height, mask, GL11.GL_NEAREST);
}
private static void bindTexture(int unit, int texture) {
GLSMTextures.glActiveTexture(GL13.GL_TEXTURE0 + unit);
GLSMTextures.glBindTexture(GL11.GL_TEXTURE_2D, texture);
}
private void syncSize() {
if (main.width() == width && main.height() == height && main.depthVersion() == depthVersion) return;
destroyTargets();
width = main.width();
height = main.height();
depthVersion = main.depthVersion();
depthFormat = DepthBufferFormat.fromGlEnumOrDefault(TextureInfoCache.INSTANCE.getInfo(main.depthTexture()).getInternalFormat());
}
private Target layer(TranslucentLayer layer) {
final int i = layer.ordinal();
if (layers[i] == null) layers[i] = new Target(width, height, depthFormat, true);
return layers[i];
}
private Target depthSnapshot() {
if (depthSnapshot == null) depthSnapshot = new Target(width, height, depthFormat, false);
return depthSnapshot;
}
private void destroyTargets() {
for (int i = 0; i < LAYERS; i++) {
if (layers[i] != null) layers[i].destroy();
layers[i] = null;
}
if (depthSnapshot != null) depthSnapshot.destroy();
depthSnapshot = null;
drawnMask = 0;
behindDrawn = false;
}
private static final class CompositeProgram {
final GlProgram<Object> program;
final int maskUniform;
CompositeProgram(String name, ShaderConstants constants) {
program = PanoramaRenderer.loadProgram(name, "angelica:panorama_blur", "angelica:translucency_composite", constants, ctx -> ctx);
final int handle = program.handle();
GLSMPrograms.glUseProgram(handle);
GLSMPrograms.glUniform1i(GLSMPrograms.glGetUniformLocation(handle, "u_Depth"), 0);
for (int i = 0; i < LAYERS; i++) {
GLSMPrograms.glUniform1i(GLSMPrograms.glGetUniformLocation(handle, "u_Layer" + i), FIRST_LAYER_UNIT + i);
GLSMPrograms.glUniform1i(GLSMPrograms.glGetUniformLocation(handle, "u_LayerDepth" + i), FIRST_LAYER_UNIT + LAYERS + i);
}
GLSMPrograms.glUniform1i(GLSMPrograms.glGetUniformLocation(handle, "u_TerrainBehind"), TERRAIN_BEHIND_UNIT);
maskUniform = GLSMPrograms.glGetUniformLocation(handle, "u_LayerMask");
GLSMPrograms.glUseProgram(0);
}
}
private static final class Target {
final int color;
final int depth;
final GlFramebuffer framebuffer;
int behind;
Target(int width, int height, DepthBufferFormat depthFormat, boolean withColor) {
depth = texture(width, height, depthFormat.getGlInternalFormat(), depthFormat.getGlType(), depthFormat.getGlFormat());
framebuffer = new GlFramebuffer();
framebuffer.addDepthAttachment(depth);
if (withColor) {
color = texture(width, height, GL11.GL_RGBA8, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE);
framebuffer.addColorAttachment(0, color);
framebuffer.drawBuffers(SINGLE_BUFFER);
framebuffer.readBuffer(0);
} else {
color = 0;
framebuffer.noDrawBuffers();
RenderSystem.readBuffer(framebuffer.getId(), GL11.GL_NONE);
}
}
void attachBehind(int width, int height) {
if (behind != 0) return;
behind = texture(width, height, GL11.GL_RGBA8, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE);
framebuffer.addColorAttachment(1, behind);
}
private static int texture(int width, int height, int internalFormat, int format, int type) {
final int previous = GLSMQueries.glGetInteger(GL11.GL_TEXTURE_BINDING_2D);
final int texture = GLSMTextures.glGenTextures();
GLSMTextures.glBindTexture(GL11.GL_TEXTURE_2D, texture);
GLSMTextures.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
GLSMTextures.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
GLSMTextures.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE);
GLSMTextures.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE);
GLSMTextures.glTexImage2D(GL11.GL_TEXTURE_2D, 0, internalFormat, width, height, 0, format, type, (ByteBuffer) null);
GLSMTextures.glBindTexture(GL11.GL_TEXTURE_2D, previous);
return texture;
}
void destroy() {
framebuffer.destroy();
if (color != 0) GLSMTextures.glDeleteTextures(color);
if (behind != 0) GLSMTextures.glDeleteTextures(behind);
GLSMTextures.glDeleteTextures(depth);
}
}
private static final class MinecraftTarget implements MainTarget {
private static Framebuffer fb() {
return Minecraft.getMinecraft().getFramebuffer();
}
@Override public int framebuffer() { return fb().framebufferObject; }
@Override public int depthTexture() { return ((IRenderTargetExt) fb()).iris$getDepthTextureId(); }
@Override public int width() { return fb().framebufferWidth; }
@Override public int height() { return fb().framebufferHeight; }
@Override public int depthVersion() { return ((IRenderTargetExt) fb()).iris$getDepthBufferVersion(); }
}
}
@@ -0,0 +1,9 @@
package com.gtnewhorizons.angelica.rendering.translucency;
public enum TranslucentLayer {
TERRAIN,
BLOCK_ENTITIES,
PARTICLES,
WEATHER,
CLOUDS
}