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.