Skip to content

Commit

Permalink
Merge support for DH 2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
IMS212 committed Jul 31, 2024
2 parents 67938d2 + 77e3c8e commit b6f3ce5
Show file tree
Hide file tree
Showing 25 changed files with 667 additions and 82 deletions.
Binary file modified DHApi.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -21,34 +21,36 @@

import com.seibel.distanthorizons.api.enums.EDhApiDetailLevel;
import com.seibel.distanthorizons.api.interfaces.override.IDhApiOverrideable;
import com.seibel.distanthorizons.coreapi.util.math.Mat4f;
import com.seibel.distanthorizons.api.objects.math.DhApiMat4f;

/**
* Used to determine if a LOD should be rendered or is outside the
* user's field of view.
*
* @author James Seibel
* @version 2024-2-6
* @since API 1.1.0
* @since API 2.0.0
*/
public interface IDhApiCullingFrustum extends IDhApiOverrideable {
public interface IDhApiCullingFrustum extends IDhApiOverrideable
{

/**
* Called before a render pass is done.
*
* @param worldMinBlockY the lowest block position this level allows.
* @param worldMaxBlockY the highest block position this level allows.
* @param worldMinBlockY the lowest block position this level allows.
* @param worldMaxBlockY the highest block position this level allows.
* @param worldViewProjection the projection matrix used in this render pass.
*/
void update(int worldMinBlockY, int worldMaxBlockY, Mat4f worldViewProjection);
void update(int worldMinBlockY, int worldMaxBlockY, DhApiMat4f worldViewProjection);

/**
* returns true if the LOD bounds intersect this frustum
*
* @param lodBlockPosMinX this LOD's starting block X position closest to negative infinity
* @param lodBlockPosMinZ this LOD's starting block Z position closest to negative infinity
* @param lodBlockWidth this LOD's width in blocks
* @param lodDetailLevel this LOD's detail level
* @param lodBlockWidth this LOD's width in blocks
* @param lodDetailLevel this LOD's detail level
*
* @see EDhApiDetailLevel
*/
boolean intersects(int lodBlockPosMinX, int lodBlockPosMinZ, int lodBlockWidth, int lodDetailLevel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

import com.mojang.blaze3d.systems.RenderSystem;
import com.seibel.distanthorizons.api.DhApi;
import com.seibel.distanthorizons.api.interfaces.override.IDhApiOverrideable;
import com.seibel.distanthorizons.api.interfaces.override.rendering.IDhApiFramebuffer;
import com.seibel.distanthorizons.api.interfaces.override.rendering.IDhApiGenericObjectShaderProgram;
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiRenderParam;
import com.seibel.distanthorizons.api.objects.math.DhApiVec3f;
import com.seibel.distanthorizons.coreapi.DependencyInjection.OverrideInjector;
import com.seibel.distanthorizons.coreapi.util.math.Vec3f;
import net.irisshaders.iris.Iris;
import net.irisshaders.iris.api.v0.IrisApi;
import net.irisshaders.iris.gl.IrisRenderSystem;
Expand All @@ -13,6 +16,7 @@
import net.irisshaders.iris.gl.texture.DepthCopyStrategy;
import net.irisshaders.iris.pipeline.IrisRenderingPipeline;
import net.irisshaders.iris.shaderpack.programs.ProgramSource;
import net.irisshaders.iris.shaderpack.properties.CloudSetting;
import net.irisshaders.iris.targets.Blaze3dRenderTargetExt;
import net.irisshaders.iris.targets.DepthTexture;
import net.irisshaders.iris.uniforms.CapturedRenderingState;
Expand All @@ -26,9 +30,11 @@ public class DHCompatInternal {
static boolean dhEnabled;
private static int guiScale = -1;
private final IrisRenderingPipeline pipeline;
private GlFramebuffer dhGenericFramebuffer;
public boolean shouldOverrideShadow;
public boolean shouldOverride;
private IrisLodRenderProgram solidProgram;
private IrisGenericRenderProgram genericShader;
private IrisLodRenderProgram translucentProgram;
private IrisLodRenderProgram shadowProgram;
private GlFramebuffer dhTerrainFramebuffer;
Expand All @@ -54,6 +60,7 @@ public DHCompatInternal(IrisRenderingPipeline pipeline, boolean dhShadowEnabled)
incompatible = true;
return;
}

cachedVersion = ((Blaze3dRenderTargetExt) Minecraft.getInstance().getMainRenderTarget()).iris$getDepthBufferVersion();

createDepthTex(Minecraft.getInstance().getMainRenderTarget().width, Minecraft.getInstance().getMainRenderTarget().height);
Expand All @@ -62,6 +69,10 @@ public DHCompatInternal(IrisRenderingPipeline pipeline, boolean dhShadowEnabled)
ProgramSource terrain = pipeline.getDHTerrainShader().get();
solidProgram = IrisLodRenderProgram.createProgram(terrain.getName(), false, false, terrain, pipeline.getCustomUniforms(), pipeline);

ProgramSource generic = pipeline.getDHGenericShader().get();
genericShader = IrisGenericRenderProgram.createProgram(generic.getName() + "_g", false, false, generic, pipeline.getCustomUniforms(), pipeline);
dhGenericFramebuffer = pipeline.createDHFramebuffer(generic, false);

if (pipeline.getDHWaterShader().isPresent()) {
ProgramSource water = pipeline.getDHWaterShader().get();
translucentProgram = IrisLodRenderProgram.createProgram(water.getName(), false, true, water, pipeline.getCustomUniforms(), pipeline);
Expand Down Expand Up @@ -160,6 +171,9 @@ public void reconnectDHTextures(int depthTex) {
if (dhWaterFramebuffer != null) {
dhWaterFramebuffer.addDepthAttachment(depthTex);
}
if (dhGenericFramebuffer != null) {
dhGenericFramebuffer.addDepthAttachment(depthTex);
}
}
}

Expand Down Expand Up @@ -196,12 +210,13 @@ public void clear() {
translucentDepthDirty = true;

OverrideInjector.INSTANCE.unbind(IDhApiFramebuffer.class, dhTerrainFramebufferWrapper);
OverrideInjector.INSTANCE.unbind(IDhApiGenericObjectShaderProgram.class, genericShader);
OverrideInjector.INSTANCE.unbind(IDhApiFramebuffer.class, dhShadowFramebufferWrapper);
dhTerrainFramebufferWrapper = null;
dhShadowFramebufferWrapper = null;
}

public void setModelPos(Vec3f modelPos) {
public void setModelPos(DhApiVec3f modelPos) {
solidProgram.bind();
solidProgram.setModelPos(modelPos);
translucentProgram.bind();
Expand Down Expand Up @@ -259,9 +274,21 @@ public GlFramebuffer getTranslucentFB() {
return dhWaterFramebuffer;
}

public GlFramebuffer getGenericFB() {
return dhGenericFramebuffer;
}

public int getDepthTexNoTranslucent() {
if (depthTexNoTranslucent == null) return 0;

return depthTexNoTranslucent.getTextureId();
}

public IDhApiGenericObjectShaderProgram getGenericShader() {
return genericShader;
}

public boolean avoidRenderingClouds() {
return pipeline.getDHCloudSetting() == CloudSetting.OFF || (pipeline.getDHCloudSetting() == CloudSetting.DEFAULT && pipeline.getCloudSetting() == CloudSetting.OFF);
}
}
Loading

0 comments on commit b6f3ce5

Please sign in to comment.