Skip to content

Fix transparent/opaque motion vector inconsistencies by allowing camera-only transparent motion vectors #788

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

Merged
merged 4 commits into from
Jun 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions com.unity.render-pipelines.high-definition/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed white flash when enabling SSR or SSGI.
- The ray traced indrect diffuse and RTGI were combined wrongly with the rest of the lighting (1254318).
- Fixed an exception happening when using RTSSS without using RTShadows.
- Fix inconsistencies with transparent motion vectors and opaque by allowing camera only transparent motion vectors.

### Changed
- Improve MIP selection for decals on Transparents
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,9 @@ unsafe internal void UpdateShaderVariablesGlobalCB(ref ShaderVariablesGlobal cb,

float exposureMultiplierForProbes = 1.0f / Mathf.Max(probeRangeCompressionFactor, 1e-6f);
cb._ProbeExposureScale = exposureMultiplierForProbes;

cb._TransparentCameraOnlyMotionVectors = (frameSettings.IsEnabled(FrameSettingsField.MotionVectors) &&
!frameSettings.IsEnabled(FrameSettingsField.TransparentsWriteMotionVector)) ? 1 : 0;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3071,6 +3071,7 @@ out ScriptableCullingParameters cullingParams
if (camera.cameraType != CameraType.Game)
{
currentFrameSettings.SetEnabled(FrameSettingsField.ObjectMotionVectors, false);
currentFrameSettings.SetEnabled(FrameSettingsField.TransparentsWriteMotionVector, false);
}

hdCamera = HDCamera.GetOrCreate(camera, xrPass.multipassId);
Expand Down Expand Up @@ -4015,7 +4016,7 @@ void RenderForwardOpaque(CullingResults cullResults, HDCamera hdCamera, Scriptab

static bool NeedMotionVectorForTransparent(FrameSettings frameSettings)
{
return frameSettings.IsEnabled(FrameSettingsField.MotionVectors) && frameSettings.IsEnabled(FrameSettingsField.TransparentsWriteMotionVector) && frameSettings.IsEnabled(FrameSettingsField.ObjectMotionVectors);
return frameSettings.IsEnabled(FrameSettingsField.MotionVectors);
}

RendererListDesc PrepareForwardTransparentRendererList(CullingResults cullResults, HDCamera hdCamera, bool preRefraction)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,13 @@ PackedVaryingsType MotionVectorVS(inout VaryingsType varyingsType, AttributesMes
ApplyVertexModification(inputMesh, normalWS, previousPositionRWS, _LastTimeParameters.xyz);
#endif

#ifdef _WRITE_TRANSPARENT_MOTION_VECTOR
if (_TransparentCameraOnlyMotionVectors > 0)
{
previousPositionRWS = varyingsType.vmesh.positionRWS.xyz;
}
#endif

varyingsType.vpass.previousPositionCS = mul(UNITY_MATRIX_PREV_VP, float4(previousPositionRWS, 1.0));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,5 +252,10 @@ unsafe struct ShaderVariablesGlobal

[HLSLArray(7, typeof(Vector4))]
public fixed float _ProbeVolumeAmbientProbeFallbackPackedCoeffs[7 * 4]; // 3 bands of SH, packed for storing global ambient probe lighting as fallback to probe volumes.

public int _TransparentCameraOnlyMotionVectors;
public float _Pad8;
public float _Pad9;
public float _Pad10;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ GLOBAL_CBUFFER_START(ShaderVariablesGlobal, b0)
float _ProbeVolumeBilateralFilterWeight;
float _Pad8;
float4 _ProbeVolumeAmbientProbeFallbackPackedCoeffs[7];
int _TransparentCameraOnlyMotionVectors;
float _Pad8;
float _Pad9;
float _Pad10;
CBUFFER_END


Expand Down