ception cref="T:System.InvalidOperationException">Un metodo di <see cref="T:System.Xml.XmlReader" /> è stato chiamato prima del completamento di un'operazione asincrona precedente.In questo caso, viene generata un'eccezione <see cref="T:System.InvalidOperationException" /> con il messaggio "Un'operazione asincrona è già in corso".</exception>
    </member>
    <member name="P:System.Xml.XmlReader.XmlSpace">
      <summary>Quando ne viene eseguito l'override in una classe derivata, ottiene l'ambito xml:space corrente.</summary>
      <returns>Uno dei valori di <see cref="T:System.Xml.XmlSpace" />.Se non esiste alcun ambito xml:space, alla proprietà viene applicata l'impostazione predefinita XmlSpace.None.</returns>
      <exception cref="T:System.InvalidOperationException">Un metodo di <see cref="T:System.Xml.XmlReader" /> è stato chiamato prima del completamento di un'operazione asincrona precedente.In questo caso, viene generata un'eccezione <see cref="T:System.InvalidOperationException" /> con il messaggio "Un'operazione asincrona è già in corso".</exception>
    </member>
    <member name="T:System.Xml.XmlReaderSettings">
      <summary>Specifica un set di funzionalità da supportare nell'oggetto <see cref="T:System.Xml.XmlReader" /> creato dal metodo <see cref="Overload:System.Xml.XmlReader.Create" />. </summary>
    </member>
    <member name="M:System.Xml.XmlReaderSettings.#ctor">
      <summary>Inizializza una nuova istanza della classe <see cref="T:System.Xml.XmlReaderSettings" />.</summary>
    </member>
    <member name="P:System.Xml.XmlReaderSettings.Async">
      <summary>Ottiene o imposta un valore che indica se è possibile usare metodi <see cref="T:System.Xml.XmlReader" /> asincroni in una determinata istanza di <see cref="T:System.Xml.XmlReader" />.</summary>
      <returns>true se i metodi asincroni possono essere usati; in caso contrario, false.</returns>
    </member>
    <member name="P:System.Xml.XmlReaderSettings.CheckCharacters">
      <summary>Ottiene o imposta un //$c3 AWK 01/19/12 prj 18464 fix LDR transparency and textures
//$c2 AWK 07/11/11 fix shader for ATI
//$c1 AWK 06/24/11 created

// this line is needed to get the associated xml files
#define SW_PARAMETER_FILES "global.xml, envmapcommon.xml, commonlighting.xml, largedesignreview.xml"
#define SW_INCLUDE "utils.glsl,common.glsl"
#define SW_SHADERFORMATERIAL





// TEMPLATE desciption
//
// this shader is doing most of it's work in the vertex shader
// it is less costly but more accurate than the per-pixel one
// Appart that, it's more or less doing the same thing






/////////////////////////////////////////////////////////////////////////////////
// varying
// this parameters are passed from the vertex to the pixel shader
// note that they are not always used, depeding on the configuration

// texture coordinate coming from the mesh (or stream) and interpolated per-pixel
// this is the one generated by parasolid
// NOTE: w is used for reflection fading (distance from floor term)
varying vec4 v_TexCoord;
varying vec3 v_Normal;
varying float v_Depth;


// diffuse and specular term
varying vec3 v_diffuseTerm;
varying vec4 v_specularTerm;

/////////////////////////////////////////////////////////////////////////////////



/////////////////////////////////////////////////////////////////////////////////
// automatic variable
// this varable are constant automatically set accorgin to other constant value
// IT's just a handy way to keep the parameters as pertinent as possible

// do we need the maxSpec value?
const bool	ga_bUseMaxSpec = false;


