-
Notifications
You must be signed in to change notification settings - Fork 855
[VFX] reimport on SRP changed + remove built-in support and notify #4379
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
Changes from all commits
84602be
f73d36d
a4c7bf3
3e771e2
453feba
2981e68
e600d59
42aa588
ea2697f
9ef7a9d
55f6371
292a833
dca3c30
cd77446
7ceeec9
d2b86f6
a81c07b
7049656
683a661
aba779d
6f4d5a6
318b302
6608c91
963d321
64fcf79
96ffc00
293b0d4
eb830bb
0958290
f6fd8a5
192b466
e72745d
12afe73
52f3133
f92c78b
62def82
f25625a
a8b921f
dd4d21a
eba1a0c
839ecc7
d590e41
61505d8
6310a99
55d4afc
9d3d1f7
a90e176
a1db362
3de3b7f
368f63c
ed83bec
2b6fcff
3438e7e
5b380cf
0d33ace
9a25692
d74c0c2
c72287d
740a296
368fc26
85e6af2
20d6fb9
296ffd3
ad2feb1
be3c497
2b02eb7
21b236c
000dfd9
128d159
4c881d0
5137fd9
02f6be6
0f6037d
145a398
8149a8b
4012fa9
f8a94ec
ae5b232
2fb7cba
4ad6493
08ff952
75b4f58
bd6167e
88af45c
81a9cb5
660b777
3e72ca9
51f3d7d
15e6ed8
644bdde
8b0397e
d1be1a1
bba06b6
a120833
c81ea3e
ea805dc
823e14b
b8212d0
182437a
adaeba7
58ae23c
024dcbf
3801a89
20a4672
61b8375
f6ee116
818adb6
ef6eeaf
15df881
fe924b0
5e1b25c
dedb913
1e7ae1b
249de48
4a0458e
0009e53
ee55b98
f181b2d
0c4cf10
981e074
1443b7d
47ce7f8
960eea5
0a7f877
3142e7b
1f63413
b6d84e9
c74194e
b514cc6
1f96809
bebb073
5015bd6
cc36c16
6356aad
1eecca7
cf3b4ae
ff94af5
9f8239f
a515f2f
183f537
071ce22
a6ee6de
8b44f3b
7649fe1
83ad751
ebcf59f
8f3b4f9
44f497b
5cf1dba
dcf74db
0656778
2a9964b
b89005c
b65e953
79d801d
ddee2e3
8c5f44f
362b7f0
dd7b751
d9a3a0b
a05860f
93c8822
20822dd
5d3b2b0
8bda777
26bbfd0
5b6cd2a
cd13ef9
3a00a4f
ee90c52
61c4249
56a1e11
fc40e69
755227a
6e5e432
cd43882
b063d9e
d610ace
1d6e19d
59edc05
83717ec
ae90ca0
bd121c5
1854731
55ce577
5831dc0
134ba25
4fe95f9
58b89ee
e20740e
c71b090
1e74af1
026d4e0
9066a0b
2765da6
e7f1576
67c19cc
4488254
6b45aad
6643035
5c0f76f
51e78b4
cbeeefb
a4f8133
46de9cc
33fd8ce
dc873e1
6dbb2e9
bd82479
6136320
e316738
4e3192a
f95bac0
42a48df
d31d7ee
71d850e
582dfdf
cb8f501
de16f20
cd03340
415ed6c
eb6f548
7232e81
8d85500
1ed5e58
c4d5b6a
1fd64ed
e84d006
973aeb6
9a64d5a
6786a05
70b8151
dde0fcc
9d51001
bd1384a
42f9ff4
5927bd5
d3208f4
f5aeecd
62a9c1a
c37b304
a4bb699
3300826
d83db5f
a315e56
3882ced
a824274
1e68bf8
dcbffc1
f95c130
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
using UnityEngine; | ||
using UnityEngine.Rendering; | ||
using Object = System.Object; | ||
using System.Reflection; | ||
|
||
namespace UnityEditor.VFX | ||
{ | ||
|
@@ -176,14 +177,6 @@ public virtual VFXAbstractRenderedOutput.BlendMode GetBlendModeFromMaterial(VFXM | |
public virtual bool IsGraphDataValid(GraphData graph) => false; | ||
} | ||
|
||
// This is the default binder used if no SRP is used in the project | ||
class VFXLegacyBinder : VFXSRPBinder | ||
{ | ||
public override string templatePath { get { return "Packages/com.unity.visualeffectgraph/Shaders/RenderPipeline/Legacy"; } } | ||
public override string SRPAssetTypeStr { get { return "None"; } } | ||
public override Type SRPOutputDataType { get { return null; } } | ||
} | ||
|
||
static class VFXLibrary | ||
{ | ||
public static IEnumerable<VFXModelDescriptor<VFXContext>> GetContexts() { LoadIfNeeded(); return VFXViewPreference.displayExperimentalOperator ? m_ContextDescs : m_ContextDescs.Where(o => !o.info.experimental); } | ||
|
@@ -475,21 +468,67 @@ private static void LoadSRPBindersIfNeeded() | |
} | ||
} | ||
|
||
private static bool unsupportedSRPWarningIssued = false; | ||
|
||
private static void LogUnsupportedSRP(VFXSRPBinder binder, bool forceLog) | ||
{ | ||
if (binder == null && (forceLog || !unsupportedSRPWarningIssued)) | ||
{ | ||
Debug.LogWarning("The Visual Effect Graph is supported in the High Definition Render Pipeline (HDRP) and the Universal Render Pipeline (URP). Please assign your chosen Render Pipeline Asset in the Graphics Settings to use it."); | ||
unsupportedSRPWarningIssued = true; | ||
} | ||
} | ||
|
||
public static void LogUnsupportedSRP(bool forceLog = true) | ||
{ | ||
bool logIssued = unsupportedSRPWarningIssued; | ||
var binder = currentSRPBinder; | ||
|
||
if (logIssued || !unsupportedSRPWarningIssued) // Don't reissue warning if inner currentSRPBinder call has already logged it | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that if is a bit weird - it can probably be removed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is because we have 2 paths. LogUnsupportedSRP can be called from lazily initializing the currentSRPBinder (in that case we want to log only the first time) or explicitely upon some users action (opening the graph view, explicitely trying to compile a VFX...) and in this case we want to log always. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let us imagine unsupportedSRPWarningIssued equals to true. then There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. logIssued is just a cache to check whether the inner call to currentSRPBinder has issued the log already (logIssued is false and unsupportedSRPWarningIssued is true after the call) and in that case we don't reissue (else it will be logged twice in a row). true to false is not possible. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shouldnt it be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the test "if (logIssued || !unsupportedSRPWarningIssued)" is false, it means the message has already been log during the inner call to currentSRPBinder just above (unsupportedSRPWarningIssued was false before currentSRPBinder call, and true after), regardless of forceLog. This just prevents logging twice from the same explicit LogUnsupportedSRP call. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. okayyyyyy.... currentSRPBinder is not a getter but a function call! now all of it makes sense :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a getter but lazily initialized. We could move the initialization directly in the callback probably. But it was safer and less intrusive to do it this way now. |
||
LogUnsupportedSRP(binder, forceLog); | ||
} | ||
|
||
public static VFXSRPBinder currentSRPBinder | ||
{ | ||
get | ||
{ | ||
LoadSRPBindersIfNeeded(); | ||
|
||
VFXSRPBinder binder = null; | ||
srpBinders.TryGetValue(GraphicsSettings.currentRenderPipeline == null ? "None" : GraphicsSettings.currentRenderPipeline.GetType().Name, out binder); | ||
var currentSRP = QualitySettings.renderPipeline ?? GraphicsSettings.currentRenderPipeline; | ||
if (currentSRP != null) | ||
srpBinders.TryGetValue(currentSRP.GetType().Name, out binder); | ||
|
||
if (binder == null) | ||
throw new NullReferenceException("The SRP was not registered in VFX: " + GraphicsSettings.currentRenderPipeline.GetType()); | ||
LogUnsupportedSRP(binder, false); | ||
|
||
return binder; | ||
} | ||
} | ||
|
||
[InitializeOnLoadMethod] | ||
private static void RegisterSRPChangeCallback() | ||
{ | ||
EventInfo onRPChanged = typeof(RenderPipelineManager).GetEvent("activeRenderPipelineTypeChanged", BindingFlags.NonPublic | BindingFlags.Static); | ||
if (onRPChanged != null) | ||
{ | ||
MethodInfo addHandler = onRPChanged.GetAddMethod(nonPublic: true); | ||
addHandler.Invoke(null, new Action[] { SRPChanged }); | ||
} | ||
|
||
// Once activeRenderPipelineTypeChanged is public don't use reflection anymore | ||
//RenderPipelineManager.activeRenderPipelineTypeChanged += OnSRPChanged; | ||
} | ||
|
||
public delegate void OnSRPChangedEvent(); | ||
public static event OnSRPChangedEvent OnSRPChanged; | ||
|
||
private static void SRPChanged() | ||
{ | ||
unsupportedSRPWarningIssued = false; | ||
OnSRPChanged?.Invoke(); | ||
VFXAssetManager.Build(); | ||
} | ||
|
||
private static LibrarySentinel m_Sentinel = null; | ||
|
||
private static volatile List<VFXModelDescriptor<VFXContext>> m_ContextDescs; | ||
|
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it should also mention the Quality Settings (A valid Render Pipeline asset needs to be assigned in the Graphics Settings or the Quality Settings.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So what would be the text? "Please assign your chosen Render Pipeline Asset in the Graphics or Quality Settings to use it" ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is what message the tech writing team gave to me for my feature "Project graphics settings do not refer to a URP Asset. Check the settings: Graphics > Scriptable Render Pipeline Settings, Quality > Render Pipeline Asset."
maybe it could be tweaked for your case to:
"The Visual Effect Graph is supported in the High Definition Render Pipeline (HDRP) and the Universal Render Pipeline (URP). Check the settings: Graphics > Scriptable Render Pipeline Settings, Quality > Render Pipeline Asset."