This is my first post here; please excuse me if it seems like I'm lost, because I am.
I'm working on implementing a large terrain in WebGL and three.js using a heightmap. I can do everything I want to (so far) with a regular PlaneGeometry - setting up the plane, reading and assigning altitude values from the heightmap, reading and interpolating inter-vertex altitudes from just the heightmap so that the player can walk smoothly along the terrain without having to refer to the geometry, and assigning textures and lights.
Problem is that I seem to be limited to around a 513x513 vertex plane; any higher than that and everything starts to either chug or crash. I understand that the solution to this is to use buffergeometry and shaders to offload the heavy lifting to the GPU, and I've figured out how to read altitudes into an array and then hand that array off to the GPU to do the displacement, but now I've lost lighting information, and I don't know how to get it back. I suppose I could add in my own lights, but I'm pretty sure there's a way to tell the shader to use the scene's lights. I think that the solution has something to do with ShaderLib and/or UniformUtils, but I don't know how to use those, and all the examples I've found online are broken.
So I guess my question is this: how do I take parts of existing shaders (phong, lambert) and add to them my own code?