Search code examples
unity-game-engineshaderhlsl

Why is my shader's call to UnityObjectToClipPos() causing my *other* shaders to be invisible?


I created a shader via a node-based shader tool called Shadero Sprite, and I'm trying to debug an issue with it. Since the code was generated by the node-based tool, I'm not entirely sure what the purpose of every line in the shader is, which makes this issue difficult to debug.

The issue is that, although the shader itself works fine, having an object with it in my Unity scene causes certain other objects in my scene to not render at all; they become invisible.

It seems to be something related to this call to UnityObjectToClipPos() below:

        v2f vert(appdata v)
        {
            v2f o;
            o.vertex = UnityObjectToClipPos(v.vertex);
            o.uv = TRANSFORM_TEX(v.uv, _MainTex);
            UNITY_TRANSFER_FOG(o,o.vertex);
            return o;
        }

...because, if I replace...

            o.vertex = UnityObjectToClipPos(v.vertex);

...with...

            o.vertex = v.vertex;

then the other shaders/objects render fine. However, this of course means that THIS shader doesn't look right.

The only other clue I've been able to deduce is that the other objects (the ones that go invisible) are Unity UI elements that all have custom shaders. One shader is using a call to UnityObjectToClipPos(). The other doesn't seem to (although it has many #includes, so perhaps a call to it does exist, buried in one of those #includes).

Why is this function call causing other objects to go invisible, and what can I replace it with to fix it?

EDIT: Here is the scene configuration for greater context:

enter image description here


Solution

  • The issue ended up being with the shader I was using for my text.

    The text uses a Unity asset called SuperTextMesh, which offers multiple shaders for text. I was using the "Dropshadow and outline unlit" shader, when I needed to use the "Dropshadow and outline" shader instead. The "unlit" one caused issues.