#How to find out why a shader is pink on a certain platform?

1 messages · Page 1 of 1 (latest)

azure heath
#

What is the way to find out quickly why is a shader is rendered as pink?

restive salmon
#

There is in general two reasons for a shader to be pink :

  1. Incompatible render pipeline (that's 99% of the cases out of the box)
  2. Shader compilation error (rest 1%. If you didn't do the shader yourself, it's definitively option 1)
azure heath
#

so its compatible on one platform and not compatible on the other?

#

these are custom shaders

restive salmon
#

You mean, changing the target platform broke a shader ?

azure heath
#

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

restive salmon
#

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.

azure heath
#

only in build of the original project

#

but it works in the build of the empty project

restive salmon
#

Might be worth checking the logs.

azure heath
#

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

restive salmon
#

In the player log ?

azure heath
#

for building

restive salmon
#

Sorry, I mean "And what about the player log ?"

azure heath
#

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

restive salmon
#

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.

azure heath
#

(I'm a gameplay programmer by the way, this is why I don't have much shader exp)

restive salmon
#

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.

azure heath
#

the first frame from top to bottom where pink appears?

restive salmon
azure heath
azure heath
#

so the earthquakedecal is the faulty one?

restive salmon
#

Yep.

#

No info in the windows about why it would swap the shader for the fallback one ?

restive salmon
#

Could you share a screenshot of the whole frame debugger window ?

restive salmon
#

Hum, yeah, didn't help....

Is that project using URP or HDRP ?

restive salmon
#

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.

azure heath
#

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)

cerulean isle
#

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?

azure heath
#

I mean these kind of things

cerulean isle
#

Are you doing some custom shader stripping during addressables build/shader compilation? People often do with addressables.

azure heath
azure heath
cerulean isle
#

Search for IPreprocessShaders interface implementation in the codebase. That's the main way.

azure heath
#

@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