Setting LightMap transform via setParameter is not working?

Hi guys,

Trying to set a lightMap transform using setParameter seems not working with the latest engine 1.57.1, however all others work as expected:

For example:

meshInstance.setParameter("texture_lightMapTransform0", [1, 0, 1]);
meshInstance.setParameter("texture_lightMapTransform1", [0, 1, 0]);

doesn’t have any effect, while diffuse or emissive transforms both work as expected:

meshInstance.setParameter("texture_diffuseMapTransform0", [1, 0, 1]);
meshInstance.setParameter("texture_diffuseMapTransform1", [0, 1, 0]);

Am I doing it wrong?

Additionally, lightMapVertexColor seems to be not supported in the 1.57.x (getting following warning in the console):

Would you be able to share a small project repro that we can investigate please?

here it is: PlayCanvas | HTML5 Game Engine

First box is sample, other have their diffuse, lightmap, emissive transforms changed via code respectively:

The 3rd one (with custom lightmap transform) looks exactly the same as first (unchanged) one

P.S. Changing the lightmap tiling via editor works as expected.

P.P.S there are a few warnings in the console:


I’ve gone back as far as engine 1.50.0 and it looks the same so this doesn’t look like a recent issue

Looking at the shader generated by Spector.js for the entity, it looks like the transforms for the lightmap aren’t created for some reason:

1 Like

Looks like for some reason, the lightmap transforms are not added unless the offset or rotation properties are changed on the material.

When I add 0.001 to offset for example, the transforms are added to the shader.

I don’t know why diffuse and emissive always has the transforms though.

@mvaligursky or @Gustav_Sterbrant maybe be able to answer that here?

Looking at the code, it looks like it is optimising the shader because the transform in the material matches an existing one (the emissive) and therefore uses the same UV result in the shader.

If you change tiling for lightmap to 2.01 and 2, it also adds the transform uniforms.

If emissive and lightmap all have the same settings for the transforms on the material, it will only create the diffuseMapTransform

#define attribute in
#define varying out
#define texture2D texture
#define GL2
#define SHADER_NAME LitShader
varying vec2 vUV0_1;
varying vec3 vPositionW;
varying vec3 vNormalW;
attribute vec3 vertex_position;
attribute vec3 vertex_normal;
attribute vec4 vertex_tangent;
attribute vec2 vertex_texCoord0;
attribute vec2 vertex_texCoord1;
attribute vec4 vertex_color;
uniform mat4 matrix_viewProjection;
uniform mat4 matrix_model;
uniform mat3 matrix_normal;
vec3 dPositionW;
mat4 dModelMatrix;
mat3 dNormalMatrix;
vec2 getUv0() {
    return vertex_texCoord0;
uniform vec3 texture_diffuseMapTransform0;
uniform vec3 texture_diffuseMapTransform1;
mat4 getModelMatrix() {
    return matrix_model;
vec4 getPosition() {
    dModelMatrix = getModelMatrix();
    vec3 localPos = vertex_position;
    vec4 posW = dModelMatrix * vec4(localPos, 1.0);
    dPositionW =;
    vec4 screenPos;
    screenPos = matrix_viewProjection * posW;
    return screenPos;
vec3 getWorldPosition() {
    return dPositionW;
vec3 getNormal() {
    dNormalMatrix = matrix_normal;
    vec3 tempNormal = vertex_normal;
    return normalize(dNormalMatrix * tempNormal);
void main(void) {
    gl_Position = getPosition();
    vPositionW = getWorldPosition();
    vNormalW = getNormal();
    vec2 uv0 = getUv0();
    vUV0_1 = vec2(dot(vec3(uv0, 1), texture_diffuseMapTransform0), dot(vec3(uv0, 1), texture_diffuseMapTransform1));

Yep I can confirm that setting different tiling values for each individual map (diffuse/emissive/normal/light) solves the issue!
This is a bit strange optimization, however I completely understand why it’s done this way in the engine :slight_smile: