My custom shader is suddenly broken so I’m trying to update it to the new API per the documentation here: Shader Chunk Migrations | Learn PlayCanvas
Here is the shader code:
uniform float uOffset;
#ifdef MAPCOLOR
uniform vec3 material_emissive;
#endif
#ifdef MAPFLOAT
uniform float material_emissiveIntensity;
#endif
#ifdef MAPTEXTURE
uniform sampler2D texture_emissiveMap;
#endif
vec3 getEmission() {
dEmission = vec3(1.0);
#ifdef MAPFLOAT
dEmission *= material_emissiveIntensity;
#endif
#ifdef MAPCOLOR
dEmission *= material_emissive;
#endif
#ifdef MAPTEXTURE
dEmission *= $DECODE(texture2D(texture_emissiveMap, $UV + vec2(uOffset, 0.0), textureBias)).$CH;
#endif
#ifdef MAPVERTEX
dEmission *= gammaCorrectInput(saturate(vVertexColor.$VC));
#endif
}
This is the same code as listed in the chunk (here) except that I have a parameterised offset on the texture.
I have also added this second line to the code to flag that it is using the current API:
currentMaterial.chunks.emissivePS = this.app.assets.find('AnalyserScreenPS', 'shader').resource;
currentMaterial.chunks.APIVersion = pc.CHUNKAPI_1_55;
However, when I run I get the following errors in the console:
Shader chunk 'emissivePS' is API version 1.55, but the supplied chunk is version -. Please update to the latest API.
Failed to compile fragment shader:
ERROR: 0:283: 'getEmission' : function does not return a value:
What is happening here? Surely in the new API the expectation is the that getEmission modifies a global and does not return a value?