Render path cleanup
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package arm.render;
|
||||
|
||||
import kha.System;
|
||||
import iron.math.Vec4;
|
||||
import iron.math.Mat4;
|
||||
import iron.math.Quat;
|
||||
@@ -188,7 +189,38 @@ class RenderPathBase {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function commandsBloom(tex = "tex") {
|
||||
public static function commands(drawCommands: Void->Void) {
|
||||
if (System.windowWidth() == 0 || System.windowHeight() == 0) return;
|
||||
|
||||
RenderPathBase.begin();
|
||||
if (RenderPathBase.isCached()) return;
|
||||
|
||||
// Match projection matrix jitter
|
||||
var skipTaa = Context.splitView || ((Context.tool == ToolClone || Context.tool == ToolBlur) && Context.pdirty > 0);
|
||||
@:privateAccess Scene.active.camera.frame = skipTaa ? 0 : RenderPathDeferred.taaFrame;
|
||||
@:privateAccess Scene.active.camera.projectionJitter();
|
||||
Scene.active.camera.buildMatrix();
|
||||
|
||||
RenderPathPaint.begin();
|
||||
RenderPathBase.drawSplit(drawCommands);
|
||||
RenderPathDeferred.drawGbuffer();
|
||||
RenderPathPaint.draw();
|
||||
|
||||
#if (kha_direct3d12 || kha_vulkan)
|
||||
if (Context.viewportMode == ViewPathTrace) {
|
||||
var useLiveLayer = arm.ui.UIHeader.inst.worktab.position == SpaceMaterial;
|
||||
RenderPathRaytrace.draw(useLiveLayer);
|
||||
return;
|
||||
}
|
||||
#end
|
||||
|
||||
drawCommands();
|
||||
RenderPathPaint.end();
|
||||
RenderPathBase.end();
|
||||
RenderPathDeferred.taaFrame++;
|
||||
}
|
||||
|
||||
public static function commandsBloom() {
|
||||
if (Config.raw.rp_bloom != false) {
|
||||
if (bloomMipmaps == null) {
|
||||
bloomMipmaps = [];
|
||||
@@ -227,16 +259,46 @@ class RenderPathBase {
|
||||
bloomCurrentMip = i;
|
||||
path.setTarget(bloomMipmaps[i].raw.name);
|
||||
path.clearTarget();
|
||||
path.bindTarget(i == 0 ? tex : bloomMipmaps[i - 1].raw.name, "tex");
|
||||
path.bindTarget(i == 0 ? "tex" : bloomMipmaps[i - 1].raw.name, "tex");
|
||||
path.drawShader("shader_datas/bloom_pass/bloom_downsample_pass");
|
||||
}
|
||||
for (i in 0...numMips) {
|
||||
var mipLevel = numMips - 1 - i;
|
||||
bloomCurrentMip = mipLevel;
|
||||
path.setTarget(mipLevel == 0 ? tex : bloomMipmaps[mipLevel - 1].raw.name);
|
||||
path.setTarget(mipLevel == 0 ? "tex" : bloomMipmaps[mipLevel - 1].raw.name);
|
||||
path.bindTarget(bloomMipmaps[mipLevel].raw.name, "tex");
|
||||
path.drawShader("shader_datas/bloom_pass/bloom_upsample_pass");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function drawSplit(drawCommands: Void->Void) {
|
||||
if (Context.splitView && !Context.paint2dView) {
|
||||
#if (kha_metal || krom_android)
|
||||
Context.ddirty = 2;
|
||||
#else
|
||||
Context.ddirty = 1;
|
||||
#end
|
||||
var cam = Scene.active.camera;
|
||||
|
||||
Context.viewIndex = Context.viewIndex == 0 ? 1 : 0;
|
||||
cam.transform.setMatrix(arm.Camera.inst.views[Context.viewIndex]);
|
||||
cam.buildMatrix();
|
||||
cam.buildProjection();
|
||||
|
||||
RenderPathDeferred.drawGbuffer();
|
||||
|
||||
#if (kha_direct3d12 || kha_vulkan)
|
||||
var useLiveLayer = arm.ui.UIHeader.inst.worktab.position == SpaceMaterial;
|
||||
Context.viewportMode == ViewPathTrace ? RenderPathRaytrace.draw(useLiveLayer) : drawCommands();
|
||||
#else
|
||||
drawCommands();
|
||||
#end
|
||||
|
||||
Context.viewIndex = Context.viewIndex == 0 ? 1 : 0;
|
||||
cam.transform.setMatrix(arm.Camera.inst.views[Context.viewIndex]);
|
||||
cam.buildMatrix();
|
||||
cam.buildProjection();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package arm.render;
|
||||
|
||||
import kha.System;
|
||||
import iron.RenderPath;
|
||||
import iron.Scene;
|
||||
import arm.shader.MakeMesh;
|
||||
@@ -152,34 +151,7 @@ class RenderPathDeferred {
|
||||
}
|
||||
|
||||
public static function commands() {
|
||||
if (System.windowWidth() == 0 || System.windowHeight() == 0) return;
|
||||
|
||||
RenderPathBase.begin();
|
||||
if (RenderPathBase.isCached()) return;
|
||||
|
||||
// Match projection matrix jitter
|
||||
var skipTaa = Context.splitView || ((Context.tool == ToolClone || Context.tool == ToolBlur) && Context.pdirty > 0);
|
||||
@:privateAccess Scene.active.camera.frame = skipTaa ? 0 : RenderPathDeferred.taaFrame;
|
||||
@:privateAccess Scene.active.camera.projectionJitter();
|
||||
Scene.active.camera.buildMatrix();
|
||||
|
||||
RenderPathPaint.begin();
|
||||
drawSplit();
|
||||
drawGbuffer();
|
||||
RenderPathPaint.draw();
|
||||
|
||||
#if (kha_direct3d12 || kha_vulkan)
|
||||
if (Context.viewportMode == ViewPathTrace) {
|
||||
var useLiveLayer = arm.ui.UIHeader.inst.worktab.position == SpaceMaterial;
|
||||
RenderPathRaytrace.draw(useLiveLayer);
|
||||
return;
|
||||
}
|
||||
#end
|
||||
|
||||
drawDeferred();
|
||||
RenderPathPaint.end();
|
||||
RenderPathBase.end();
|
||||
taaFrame++;
|
||||
RenderPathBase.commands(drawDeferred);
|
||||
}
|
||||
|
||||
public static function drawDeferred() {
|
||||
@@ -428,8 +400,8 @@ class RenderPathDeferred {
|
||||
}
|
||||
}
|
||||
|
||||
public static function drawGbuffer(gbuffer0 = "gbuffer0", gbuffer1 = "gbuffer1", gbuffer2 = "gbuffer2") {
|
||||
path.setTarget(gbuffer0); // Only clear gbuffer0
|
||||
public static function drawGbuffer() {
|
||||
path.setTarget("gbuffer0"); // Only clear gbuffer0
|
||||
#if kha_metal
|
||||
path.clearTarget(0x00000000, 1.0);
|
||||
#else
|
||||
@@ -439,7 +411,7 @@ class RenderPathDeferred {
|
||||
path.setTarget("gbuffer2");
|
||||
path.clearTarget(0xff000000);
|
||||
}
|
||||
path.setTarget(gbuffer0, [gbuffer1, gbuffer2]);
|
||||
path.setTarget("gbuffer0", ["gbuffer1", "gbuffer2"]);
|
||||
var currentG = path.currentG;
|
||||
RenderPathPaint.bindLayers();
|
||||
path.drawMeshes("mesh");
|
||||
@@ -515,34 +487,4 @@ class RenderPathDeferred {
|
||||
path.bindTarget("gbuffer2_copy", "tex2");
|
||||
path.drawShader("shader_datas/copy_mrt3_pass/copy_mrt3RGBA64_pass");
|
||||
}
|
||||
|
||||
static function drawSplit() {
|
||||
if (Context.splitView && !Context.paint2dView) {
|
||||
#if (kha_metal || krom_android)
|
||||
Context.ddirty = 2;
|
||||
#else
|
||||
Context.ddirty = 1;
|
||||
#end
|
||||
var cam = Scene.active.camera;
|
||||
|
||||
Context.viewIndex = Context.viewIndex == 0 ? 1 : 0;
|
||||
cam.transform.setMatrix(arm.Camera.inst.views[Context.viewIndex]);
|
||||
cam.buildMatrix();
|
||||
cam.buildProjection();
|
||||
|
||||
RenderPathDeferred.drawGbuffer();
|
||||
|
||||
#if (kha_direct3d12 || kha_vulkan)
|
||||
var useLiveLayer = arm.ui.UIHeader.inst.worktab.position == SpaceMaterial;
|
||||
Context.viewportMode == ViewPathTrace ? RenderPathRaytrace.draw(useLiveLayer) : drawDeferred();
|
||||
#else
|
||||
drawDeferred();
|
||||
#end
|
||||
|
||||
Context.viewIndex = Context.viewIndex == 0 ? 1 : 0;
|
||||
cam.transform.setMatrix(arm.Camera.inst.views[Context.viewIndex]);
|
||||
cam.buildMatrix();
|
||||
cam.buildProjection();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package arm.render;
|
||||
|
||||
import kha.System;
|
||||
import iron.RenderPath;
|
||||
import iron.Scene;
|
||||
import arm.Enums;
|
||||
@@ -14,44 +13,17 @@ class RenderPathForward {
|
||||
}
|
||||
|
||||
public static function commands() {
|
||||
if (System.windowWidth() == 0 || System.windowHeight() == 0) return;
|
||||
|
||||
RenderPathBase.begin();
|
||||
if (RenderPathBase.isCached()) return;
|
||||
|
||||
// Match projection matrix jitter
|
||||
var skipTaa = Context.splitView || ((Context.tool == ToolClone || Context.tool == ToolBlur) && Context.pdirty > 0);
|
||||
@:privateAccess Scene.active.camera.frame = skipTaa ? 0 : RenderPathDeferred.taaFrame;
|
||||
@:privateAccess Scene.active.camera.projectionJitter();
|
||||
Scene.active.camera.buildMatrix();
|
||||
|
||||
RenderPathPaint.begin();
|
||||
drawSplit();
|
||||
RenderPathDeferred.drawGbuffer();
|
||||
RenderPathPaint.draw();
|
||||
|
||||
#if (kha_direct3d12 || kha_vulkan)
|
||||
if (Context.viewportMode == ViewPathTrace) {
|
||||
var useLiveLayer = arm.ui.UIHeader.inst.worktab.position == SpaceMaterial;
|
||||
RenderPathRaytrace.draw(useLiveLayer);
|
||||
return;
|
||||
}
|
||||
#end
|
||||
|
||||
drawForward();
|
||||
RenderPathPaint.end();
|
||||
RenderPathBase.end();
|
||||
RenderPathDeferred.taaFrame++;
|
||||
RenderPathBase.commands(drawForward);
|
||||
}
|
||||
|
||||
public static function drawForward(eye = false, output = "", gbuffer0 = "gbuffer0", gbuffer1 = "gbuffer1", gbuffer2 = "gbuffer2", buf = "buf", bufa = "bufa", taa = "taa", taa2 = "taa2") {
|
||||
path.setDepthFrom(gbuffer1, gbuffer0);
|
||||
path.setTarget(gbuffer1);
|
||||
public static function drawForward() {
|
||||
path.setDepthFrom("gbuffer1", "gbuffer0");
|
||||
path.setTarget("gbuffer1");
|
||||
path.drawSkydome("shader_datas/world_pass/world_pass");
|
||||
path.setDepthFrom(gbuffer1, gbuffer2);
|
||||
path.setDepthFrom("gbuffer1", "gbuffer2");
|
||||
|
||||
path.setTarget(buf);
|
||||
path.bindTarget(gbuffer1, "tex");
|
||||
path.setTarget("buf");
|
||||
path.bindTarget("gbuffer1", "tex");
|
||||
if (Context.viewportMode == ViewLit) {
|
||||
path.drawShader("shader_datas/compositor_pass/compositor_pass");
|
||||
}
|
||||
@@ -59,87 +31,54 @@ class RenderPathForward {
|
||||
path.drawShader("shader_datas/copy_pass/copy_pass");
|
||||
}
|
||||
|
||||
if (output == "") {
|
||||
path.setTarget(buf);
|
||||
var currentG = path.currentG;
|
||||
path.drawMeshes("overlay");
|
||||
RenderPathBase.drawCompass(currentG);
|
||||
}
|
||||
path.setTarget("buf");
|
||||
var currentG = path.currentG;
|
||||
path.drawMeshes("overlay");
|
||||
RenderPathBase.drawCompass(currentG);
|
||||
|
||||
var taaFrame = RenderPathDeferred.taaFrame;
|
||||
var current = taaFrame % 2 == 0 ? bufa : taa2;
|
||||
var last = taaFrame % 2 == 0 ? taa2 : bufa;
|
||||
var current = taaFrame % 2 == 0 ? "bufa" : "taa2";
|
||||
var last = taaFrame % 2 == 0 ? "taa2" : "bufa";
|
||||
|
||||
path.setTarget(current);
|
||||
path.clearTarget(0x00000000);
|
||||
path.bindTarget(buf, "colorTex");
|
||||
path.bindTarget("buf", "colorTex");
|
||||
path.drawShader("shader_datas/smaa_edge_detect/smaa_edge_detect");
|
||||
|
||||
path.setTarget(taa);
|
||||
path.setTarget("taa");
|
||||
path.clearTarget(0x00000000);
|
||||
path.bindTarget(current, "edgesTex");
|
||||
path.drawShader("shader_datas/smaa_blend_weight/smaa_blend_weight");
|
||||
|
||||
path.setTarget(current);
|
||||
path.bindTarget(buf, "colorTex");
|
||||
path.bindTarget(taa, "blendTex");
|
||||
path.bindTarget(gbuffer2, "sveloc");
|
||||
path.bindTarget("buf", "colorTex");
|
||||
path.bindTarget("taa", "blendTex");
|
||||
path.bindTarget("gbuffer2", "sveloc");
|
||||
path.drawShader("shader_datas/smaa_neighborhood_blend/smaa_neighborhood_blend");
|
||||
|
||||
var skipTaa = Context.splitView || eye;
|
||||
var skipTaa = Context.splitView;
|
||||
if (skipTaa) {
|
||||
path.setTarget(taa);
|
||||
path.setTarget("taa");
|
||||
path.bindTarget(current, "tex");
|
||||
path.drawShader("shader_datas/copy_pass/copy_pass");
|
||||
}
|
||||
else {
|
||||
path.setTarget(taa);
|
||||
path.setTarget("taa");
|
||||
path.bindTarget(current, "tex");
|
||||
path.bindTarget(last, "tex2");
|
||||
path.bindTarget(gbuffer2, "sveloc");
|
||||
path.bindTarget("gbuffer2", "sveloc");
|
||||
path.drawShader("shader_datas/taa_pass/taa_pass");
|
||||
}
|
||||
|
||||
if (!RenderPathBase.ssaa4()) {
|
||||
path.setTarget(output);
|
||||
path.bindTarget(taaFrame % 2 == 0 ? current : taa, "tex");
|
||||
path.drawShader("shader_datas/copy_pass/copy_pass");
|
||||
}
|
||||
|
||||
if (RenderPathBase.ssaa4()) {
|
||||
path.setTarget(output);
|
||||
path.bindTarget(taaFrame % 2 == 0 ? taa2 : taa, "tex");
|
||||
path.setTarget("");
|
||||
path.bindTarget(taaFrame % 2 == 0 ? "taa2" : "taa", "tex");
|
||||
path.drawShader("shader_datas/supersample_resolve/supersample_resolve");
|
||||
}
|
||||
}
|
||||
|
||||
static function drawSplit() {
|
||||
if (Context.splitView && !Context.paint2dView) {
|
||||
#if (kha_metal || krom_android)
|
||||
Context.ddirty = 2;
|
||||
#else
|
||||
Context.ddirty = 1;
|
||||
#end
|
||||
var cam = Scene.active.camera;
|
||||
|
||||
Context.viewIndex = Context.viewIndex == 0 ? 1 : 0;
|
||||
cam.transform.setMatrix(arm.Camera.inst.views[Context.viewIndex]);
|
||||
cam.buildMatrix();
|
||||
cam.buildProjection();
|
||||
|
||||
RenderPathDeferred.drawGbuffer();
|
||||
|
||||
#if (kha_direct3d12 || kha_vulkan)
|
||||
var useLiveLayer = arm.ui.UIHeader.inst.worktab.position == SpaceMaterial;
|
||||
Context.viewportMode == ViewPathTrace ? RenderPathRaytrace.draw(useLiveLayer) : drawForward();
|
||||
#else
|
||||
drawForward();
|
||||
#end
|
||||
|
||||
Context.viewIndex = Context.viewIndex == 0 ? 1 : 0;
|
||||
cam.transform.setMatrix(arm.Camera.inst.views[Context.viewIndex]);
|
||||
cam.buildMatrix();
|
||||
cam.buildProjection();
|
||||
else {
|
||||
path.setTarget("");
|
||||
path.bindTarget(taaFrame % 2 == 0 ? current : "taa", "tex");
|
||||
path.drawShader("shader_datas/copy_pass/copy_pass");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,9 +107,7 @@ class RenderPathForwardVR {
|
||||
}
|
||||
}
|
||||
|
||||
@:access(iron.RenderPath)
|
||||
public static function commands() {
|
||||
|
||||
if (System.windowWidth() == 0 || System.windowHeight() == 0) return;
|
||||
|
||||
if (Krom.vrGetSensorStateHmdMounted()) {
|
||||
@@ -160,8 +158,8 @@ class RenderPathForwardVR {
|
||||
Scene.active.camera.P._33 = proj._33;
|
||||
Scene.active.camera.VP.multmats(Scene.active.camera.P, Scene.active.camera.V);
|
||||
Scene.active.camera.transform.world.getInverse(Scene.active.camera.V);
|
||||
RenderPathDeferred.drawGbuffer("gbuffer0_eye", "gbuffer1_eye", "gbuffer2_eye");
|
||||
RenderPathForward.drawForward(true, "eye" + eye, "gbuffer0_eye", "gbuffer1_eye", "gbuffer2_eye", "buf_eye", "bufa_eye", "taa_eye", "taa2_eye");
|
||||
// RenderPathDeferred.drawGbuffer("gbuffer0_eye", "gbuffer1_eye", "gbuffer2_eye");
|
||||
// RenderPathForward.drawForward(true, "eye" + eye, "gbuffer0_eye", "gbuffer1_eye", "gbuffer2_eye", "buf_eye", "bufa_eye", "taa_eye", "taa2_eye");
|
||||
}
|
||||
|
||||
Scene.active.camera.transform.world.setFrom(m);
|
||||
@@ -178,7 +176,7 @@ class RenderPathForwardVR {
|
||||
Krom.vrWarpSwap();
|
||||
}
|
||||
|
||||
iron.Scene.active.camera.buildMatrix();
|
||||
Scene.active.camera.buildMatrix();
|
||||
|
||||
RenderPathPaint.begin();
|
||||
RenderPathDeferred.drawGbuffer();
|
||||
|
||||
Reference in New Issue
Block a user