Skip to content

[HDRP] Add support for the recorder / camera bridge in the graphics compositor #4599

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 1 commit into from
May 28, 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 @@ -62,6 +62,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Added support for tessellation for all master node in shader graph.
- Added ValidateMaterial callbacks to ShaderGUI.
- Added support for internal plugin materials and HDSubTarget with their versioning system.
- Added support for the camera bridge in the graphics compositor

### Fixed
- Fixed Intensity Multiplier not affecting realtime global illumination.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -802,12 +802,39 @@ void CustomRender(ScriptableRenderContext context, HDCamera camera)

if (camera.camera.targetTexture)
{
// When rendering to texture (or to camera bridge) we don't need to flip the image.
// If this matrix was used for the game view, then the image would appear flipped, hense the name of the variable.
m_ShaderVariablesGlobalCB._ViewProjMatrix = m_ViewProjMatrixFlipped;
ConstantBuffer.PushGlobal(cmd, m_ShaderVariablesGlobalCB, HDShaderIDs._ShaderVariablesGlobal);
cmd.Blit(null, camera.camera.targetTexture, m_Material, m_Material.FindPass("ForwardOnly"));

var recorderCaptureActions = CameraCaptureBridge.GetCaptureActions(camera.camera);
if (recorderCaptureActions != null)
{
for (recorderCaptureActions.Reset(); recorderCaptureActions.MoveNext();)
{
recorderCaptureActions.Current(camera.camera.targetTexture, cmd);
}
}
}
else
{
var recorderCaptureActions = CameraCaptureBridge.GetCaptureActions(camera.camera);

if (recorderCaptureActions != null)
{
m_ShaderVariablesGlobalCB._ViewProjMatrix = m_ViewProjMatrixFlipped;
cmd.SetInvertCulling(true);
ConstantBuffer.PushGlobal(cmd, m_ShaderVariablesGlobalCB, HDShaderIDs._ShaderVariablesGlobal);
cmd.Blit(null, BuiltinRenderTextureType.CameraTarget, m_Material, m_Material.FindPass("ForwardOnly"));
for (recorderCaptureActions.Reset(); recorderCaptureActions.MoveNext();)
{
recorderCaptureActions.Current(BuiltinRenderTextureType.CameraTarget, cmd);
}
cmd.SetInvertCulling(false);
}

// When we render directly to game view, we render the image flipped up-side-down, like other HDRP cameras
m_ShaderVariablesGlobalCB._ViewProjMatrix = m_ViewProjMatrix;
ConstantBuffer.PushGlobal(cmd, m_ShaderVariablesGlobalCB, HDShaderIDs._ShaderVariablesGlobal);
cmd.Blit(null, BuiltinRenderTextureType.CameraTarget, m_Material, m_Material.FindPass("ForwardOnly"));
Expand Down