Figure: Diagnostic workflow: Deform positions → Update normals/tangents → Shade in matching spaces
Figure: Diagnostic workflow: Deform positions → Update normals/tangents → Shade in matching spaces

Cause and mechanism

Moving vertices changes a model's shape but does not automatically update its normals, used for surface lighting, or its tangents, which run along the surface. If a displaced surface has incorrect lighting, reconstruct these directions from the deformed surface's slope. Use the same coordinate space for the positions and directions.

Check and correct the setup

  1. Calculate displaced position, normal, and tangent in the same space.
    Same silhouette; different lighting normals
    Same silhouette; different lighting normals
  2. For y=A sin(kx+t), let d=A k cos(kx+t). An upward normal is normalize((-d,1,0)); the tangent is normalize((1,d,0)).
    Same silhouette; different lighting normals
    Same silhouette; different lighting normals
  3. Feed the corresponding vertex blocks. Convert to the selected normal space before feeding a fragment normal block.
    Same silhouette; different lighting normals
    Same silhouette; different lighting normals

Limits and verification

DDX/DDY are screen derivatives for fragment processing, not vertex operations. Verify tangent orientation, handedness, and displaced shadow silhouettes.

A focused diagnostic setup

Use a sufficiently subdivided plane and an analytically traceable sine-wave displacement. Compare position-only deformation against matching reconstructed normals.

Test in this order

  1. Verify undeformed normals/tangents under a standard light.
    Same silhouette; different lighting normals
    Same silhouette; different lighting normals
  2. Increase amplitude gently and supply normalized same-space slope-derived normals.
    Same silhouette; different lighting normals
    Same silhouette; different lighting normals
  3. Restore rotation, non-uniform scale, shadow and bounds conditions.
    Same silhouette; different lighting normals
    Same silhouette; different lighting normals

Interpret the result

Correct lighting with coarse edges suggests vertex density; view-edge disappearance suggests bounds. Match finite-difference units and do not use fragment derivatives in the vertex stage.

Related explanations

References