Skip to content

Fix for issue with Default material not available when Models are imported at project startup. #345

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 6 commits into from
May 27, 2020

Conversation

Thomasch-unity3d
Copy link
Contributor

@Thomasch-unity3d Thomasch-unity3d commented May 1, 2020

Please read

PR workflow guidelines

  • SRP ABV will start automatically on Yamato when you open your PR
  • Changes to docs and md files will not trigger ABV jobs
  • Consider making use of draft PRs if you are not 100% sure that your PR is ready for review
  • ABV will restart if you add a new commit to a branch with an open PR (hence why you should consider using draft PRs)
  • Adding [skip ci] (case insensitive) to the title of PRs will stop any jobs being trigger automatically - you will need to open Yamato and find your branch to run ABV
  • You can also add [skip ci] to commit messages to prevent CI from running on that push
  • Add [cancel old ci] to your commit message if you've made changes you want to test and no longer need the previous jobs

Checklist for PR maker

  • Have you added a backport label (if needed)? For example, the need-backport-* label. After you backport the PR, the label changes to backported-*.
  • 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.
  • 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

Fixes case 1141488 where Materials generated by the model importer fallback to the legacy default material rather than HDRP's default material.
The issue here is that HDRenderPipelineEditorResources fails to load using LoadAssetAtPath.
Using LoadSerializedFileAndForget succeeds but imples that changes to the HDRenderPipelineEditorResources asset are not picked up until Unity is restarted.


Testing status

Manual Tests: What did you do?

  • Opened test project + Run graphic tests locally
  • Built a player
  • Checked new UI names with UX convention
  • Tested UI multi-edition + Undo/Redo + Prefab overrides + Alignment in Preset
  • C# and shader warnings (supress shader cache to see them)
  • Checked new resources path for the reloader (in developer mode, you have a button at end of resources that check the paths)
  • Other:

Automated Tests: What did you setup? (Add a screenshot or the reference image of the test please)

Yamato: (Select your branch):
https://yamato.prd.cds.internal.unity3d.com/jobs/902-Graphics

Any test projects to go with this to help reviewers?


Comments to reviewers

Notes for the reviewers you have assigned.

Copy link
Contributor

@RSlysz RSlysz left a comment

Choose a reason for hiding this comment

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

This should work AFAIK.

@sebastienlagarde
Copy link
Contributor

Thanks for this @Thomasch-unity3d . I have merged master and relaunched as all was red but not due to this PR. Question what are we donig with this PR: https://github.com/Unity-Technologies/ScriptableRenderPipeline/pull/5862 (Guess it is almost the same?) could you close it. THanks!

@Thomasch-unity3d
Copy link
Contributor Author

Yes, Unity-Technologies/ScriptableRenderPipeline#5862 is the previous iteration, closed now. QA is in progress but I'd be great to have more from your team and there might be other issues that this fixes ( ie : I know there's a similar bug for speedTree in URP ). Thanks guys!

@Thomasch-unity3d
Copy link
Contributor Author

And just to make sure, are you ok with " changes to the HDRenderPipelineEditorResources asset are not picked up until Unity is restarted." ? It's supposed to be read-only for users so I assume it's not a problem but should we document that ?

@sebastienlagarde sebastienlagarde requested a review from a team May 6, 2020 16:08
@sebastienlagarde
Copy link
Contributor

I am adding our QA so they can check. @Thomasch-unity3d could you put a description about what you have tested and what workflow was failing before this PR. THanks (for @Unity-Technologies/gfx-qa-hdrp Thomas ios in Montreal timezone)

@sebastienlagarde
Copy link
Contributor

One of the thing to pay attention is upgrade (between two version where we have added stuff in RPResources, this could be from 8.1.0 to latest 9.x-preview package (so this PR))

Copy link

@etienne-unity etienne-unity left a comment

Choose a reason for hiding this comment

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

Default material now applies correctly upon re-import

Tests done:

Upgrade path

  1. Create HDRP project from trunk (Vanilla), complete import and close
  2. Edit Package path to this PR
  3. Re-open
    Result : Materials were seemed correct, no missing materials.
    Preview thumbnails update require re-import
    Note: I'm not a regular user of HDRP so this needs to be validated by owner team

Re-import assets with correct HRDP materials applied

  1. Set a model material import to None.
  2. Close project and delete Library
  3. Open project and validate material used by model
    Result : Material used is HDRP

Add field in HDRenderPipelineEditorResources/MaterialResources

  1. Open \Runtime\RenderPipelineHDRenderPipelineEditorResources.cs
  2. Add Material field to MaterialResources and give it a .mat
  3. Reload
    Result: Field is added and no error thrown
  4. Close and delete Library
    Result: Field is added, material is assigned and no error is thrown

Main purpose of PR is fulfilled and no side effect seems apparent.

Version: 2020.2.0a12.git.4668243
Revision: trunk 473b5360955a
Built: Wed, 06 May 2020 11:41:47 GMT

@iM0ve
Copy link
Contributor

iM0ve commented May 13, 2020

I also upgraded 2 project from HDRP 8.0.0 Unity 2020.1.a23 to this PR Unity 2020.2.a11

Visually there were no issues and no pink materials, however noticed a new minor issue. The yellow highlight stopped working that showcases which HDRP editor resources asset is used. See the video

HDRP/staging (working)
Highlights and selects the asset

staging

hdrp-editorResourcesAsset-loadAndForget (issue)
Does not highlight only selects

PR

Copy link
Contributor

@iM0ve iM0ve left a comment

Choose a reason for hiding this comment

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

See above

@Thomasch-unity3d
Copy link
Contributor Author

Thanks for the test pass, I'm not sure how to deal with that issue, that field is editable but any change in there is reverted when the editor is closed and restarted because HDRenderPipelineAsset always finds the HDRenderPipelineEditorResources.asset at a specific hardcoded path.
I wonder if that field should be removed or made not editable, I'm confused about its role. I'll see if I can force the ObjectField to always highlight that asset.
Any other idea or suggestion ?

@sebastienlagarde
Copy link
Contributor

Thanks for the test pass, I'm not sure how to deal with that issue, that field is editable but any change in there is reverted when the editor is closed and restarted because HDRenderPipelineAsset always finds the HDRenderPipelineEditorResources.asset at a specific hardcoded path.
I wonder if that field should be removed or made not editable, I'm confused about its role. I'll see if I can force the ObjectField to always highlight that asset.
Any other idea or suggestion ?

@RSlysz any thought? thanks

@RSlysz
Copy link
Contributor

RSlysz commented May 26, 2020

True... I haven't see this comming.
Without a loading persistent (with an handle) you cannot ping it any more in the Project Window.

In therm of memory management, the current Resource Asset is saved on the only occasion where it can be modified so it is good.

In therm of loading issue, it seams to fix somewhat issue that was happening previously.

So I can only see one way. As using this loading method was a workarround in the first place, I think that we should aim to reload with persistency some frame later. This way, the ping will be working again.
@Thomasch-unity3d : Do you see any time after the initial loading where you can perform a standard load again ?

Copy link
Contributor

@iM0ve iM0ve left a comment

Choose a reason for hiding this comment

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

To check the highlight fix, updated HDRP template from 7.1.7 to this branch. No new issues and the asset is now highlighted.

9QrgQp9pLq

@sebastienlagarde sebastienlagarde merged commit 9c47629 into master May 27, 2020
@sebastienlagarde sebastienlagarde deleted the hdrp-editorResourcesAsset-loadAndForget branch May 27, 2020 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants