Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(VR): vl ghosting #762

Merged
merged 2 commits into from
Nov 19, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions package/Shaders/ISApplyVolumetricLighting.hlsl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "Common/DummyVSTexCoord.hlsl"
#include "Common/FrameBuffer.hlsli"
#include "Common/VR.hlsli"

typedef VS_OUTPUT PS_INPUT;

Expand Down Expand Up @@ -52,7 +53,16 @@ PS_OUTPUT main(PS_INPUT input)

if (0.001 < g_IntensityX_TemporalY.y) {
float2 motionVector = MotionVectorsTex.Sample(MotionVectorsSampler, screenPosition).xy;
# ifdef VR
uint eyeIndex = Stereo::GetEyeIndexFromTexCoord(input.TexCoord);
float2 previousTexCoord = Stereo::ConvertFromStereoUV(input.TexCoord, eyeIndex);
previousTexCoord += motionVector;
bool isValid = previousTexCoord.x >= 0 && previousTexCoord.x < 1 && previousTexCoord.y >= 0 && previousTexCoord.y < 1;
previousTexCoord = Stereo::ConvertToStereoUV(previousTexCoord, eyeIndex);
# else
float2 previousTexCoord = input.TexCoord + motionVector;
bool isValid = previousTexCoord.x >= 0 && previousTexCoord.x < 1 && previousTexCoord.y >= 0 && previousTexCoord.y < 1;
# endif
float2 previousScreenPosition = FrameBuffer::GetPreviousDynamicResolutionAdjustedScreenPosition(previousTexCoord);
float previousVl = PreviousFrameTex.Sample(PreviousFrameSampler, previousScreenPosition).x;
float previousDepth = PreviousDepthTex.Sample(PreviousDepthSampler,
Expand All @@ -67,13 +77,11 @@ PS_OUTPUT main(PS_INPUT input)
)
.x;

float temporalContribution = g_IntensityX_TemporalY.y * (1 - smoothstep(0, 1, min(1, 100 * abs(depth - previousDepth))));

float isValid = (previousTexCoord.x >= 0 && previousTexCoord.x < 1 && previousTexCoord.y >= 0 && previousTexCoord.y < 1
# ifdef VR
&& abs(previousDepth) > 0.0001
isValid = isValid && abs(previousDepth) > 0.0001;
# endif
);

float temporalContribution = g_IntensityX_TemporalY.y * (1 - smoothstep(0, 1, min(1, 100 * abs(depth - previousDepth))));
psout.VL = lerp(adjustedVl, previousVl, temporalContribution * isValid);
} else {
psout.VL = adjustedVl;
Expand Down