So for my terrain I have a shader to blend multiple textures together (like grass, sand, rocks). This all works nicely, but the only problem is that the shader isn't compatible with the Three.js lighting engine, all vertices are just brightly lit. I can manually calculate some lighting like the sun/moon, but it would be nice if I could just use the Three.js lighting engine with my shader. Is there a way to combine e.g. the lambert material shader (which uses Three.js lighting) with my custom shader?
1
votes
1 Answers
2
votes
What you can do is set the ShaderMaterial.lights property to true. You will still have to handle the lighting calculations yourself, but you will have access, via uniforms, to the lights you create.
See, for example, http://mrdoob.github.com/three.js/examples/webgl_materials_normalmap.html
Example source: https://github.com/mrdoob/three.js/blob/master/src/renderers/WebGLShaders.js
three.js r.56