attempted taa support
This commit is contained in:
@@ -200,6 +200,11 @@ public abstract class AbstractRenderPipeline extends TrackedObject {
|
|||||||
public abstract void setupAndBindTranslucent(Viewport<?> viewport);
|
public abstract void setupAndBindTranslucent(Viewport<?> viewport);
|
||||||
|
|
||||||
|
|
||||||
|
//null means no function, otherwise return the taa injection function
|
||||||
|
public String taaFunction(AbstractSectionRenderer<?,?> renderer, String functionName) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
//null means dont transform the shader
|
//null means dont transform the shader
|
||||||
public String patchOpaqueShader(AbstractSectionRenderer<?,?> renderer, String input) {
|
public String patchOpaqueShader(AbstractSectionRenderer<?,?> renderer, String input) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -172,12 +172,13 @@ public class IrisVoxyRenderPipeline extends AbstractRenderPipeline {
|
|||||||
super.addDebug(debug);
|
super.addDebug(debug);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final int UNIFORM_BINDING_POINT = 5;//TODO make ths binding point... not randomly 5
|
||||||
|
|
||||||
private StringBuilder buildGenericShaderHeader(AbstractSectionRenderer<?, ?> renderer, String input) {
|
private StringBuilder buildGenericShaderHeader(AbstractSectionRenderer<?, ?> renderer, String input) {
|
||||||
StringBuilder builder = new StringBuilder(input).append("\n\n\n");
|
StringBuilder builder = new StringBuilder(input).append("\n\n\n");
|
||||||
|
|
||||||
if (this.data.getUniforms() != null) {
|
if (this.data.getUniforms() != null) {
|
||||||
//TODO make ths binding point... not randomly 5
|
builder.append("layout(binding = "+UNIFORM_BINDING_POINT+", std140) uniform ShaderUniformBindings ")
|
||||||
builder.append("layout(binding = 5, std140) uniform ShaderUniformBindings ")
|
|
||||||
.append(this.data.getUniforms().layout())
|
.append(this.data.getUniforms().layout())
|
||||||
.append(";\n\n");
|
.append(";\n\n");
|
||||||
}
|
}
|
||||||
@@ -195,6 +196,8 @@ public class IrisVoxyRenderPipeline extends AbstractRenderPipeline {
|
|||||||
return builder.append("\n\n");
|
return builder.append("\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String patchOpaqueShader(AbstractSectionRenderer<?, ?> renderer, String input) {
|
public String patchOpaqueShader(AbstractSectionRenderer<?, ?> renderer, String input) {
|
||||||
var builder = this.buildGenericShaderHeader(renderer, input);
|
var builder = this.buildGenericShaderHeader(renderer, input);
|
||||||
@@ -212,4 +215,20 @@ public class IrisVoxyRenderPipeline extends AbstractRenderPipeline {
|
|||||||
builder.append(this.data.translucentFragPatch());
|
builder.append(this.data.translucentFragPatch());
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String taaFunction(AbstractSectionRenderer<?, ?> renderer, String functionName) {
|
||||||
|
var builder = new StringBuilder();
|
||||||
|
|
||||||
|
if (this.data.getUniforms() != null) {
|
||||||
|
builder.append("layout(binding = "+UNIFORM_BINDING_POINT+", std140) uniform ShaderUniformBindings ")
|
||||||
|
.append(this.data.getUniforms().layout())
|
||||||
|
.append(";\n\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
builder.append("vec2 ").append(functionName).append("()\n");
|
||||||
|
builder.append(this.data.getTAAOffset());
|
||||||
|
builder.append("\n");
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ public class ModelTextureBakery {
|
|||||||
var quads = part.getQuads(direction);
|
var quads = part.getQuads(direction);
|
||||||
for (var quad : quads) {
|
for (var quad : quads) {
|
||||||
//TODO: add meta specifiying quad has a tint
|
//TODO: add meta specifiying quad has a tint
|
||||||
|
//quad.hasTint()
|
||||||
this.vc.quad(quad, meta);
|
this.vc.quad(quad, meta);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -145,7 +145,7 @@ public class ModelTextureBakery {
|
|||||||
public int getBottomY() {
|
public int getBottomY() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}, this.vc, state, state.getFluidState());
|
}, this. vc, state, state.getFluidState());
|
||||||
this.vc.setDefaultMeta(0);//Reset default meta
|
this.vc.setDefaultMeta(0);//Reset default meta
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -93,9 +93,16 @@ public class MDICSectionRenderer extends AbstractSectionRenderer<MDICViewport, B
|
|||||||
super(modelStore, geometryData);
|
super(modelStore, geometryData);
|
||||||
this.pipeline = pipeline;
|
this.pipeline = pipeline;
|
||||||
//The pipeline can be used to transform the renderer in abstract ways
|
//The pipeline can be used to transform the renderer in abstract ways
|
||||||
|
|
||||||
|
String vertex = ShaderLoader.parse("voxy:lod/gl46/quads2.vert");
|
||||||
|
String taa = pipeline.taaFunction(this, "taaShift");
|
||||||
|
if (taa != null) {
|
||||||
|
vertex += "\n"+taa;//inject it at the end
|
||||||
|
}
|
||||||
var builder = Shader.make()
|
var builder = Shader.make()
|
||||||
|
.defineIf("TAA_PATCH", taa != null)
|
||||||
.defineIf("DEBUG_RENDER", false)
|
.defineIf("DEBUG_RENDER", false)
|
||||||
.add(ShaderType.VERTEX, "voxy:lod/gl46/quads2.vert");
|
.addSource(ShaderType.VERTEX, vertex);
|
||||||
|
|
||||||
String frag = ShaderLoader.parse("voxy:lod/gl46/quads.frag");
|
String frag = ShaderLoader.parse("voxy:lod/gl46/quads.frag");
|
||||||
|
|
||||||
|
|||||||
@@ -154,6 +154,7 @@ public class IrisShaderPatch {
|
|||||||
public Int2ObjectOpenHashMap<String> ssbos;
|
public Int2ObjectOpenHashMap<String> ssbos;
|
||||||
@JsonAdapter(BlendStateDeserializer.class)
|
@JsonAdapter(BlendStateDeserializer.class)
|
||||||
public Int2ObjectOpenHashMap<BlendState> blending;
|
public Int2ObjectOpenHashMap<BlendState> blending;
|
||||||
|
public String taaOffset;
|
||||||
public boolean excludeLodsFromVanillaDepth;
|
public boolean excludeLodsFromVanillaDepth;
|
||||||
public boolean checkValid() {
|
public boolean checkValid() {
|
||||||
return this.opaqueDrawBuffers != null && this.translucentDrawBuffers != null && this.uniforms != null && this.opaquePatchData != null;
|
return this.opaqueDrawBuffers != null && this.translucentDrawBuffers != null && this.uniforms != null && this.opaquePatchData != null;
|
||||||
@@ -185,6 +186,9 @@ public class IrisShaderPatch {
|
|||||||
public String getPatchTranslucentSource() {
|
public String getPatchTranslucentSource() {
|
||||||
return this.patchData.translucentPatchData!=null?String.join("\n", this.patchData.translucentPatchData):null;
|
return this.patchData.translucentPatchData!=null?String.join("\n", this.patchData.translucentPatchData):null;
|
||||||
}
|
}
|
||||||
|
public String getTAAShift() {
|
||||||
|
return this.patchData.taaOffset == null?"{return vec2(0.0);}":this.patchData.taaOffset;
|
||||||
|
}
|
||||||
public String[] getUniformList() {
|
public String[] getUniformList() {
|
||||||
return this.patchData.uniforms;
|
return this.patchData.uniforms;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ public class IrisVoxyRenderPipelineData {
|
|||||||
private final ImageSet imageSet;
|
private final ImageSet imageSet;
|
||||||
private final SSBOSet ssboSet;
|
private final SSBOSet ssboSet;
|
||||||
public final boolean renderToVanillaDepth;
|
public final boolean renderToVanillaDepth;
|
||||||
|
private final String TAA;
|
||||||
private IrisVoxyRenderPipelineData(IrisShaderPatch patch, int[] opaqueDrawTargets, int[] translucentDrawTargets, StructLayout uniformSet, Runnable blendingSetup, ImageSet imageSet, SSBOSet ssboSet) {
|
private IrisVoxyRenderPipelineData(IrisShaderPatch patch, int[] opaqueDrawTargets, int[] translucentDrawTargets, StructLayout uniformSet, Runnable blendingSetup, ImageSet imageSet, SSBOSet ssboSet) {
|
||||||
this.opaqueDrawTargets = opaqueDrawTargets;
|
this.opaqueDrawTargets = opaqueDrawTargets;
|
||||||
this.translucentDrawTargets = translucentDrawTargets;
|
this.translucentDrawTargets = translucentDrawTargets;
|
||||||
@@ -57,6 +58,7 @@ public class IrisVoxyRenderPipelineData {
|
|||||||
this.imageSet = imageSet;
|
this.imageSet = imageSet;
|
||||||
this.ssboSet = ssboSet;
|
this.ssboSet = ssboSet;
|
||||||
this.renderToVanillaDepth = patch.emitToVanillaDepth();
|
this.renderToVanillaDepth = patch.emitToVanillaDepth();
|
||||||
|
this.TAA = patch.getTAAShift();
|
||||||
}
|
}
|
||||||
|
|
||||||
public SSBOSet getSsboSet() {
|
public SSBOSet getSsboSet() {
|
||||||
@@ -107,6 +109,10 @@ public class IrisVoxyRenderPipelineData {
|
|||||||
return targetTextures;
|
return targetTextures;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getTAAOffset() {
|
||||||
|
return this.TAA;
|
||||||
|
}
|
||||||
|
|
||||||
public record StructLayout(int size, String layout, LongConsumer updater) {}
|
public record StructLayout(int size, String layout, LongConsumer updater) {}
|
||||||
private static StructLayout createUniformLayoutStructAndUpdater(CachedUniform[] uniforms) {
|
private static StructLayout createUniformLayoutStructAndUpdater(CachedUniform[] uniforms) {
|
||||||
if (uniforms.length == 0) {
|
if (uniforms.length == 0) {
|
||||||
|
|||||||
@@ -80,6 +80,8 @@ ivec3 extractLoDPosition(uvec2 encPos) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
vec2 taaShift();
|
||||||
|
|
||||||
//TODO: add a mechanism so that some quads can ignore backface culling
|
//TODO: add a mechanism so that some quads can ignore backface culling
|
||||||
// this would help alot with stuff like crops as they would look kinda weird i think,
|
// this would help alot with stuff like crops as they would look kinda weird i think,
|
||||||
// same with flowers etc
|
// same with flowers etc
|
||||||
@@ -116,6 +118,9 @@ void main() {
|
|||||||
vec3 pointPos = (cornerPos+swizzelDataAxis(face>>1,vec3(cQuadSize,0)))*(1<<lodLevel)+origin;
|
vec3 pointPos = (cornerPos+swizzelDataAxis(face>>1,vec3(cQuadSize,0)))*(1<<lodLevel)+origin;
|
||||||
gl_Position = MVP*vec4(pointPos, 1.0);
|
gl_Position = MVP*vec4(pointPos, 1.0);
|
||||||
|
|
||||||
|
//Apply taa shift
|
||||||
|
gl_Position.xy *= taaShift()*gl_Position.w;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (cornerIdx == 1) //Only if we are the provoking vertex
|
if (cornerIdx == 1) //Only if we are the provoking vertex
|
||||||
@@ -183,3 +188,7 @@ void main() {
|
|||||||
quadDebug = lodLevel;
|
quadDebug = lodLevel;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef TAA_PATCH
|
||||||
|
vec2 taaShift() {return vec2(0.0);}
|
||||||
|
#endif
|
||||||
Reference in New Issue
Block a user