Skip to content
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

[HDRP][Compositor] Update the compositor output when not in play mode #1653

Merged
merged 2 commits into from
Sep 8, 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
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 @@ -61,6 +61,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed issue with composition graphs that include virtual textures, cubemaps and other non-2D textures (cases 1263347, 1265638).
- Fixed issues when selecting a new composition graph or setting it to None (cases 1263350, 1266202)
- Fixed ArgumentNullException when saving shader graphs after removing the compositor from the scene (case 1268658)
- Fixed issue with updating the compositor output when not in play mode (case 1266216)

### Changed
- Preparation pass for RTSSShadows to be supported by render graph.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,30 @@ void Update()
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)
const float timeThreshold = 0.25f;
if (m_TimeSinceLastRepaint > timeThreshold)
{
Repaint();

// [case 1266216] Ensure the game view gets repainted a few times per second even when we are not in play mode.
// This ensures that we will not always display the first frame, which might have some artifacts for effects that require temporal data
if (!Application.isPlaying)
{
CompositionManager compositor = CompositionManager.GetInstance();
if (compositor && compositor.enableOutput)
{
compositor.timeSinceLastRepaint += Time.deltaTime;
// The Editor will repaint the game view if the scene view is also visible (side-by-side) and
// "always refresh" is enabled so we call manually repaint only if enough time has passed
if (compositor.timeSinceLastRepaint > timeThreshold)
{
compositor.Repaint();
}
}

}
}

}

void OnGUI()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public enum AlphaChannelSupport

internal AlphaChannelSupport m_AlphaSupport = AlphaChannelSupport.RenderingAndPostProcessing;

internal float timeSinceLastRepaint;

public bool enableOutput
{
get
Expand Down Expand Up @@ -722,6 +724,15 @@ public RenderTexture GetRenderTarget(int indx)
return null;
}

public void Repaint()
{
for (int indx = 0; indx < m_InputLayers.Count; indx++)
{
if (m_InputLayers[indx].camera)
m_InputLayers[indx].camera.Render();
}
}

void CustomRender(ScriptableRenderContext context, HDCamera camera)
{
if (camera == null || camera.camera == null || m_Material == null || m_Shader == null)
Expand All @@ -733,6 +744,8 @@ void CustomRender(ScriptableRenderContext context, HDCamera camera)
}


timeSinceLastRepaint = 0;

// set shader uniforms
m_CompositionProfile.CopyPropertiesToMaterial(m_Material);

Expand Down