# Fragment shader error when adding lightmap to PBRMaterial

**URL:** <https://forum.babylonjs.com/t/fragment-shader-error-when-adding-lightmap-to-pbrmaterial/12638>\
**Category:** Bugs\
**Tags:** material\
**Created:** [July 19, 2020, 4:16am UTC](https://forum.babylonjs.com/t/fragment-shader-error-when-adding-lightmap-to-pbrmaterial/12638 "2020-07-19T04:16:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ankit\_Singh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/ankit_singh/32/9743_2.png) [@Ankit\_Singh](https://forum.babylonjs.com/u/Ankit_Singh)\
**Post date:** [July 19, 2020, 4:16am UTC](https://forum.babylonjs.com/t/fragment-shader-error-when-adding-lightmap-to-pbrmaterial/12638/1 "2020-07-19T04:16:08Z")

</div>

Hello guys,

I have created a new PBRMaterial like this…

```
    let mat = new PBRMaterial('new',this._scene);
    mat.albedoTexture = diffuse;
    mat.useLightmapAsShadowmap = true;
    mat.lightmapTexture = lightmap;
   mat.unlit = true; 
  for(let i = 0 ; i < meshes.length ; i++)
  {
    let mesh =result.meshes[i];
    mesh.material = mat;
  }

```

I get the following error when I run the game…

> BJS - [09:44:52]: Error: FRAGMENT SHADER ERROR: 0:449: ‘lightmapColor’ : undeclared identifier  
> ERROR: 0:449: ‘rgb’ : field selection requires structure, vector, or interface block on left hand side

Am I doing something wrong?

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [July 19, 2020, 9:40am UTC](https://forum.babylonjs.com/t/fragment-shader-error-when-adding-lightmap-to-pbrmaterial/12638/2 "2020-07-19T09:40:38Z")

</div>

Duplicate of [Fragment shader error on assigning lightmap to PBRMaterial](https://forum.babylonjs.com/t/fragment-shader-error-on-assigning-lightmap-to-pbrmaterial/12639)
