Skip to content

[HDRP] Added a RenderGraph pass that resets the camera size after the dynamic res upscale #3070

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 7 commits into from
Jan 14, 2021
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 @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Fixed
- Fixed GC allocations from XR occlusion mesh when using multipass.
- Fixed XR depth copy when using MSAA.
- Fixed after post process custom pass scale issue when dynamic resolution is enabled (case 1299194).

### Changed
- Change the source value for the ray tracing frame index iterator from m_FrameCount to the camera frame count (case 1301356).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,8 @@ internal GameObject exposureTarget

internal bool stopNaNs => m_AdditionalCameraData != null && m_AdditionalCameraData.stopNaNs;

internal bool allowDynamicResolution => m_AdditionalCameraData != null && m_AdditionalCameraData.allowDynamicResolution;

internal HDPhysicalCamera physicalParameters { get; private set; }

internal IEnumerable<AOVRequestData> aovRequests =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,8 @@ void ExecuteWithRenderGraph(RenderRequest renderRequest,
}
PushFullScreenExposureDebugTexture(m_RenderGraph, postProcessDest);

ResetCameraSizeForAfterPostProcess(m_RenderGraph, hdCamera, commandBuffer);

RenderCustomPass(m_RenderGraph, hdCamera, postProcessDest, prepassOutput, customPassCullingResults, cullingResults, CustomPassInjectionPoint.AfterPostProcess, aovRequest, aovCustomPassBuffers);

CopyXRDepth(m_RenderGraph, hdCamera, prepassOutput.resolvedDepthBuffer, backBuffer);
Expand Down Expand Up @@ -1542,6 +1544,34 @@ bool RenderCustomPass(RenderGraph renderGraph,
return executed;
}

class ResetCameraSizeForAfterPostProcessPassData
{
public HDCamera hdCamera;
public ShaderVariablesGlobal shaderVariablesGlobal;
}

void ResetCameraSizeForAfterPostProcess(RenderGraph renderGraph, HDCamera hdCamera, CommandBuffer commandBuffer)
{
if (DynamicResolutionHandler.instance.DynamicResolutionEnabled())
{
using (var builder = renderGraph.AddRenderPass("Reset Camera Size After Post Process", out ResetCameraSizeForAfterPostProcessPassData passData))
{
passData.hdCamera = hdCamera;
passData.shaderVariablesGlobal = m_ShaderVariablesGlobalCB;
builder.AllowPassCulling(false);

builder.SetRenderFunc(
(ResetCameraSizeForAfterPostProcessPassData data, RenderGraphContext ctx) =>
{
data.shaderVariablesGlobal._ScreenSize = new Vector4(data.hdCamera.finalViewport.width, data.hdCamera.finalViewport.height, 1.0f / data.hdCamera.finalViewport.width, 1.0f / data.hdCamera.finalViewport.height);
data.shaderVariablesGlobal._RTHandleScale = RTHandles.rtHandleProperties.rtHandleScale;
ConstantBuffer.PushGlobal(ctx.cmd, data.shaderVariablesGlobal, HDShaderIDs._ShaderVariablesGlobal);
RTHandles.SetReferenceSize((int)data.hdCamera.finalViewport.width, (int)data.hdCamera.finalViewport.height, data.hdCamera.msaaSamples);
});
}
}
}

class BindCustomPassBuffersPassData
{
public Lazy<RTHandle> customColorTexture;
Expand Down