///////////////////////////////////////////////////////////////////////  
//  UniformVariables.hlsl
//
//
//	*** INTERACTIVE DATA VISUALIZATION (IDV) CONFIDENTIAL AND PROPRIETARY INFORMATION ***
//
//	This software is supplied under the terms of a license agreement or
//	nondisclosure agreement with Interactive Data Visualization, Inc. and
//  may not be copied, disclosed, or exploited except in accordance with 
//  the terms of that agreement.
//
//      Copyright (c) 2003-2010 IDV, Inc.
//      All rights reserved in all media.
//
//      IDV, Inc.
//      http://www.idvinc.com

///////////////////////////////////////////////////////////////////////  
//  Common Global Variables
//
//  These are all global variables that are shared by more than one of
//  the main shader types (branch, frond, leaf, and billboard).  The constant
//  registers are specified after many of the global parameters in order
//  to ensure that the variables will be successfully shared even when the
//  shaders are compiled off-line separately.
//
//  Note: What we call "composite maps" or "composite textures" are also known
//        as "texture atlases"

float4		g_vMaterialAmbient      GLOBAL_REG(0);	// material_ambient * light_ambient
float4		g_vMaterialDiffuse      GLOBAL_REG(1);	// material_diffuse * light_diffuse
float4		g_vMaterialSpecular     GLOBAL_REG(2);	// material_specular * light_specular, w = shininess [0-128]
float4		g_vMaterialEmissive     GLOBAL_REG(3);	// material_emissive * light_emissive
float3		g_vMaterialTransmission GLOBAL_REG(4);	// x = shadow darkness, y = view dependence, z = normal adjustment
float3		g_vLightDir             GLOBAL_REG(5);	// light direction
float4		g_vMaterialExtras       GLOBAL_REG(6);	// x = light scalar, y = alpha scalar, z = shininess, w = 1.0 - ambient_contrast
float3 		g_vSkyColor             GLOBAL_REG(7);	// rgb = color, a = horizon offset
float4		g_vFogParams            GLOBAL_REG(8);	// x = fog_end, .y = fog_end - fog_start, z = -min sky fog, w = -1.0 / sky fog range
float3		g_vFogColor             GLOBAL_REG(9);	// rgb fog color
float3		g_vSunColor             GLOBAL_REG(10);	// rgb sun color
float3		g_vSunParams            GLOBAL_REG(11);	// x = size, y = spread exponent, z = fog bloom
float4x4    g_mModelViewProj        GLOBAL_REG(12);	// composite modelview/projection matrix
float4		g_vTreePosAndScale		GLOBAL_REG(16);	// xyz = position, w = scale
float4		g_vTreeRotation         GLOBAL_REG(17);	// xy = rotation values, w = lod lerp value (1 = highest, 0 = lowest), z = current lod value 
float4		g_vLodProfile           GLOBAL_REG(18);	// x = high 3D LOD distance, y = low 3D LOD distance, z = billboard start distance, w = billboard final distance
float3		g_vCameraPosition       GLOBAL_REG(19);	// camera/eye location in world space
float3		g_vCameraDirection      GLOBAL_REG(20);	// camera/eye direction in world space
float2      g_vCameraAngles         GLOBAL_REG(21);	// shared by Billboard.fx and Leaf.fx - stores camera azimuth and pitch for billboarding computations
float		g_fFarClip              GLOBAL_REG(22);	// far clipping plane distance (visibility)
float		g_fHorzBillboardFade    GLOBAL_REG(23);	// 0.0 = horz bbs are transparent, 1.0 = they are opaque
float4		g_vSplitDistances       GLOBAL_REG(24);	// x = shadow_map_0_end, y = shadow_map_1_end, etc.
float3		g_vShadowFadeParams     GLOBAL_REG(25);	// x = shadow fade %, y = 1/(fade% - end), z = 1/(end - fade%); all to reduce pixel shader instructions

// wind
float3		g_vWindDir          	GLOBAL_REG(26);	// xyz = dir
float4		g_vWindTimes        	GLOBAL_REG(27);	// x = primary, y = secondary, z = frond, w = leaves
float4		g_vWindDistances    	GLOBAL_REG(28);	// x = primary osc, y = secondary osc, z = wind height, w = height exponent
float3		g_vWindLeaves       	GLOBAL_REG(29);	// x = distance, y = leaves lighting change, z = leaves windward scalar
float3		g_vWindFrondRipple  	GLOBAL_REG(30);	// x = amount, y = u tile, z = v tile
float3		g_vWindGust         	GLOBAL_REG(31);	// x = combined wind strength, y = primary distance, z = gust scale
float3		g_vWindGustHints    	GLOBAL_REG(32);	// x = vertical offset %, y = wind dir adjustment, z = unison

// terrain/grass
float4		g_vSplatMapTiles		GLOBAL_REG(33);	// x = splat0 tile, y = splat1 tile, z = splat2 tile, w = normal map blue scalar

// variable-sized shadow
#ifdef SPEEDTREE_SHADOWS_ENABLED
	#ifndef SPEEDTREE_NUM_SHADOW_MAPS
		#define SPEEDTREE_NUM_SHADOW_MAPS 1
	#endif

	float4x4    g_amLightViewProjs[SPEEDTREE_NUM_SHADOW_MAPS] GLOBAL_REG(34);
#endif
