
.. _program_listing_file_Src_GraphicsEngineVulkan_common_LightDirection.hpp:

Program Listing for File LightDirection.hpp
===========================================

|exhale_lsh| :ref:`Return to documentation for file <file_Src_GraphicsEngineVulkan_common_LightDirection.hpp>` (``Src/GraphicsEngineVulkan/common/LightDirection.hpp``)

.. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS

.. code-block:: cpp

   #pragma once
   
   #include <glm/glm.hpp>
   
   namespace Kataglyphis {
   
   // The direction the directional light travels (see GUI.cpp's "Light
   // Direction" slider). The GUI lets all three components be dragged to 0,
   // which would normalize to NaN and poison every shader/matrix that consumes
   // it; fall back to CascadedShadowMapMath.cpp's existing rule (straight down)
   // instead. Call this once on the host so downstream consumers always see a
   // unit vector.
   inline auto normalizedLightDirection(glm::vec3 raw) -> glm::vec3
   {
       if (glm::length(raw) < 1e-6F) { raw = glm::vec3(0.0F, -1.0F, 0.0F); }
       return glm::normalize(raw);
   }
   
   }// namespace Kataglyphis
