Hello everyone, I am experiencing this problem and i’m wondering if anyone can help me. It seems like the shaders are inverted on mobile but not on desktop, what are the steps that i should take to solve this problem?
There’s a note at the bottom of the page you linked to that mentions this problem and subsequently links to this Unity documentation:
The TLDR version is OpenGL (or in your case specifically OpenGL ES as that’s what your mobile device is running) generally renders upside down compared to Direct3D, and really all other rendering APIs. Except when it doesn’t. Unity does a lot to try to make everything else act like OpenGL, but as a result it can make a lot of things like post processing more complicated.
There’s an old graphics programming joke of “make sure you have an even number of sign errors.”
To make things a little easier, you can force the editor to run in OpenGL which should show the same issue.
There’s probably a “correct” way to handle this by putting the special macros and/or #if lines in every shader, but I’ve honestly never found the perfect combination that works in all cases. The hack I fall back on is I flip the y on the shader I use to render the original mask to whatever orientation is needed for the final result to look right.
In your case, I would try modifying the “unlit” vertex shader used with the DrawAsSolidColor material.
o.vertex = UnityObjectToClipPos(v.vertex);
// flip the mask upside down if you're rendering using OpenGL
#if UNITY_UV_STARTS_AT_TOP == 0
o.vertex.y = -o.vertex.y;
#endif
return o;
That might be enough to make it “just work” for this specific case.
[quote=“bgolus, post:2, topic: 831800, username:bgolus”]
There’s a note at the bottom of the page you linked to that mentions this problem and subsequently links to this Unity documentation: https://docs.unity3d.com/Manual/SL-PlatformDifferences.html
The TLDR version is OpenGL (or in your case specifically OpenGL ES as that’s what your mobile device is running) generally renders upside down compared to Direct3D, and really all other rendering APIs. Except when it doesn’t. Unity does a lot to try to make everything else act like OpenGL, but as a result it can make a lot of things like post processing more complicated.
There’s an old graphics programming joke of “make sure you have an even number of sign errors.”
There’s probably a “correct” way to handle this by putting the special macros and/or #if lines in every shader, but I’ve honestly never found the perfect combination that works in all cases. The hack I fall back on is I flip the y on the shader I use to render the original mask to whatever orientation is needed for the final result to look right.
In your case, I would try modifying the “unlit” vertex shader used with the DrawAsSolidColor material.
o.vertex = UnityObjectToClipPos(v.vertex);
// flip the mask upside down if you're rendering using OpenGL
#if UNITY_UV_STARTS_AT_TOP == 0
o.vertex.y = -o.vertex.y;
#endif
return o;
That might be enough to make it “just work” for this specific case.
[/quote]
Thanks to you, the shaders stopped flying around. However, a new problem currently persists where the non-glowing part of the image moves while I move. Do you have a solution for that?
I guess that means the “just work” hack didn’t just work.
I looked over the shader in the linked article a little closer and … it’s kind of terrible. Using a grab pass in a shader used for a blit … just, why?! It can be fixed. But there are similar, and still free, options for outlines that should work without any modifications. Like this one: