mrdoob / three.js

JavaScript 3D Library.
https://threejs.org/
MIT License
102.58k stars 35.36k forks source link

Multiple materials creates multiple geometries #585

Closed Pitel closed 13 years ago

Pitel commented 13 years ago

I've plane geometry with one LambertMaterial and one ShaderMaterial, which is just vertex shader (doing simple sinus waves). The result is lambert shaded plane with sinus waves above and it (screenshot). The expected result would be having lamber shaded sinus waves, or just not having multiple geometries, which is confusing.

alteredq commented 13 years ago

You can't achieve this with material array (this is just for multi-pass rendering of the same geometry using different materials).

You'll need create a new ShaderMaterial based on MeshLambertMaterial, adding your own uniforms and vertex displacement code to vertex shader:

https://github.com/mrdoob/three.js/blob/master/src/renderers/WebGLShaders.js#L1263