0
\$\begingroup\$

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: Per @DMGregory's comment, it's unlikely an issue with the shader itself; here is the scene configuration for greater context:

enter image description here

\$\endgroup\$
3
  • \$\begingroup\$ This function's job is to map vertices from the local coordinate space of their containing object to the clipping space used for drawing to the screen. Its presence is not the problem. My best guess is that your object is rendering across the whole screen, setting the depth or stencil buffer to some state that's blocking the other objects from rendering, and so by transforming it so it no longer appears on screen you're avoiding this side effect, but we really can't see enough of your shaders to know for sure. Please edit your question to contain a complete reproducible example we can test. \$\endgroup\$
    – DMGregory
    Oct 9 at 3:09
  • \$\begingroup\$ @DMGregory That makes sense. It must be something else beyond just the shader, then. I'll update the question right now with a screenshot of how the scene is configured. \$\endgroup\$ Oct 9 at 18:16
  • \$\begingroup\$ What we need is a Minimal Complete Verifiable Example. A reader should be able to use only the content of your question to reproduce this issue in a new empty project. Once we can reproduce the problem, we can test potential fixes to be sure they'll work for you. \$\endgroup\$
    – DMGregory
    Oct 9 at 18:34
0
\$\begingroup\$

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.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.