[SOLVED] Lightmap/AO shader chunk

Hi please i can’t find any documentation about the exact Lightmap shader chunk name, i tried to assign the shader chunk to:

material.chunks.lightmapPS

material.chunks.lightmap

but non of them works,
i used the shader chunk in this link below:
engine/src/scene/shader-lib/chunks-glsl/standard/frag/lightmap.js at main · playcanvas/engine · GitHub

also i’m using the AO shader chunk in the link below, and i assigned it to:
material.chunks.aoPS
but it seems like there is something not compatible with the shader as it’s not showing the AO result in the render

update: regarding the aoPS, i tried to match the definitions with the diffusePS shader chuck and it works now, but it seems like the “material_aoIntensity” uniform attribute in the shader chunk is not the right one that match with the ao intensity attribute in the material


#if defined(MAPTEXTURE)
    uniform float material_aoIntensity;
#endif
#if defined(MAPVERTEX)
    uniform float material_aoIntensity;
#endif

#ifdef STD_AODETAIL_TEXTURE
    #include "detailModesPS"
#endif
uniform sampler2D texture_aoMap;
void getAO() {
    dAo = 1.0;

    #ifdef MAPTEXTURE
        float aoBase = texture2DBias(texture_aoMap, $UV, textureBias).$CH;

        #ifdef STD_AODETAIL_TEXTURE
            float aoDetail = texture2DBias($DETAILTEXTURE, $DETAILUV, textureBias).$CH;
            aoBase = detailMode_$DETAILMODE(vec3(aoBase), vec3(aoDetail)).r;
        #endif

        dAo *= aoBase;
    #endif

    #ifdef MAPVERTEX
        dAo *= saturate(vVertexColor.$VC);
    #endif

    #ifdef MAPTEXTURE
        dAo = mix(1.0, dAo, material_aoIntensity);
    #endif
    #ifdef MAPVERTEX
        dAo = mix(1.0, dAo, material_aoIntensity);
    #endif

}

Here’s the full list: engine/src/scene/shader-lib/chunks/chunks.js at release-2.7 · playcanvas/engine · GitHub

Not that this points to release-2.7 branch, which is the latest released engine. I’m making changes to chunks on main branch for 2.8 release, there are possibly some differences there.

This is the ao chunk: engine/src/scene/shader-lib/chunks/standard/frag/ao.js at release-2.7 · playcanvas/engine · GitHub

you need to use the same defines as it uses, for example

#if defined(STD_AO_TEXTURE) || defined(STD_AO_VERTEX)
    uniform float material_aoIntensity;
#endif

MAPTEXTURE and MAPVERTEX are no longer supported. You should have a clear error message when using a debug engine version.

Thank you for your help @mvaligursky !! i forgot to mention that i was using v1.77 , but anyway i found my way through the link you provided, by the way please do not stop the support or remove the playcanvas engine v1.x, because v2.x is a little bit buggy on the meta quest 3 browser specially when it comes to the web xr experience!
thank you again!

We’re not planning to remove support for V1 engine for a long time. But please do log issues you get with engine V2 so that we can fix any problems, thanks.

1 Like