Skip to content

[8.x.x Backport] Fix transparent/opaque motion vector inconsistencies by allowing camera-only transparent motion vectors #837

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
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 @@ -69,6 +69,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- The `CustomPassLoadCameraColor` and `CustomPassSampleCameraColor` functions now returns the correct color buffer when used in after post process instead of the color pyramid (which didn't had post processes).
- Fixed for area light not updating baked light result when modifying with gizmo.
- Fixed issue with white flash when enabling SSR.
- Fix inconsistencies with transparent motion vectors and opaque by allowing camera only transparent motion vectors.

### Changed
- Shadowmask and realtime reflection probe property are hide in Quality settings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,7 @@ internal void SetupGlobalParams(CommandBuffer cmd, int frameCount)
cmd.SetGlobalVectorArray(HDShaderIDs._XRPrevWorldSpaceCameraPos, m_XRPrevWorldSpaceCameraPos);
}

cmd.SetGlobalInt(HDShaderIDs._TransparentCameraOnlyMotionVectors, (frameSettings.IsEnabled(FrameSettingsField.MotionVectors) && !frameSettings.IsEnabled(FrameSettingsField.TransparentsWriteMotionVector)) ? 1 : 0);
}

internal void AllocateAmbientOcclusionHistoryBuffer(float scaleFactor)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2728,6 +2728,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 @@ -3596,7 +3597,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 @@ -310,6 +310,8 @@ static class HDShaderIDs
public static readonly int _TaaFrameInfo = Shader.PropertyToID("_TaaFrameInfo");
public static readonly int _TaaJitterStrength = Shader.PropertyToID("_TaaJitterStrength");

public static readonly int _TransparentCameraOnlyMotionVectors = Shader.PropertyToID("_TransparentCameraOnlyMotionVectors ");

public static readonly int _WorldSpaceCameraPos1 = Shader.PropertyToID("_WorldSpaceCameraPos1");
public static readonly int _ViewMatrix1 = Shader.PropertyToID("_ViewMatrix1");

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 @@ -283,6 +283,9 @@ CBUFFER_START(UnityGlobal)

float4 _CoarseStencilBufferSize;

int _TransparentCameraOnlyMotionVectors;
float3 _Pad;

CBUFFER_END

// Custom generated by HDRP, not from Unity Engine (passed in via HDCamera)
Expand Down