Skip to content

Commit 2325e3f

Browse files
authored
Add support for the camera bridge in the graphics compositor (#4599)
1 parent 05cc16a commit 2325e3f

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

com.unity.render-pipelines.high-definition/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
6262
- Added support for tessellation for all master node in shader graph.
6363
- Added ValidateMaterial callbacks to ShaderGUI.
6464
- Added support for internal plugin materials and HDSubTarget with their versioning system.
65+
- Added support for the camera bridge in the graphics compositor
6566

6667
### Fixed
6768
- Fixed Intensity Multiplier not affecting realtime global illumination.

com.unity.render-pipelines.high-definition/Runtime/Compositor/CompositionManager.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -802,12 +802,39 @@ void CustomRender(ScriptableRenderContext context, HDCamera camera)
802802

803803
if (camera.camera.targetTexture)
804804
{
805+
// When rendering to texture (or to camera bridge) we don't need to flip the image.
806+
// If this matrix was used for the game view, then the image would appear flipped, hense the name of the variable.
805807
m_ShaderVariablesGlobalCB._ViewProjMatrix = m_ViewProjMatrixFlipped;
806808
ConstantBuffer.PushGlobal(cmd, m_ShaderVariablesGlobalCB, HDShaderIDs._ShaderVariablesGlobal);
807809
cmd.Blit(null, camera.camera.targetTexture, m_Material, m_Material.FindPass("ForwardOnly"));
810+
811+
var recorderCaptureActions = CameraCaptureBridge.GetCaptureActions(camera.camera);
812+
if (recorderCaptureActions != null)
813+
{
814+
for (recorderCaptureActions.Reset(); recorderCaptureActions.MoveNext();)
815+
{
816+
recorderCaptureActions.Current(camera.camera.targetTexture, cmd);
817+
}
818+
}
808819
}
809820
else
810821
{
822+
var recorderCaptureActions = CameraCaptureBridge.GetCaptureActions(camera.camera);
823+
824+
if (recorderCaptureActions != null)
825+
{
826+
m_ShaderVariablesGlobalCB._ViewProjMatrix = m_ViewProjMatrixFlipped;
827+
cmd.SetInvertCulling(true);
828+
ConstantBuffer.PushGlobal(cmd, m_ShaderVariablesGlobalCB, HDShaderIDs._ShaderVariablesGlobal);
829+
cmd.Blit(null, BuiltinRenderTextureType.CameraTarget, m_Material, m_Material.FindPass("ForwardOnly"));
830+
for (recorderCaptureActions.Reset(); recorderCaptureActions.MoveNext();)
831+
{
832+
recorderCaptureActions.Current(BuiltinRenderTextureType.CameraTarget, cmd);
833+
}
834+
cmd.SetInvertCulling(false);
835+
}
836+
837+
// When we render directly to game view, we render the image flipped up-side-down, like other HDRP cameras
811838
m_ShaderVariablesGlobalCB._ViewProjMatrix = m_ViewProjMatrix;
812839
ConstantBuffer.PushGlobal(cmd, m_ShaderVariablesGlobalCB, HDShaderIDs._ShaderVariablesGlobal);
813840
cmd.Blit(null, BuiltinRenderTextureType.CameraTarget, m_Material, m_Material.FindPass("ForwardOnly"));

0 commit comments

Comments
 (0)