Skip to content

Conversation

ellioman
Copy link
Contributor

@ellioman ellioman commented Apr 20, 2021

Purpose of this PR

This PR is adding the option to disable volume framework updates in the Camera Inspector and to the URP Asset. It also adds public API on the Camera for users to update the volume or to change the setting.

Things done in this PR

Editor changes

  • Camera Inspector: Added a Update Mode dropdown
  • URP Asset: Added a Update Mode dropdown under Advanced

Scripting changes

Public

  • VolumeManager: Made the stack setter public
  • VolumeManager: Added a m_DefaultStack variable and cache the original stack in that.
  • VolumeManager: Added a public ResetMainStack() function.
  • Camera: Added a public function GetVolumeFrameworkUpdateMode()
  • Camera: Added a public function SetVolumeFrameworkUpdateMode(VolumeFrameworkUpdateMode mode)
  • Camera: Added a public function UpdateVolumeStack()
  • Camera: Added a public function UpdateVolumeStack(UniversalAdditionalCameraData cameraData)
  • AdditionalCameraData: Added an public property requiresVolumeFrameworkUpdate
  • AdditionalCameraData: Added an public property volumeStack
  • UniversalRenderPipelineAsset: Added a public enum VolumeFrameworkUpdateMode
  • UniversalRenderPipelineAsset: Added a public property volumeFrameworkUpdateMode

Internal

  • Camera: Added an internal function GetVolumeLayerMaskAndTrigger(UniversalAdditionalCameraData cameraData, out LayerMask layerMask, out Transform trigger)
  • AdditionalCameraData: Added an internal property volumeFrameworkUpdateMode

Other changes

  • Testing: Created a new test scene using a global and local volume with three cameras using different masks. This test scene will be enabled in a follow-up PR.
  • Other: Added some Documentation that were missing for some public properties

UI Changes

Camera Inspector

Before

image

After

image

URP Asset

Before

image

After

image

Testing

What has been tested

  • Tested locally in the editor (OS X)

What needs testing

  • Editor: Test if Volumes are always updated when not in playmode
  • Editor: Test if Volumes are updated in playmode when EveryFrame is selected on the camera and/or URP Asset
  • Editor: Test if Volumes are not updated in playmode when ViaScripting is selected on the camera and/or URP Asset
  • Editor/Builds: Scripting: Camera: Test Getting & Setting VolumeFrameworkUpdateMode on the camera.
  • Editor/Builds: Scripting: Camera: Test if the two UpdateVolumeStack() functions do not do anything when it's set to EveryFrame
  • Editor/Builds: Scripting: Camera: Test if the two UpdateVolumeStack() functions update the correct volume stack when it's set to Via Scripting (Test with multiple cameras with various mask settings)
  • Editor/Builds: Scripting: AdditionalCameraData: Test if requiresVolumeFrameworkUpdate returns correct results

Later work

A follow-up PR will add the new test scene to our CI

@ellioman ellioman requested a review from Verasl April 20, 2021 13:14
@ellioman ellioman requested review from a team and oleks-k April 20, 2021 13:17
@ellioman ellioman removed the testing label Apr 20, 2021
Comment on lines +429 to +431
/// <summary>
/// Returns true if this camera should automatically replace NaN/Inf in shaders by a black pixel to avoid breaking some effects.
/// </summary>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra documentation that bothered me when looking at the code.

Comment on lines +438 to +440
/// <summary>
/// Returns true if this camera applies 8-bit dithering to the final render to reduce color banding
/// </summary>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra documentation that bothered me when looking at the code.

Comment on lines +348 to +350
/// <summary>
/// Returns the selected scene-layers affecting this camera.
/// </summary>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra documentation that bothered me when looking at the code.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit vague IMO. In HDRP this field is documented like this:

Layer mask used to select which volumes will influence this camera.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@oleks-k I like the suggestion here. What are your thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest this description (does it return a list?):

Returns the list of Layers selected in the Layer property of this Camera.

Is it technically correct?

Comment on lines 357 to 359
/// <summary>
/// Returns the transform that will act as a trigger for volume blending.
/// </summary>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra documentation that bothered me when looking at the code.

@ellioman ellioman requested review from a team and svens-unity April 20, 2021 14:29
@erikabar erikabar requested review from a team and erikabar April 21, 2021 08:41
@erikabar
Copy link
Contributor

@Unity-Technologies/mobile-qa could you test if this PR does not regress anything on mobile side?

Copy link
Contributor

@svens-unity svens-unity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking good :) Main question I have is how we expect users to update volumes via scripting - what is the API point for this. At first thought, I would expect a call on Camera or similar to update the volume for that camera that instant. Furthermore, another call to update all volumes stacks at once.

/// Returns the current volume stack used by this camera
/// </summary>
VolumeStack m_VolumeStack = null;
public VolumeStack volumeStack
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the moment this is the main location where we expect users to interact with when using ViaScripting?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(As you know but replying in case other reviewers are thinking the same)
We now have functions on the Camera to update the volume framework.
If users would like to change the stack used by this camera, then they have the possibility here to replace the volumeStack with their custom one.

@aleksandrasdzikia aleksandrasdzikia requested review from aleksandrasdzikia and removed request for a team April 22, 2021 07:51
Copy link
Contributor

@Verasl Verasl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@oleks-k oleks-k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

Copy link
Contributor

@erikabar erikabar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found. Tested Scripting API and Settings in the inspector with one camera, multiple cameras, camera stacking.
Test doc: https://docs.google.com/document/d/1oMyqz56wyz0r2PZtnZnn1Zkp53GggA-nKg1kJon9FMI/edit#

Copy link

@aleksandrasdzikia aleksandrasdzikia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good on mobile side and no issues found. Used Erika's provided project to test different scenarios. Regarding performance, as discussed with Elvar, this will be done later due to lack of time, but performance should only be improved due to given option for user to disable or control the volume frame work updates. Other than that, looks good.

ellioman added 2 commits May 7, 2021 11:45
# Conflicts:
#	com.unity.render-pipelines.universal/Editor/Camera/UniversalRenderPipelineCameraEditor.cs
@ellioman ellioman requested a review from alex-vazquez May 7, 2021 10:04
Copy link
Contributor

@alex-vazquez alex-vazquez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change the DrawPopUp


// Dropdown menu options
public static string[] mainLightOptions = { "Disabled", "Per Pixel" };
public static string[] volumeFrameworkUpdateOptions = { "Every Frame", "Via Scripting" };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do in a next PR

@phi-lira phi-lira marked this pull request as ready for review May 7, 2021 12:17
@phi-lira phi-lira requested a review from a team as a code owner May 7, 2021 12:17
@phi-lira phi-lira merged commit 6865b10 into master May 7, 2021
@phi-lira phi-lira deleted the universal/volumes/control-updates branch May 7, 2021 12:17
ellioman added a commit that referenced this pull request Sep 9, 2021
ellioman added a commit that referenced this pull request Sep 9, 2021
ellioman added a commit that referenced this pull request Sep 13, 2021
ellioman added a commit that referenced this pull request Sep 13, 2021
…pdates (#5594)

* Backport of #4242

* Changelog

* Fixing an issue where changing Camera ViaScripting to URP Asset ViaScripting, would update the volumeStack
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.