Skip to content

HDRP Compositor related fixes #730

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 4, 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,9 @@ EditorBuildSettings:
- enabled: 1
path: Assets/GraphicTests/Scenes/9x_Other/9702_CustomPass_API.unity
guid: 3d584f34970fc5c44871961e3178f4ce
- enabled: 1
path: Assets/GraphicTests/Scenes/9x_Other/9800_Compositor.unity
guid: 708bd21bc204d2342bc1702a5a6de1d3
- enabled: 1
path: Assets/GraphicTests/Scenes/9x_Other/9801_ShurikenLightModule.unity
guid: d50ee167e49a2d74988347d7888c3613
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ static partial class Styles
CompositionManagerEditor m_Editor;
Vector2 m_ScrollPosition = Vector2.zero;
bool m_RequiresRedraw = false;
float m_TimeSinceLastRepaint = 0;

[MenuItem("Window/Render Pipeline/HD Render Pipeline Compositor", false, 10400)]
static void Init()
Expand All @@ -34,12 +35,16 @@ static void Init()

void Update()
{
// This ensures that layer thumbnails are updated every frame (for video layers)
Repaint();
m_TimeSinceLastRepaint += Time.deltaTime;

// This ensures that layer thumbnails are updated at least 4 times per second (redrawing the UI on every frame is too CPU intensive)
if (m_TimeSinceLastRepaint > 0.25f)
Repaint();
}

void OnGUI()
{
m_TimeSinceLastRepaint = 0;
CompositionManager compositor = CompositionManager.GetInstance();
bool enableCompositor = false;
if (compositor)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@

namespace UnityEngine.Rendering.HighDefinition.Compositor
{
[Serializable]
// Injects an external alpha texture into the alpha channel. Used for controlling which pixels will be affected by post processing.
// Use VolumeComponentDeprecated to hide the component from the volume menu (it's for internal compositor use only)
[Serializable, VolumeComponentDeprecated]
internal sealed class AlphaInjection : CustomPostProcessVolumeComponent, IPostProcessComponent
{
internal class ShaderIDs
Expand All @@ -31,8 +33,8 @@ public override void Render(CommandBuffer cmd, HDCamera camera, RTHandle source,
{
Debug.Assert(m_Material != null);

//TODO: can we detect this before we get here?
AdditionalCompositorData layerData = camera.camera.gameObject.GetComponent<AdditionalCompositorData>();
AdditionalCompositorData layerData = null;
camera.camera.gameObject.TryGetComponent<AdditionalCompositorData>(out layerData);
if (layerData == null || layerData.layerFilters == null)
{
HDUtils.BlitCameraTexture(cmd, source, destination);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ namespace UnityEngine.Rendering.HighDefinition.Compositor
{
// Custom post-processing pass that performs chroma keying
// Shader adapted from: https://github.com/keijiro/ProcAmp
[Serializable]
// Use VolumeComponentDeprecated to hide the component from the volume menu (it's for internal use only)
[Serializable, VolumeComponentDeprecated]
internal sealed class ChromaKeying : CustomPostProcessVolumeComponent, IPostProcessComponent
{
internal class ShaderIDs
Expand Down Expand Up @@ -35,7 +36,8 @@ public override void Render(CommandBuffer cmd, HDCamera camera, RTHandle source,
{
Debug.Assert(m_Material != null);

AdditionalCompositorData layerData = camera.camera.gameObject.GetComponent<AdditionalCompositorData>();
AdditionalCompositorData layerData = null;
camera.camera.gameObject.TryGetComponent<AdditionalCompositorData>(out layerData);

if (activate.value == false || layerData == null || layerData.layerFilters == null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ public bool ValidateRTSize(int referenceWidth, int referenceHeight)
}

float scale = EnumToScale(m_ResolutionScale);
return ((m_RenderTarget.width == referenceWidth * scale) && (m_RenderTarget.height == referenceHeight * scale));
return ((m_RenderTarget.width == Mathf.FloorToInt(referenceWidth * scale)) && (m_RenderTarget.height == Mathf.FloorToInt(referenceHeight * scale)));
}

public void SetupClearColor()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -693,8 +693,7 @@ void CustomRender(ScriptableRenderContext context, HDCamera camera)
{
m_ShaderVariablesGlobalCB._ViewProjMatrix = m_ViewProjMatrixFlipped;
ConstantBuffer.PushGlobal(cmd, m_ShaderVariablesGlobalCB, HDShaderIDs._ShaderVariablesGlobal);
cmd.Blit(null, BuiltinRenderTextureType.CurrentActive, m_Material, m_Material.FindPass("ForwardOnly"));
cmd.Blit(BuiltinRenderTextureType.CurrentActive, camera.camera.targetTexture);
cmd.Blit(null, camera.camera.targetTexture, m_Material, m_Material.FindPass("ForwardOnly"));
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ protected override void Setup(ScriptableRenderContext renderContext, CommandBuff
protected override void Execute(CustomPassContext ctx)
{
// Executed every frame for all the camera inside the pass volume
AdditionalCompositorData layerData = ctx.hdCamera.camera.gameObject.GetComponent<AdditionalCompositorData>();
AdditionalCompositorData layerData = null;
ctx.hdCamera.camera.gameObject.TryGetComponent<AdditionalCompositorData>(out layerData);
if (layerData == null || layerData.clearColorTexture == null)
{
return;
Expand Down