Closed stmaccarelli closed 7 years ago
I generally agree. I do not think the docs need to describe what a displacement map is. The docs are not tutorials. Users who are not familiar with the concept of a displacement map can google it.
I would replace what is there with something like: "Note: You must specify a customDepthMaterial
if you want your displaced vertices to cast proper shadows."
Regarding "simplification", the depth material that is currently used by the renderer automatically accommodates the use of skinning and morphs. That amounts to 2 x 2 = 4 cases.
Thing is, there can also be a displacement map, an alpha map, a texture with alpha, and/or an arbitrary value for alphaTest
. As currently implemented, all the possible combinations require a different depth material.
For that reason, we currently require the user to specify a custom depth material in these cases:
mesh.customDepthMaterial = new THREE.MeshDepthMaterial( {
depthPacking: THREE.RGBADepthPacking,
displacementMap: displacementMap,
displacementScale: displacementScale,
displacementBias: displacementBias,
} );
Great. I also hope someone would add a good customDepthMaterial definition in the docs. Right now it looks it's missing.
Docs updated. #11763
Description of the problem
This is a old issue with displacement map + shadow map. The displacementMap description says: ".displacementMap The displacement map affects the position of the mesh's vertices. Unlike other maps which only affect the light and shade of the material the displaced vertices can cast shadows, block other objects, and otherwise act as real geometry. The displacement texture is an image where the value of each pixel (white being the highest) is mapped against, and repositions, the vertices of the mesh."
Point is that as long as I'm trying a displaced material that uses a Standard or Phong Material cannot cast shadows as is. The Mesh needs a MeshDepthMaterial added as a customDepthMaterial.
I think you should simplify this, or change the description. For simplify I mean that if I declare that a displaced material can cast shadows, THREE should automatically take care of what's needed to allow shadows to cast correctly.
Three.js version
Browser
OS
Hardware Requirements (graphics card, VR Device, ...)