Skip to content

Commit

Permalink
Update post process to fit depth buffer sampling.
Browse files Browse the repository at this point in the history
  • Loading branch information
clementlandrin authored and clementlandrin committed Sep 13, 2023
1 parent c30a405 commit fa045bc
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 14 deletions.
2 changes: 1 addition & 1 deletion hrt/prefab/l3d/Layers2D.hx
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class Layer2DRFX extends hrt.prefab.rfx.RendererFX {
s.depthChannelChannel = depthMap.channel == null ? hxsl.Channel.R : depthMap.channel;
}

r.setTarget(output);
r.setTarget(output, ReadOnly);
pass.render();
}
}
Expand Down
4 changes: 3 additions & 1 deletion hrt/prefab/rfx/Sharpen.hx
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,16 @@ class Sharpen extends RendererFX {
r.mark("Sharpen");
var sharpen = r.allocTarget("sharpen", true, 1.0, RGBA);
var ctx = r.ctx;
var prevDepthBinding = @:privateAccess ctx.engine.currentDepthBinding;
ctx.engine.pushTarget(sharpen);
sharpenPass.shader.source = ctx.getGlobal("ldrMap");
sharpenPass.shader.intensity = intensity;
sharpenPass.shader.resolution.set(ctx.engine.width, ctx.engine.height);
sharpenPass.render();
ctx.engine.popTarget();
ctx.setGlobal("ldrMap", sharpen);
r.setTarget(sharpen);
@:privateAccess cast(r, h3d.scene.pbr.Renderer).textures.ldr = sharpen;
r.setTarget(sharpen, prevDepthBinding);
}
}

Expand Down
15 changes: 4 additions & 11 deletions hrt/prefab/rfx/TemporalFiltering.hx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ class TemporalFilteringShader extends h3d.shader.ScreenShader {
@param var prevCamMat : Mat4;
@param var cameraInverseViewProj : Mat4;

@const var PACKED_DEPTH : Bool;
@param var depthChannel : Channel;
@param var depthTexture : Sampler2D;

Expand Down Expand Up @@ -71,7 +70,7 @@ class TemporalFilteringShader extends h3d.shader.ScreenShader {
var isSky : Bool;

function getPixelPosition( uv : Vec2 ) : Vec3 {
var d = PACKED_DEPTH ? unpack(depthTexture.get(uv)) : depthChannel.get(uv).r;
var d = depthChannel.get(uv).r;
var tmp = vec4(uvToScreen(uv), d, 1) * cameraInverseViewProj;
tmp.xyz /= tmp.w;
isSky = d == 1.0;
Expand Down Expand Up @@ -172,21 +171,15 @@ class TemporalFiltering extends hrt.prefab.rfx.RendererFX {
s.prevFrame = prevFrame;
s.amount = amount;

s.PACKED_DEPTH = depthMap.packed != null && depthMap.packed == true;
if( s.PACKED_DEPTH ) {
s.depthTexture = depthMap.texture;
}
else {
s.depthChannel = depthMap.texture;
s.depthChannelChannel = depthMap.channel == null ? hxsl.Channel.R : depthMap.channel;
}
s.depthChannel = depthMap.texture;
s.depthChannelChannel = depthMap.channel == null ? hxsl.Channel.R : depthMap.channel;

s.resolution.set(output.width, output.height);
s.VARIANCE_CLIPPING = varianceClipping;
s.YCOCG = ycocg;
s.UNJITTER = unjitter;

r.setTarget(output);
r.setTarget(output, ReadOnly);
pass.render();

h3d.pass.Copy.run(output, prevFrame);
Expand Down
2 changes: 1 addition & 1 deletion hrt/prefab/rfx/VolumetricLighting.hx
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class VolumetricLighting extends RendererFX {
}
light = light.next;
}
if ( sun == null || sun.shadows == null || !sun.shadows.enabled )
if ( sun == null || sun.shadows == null || !sun.shadows.enabled || sun.shadows.getShadowTex() == null )
return;
var tex = r.allocTarget("volumetricLighting", false, textureSize, RGBA16F);
tex.clear(0, 0.0);
Expand Down

0 comments on commit fa045bc

Please sign in to comment.