/*****************************************************************************
 * $LastChangedDate: 2009-12-14 13:08:18 -0500 (Mon, 14 Dec 2009) $
 * @file
 * @author  Jim E. Brooks  http://www.palomino3d.org
 * @brief   Module.
 *//*
 * LEGAL:   COPYRIGHT (C) 2009 JIM E. BROOKS
 *          THIS SOURCE CODE IS RELEASED UNDER THE TERMS
 *          OF THE GNU GENERAL PUBLIC LICENSE VERSION 2 (GPL 2).
 *****************************************************************************/

#define SHADER_MODULE_CC 1
#include "base/module.hh"
#include "base/module_macros.hh"
using namespace base;
#include "graph/module.hh"
#include "graph/scene_graph.hh"
using namespace graph;
#include "shader/module.hh"
#include "shader/conf.hh"
#include "shader/shader_funcs.hh"
#include "shader/shader_name.hh"
#include "shader/light.hh"

namespace shader {

/*****************************************************************************
 * Initialize module.
 *****************************************************************************/
void
Init( const base::InitArgs& initArgs )
{
    MODULE_INIT_LOAD_CONF_TXT( shader )
}

/*****************************************************************************
 * Start module.
 *****************************************************************************/
void
Start( void )
{
    RefPtr<GroupNode> rootNode = GET_SCENE_GRAPH().GetRootNode();
    Light& light = GET_LIGHT();

    // Shader uniform defaults.
    ResetShaderUniformsForRootNode( *rootNode );

    // Lighting.
    light.SetLightPosition( 0, SHADER_CONF.mLight0Position );
    light.SetLightBrightness( SHADER_CONF.mBrightness );

    // Fog.
    light.SetFogColor( SHADER_CONF.mFogColor );
    light.SetFogDensity( SHADER_CONF.mFogDensity );
    light.SetFogMin( SHADER_CONF.mFogMin );
}

} // namespace shader
