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

[2021.2][URP][ShaderGraph] Enable automatic render queue control on SG-based material inspector #4610

Merged
merged 5 commits into from
Jun 10, 2021

Conversation

jessebarker
Copy link
Contributor

@jessebarker jessebarker commented May 21, 2021

Checklist for PR maker

  • Have you updated the changelog? Each package has a CHANGELOG.md file.
  • Have you updated or added the documentation for your PR? When you add a new feature, change a property name, or change the behavior of a feature, it's best practice to include related documentation changes in the same PR. If you do add documentation, make sure to add the relevant Graphics Docs team member as a reviewer of the PR. If you are not sure which person to add, see the Docs team contacts sheet.
  • Have you added a graphic test for your PR (if needed)? When you add a new feature, or discover a bug that tests don't cover, please add a graphic test.

Purpose of this PR

This PR fixes https://fogbugz.unity3d.com/f/cases/1335795/

The material inspector behaves differently for handwritten shader-based materials than it does for ShaderGraph based materials. The handwritten shaders automatically force the setting of the render queue based on the surface type property, whereas the ShaderGraph materials allow for independent control of the render queue. This PR adds a new "Queue Control" on the material inspector with "Auto" and "UserOverride" options. The "Auto" option is selected by default and behaves the same way as a material created from the handwritten URP shaders (Lit.shader, Unlit.shader). The "UserOverride" option allows the current behavior of independent control over surface type and render queue. When "Auto" is selected, there is no Render Queue field (as with handwritten shaders).

The UI had a bit of a review after the original screen shot below in the testing status section. Currently, a "Queue Control" of "UserOverride" enables the "Render Queue" field, whereas "Auto" does not. "Sorting Priority" is always present as it is relevant regardless of where the render queue setting comes from. See these material inspector shots for detail:

Screen Shot 2021-06-09 at 6 19 59 AM
Screen Shot 2021-06-09 at 6 19 15 AM

It is perhaps worth mentioning that those two materials and shadergraphs were created with 2021.1 and dropped into a project that is using this branch (so they've been upgraded and not just created by these changes).


Testing status

Created a scene with 3 objects:

  • A material created using Lit.shader
  • A material created using a Lit Shader Graph
  • A material created using an Unlit Shader Graph

See this image:
Screen Shot 2021-05-21 at 9 18 22 AM

Observed the following behaviors/test cases:

  • The "Auto" queue control behaves as the handwritten shader material.
  • The "UserOverride" queue control behaves as before (e.g., selecting "Transparent" for the render queue when the surface type is "Opaque" is both possible and will make the object disappear from the scene).
  • Disabling "allow material override" on the Shader Graph forces "from shader" on the render queue setting with "Auto" queue control.
  • Disabling "allow material override" on the Shader Graph allows render queue switching with "UserOverride" queue control.
  • Combinations of switching back and forth between these (e.g., re-enabling "allow material override" restores the previous material property settings from before disabling it). Enabling/disabling "allow material override", switching between "Auto" and "UserOverride", switching surface type with both "Auto" and "UserOverride".

Upgrade testing:
Created Shader Graphs and corresponding materials in Unity 2021.1, loaded them in the 2021.2 build from this PR, and observed the following:

  • Materials previously saved with render queue "from shader" were upgraded to queue control "Auto"
  • Materials previously saved with custom render queue (explicitly "geometry", "alphatest", "transparent") were upgraded to queue control "UserOverride"

Yamato details below

(N.b., the following yamato jobs failed on master at the point of branch-off for this PR)

Test minimum editor version - Win
Test minimum editor version - OSX
Test all packages - OSX
Test all packages - Win
Universal_Hybrid - OSX Metal
Universal_Hybrid - Win DX11

The remaining "failures" are the result of those 4 dependencies failing, so this PR is as green as master at the point of branch-off.


Comments to reviewers

Notes for the reviewers you have assigned.

@jessebarker jessebarker requested review from Verasl, cdxntchou and a user May 21, 2021 16:34
@jessebarker
Copy link
Contributor Author

I'm not marking the upgrade testing as complete yet, so this should not get merged until I update further. Basically, I have local changes that I've confirmed let the upgrade work correctly (so technically I have done the upgrade testing), but the upgraded material property values are getting stomped on by the target/shaderGUI later on, and I need to unravel that before committing an update.

    - Two modes are "Auto" (0) and "UserOverride" (1)
    - Auto is by default, and behaves like hand-written shader based materials
      (switches based on SurfaceType for material override, otherwise based on
      what the shader defines).
    - UserOverride allows for a render queue selection independent of what the
      SurfaceType would select.
    - When encountering an older material, we initialize according to the actual
      serialized render queue property in the material (-1 or "FromShader"
      sets up queue control of "Auto", an expliict render queue sets up queue
      control of "UserOverride" and preserves the user's render queue choice.
@jessebarker
Copy link
Contributor Author

I'm not marking the upgrade testing as complete yet, so this should not get merged until I update further. Basically, I have local changes that I've confirmed let the upgrade work correctly (so technically I have done the upgrade testing), but the upgraded material property values are getting stomped on by the target/shaderGUI later on, and I need to unravel that before committing an update.

I've resolved this issue, but the code is a bit different (same logic, but not handled as part of the material upgrade path), so once the Yamato runs finish, we can call this done.

@jessebarker jessebarker marked this pull request as ready for review June 4, 2021 23:09
@jessebarker jessebarker requested review from a team as code owners June 4, 2021 23:09
Copy link
Contributor

@joshua-davis joshua-davis left a comment

Choose a reason for hiding this comment

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

Mostly good, but it would be nice if a lot of the int literals could be turned into constants.

Copy link

@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.

LGTM

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.

I have some small UX/UI requests but these can be tweaked later:

  • the Render Queue /Sorting Priority should be indented I think since it is a setting directly affected by the above enum
  • Sorting priority should be moved up one to sit under Queue Control

If these are simple changes would be great to get them in, just to give it that polished feel but no need for holding up the PR if not.

@marctem marctem merged commit 854d3ed into master Jun 10, 2021
@marctem marctem deleted the sg-fix-1335795 branch June 10, 2021 23:10
jessebarker added a commit that referenced this pull request Jun 17, 2021
    - See #4610 and #4920 that address fogbugz 1335795 for details
    - This makes the shader GUI for built-in behave as URP does for better
      user experience
jessebarker added a commit that referenced this pull request Jun 21, 2021
* Apply render queue control to BuiltIn Target and shader GUI to match URP
    - See #4610 and #4920 that address fogbugz 1335795 for details
    - This makes the shader GUI for built-in behave as URP does for better
      user experience

* Update changelog to reflect the render queue control changes for the BuiltIn target
JarkkoUnity pushed a commit that referenced this pull request Jun 30, 2021
* Apply render queue control to BuiltIn Target and shader GUI to match URP
    - See #4610 and #4920 that address fogbugz 1335795 for details
    - This makes the shader GUI for built-in behave as URP does for better
      user experience

* Update changelog to reflect the render queue control changes for the BuiltIn target
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.

5 participants