Advertisement
Masterchoc

Untitled

Jul 19th, 2019
365
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None | 0 0
  1.     glm::vec3 Landscape::calculateNormal(const glm::vec2& position)
  2.     {
  3.         float height_l = getHeightAtXZ(glm::dvec2(position.x - 1, position.y));
  4.         float height_r = getHeightAtXZ(glm::dvec2(position.x + 1, position.y));
  5.         float height_d = getHeightAtXZ(glm::dvec2(position.x, position.y + 1));
  6.         float height_u = getHeightAtXZ(glm::dvec2(position.x, position.y - 1));
  7.  
  8.         return glm::normalize(glm::dvec3(height_l - height_r, 0.1f, height_d - height_u));
  9.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement