Custom directional lightmap

Is it possible in some way to use a custom directional lightmap without using the built-in lightmapper and change the co-processing of the directional lightmap. I found the corresponding chunks, but I’m not completely sure that directions are connected at the shader build stage, without using lightmapper?

code js:
material.chunks.lightmapDirPS = fs;

void getLightMap() {
dLightmap = vec3( 1.0, 0.0, 0.0);
dLightmapDir = vec3( 1.0, 0.0, 0.0);

But visually nothing has changed, I think the generator avoids the directional lightmap chunk

Custom directional light maps would be definitely possible, but we have not tried this, it would likely involve changes in multiple chunks. Capture your application with Spector JS and inspect the shader that does not work - this way you get to see the whole shader, which makes it easier to understand what needs to be done.

I managed to replace both chunks, but the feeling is that the texture of the lightmap is lost somewhere.

this.material.chunks.APIVersion = pc.CHUNKAPI_1_62;

this.material.chunks.lightmapDirPS = fsDir;
this.material.chunks.lightmapDirAddPS = fsDirAdd;

this.material.setParameter('lightmap_L0', this.lightmap_L0);//custom lightmap
this.material.setParameter('lightmap_L1', this.lightmap_L1);//custom lightmapdir

in editor

lightmapDirPS chunk:

void getLightMap() {
    dLightmap    = $DECODE(texture2DBias(lightmap_L0, vUv1, textureBias));
    dLightmapDir = texture2DBias(lightmap_L1, vUv1, textureBias).xyz;

lightmapDirAddPS chunk:

void addLightMap(
    vec3 lightmap,
    vec3 dir,
    vec3 worldNormal,
    vec3 viewDir,
    vec3 reflectionDir,
    float gloss,
    vec3 specularity,
    vec3 vertexNormal,
    mat3 tbn
#if defined(LIT_IRIDESCENCE)
    vec3 iridescenceFresnel,
    IridescenceArgs iridescence
) {
        dDiffuseLight += dir;//lightmap;

in the editor, I do not see the textures that I pass to the shader :frowning:

in order for the directional lightmap chunk to be included in the shader, I used the flag lightmapped and static on mesh:

and settings of the lightmapper:

The code where you set up chunks on materials does not execute in the Editor, and so you cannot (easily) see those in the Editor.

So it seems you got it to work in the launcher?

Yes, I put it a little wrong, this is a screenshot from the launch

I tried to directly pass the texture to:

uniform sampler2D lightmap_L1;
dDiffuseLight += texture2DBias(lightmap_L1, vUv1, textureBias).xyz;

this.material.setParameter('lightmap_L1', this.lightmap_L1);

is it possible to somehow pass my texture to the addLightMap function?

What you’re doing should work … your lightmap_L1 uniform is global, so you can simply use it inside the addLightMap function, no need to pass it in.