User Manual

Shader Chunk Migrations


The PlayCanvas Engine's material shader chunk system is undergoing substantial changes in order to support a more flexible material system. Please see this page for more context.

In order to help users migrate their existing custom shader chunks, this page lists the changes made to chunks and organizes them by engine release (starting v1.51).

Chunk API Versions

The debug version of the Engine will report any API changes to the runtime console when it detects overridden chunks. For example:

Console output

Once an application's chunks have been updated to the latest API they must be flagged as such. For example, after updating a material's custom chunks to the latest engine release (say v1.55), specify this in the chunks object as follows:

material.chunks.diffusePS = '...';
material.chunks.APIVersion = pc.CHUNKAPI_1_55;

By doing this you will no longer see warning messages in the console.

Chunk changes

The following tables break down the chunk changes by Engine release.

Engine v1.55

Chunk Changes
  • refrain from generating world CC reflection, now done on the backend instead
  • normalize final world space normal
  • Updated all combine chunks to be more consistent between phong and blinn-phong chunks. These chunks will undergo more changes in future and may even be removed completely.
  • Fix gamma handling relative to albedo detail
  • Gamma correct detail map before combining with base albedo
  • set dEmissive global instead of returning the value in order to bring it in line with the other frontend components
  • removed (unused)
lightmapDirPS, lightmapSinglePS
  • renamed the lightmap function to getLightMap() instead of addLightMap()
  • changed the implementation to write dLightmap and dLightmapDir global instead of updating dDiffuseLight and dSpecularLight directly
  • backend now handles combining lightmap in lightmapAddPS and lightmapDirAddPS
  • removed
  • added MAPTEXTURE #define like the other chunks
  • normalize final normal
  • when normal texture isn't defined, calculate normal from geometry normal instead
  • remove two (mostly) unnecessary calls to normalise - final normal is normalized instead
  • remove dead code
  • combine emissive with dEmissive instead of a call to getEmission()
lightmapAddPS, lightmapDirAddPS
  • new chunks for adding the lightmap values passed in from the backend
  • added clear coat #define
lightSpecularBlinnPS, lightSpecularPhongPS
  • added clear coat #define, removed call to antiAliasGlossiness()
  • removed chunk, moved functionality to normalMapPS frontend chunk
specularAaNonePS, specularAaToksvigPS, specularAaToksvigFastPS
  • removed
  • removed global declarations, generate them on demand instead