Support render scaling factor in shaders
This commit is contained in:
@@ -215,4 +215,7 @@ public abstract class AbstractRenderPipeline extends TrackedObject {
|
||||
return null;
|
||||
}
|
||||
|
||||
//Null means no scaling factor
|
||||
public float[] getRenderScalingFactor() {return null;}
|
||||
|
||||
}
|
||||
|
||||
@@ -227,8 +227,13 @@ public class IrisVoxyRenderPipeline extends AbstractRenderPipeline {
|
||||
}
|
||||
|
||||
builder.append("vec2 ").append(functionName).append("()\n");
|
||||
builder.append(this.data.getTAAOffset());
|
||||
builder.append(this.data.TAA);
|
||||
builder.append("\n");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float[] getRenderScalingFactor() {
|
||||
return this.data.resolutionScale;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,6 +174,14 @@ public class VoxyRenderSystem {
|
||||
int width = dims[2];
|
||||
int height = dims[3];
|
||||
|
||||
{//Apply render scaling factor
|
||||
var factor = this.pipeline.getRenderScalingFactor();
|
||||
if (factor != null) {
|
||||
width = (int) (width*factor[0]);
|
||||
height = (int) (height*factor[1]);
|
||||
}
|
||||
}
|
||||
|
||||
viewport
|
||||
.setVanillaProjection(matrices.projection())
|
||||
.setProjection(projection)
|
||||
|
||||
@@ -156,6 +156,7 @@ public class IrisShaderPatch {
|
||||
public Int2ObjectOpenHashMap<BlendState> blending;
|
||||
public String taaOffset;
|
||||
public boolean excludeLodsFromVanillaDepth;
|
||||
public float[] renderScale;
|
||||
public boolean checkValid() {
|
||||
return this.opaqueDrawBuffers != null && this.translucentDrawBuffers != null && this.uniforms != null && this.opaquePatchData != null;
|
||||
}
|
||||
@@ -209,6 +210,16 @@ public class IrisShaderPatch {
|
||||
return !this.patchData.excludeLodsFromVanillaDepth;
|
||||
}
|
||||
|
||||
public float[] getRenderScale() {
|
||||
if (this.patchData.renderScale == null || this.patchData.renderScale.length==0) {
|
||||
return new float[]{1,1};
|
||||
}
|
||||
if (this.patchData.renderScale.length == 1) {
|
||||
return new float[]{this.patchData.renderScale[0],this.patchData.renderScale[0]};
|
||||
}
|
||||
return new float[]{Math.max(0.01f,this.patchData.renderScale[0]),Math.max(0.01f,this.patchData.renderScale[1])};
|
||||
}
|
||||
|
||||
public Runnable createBlendSetup() {
|
||||
if (this.patchData.blending == null || this.patchData.blending.isEmpty()) {
|
||||
return ()->{};//No blending change
|
||||
|
||||
@@ -47,7 +47,8 @@ public class IrisVoxyRenderPipelineData {
|
||||
private final ImageSet imageSet;
|
||||
private final SSBOSet ssboSet;
|
||||
public final boolean renderToVanillaDepth;
|
||||
private final String TAA;
|
||||
public final float[] resolutionScale;
|
||||
public final String TAA;
|
||||
private IrisVoxyRenderPipelineData(IrisShaderPatch patch, int[] opaqueDrawTargets, int[] translucentDrawTargets, StructLayout uniformSet, Runnable blendingSetup, ImageSet imageSet, SSBOSet ssboSet) {
|
||||
this.opaqueDrawTargets = opaqueDrawTargets;
|
||||
this.translucentDrawTargets = translucentDrawTargets;
|
||||
@@ -59,6 +60,7 @@ public class IrisVoxyRenderPipelineData {
|
||||
this.ssboSet = ssboSet;
|
||||
this.renderToVanillaDepth = patch.emitToVanillaDepth();
|
||||
this.TAA = patch.getTAAShift();
|
||||
this.resolutionScale = patch.getRenderScale();
|
||||
}
|
||||
|
||||
public SSBOSet getSsboSet() {
|
||||
@@ -109,10 +111,6 @@ public class IrisVoxyRenderPipelineData {
|
||||
return targetTextures;
|
||||
}
|
||||
|
||||
public String getTAAOffset() {
|
||||
return this.TAA;
|
||||
}
|
||||
|
||||
public record StructLayout(int size, String layout, LongConsumer updater) {}
|
||||
private static StructLayout createUniformLayoutStructAndUpdater(CachedUniform[] uniforms) {
|
||||
if (uniforms.length == 0) {
|
||||
|
||||
Reference in New Issue
Block a user