Closed mikialex closed 5 years ago
this.tickNum++;
const depthPass = pass("depthPass").use(scene.render)
const scenePass = pass("scenePass")
.use(scene.renderScene)
.overrideShading(this.depthShader)
const depthResult = target("depthResult").needDepth().from(depthPass)
const sceneResult = target("sceneResult").needDepth().from(scenePass)
const createTAA = ()=> {
const taaHistory = pingpong("TAAHistory", this.tickNum)
const taaPass = pass("taa").useQuad()
.overrideShading(this.taaShader)
.disableColorClear()
.beforeExecute(() => {
this.engine.unJit();
const VP: Matrix4 = this.engine.globalUniforms.VPMatrix.value
this.taaShading.VPMatrixInverse = this.taaShading.VPMatrixInverse.getInverse(VP, true); // TODO maybe add watch
this.taaShading.sampleCount = this.sampleCount;
})
.input("sceneResult", sceneResult)
.input("depthResult", depthResult)
.input("TAAHistoryOld", taaHistory.ping())
taaHistory.pong().from(taaPass)
return taaHistory
}
const AAedScene = when(this.enableTAA, createTAA().pong(), sceneResult)
const createTSSAO = () => {
const TSSAOHistory = pingpong("TSSAOHistory", this.tickNum)
const tssaoPass = pass("tssao").useQuad()
.overrideShading(this.tssaoShader)
.disableColorClear()
.beforeExecute(() => {
const VP: Matrix4 = this.engine.globalUniforms.VPMatrix.value
this.tssaoShading.VPMatrixInverse = this.tssaoShading.VPMatrixInverse.getInverse(VP, true);
this.tssaoShading.sampleCount = this.sampleCount;
})
.input("depthResult", depthResult)
.input("AOAcc", TSSAOHistory.ping())
TSSAOHistory.pong().from(tssaoPass)
const tssaoCompose = pass("composeAll")
.overrideShading(this.composeShader)
.input("basic", AAedScene)
.input("tssao", TSSAOHistory.pong())
.beforeExecute(() => {
this.composeShading.sampleCount = this.sampleCount;
})
.afterExecute(() => {
this.composeShading.sampleCount = this.sampleCount;
})
.disableColorClear()
return screen().from(tssaoCompose);
}
this.graph.setScreenRoot(
when(this.enableTSSAO, createTSSAO(), AAedScene)
)
perfect solved some left issues: node should create as need, as well as connect as need. Logic is clear and expressive. Code size reduced. No more ugly and ambigus input or from getters to define graph struct. What left todo is impl a node pool to solve pre frame memory allocation issues
better enough~
Consider ship it with new rendergraph api
taaHistory = pingpong("taaHistory")
sounds good