attempted taa support
This commit is contained in:
@@ -200,6 +200,11 @@ public abstract class AbstractRenderPipeline extends TrackedObject {
|
||||
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
|
||||
public String patchOpaqueShader(AbstractSectionRenderer<?,?> renderer, String input) {
|
||||
return null;
|
||||
|
||||
@@ -172,12 +172,13 @@ public class IrisVoxyRenderPipeline extends AbstractRenderPipeline {
|
||||
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) {
|
||||
StringBuilder builder = new StringBuilder(input).append("\n\n\n");
|
||||
|
||||
if (this.data.getUniforms() != null) {
|
||||
//TODO make ths binding point... not randomly 5
|
||||
builder.append("layout(binding = 5, std140) uniform ShaderUniformBindings ")
|
||||
builder.append("layout(binding = "+UNIFORM_BINDING_POINT+", std140) uniform ShaderUniformBindings ")
|
||||
.append(this.data.getUniforms().layout())
|
||||
.append(";\n\n");
|
||||
}
|
||||
@@ -195,6 +196,8 @@ public class IrisVoxyRenderPipeline extends AbstractRenderPipeline {
|
||||
return builder.append("\n\n");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public String patchOpaqueShader(AbstractSectionRenderer<?, ?> renderer, String input) {
|
||||
var builder = this.buildGenericShaderHeader(renderer, input);
|
||||
@@ -212,4 +215,20 @@ public class IrisVoxyRenderPipeline extends AbstractRenderPipeline {
|
||||
builder.append(this.data.translucentFragPatch());
|
||||
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);
|
||||
for (var quad : quads) {
|
||||
//TODO: add meta specifiying quad has a tint
|
||||
|
||||
//quad.hasTint()
|
||||
this.vc.quad(quad, meta);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,9 +93,16 @@ public class MDICSectionRenderer extends AbstractSectionRenderer<MDICViewport, B
|
||||
super(modelStore, geometryData);
|
||||
this.pipeline = pipeline;
|
||||
//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()
|
||||
.defineIf("TAA_PATCH", taa != null)
|
||||
.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");
|
||||
|
||||
|
||||
@@ -154,6 +154,7 @@ public class IrisShaderPatch {
|
||||
public Int2ObjectOpenHashMap<String> ssbos;
|
||||
@JsonAdapter(BlendStateDeserializer.class)
|
||||
public Int2ObjectOpenHashMap<BlendState> blending;
|
||||
public String taaOffset;
|
||||
public boolean excludeLodsFromVanillaDepth;
|
||||
public boolean checkValid() {
|
||||
return this.opaqueDrawBuffers != null && this.translucentDrawBuffers != null && this.uniforms != null && this.opaquePatchData != null;
|
||||
@@ -185,6 +186,9 @@ public class IrisShaderPatch {
|
||||
public String getPatchTranslucentSource() {
|
||||
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() {
|
||||
return this.patchData.uniforms;
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@ public class IrisVoxyRenderPipelineData {
|
||||
private final ImageSet imageSet;
|
||||
private final SSBOSet ssboSet;
|
||||
public final boolean renderToVanillaDepth;
|
||||
private 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;
|
||||
@@ -57,6 +58,7 @@ public class IrisVoxyRenderPipelineData {
|
||||
this.imageSet = imageSet;
|
||||
this.ssboSet = ssboSet;
|
||||
this.renderToVanillaDepth = patch.emitToVanillaDepth();
|
||||
this.TAA = patch.getTAAShift();
|
||||
}
|
||||
|
||||
public SSBOSet getSsboSet() {
|
||||
@@ -107,6 +109,10 @@ 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) {
|
||||
|
||||
@@ -80,6 +80,8 @@ ivec3 extractLoDPosition(uvec2 encPos) {
|
||||
}
|
||||
|
||||
|
||||
vec2 taaShift();
|
||||
|
||||
//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,
|
||||
// same with flowers etc
|
||||
@@ -116,6 +118,9 @@ void main() {
|
||||
vec3 pointPos = (cornerPos+swizzelDataAxis(face>>1,vec3(cQuadSize,0)))*(1<<lodLevel)+origin;
|
||||
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
|
||||
@@ -183,3 +188,7 @@ void main() {
|
||||
quadDebug = lodLevel;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef TAA_PATCH
|
||||
vec2 taaShift() {return vec2(0.0);}
|
||||
#endif
|
||||
Reference in New Issue
Block a user