I’m trying to sort out a render order issue, and I’m using some custom shaders - one of them relies on the uScreenSize
global shader variable. Unfortunately when I move it to the new layer I get the error message:
'uScreenSize' : undeclared identifier
Is there something I’m missing? I’m browsing the source code trying to find the cause but any advice would be welcomed.
Hi @hearsepileup,
So there are two shader chunks that declare that variable (screen depth and pixel snap), so if those are missing it will be indeed undeclared.
Are you overriding shader chunks or are you writing pixel shaders from scratch? As an easy fix you can just try and declare the uniform on top of your shader:
uniform vec4 uScreenSize;
If the engine sets the value on this material, and it’s not a full custom shader, then I think that should be enough. @mvaligursky
1 Like
I’ll give that a go; I’m just modifying chunks atm - thanks for the suggestion! I was just a little puzzled as to why it was working before in the ‘World’ layer, but not in my custom one 
That’s a good point, curious why that’s the case.
Hmm, it seems like the problem is a bit more deeply engrained than I thought; I’m currently customising my shaders but adding to the lightDiffuseLambertPS section of the shader definition; but this whole section seems to be being excluded when it’s moved to the new layer.
I’m going to keep investigating; I’m guessing there’s something that’s changing how the layer is rendering with regard to Lambert shader settings, or maybe there’s a toggle I can set on the material to ensure it’s used. It still strikes me as odd that it’s causing this issue.
Ok, I got it!
What I was missing was adding lights to the new layer as well. A silly thing I missed on my part, thanks for talking it out with me!
3 Likes
Right, that makes sense! The shader is generated automatically based on the selected properties/lights/shadows settings.
2 Likes