Skip to content

Commit 48cb95b

Browse files
[VFX] Fix URP compilation with SG (& fix warning) (#5187)
* Fix case 1349894 Issue with Lit Quad Output using ShaderGraph in URP * Fix & Improve warning message about VFX Fix sub issue from case 1343124 * *Update changelog.md * Improve condition to correctly support URP & HDRP together
1 parent 09e1584 commit 48cb95b

File tree

7 files changed

+27
-7
lines changed

7 files changed

+27
-7
lines changed

com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/HDTarget.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,15 +366,22 @@ public override bool WorksWithSRP(RenderPipelineAsset scriptableRenderPipeline)
366366
return scriptableRenderPipeline?.GetType() == typeof(HDRenderPipelineAsset);
367367
}
368368

369-
public bool SupportsVFX()
369+
public bool CanSupportVFX()
370370
{
371371
if (m_ActiveSubTarget.value == null)
372372
return false;
373373

374374
if (m_IncompatibleVFXSubTargets.Contains(m_ActiveSubTarget.value.GetType()))
375375
return false;
376376

377-
return m_SupportVFX;
377+
return true;
378+
}
379+
380+
public bool SupportsVFX()
381+
{
382+
if (CanSupportVFX())
383+
return m_SupportVFX;
384+
return false;
378385
}
379386

380387
public void ConfigureContextData(VFXContext context, VFXContextCompiledData data)

com.unity.render-pipelines.universal/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
154154
- Fixed issue with legacy stereo matrices with XR multipass. [case 1342416]
155155
- Fixed unlit shader function name ambiguity
156156
- Fixed Terrain holes not appearing in shadows [case 1349305]
157+
- VFX: Compilation issue with ShaderGraph and planar lit outputs [case 1349894](https://issuetracker.unity3d.com/product/unity/issues/guid/1349894/)
157158

158159
### Changed
159160
- Change Asset/Create/Shader/Universal Render Pipeline/Lit Shader Graph to Asset/Create/Shader Graph/URP/Lit Shader Graph

com.unity.render-pipelines.universal/Editor/VFXGraph/Shaders/Templates/ParticlePlanarPrimitivesLit/PassForward.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ ${VFXEnd}
104104
${SHADERGRAPH_PIXEL_CALL_FORWARD}
105105

106106
${VFXIncludeRP("VFXSGSurfaceData.template")}
107-
outColor = VFXGetPixelOutputForwardShaderGraph(i, surface, builtinEmissiveColor, builtinOpacity);
107+
outColor = VFXGetPixelOutputForwardShaderGraph(i, surface, normalWS);
108108
#else
109109
outColor = VFXGetPixelOutputForward(i, normalWS, uvData);
110110
#endif

com.unity.shadergraph/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
126126
- Fixed a ShaderGraph issue where Float properties in Integer mode would not be cast properly in graph previews [1330302](https://fogbugz.unity3d.com/f/cases/1330302/)
127127
- Fixed a ShaderGraph issue where hovering over a context block but not its node stack would not bring up the incorrect add menu [1351733](https://fogbugz.unity3d.com/f/cases/1351733/)
128128
- Fixed the BuiltIn Target to perform shader variant stripping [1345580] (https://issuetracker.unity3d.com/product/unity/issues/guid/1345580/)
129+
- Fixed incorrect warning while using VFXTarget
129130

130131
## [11.0.0] - 2020-10-21
131132

com.unity.shadergraph/Editor/Data/Interfaces/IMaySupportVFX.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ namespace UnityEditor.ShaderGraph
33
public interface IMaySupportVFX
44
{
55
bool SupportsVFX();
6+
bool CanSupportVFX();
67
}
78

89
static class MaySupportVFXExtensions
@@ -12,5 +13,11 @@ public static bool SupportsVFX(this Target target)
1213
var vfxTarget = target as IMaySupportVFX;
1314
return vfxTarget != null && vfxTarget.SupportsVFX();
1415
}
16+
17+
public static bool CanSupportVFX(this Target target)
18+
{
19+
var vfxTarget = target as IMaySupportVFX;
20+
return vfxTarget != null && vfxTarget.CanSupportVFX();
21+
}
1522
}
1623
}

com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/GraphDataPropertyDrawer.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,16 @@ void RegisterActionToUndo(string actionName)
112112

113113
#if VFX_GRAPH_10_0_0_OR_NEWER
114114
// Inform the user that VFXTarget is deprecated, if they are using one.
115-
if (graphData.m_ActiveTargets.Count(t => t.value.SupportsVFX()) == 1 &&
116-
graphData.m_ActiveTargets.Count(t => t.value is VFXTarget) == 1)
115+
var activeTargetSRP = graphData.m_ActiveTargets.Where(t => !(t.value is VFXTarget));
116+
if (graphData.m_ActiveTargets.Any(t => t.value is VFXTarget) //Use Old VFXTarget
117+
&& activeTargetSRP.Any()
118+
&& activeTargetSRP.All(o => o.value.CanSupportVFX()))
117119
{
118120
var vfxWarning = new HelpBoxRow(MessageType.Info);
119121

120-
var vfxWarningLabel = new Label("The Visual Effect target is deprecated. \n" +
121-
"Add a Universal or HDRP target instead, and enable 'Support VFX Graph' in the Graph Inspector.");
122+
var vfxWarningLabel = new Label("The Visual Effect target is deprecated.\n" +
123+
"Use the SRP target(s) instead, and enable 'Support VFX Graph' in the Graph Inspector.\n" +
124+
"Then, you can remove the Visual Effect Target.");
122125

123126
vfxWarningLabel.style.color = new StyleColor(Color.white);
124127
vfxWarningLabel.style.whiteSpace = WhiteSpace.Normal;

com.unity.shadergraph/Editor/Generation/Targets/VFXTarget.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ public override bool WorksWithSRP(RenderPipelineAsset scriptableRenderPipeline)
145145
}
146146

147147
public bool SupportsVFX() => true;
148+
public bool CanSupportVFX() => true;
148149
}
149150
}
150151
#endif

0 commit comments

Comments
 (0)