#ifdef _VERTEX_PROGRAM
void main()
{
	///////////////////////////////////////////////////////////////////////
	// first, do some space-related computation to prepare for further use
	
	// transform the vertex position from object space to view space
	gl_Position = pGetProjectedPosition(gl_Vertex, gl_ModelViewProjectionMatrix);
	
#ifdef SW_SHADER_USE_CLIPVERTEX
	// set position for clip planes
	gl_ClipVertex = gl_ModelViewMatrix * gl_Vertex;
#endif
	
	// transform normal from model-space to eye-space
	vec3 eNormal = eGetNormal(gl_Normal, gl_NormalMatrix, doubleSided != 0.0);
	
	// get eye-related information:
	// - position of the vertex in eye space
	// - eye direction (from camera to vertex) in eye space
	EyeInfo_s eyeInfo = GetEyeInfo(gl_Vertex, gl_ModelViewMatrix);
	///////////////////////////////////////////////////////////////////////

	
	///////////////////////////////////////////////////////////////////////
	// light computation
	
	// init light value to zero	
	vec3 diffuseLight = vec3(0.0);
	vec4 specularLight = vec4(0.0);
		
	// add light influence, this could be done in a loop really
	// for each light it's same story: standard diffuse and specular term are computed in eye space
	if(g_bUseLight0)
	{
		vec3 eLightDirAux0 = eGetLightDir_DP(vec3(lightDir0), eyeInfo.ePosition.xyz, lightType.x);
		vec3 eHalfVector0 = eGetHalfVector(eLightDirAux0,eyeInfo.eEyeDirection);
		AddSpecularAndDiffuse(eNormal,
			eLightDirAux0, vec3(lightColor0), g_iAlphaType,
			eHalfVector0, vec3(lightSpec0), specularMaterial.w, ga_bUseMaxSpec, g_noSpecular,
			diffuseLight, specularLight, transparency);
	}
	if(g_bUseLight1)
	{
		vec3 eLightDirAux1 = eGetLightDir_DP(vec3(lightDir1), eyeInfo.ePosition.xyz, lightType.y);
		vec3 eHalfVector1 = eGetHalfVector(eLightDirAux1,eyeInfo.eEyeDirection);
		AddSpecularAndDiffuse(eNormal,
			eLightDirAux1, vec3(lightColor1), g_iAlphaType,
			eHalfVector1, vec3(lightSpec1), specularMaterial.w, ga_bUseMaxSpec, g_noSpecular,
			diffuseLight, specularLight, transparency);
	}
	if(g_bUseLight2)
	{
		vec3 eLightDirAux2 = eGetLightDir_DP(vec3(lightDir2), eyeInfo.ePosition.xyz, lightType.z);
		vec3 eHalfVector2 = eGetHalfVector(eLightDirAux2,eyeInfo.eEyeDirection);
		AddSpecularAndDiffuse(eNormal,
			eLightDirAux2, vec3(lightColor2), g_iAlphaType,
			eHalfVector2, vec3(lightSpec2), specularMaterial.w, ga_bUseMaxSpec, g_noSpecular,
			diffuseLight, specularLight, transparency);
	}


	///////////////////////////////////////////////////////////////////////
	// finalise diffuse and specular term

	// add material color influence
	v_diffuseTerm = diffuseLight*matDiffuse;
	v_specularTerm.xyz = GetSpecularTerm(vec3(specularLight),vec3(specularMaterial));

	// hard-coded term (should dissapear)
	v_specularTerm.xyz*=specularLightModifier;

	// max specular value to control specular treshold, store in the w component of v_specularTerm
	if(ga_bUseMaxSpec)
	{
		v_specularTerm.w = specularLight.w * specularMaterial.x;
	}
	
	///////////////////////////////////////////////////////////////////////
	// texture coordinate
	
	// common texture coordinate (coming from the stream)
	if(g_iTextureCoordinates != e_TextureCoordinates_None)
	{
		vec3 texCoords = vec3(0.0,0.0,0.0);
		texCoords = GetCommonTexCoord(gl_MultiTexCoord0, gl_Vertex, g_iTextureCoordinates, gl_TextureMatrix[0], gl_TextureMatrix[4]);
		v_TexCoord.xy = tGetTexCoords(texCoords, gl_Normal, g_iTextureCoordinates, gl_TextureMatrix[0]);
		v_Normal = gl_Normal;
	}
	
	v_Depth = ((gl_ModelViewMatrix*gl_Vertex).z - ldrminz)/(ldrmaxz-ldrminz);
}
#endif //_VERTEX_PROGRAM












#ifdef _FRAGMENT_PROGRAM
void main()
{

	///////////////////////////////////////////////////////////////////////
	float alpha = 1.0;

	vec4 mixColor = matColor;//vec4(1.0,1.0,1.0,1.0);;

	///////////////////////////////////////////////////////////////////////
	// ambient term
	// this is currently computed per-pixel
	// this could be moved at the vertex level, but interpolator are precious... Perhaps...
	
	// basic ambient term
	vec3 ambientTerm = vec3(ambientLight) * mixColor.xyz;


	///////////////////////////////////////////////////////////////////////
	// ambient and texture modifier
	// To make stuff looks look, we need more that just a standard vertex lighing,
	// we need to add some high-frequency per-pixel
	// this is the light equation:
	// 
	// color = ambient + diffuse + specular
	// 
	// adding some noise is quite often done using this equatin:
	//
	// color = modifier1 * (ambient + diffuse) + modifier2 * specular
	//
	// this bits of code compute the value of modifier1
	
	// texture coordinate
	vec2 texCoords = vec2(0.0,0.0);
	if(g_iTextureCoordinates != e_TextureCoordinates_None)
	{
		texCoords = v_TexCoord.xy;
	}
	vec4 specularTerm = v_specularTerm;

	vec3 ambientAndDiffuseModifier = vec3(1.0);
	if(g_bUseDiffMap)
	{
		ambientAndDiffuseModifier = GetAmbiantAndDiffuseModifierDiff(diffMap2D, texCoords, diffuseAverage, diffuseMapModifier);
	}
	
	vec3 diffuseTerm = v_diffuseTerm * mixColor.xyz;

	alpha *= transparency;


	///////////////////////////////////////////////////////////////////////
	// Combine all
	// basically just a way to put ambient, specular and diffuse together
	// there's a lot of variation and this should definitely be simplified

	vec4 finalColor;

	finalColor = GetFinalColor(
			ambientTerm * ambientAndDiffuseModifier,
			diffuseTerm * ambientAndDiffuseModifier, 
			vec3(specularTerm),
			1.0 );		
	///////////////////////////////////////////////////////////////////////

	gl_FragColor = vec4(finalColor.r,finalColor.g,finalColor.b,v_Depth);

} 
#endif //_FRAGMENT_PROGRAM


