/******************************************************************************
** Copyright(c) 2026 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/

//! \file EffectMapTerrainEffect.h
//! \brief Effect that applies effect mapping to the terrain.
//! \ingroup osgdb_osgearth_effectmap
#ifndef OSGEARTH_EFFECTMAP_TERRAIN_EFFECT_H
#define OSGEARTH_EFFECTMAP_TERRAIN_EFFECT_H

#include <osgEarth/TerrainEffect>
#include <osgEarth/ImageLayer>
#include <osg/Image>
#include <osg/Uniform>
#include <osg/Texture2D>

#include <osgdb_osgearth_effectmap/EffectMapOptions.h>

using namespace osgEarth;


namespace osgEarth
{
   namespace EffectMap
   {
      /**
       * Effect that applies effect mapping to the terrain.
       */
      class EffectMapTerrainEffect : public TerrainEffect
      {
      public:
         /** construct a new terrain effect. */
         EffectMapTerrainEffect(const osgDB::Options* dbOptions, int effectMapId, const EffectMapOptions& effectMapOptions);

      protected:
         //!Destructor
         virtual ~EffectMapTerrainEffect() { }

      public: // TerrainEffect interface
          //! setup the virtual program package and uniforms to load based on the effect type
         void onInstall(TerrainEngineNode* engine);

         //! remove the virtual program for this effect map from the engine
         void onUninstall(TerrainEngineNode* engine);

      protected:
         //! create a texture uniform name based on the effectMapId
         virtual const std::string generateShareTexUniformNameShaderString() const;

         //! create a texture matrix uniform name based on the effectMapId
         virtual const std::string generateShareTexMatUniformNameShaderString() const;

         //! create a texture read command based on the effectMapId
         virtual const std::string generateEffectMapFragShaderString() const;

         //! create a texture matrix name based on the effectMapId
         virtual const std::string generateEffectMapTexMatNameShaderString() const;

         //! create a texture name based on the effectMapId
         virtual const std::string generateEffectMapTexNameShaderString() const;


      protected:
         std::string myVertexName;
         std::string myFragmentName;
         unsigned int myEffectMapId;
         EffectMapOptions::EffectType myEffectType;
         float myFadeMaxRange;
         float myFadeAttenuationDistance;
         float mySpecMapShininess;
      };

   } // namespace osgEarth:EffectMap
}

#endif // OSGEARTH_EFFECTMAP_TERRAIN_EFFECT_H
