Raytrace only when dirty
This commit is contained in:
@@ -149,15 +149,13 @@ class Camera {
|
||||
|
||||
var d = Time.delta * speed * fast * ease;
|
||||
if (d > 0.0) {
|
||||
Context.ddirty = 2;
|
||||
camera.transform.move(dir, d);
|
||||
|
||||
if (UITrait.inst.cameraType == 1) {
|
||||
ViewportUtil.updateCameraType(UITrait.inst.cameraType);
|
||||
}
|
||||
}
|
||||
|
||||
Context.ddirty = 2;
|
||||
redraws = 2;
|
||||
camera.transform.rotate(Vec4.zAxis(), -mouse.movementX / 200);
|
||||
camera.transform.rotate(camera.right(), -mouse.movementY / 200);
|
||||
}
|
||||
|
||||
@@ -73,7 +73,11 @@ class RenderPathDeferred {
|
||||
t.name = "buf";
|
||||
t.width = 0;
|
||||
t.height = 0;
|
||||
#if kha_direct3d12 // Match raytrace_target format
|
||||
t.format = "RGBA128";
|
||||
#else
|
||||
t.format = Inc.getHdrFormat();
|
||||
#end
|
||||
t.scale = Inc.getSuperSampling();
|
||||
path.createRenderTarget(t);
|
||||
}
|
||||
@@ -103,11 +107,7 @@ class RenderPathDeferred {
|
||||
t.name = "taa";
|
||||
t.width = 0;
|
||||
t.height = 0;
|
||||
#if kha_direct3d12 // Match raytrace_target format
|
||||
t.format = "RGBA128";
|
||||
#else
|
||||
t.format = "RGBA32";
|
||||
#end
|
||||
t.scale = Inc.getSuperSampling();
|
||||
path.createRenderTarget(t);
|
||||
}
|
||||
@@ -544,7 +544,12 @@ class RenderPathDeferred {
|
||||
cam.buildProjection();
|
||||
|
||||
drawGbuffer();
|
||||
|
||||
#if kha_direct3d12
|
||||
UITrait.inst.viewportMode == 10 ? drawRaytraced() : drawDeferred;
|
||||
#else
|
||||
drawDeferred();
|
||||
#end
|
||||
|
||||
UITrait.inst.viewIndex = UITrait.inst.viewIndex == 0 ? 1 : 0;
|
||||
cam.transform.setMatrix(arm.plugin.Camera.inst.views[UITrait.inst.viewIndex]);
|
||||
@@ -685,18 +690,7 @@ class RenderPathDeferred {
|
||||
|
||||
#if kha_direct3d12
|
||||
if (UITrait.inst.viewportMode == 10) { // Ray-traced
|
||||
if (Context.ddirty > 1) {
|
||||
RenderPathRaytrace.frame = 0;
|
||||
}
|
||||
RenderPathRaytrace.commands();
|
||||
path.setTarget("taa");
|
||||
drawCompass(path.currentG);
|
||||
path.setTarget("");
|
||||
path.bindTarget("taa", "tex");
|
||||
path.drawShader("shader_datas/compositor_pass/compositor_pass");
|
||||
if (UITrait.inst.brush3d) {
|
||||
RenderPathPaint.commandsCursor();
|
||||
}
|
||||
drawRaytraced();
|
||||
return;
|
||||
}
|
||||
#end
|
||||
@@ -1006,6 +1000,24 @@ class RenderPathDeferred {
|
||||
}
|
||||
}
|
||||
|
||||
static function drawRaytraced() {
|
||||
if (Context.ddirty > 1) {
|
||||
RenderPathRaytrace.frame = 0;
|
||||
}
|
||||
RenderPathRaytrace.commands();
|
||||
path.setTarget("buf");
|
||||
drawCompass(path.currentG);
|
||||
path.setTarget("taa");
|
||||
path.bindTarget("buf", "tex");
|
||||
path.drawShader("shader_datas/compositor_pass/compositor_pass");
|
||||
path.setTarget("");
|
||||
path.bindTarget("taa", "tex");
|
||||
path.drawShader("shader_datas/copy_pass/copy_pass");
|
||||
if (UITrait.inst.brush3d) {
|
||||
RenderPathPaint.commandsCursor();
|
||||
}
|
||||
}
|
||||
|
||||
static function endSplit() {
|
||||
UITrait.inst.viewIndexLast = UITrait.inst.viewIndex;
|
||||
UITrait.inst.viewIndex = -1;
|
||||
|
||||
@@ -138,14 +138,16 @@ class RenderPathRaytrace {
|
||||
f32[21] = UITrait.inst.showEnvmap ? 1.0 : 0.0;
|
||||
|
||||
var path = RenderPathDeferred.path;
|
||||
var framebuffer = path.renderTargets.get("taa").image;
|
||||
var framebuffer = path.renderTargets.get("buf").image;
|
||||
|
||||
Krom.raytraceDispatchRays(framebuffer.renderTarget_, f32.buffer);
|
||||
|
||||
Context.ddirty = 1;
|
||||
// Context.ddirty--;
|
||||
if (Context.ddirty == 1 || Context.pdirty == 1) Context.rdirty = 4;
|
||||
Context.ddirty--;
|
||||
Context.pdirty--;
|
||||
Context.rdirty--;
|
||||
|
||||
// Context.ddirty = 1; // _RENDER
|
||||
}
|
||||
|
||||
public static function commandsBake() {
|
||||
|
||||
Reference in New Issue
Block a user