#How to find out why a shader is pink on a certain platform?
1 messages · Page 1 of 1 (latest)
There is in general two reasons for a shader to be pink :
- Incompatible render pipeline (that's 99% of the cases out of the box)
- Shader compilation error (rest 1%. If you didn't do the shader yourself, it's definitively option 1)
so its compatible on one platform and not compatible on the other?
these are custom shaders
You mean, changing the target platform broke a shader ?
yeah
but if I place it in an empty project and build for the target platform, then it works
so something is in the project, which brakes it
I just don't know what
It breaks only in build ?
Then you might to check for potential shader compilation errors in the console when building, or in the player logs of the executable.
only in build of the original project
but it works in the build of the empty project
Might be worth checking the logs.
there are only warnings
but a lot of them
but these warnings are also in the empty project
and since making a build from that has a working shader, I don't think solving these would solve the issue
In the player log ?
not in the player log, in the console
for building
Sorry, I mean "And what about the player log ?"
what should I see here? "shader error"?
@restive salmon on this platform there's no regular "player log", but I can't see any lines mentioning "shader error"
or any shader related warnings
I don't even remember if it's logged, maybe something about error displaying a shader, with more information.
If you make a debug build you should be able to see an in game console with logs. Nothing here either ?
The other option is to use a rendering debugger, which varies from one platform to an other.
yeah, I tried to use that. But what might be relevant in that?
(I'm a gameplay programmer by the way, this is why I don't have much shader exp)
Well, the rendering debug tool depends on the platform. You could try Unity's frame debugger and attach to the platform for remote capture and debug.
Else you need to rely to the platform specific tool.
and what should I look for in the frame debugger?
the first frame from top to bottom where pink appears?
Yes, that's where the object with the faulty shader is draw, if might give more informations on the issue.
okay, so that's the ForwardOpaqueDebug
so the earthquakedecal is the faulty one?
Yep.
No info in the windows about why it would swap the shader for the fallback one ?
what should I look for?
Could you share a screenshot of the whole frame debugger window ?
Hum, yeah, didn't help....
Is that project using URP or HDRP ?
Hum, that's very suspicious ... in particular if it works in an other project ...
So, must be that something in the projet (settings probably) breaks the shader when compiling for the platform.
You could try to make a backup of the project settings and HDRP assets, and copy of the ones from the working project to narrow down what breaks.
well, maybe, but that would mean it would compile shaders for 4-5 hours for the project...
and that's bad, these are 2-3 other shaders, which are not relevant to this one
but I can't rewrite those
but there's one other HDRP asset I could use for check
because I made builds using that before (but didn't see this exact shader with that)
Could be that that specific shader variant is stripped from the build.
Does that object exist in the scene(or a prefab that is referenced in a scene) with exactly same material and renderer params at build time?
everything is loaded via addressables
I mean these kind of things
Are you doing some custom shader stripping during addressables build/shader compilation? People often do with addressables.
I will also try to add the shadergraph to the list of the mandatory added shaders (don't remember the list name specifically, but the one inside project settings or graphics settings
even if the project does that, I'm not aware of that. Where would that happen?
Search for IPreprocessShaders interface implementation in the codebase. That's the main way.
@restive salmon @cerulean isle okay, changing the HDRP asset solved the issue at least for one shader. I'm checking the others, which were faulty