# Extending PointLight uniforms

**URL:** <https://discourse.threejs.org/t/extending-pointlight-uniforms/10494>\
**Category:** Questions\
**Tags:** lights, point-light, webgl-renderer\
**Created:** [October 28, 2019, 7:43pm UTC](https://discourse.threejs.org/t/extending-pointlight-uniforms/10494 "2019-10-28T19:43:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![JamesG](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/jamesg/32/7837_2.png) [@JamesG](https://discourse.threejs.org/u/JamesG)\
**Post date:** [October 28, 2019, 7:43pm UTC](https://discourse.threejs.org/t/extending-pointlight-uniforms/10494/1 "2019-10-28T19:43:44Z")

</div>

I have need in my app to add custom uniforms to PointLights.

My app currently uses a fixed amount of PointLights _(8 to be exact)_ that get recycled and reused depending on player position in the scene. I have set my custom shader to ignore these lights if my geometry is lightmapped. The only thing is now i need certain lights to work on my lightmapped geometry.

I have been able to achieve this in my app by adding the bolded line below to the PointLight section of THREEs WebGLLights function.

> } else if ( light.isPointLight ) {
> 
> var uniforms = cache.get( light );
> 
> uniforms.position.setFromMatrixPosition( light.matrixWorld );  
> uniforms.position.applyMatrix4( viewMatrix );
> 
> uniforms.color.copy( light.color ).multiplyScalar( light.intensity );  
> uniforms.distance = light.distance;  
> uniforms.decay = light.decay;  
> _ **uniforms.animated = light.animated;** _
> 
> ```
> uniforms.shadow = light.castShadow;
> 
> if ( light.castShadow ) {
> 
> ```

I then use the animated value _(0 for off and 1 for on)_ in my shader code to determine when a light can affect lightmapped geometry.

I’m hoping there is a better way to go about this instead of hacking it into the library source code. My app includes three.js as an npm module and I would like to leave it the way it comes if possible.

---

<div class="post-metadata">

**Author:** ![EliasHasle](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/eliashasle/32/3010_2.png) [@EliasHasle](https://discourse.threejs.org/u/EliasHasle)\
**Post date:** [October 28, 2019, 9:01pm UTC](https://discourse.threejs.org/t/extending-pointlight-uniforms/10494/2 "2019-10-28T21:01:55Z")

</div>

Are you sure masking lights by uniforms will save a lot?

Since you are already digging into the source of `WebGLLights` (👍 for that!) , would it be an option to extract the relevant code that defines light counts and types and put it in `onBeforeCompile` on your custom material (but adding only the lights that you want, instead of masking in the shader), and extract the code that sets light-related uniforms and put it in `onBeforeRender` of the lightmapped objects?
