Problem adding shader variants with GrabPass

I’m trying to add a shader which uses GrabPass to a shader variant collection, but I get an error when attempting to add a variant. Im just using the example shader from https://docs.unity3d.com/Manual/SL-GrabPass.html. Anyone got any ideas on how to fix this, or is it an actual bug?

ArgumentException: shader GrabPassInvert pass type 0 does not have a shader snippet
UnityEngine.ShaderVariantCollection+ShaderVariant…ctor (UnityEngine.Shader shader, PassType passType, System.String[ ] keywords) (at /Users/builduser/buildslave/unity/build/artifacts/generated/common/runtime/ShaderBindings.gen.cs:525)
UnityEditor.AddShaderVariantWindow.Draw (Rect windowRect) (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/ShaderVariantCollectionInspector.cs:397)
UnityEditor.AddShaderVariantWindow.OnGUI () (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/ShaderVariantCollectionInspector.cs:261)
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[ ] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[ ] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:232)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[ ] parameters) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MethodBase.cs:115)
UnityEditor.HostView.Invoke (System.String methodName, System.Object obj) (at /Users/builduser/buildslave/unity/build/Editor/Mono/HostView.cs:187)
UnityEditor.HostView.Invoke (System.String methodName) (at /Users/builduser/buildslave/unity/build/Editor/Mono/HostView.cs:180)
UnityEditor.HostView.OnGUI () (at /Users/builduser/buildslave/unity/build/Editor/Mono/HostView.cs:76)

how fixed it?

I have the same problem. Unity 2019.4 LTS

So shaders using grabpass are not supported in ShaderVariantCollections?

For me this is part of the bigger problem of shader variants that are used in materials within asset bundles are being stripped, if they are not in a variant collection. So, this is all very annoying)

Hi!
Which pass are you trying to add?
Does this happen when you add GrabPass, or when you’re adding any pass from a shader that has a grab pass?

Hi @aleksandrk , this is when adding a shader that is using grabpass. (As the initial poster writes, the example grabpass shader does not work)

@sschoellhammer thanks, I’ll take a look tomorrow :slight_smile:

Amazing :slight_smile: Thanks so much!

Hey, I reproduced this issue, will post here when an issue tracker link is available. The case # is 1264467.

You’re a star! Thanks!

There it is: Unity Issue Tracker - [ShaderVariantCollection] Impossible to add a shader to SVC when the shader contains a GrabPass

1 Like

:roll_eyes: