0

I need to do vertex displacements using a texture map in Three.js.

  1. Is there an existing material that supports that?
  2. If not, what is the best way to duplicate an existing Three.js shader so that I can add in some vertex displacement calculations? I would like to keep existing functionalities such as shadows and wireframe on the material.
Edric
  • 24,639
  • 13
  • 81
  • 91
skeelogy
  • 397
  • 2
  • 12

1 Answers1

0

Vertex displacements using a texture map are supported by THREE.ShaderTerrain[ "terrain" ] and THREE.ShaderLib[ "normalmap" ].

Examples of their use can be found in http://threejs.org/examples/webgl_terrain_dynamic.html and http://threejs.org/examples/webgl_materials_normalmap.html.

If these do not suit your needs, then you will have to write your own shader. Doing so is not easy. It is best to modify an existing shader.

three.js r.61

WestLangley
  • 102,557
  • 10
  • 276
  • 276
  • Thanks. I've looked at the files and managed to add in bits of codes in my custom shader to get shadows to work. However, now my object does not seem to cast shadows (it can received shadows). What other shader chunks do I need? I've edited my question with some codes. – skeelogy Sep 23 '13 at 11:15
  • Please do not modify your question after it is answered. Please accept this answer and make a new post if you are having additional problems. Thank you. – WestLangley Sep 23 '13 at 13:59
  • Removed and asked in another stackoverflow post: http://stackoverflow.com/questions/18962155/getting-shadows-to-work-in-three-js-custom-shader – skeelogy Sep 23 '13 at 14:40