If you appreciate the work done within the wiki, please consider supporting The Cutting Room Floor on Patreon. Thanks for all your support!

Bully: Scholarship Edition (Windows)/Unused Text

From The Cutting Room Floor
Jump to navigation Jump to search

This is a sub-page of Bully: Scholarship Edition (Windows).

Sub-Pages

BullySE Windows gm english.png
Development Text
Author: Bill Henderson Created 10/12/1999

Effects2.bft

Effect
	BEGIN
		EffectName "DoNothing"
		UpdateWhenFaded TRUE
		KillWhenFaded TRUE
		EffectImportance 1
		HightDetailDistance 1.000000
		LowDetailDistance 5.000000
		MaxRadius 1.000000
		FadeDistance 9.000000
		LIST_COUNT 1
		DefinitionTypeName "HeatHazePrimitive"
		Definition
			BEGIN
				StartTime 0.000000
				Duration 0.010000
				PrimitiveDescription "Heat Haze does nothing now and dies right away"
				Definition
					BEGIN
						UsingInterpolator FALSE
						IndexValues 0
						FloatValue 0.000000
					END
				FloatValue 1.000000
				FloatValue 1.000000
				Bool FALSE
			END
	END

Uncompiled Shader Code

There's a few good spots of raw shader code still within the game's executable.

0x54D798

// Input data (needs to match, or be a subset of the vertex shader output)
struct PsInput
{
	float4 diffuse: COLOR0;	
};

//------------------------------------------------------------------------------
// This is the main pixel shader.
//------------------------------------------------------------------------------
float4 main(PsInput i) : COLOR
{
	// Output final color
	float4 o;
	o.rgb = i.diffuse.rgb;	
	o.a = i.diffuse.a;
	return o;
}//main	
  ps_2_0      // Input data (needs to match, or be a subset of the vertex shader output)
struct PsInput	
{	
	float2 texCoord:  TEXCOORD0;
	float4 diffuse:   COLOR0;
};

sampler2D baseTex : register(s0);       

//------------------------------------------------------------------------------
// This is the main pixel shader.
//------------------------------------------------------------------------------
float4 main(PsInput i) : COLOR	
{ 	
	// Get base color	
	float4 cBase = tex2D(baseTex, i.texCoord);		

	// Output final color
	float4 o;
	o.rgb = cBase.rgb * i.diffuse.rgb;
	o.a = cBase.a * i.diffuse.a;	
	return o;
}//main	
 float4x4 mViewProjection : register(c0);	

// Our input structure	
struct VsInput	
{	
	float3 pos:       POSITION0;	
	float4 color:     COLOR0;
};				

// Our output structure, this needs to match what lives in the pixel shader
// or at least not be any less than what's used in the pixel shader.	
struct VsOutput		
{			
	float4 pos:       POSITION0;	
	float4 diffuse:   COLOR0;	
};				

//-----------------------------------------------------------------------------
// The main vertex shader function (entry point into shader)
//-----------------------------------------------------------------------------
VsOutput main(VsInput i)	
{	
	// Output structure	
	VsOutput o;		

	// Convert our position to view space.
	float4 pos = float4(i.pos, 1.0f);
	o.pos = mul(pos, mViewProjection);

	// Pass along vertex color
	o.diffuse = i.color.bgra / 255.0f;

	// All done
	return o;
}//mainVS
     float4x4 mProjection : register(c0);

// Our input structure	
struct VsInput		
{	
	float3 pos:       POSITION0;	
	float2 texCoord:  TEXCOORD0;
	float4 color:     COLOR0;
};

// Our output structure, this needs to match what lives in the pixel shader
// or at least not be any less than what's used in the pixel shader.
struct VsOutput	
{
	float4 pos:       POSITION0;
	float2 texCoord:  TEXCOORD0;
	float4 diffuse:   COLOR0;
};

//-----------------------------------------------------------------------------
// The main vertex shader function (entry point into shader)
//-----------------------------------------------------------------------------
VsOutput main(VsInput i)
{
	// Output structure
	VsOutput o;

	// Convert our position to view space.	
	float4 pos = float4(i.pos, 1.0f);
	o.pos = pos;	
	o.pos.y = 1.0f - i.pos.y;	
	o.pos.xy = (o.pos.xy * 2.0f) - 1.0f;
	o.pos.zw = mul(pos, mProjection).zw;
	o.pos.z = o.pos.z / o.pos.w;	
	o.pos.w = 1.0f;	

	// Pass along texture coordinate
	o.texCoord.xy = i.texCoord.xy;

	// Pass along vertex color
	o.diffuse = i.color.bgra / 255.0f;

	// All done	
	return o;
}//mainVS
  vs_2_0  float4x4 mViewProjection : register(c0);

// Our input structure	
struct VsInput	
{
	float3 pos:       POSITION0;
	float2 texCoord:  TEXCOORD0;
	float4 color:     COLOR0;
};

// Our output structure, this needs to match what lives in the pixel shader
// or at least not be any less than what's used in the pixel shader.
struct VsOutput	
{	
	float4 pos:       POSITION0;
	float2 texCoord:  TEXCOORD0;	
	float4 diffuse:   COLOR0;
};
//-----------------------------------------------------------------------------
// The main vertex shader function (entry point into shader)
//-----------------------------------------------------------------------------
VsOutput main(VsInput i)
{
	// Output structure
	VsOutput o;	

	// Convert our position to view space.
	float4 pos = float4(i.pos, 1.0f);
	o.pos = mul(pos, mViewProjection);

	// Pass along texture coordinate
	o.texCoord.xy = i.texCoord.xy;
																
	// Pass along vertex color	
	o.diffuse = i.color.bgra / 255.0f;	

	// All done
	return o;
}//mainVS

0x555FE9

    if (LightType != 2)
    {
        // This version only supports spotlights.
        ShadowOut = 1.0;
    }
    else
    {
        float3 LightToWorldPos = normalize(float3(WorldPos - LightPos));

        if (dot(LightDirection, LightToWorldPos) > CosOfCutoff)
        {
            float4 LightProjPos = mul(WorldPos, WorldToLightProjMat);
            float3 ShadowTexC = LightProjPos.xyz / LightProjPos.w;               
            ShadowTexC.xy =( 0.5 * ShadowTexC.xy) + float2( 0.5, 0.5 );
            ShadowTexC.y = 1.0f - ShadowTexC.y;

            float LightSpaceDepth = clamp(ShadowTexC.z - ShadowBias, 
                0.0, 1.0);
            
            float2 ShadowMapSizeInverse = 1.0 / ShadowMapSize;

            ShadowTexC.xy = ShadowTexC.xy - ShadowMapSizeInverse;
               
            ShadowOut = 0;
            float4 fOnes = float4(1.0, 1.0, 1.0, 1.0);
            float4 fKernels = float4(1.0, 1.0, 1.0, 1.0);
            float faKernels[4] = {1.0, 1.0, 1.0, 1.0};
           
            faKernels[0] = 1-frac(ShadowTexC.y * ShadowMapSize.y);
            faKernels[3]= frac(ShadowTexC.y  * ShadowMapSize.y); 
           
            fKernels.x = 1-frac(ShadowTexC.x * ShadowMapSize.x);
            fKernels.w = frac(ShadowTexC.x  * ShadowMapSize.x);
                              
            float fTotalPercent = 0;
            
            // This loop is manually unrolled here to avoid long
            // shader compilation times.
            //for (int i=0; i < 4; i++)
            // i == 0
            {
                float4 shadowMapDepth = 0;
                float2 pos = ShadowTexC.xy;
                shadowMapDepth.x = tex2D(ShadowMap, pos).x; 
                pos.x += ShadowMapSizeInverse;
                shadowMapDepth.y = tex2D(ShadowMap, pos).x;
                pos.x += ShadowMapSizeInverse;        
                shadowMapDepth.z = tex2D(ShadowMap, pos).x;
                pos.x += ShadowMapSizeInverse;                
                shadowMapDepth.w = tex2D(ShadowMap, pos).x;
                
                float4 shad = (LightSpaceDepth <= shadowMapDepth);
                    
                ShadowOut += dot(shad, fKernels) * faKernels[0];
                fTotalPercent += dot(fOnes, fKernels) * faKernels[0];
            }
            // i == 1
            {
                float4 shadowMapDepth = 0;
                float2 pos = ShadowTexC.xy;
                pos.y += ShadowMapSizeInverse;
                shadowMapDepth.x = tex2D(ShadowMap, pos).x; 
                pos.x += ShadowMapSizeInverse;
                shadowMapDepth.y = tex2D(ShadowMap, pos).x;
                pos.x += ShadowMapSizeInverse;        
                shadowMapDepth.z = tex2D(ShadowMap, pos).x;
                pos.x += ShadowMapSizeInverse;                
                shadowMapDepth.w = tex2D(ShadowMap, pos).x;
                
                float4 shad = (LightSpaceDepth <= shadowMapDepth);
                    
                ShadowOut += dot(shad, fKernels) * faKernels[1];
                fTotalPercent += dot(fOnes, fKernels) * faKernels[1];
            }
            // i == 2
            {
                float4 shadowMapDepth = 0;
                float2 pos = ShadowTexC.xy;
                pos.y += 2 * ShadowMapSizeInverse;
                shadowMapDepth.x = tex2D(ShadowMap, pos).x; 
                pos.x += ShadowMapSizeInverse;
                shadowMapDepth.y = tex2D(ShadowMap, pos).x;
                pos.x += ShadowMapSizeInverse;        
                shadowMapDepth.z = tex2D(ShadowMap, pos).x;
                pos.x += ShadowMapSizeInverse;                
                shadowMapDepth.w = tex2D(ShadowMap, pos).x;
                
                float4 shad = (LightSpaceDepth <= shadowMapDepth);
                    
                ShadowOut += dot(shad, fKernels) * faKernels[2];
                fTotalPercent += dot(fOnes, fKernels) * faKernels[2];
            }
            // i == 3
            {
                float4 shadowMapDepth = 0;
                float2 pos = ShadowTexC.xy;
                pos.y += 3 * ShadowMapSizeInverse;
                shadowMapDepth.x = tex2D(ShadowMap, pos).x; 
                pos.x += ShadowMapSizeInverse;
                shadowMapDepth.y = tex2D(ShadowMap, pos).x;
                pos.x += ShadowMapSizeInverse;        
                shadowMapDepth.z = tex2D(ShadowMap, pos).x;
                pos.x += ShadowMapSizeInverse;                
                shadowMapDepth.w = tex2D(ShadowMap, pos).x;
                
                float4 shad = (LightSpaceDepth <= shadowMapDepth);
                    
                ShadowOut += dot(shad, fKernels) * faKernels[3];
                fTotalPercent += dot(fOnes, fKernels) * faKernels[3];
            }
           
            ShadowOut = ShadowOut / fTotalPercent;         
        }
        else
        {
            // Outside of the light cone is shadowed completely
            ShadowOut = 0.0;
        }
    }    
         
    if (LightType != 2)
    {
        // This version only supports spotlights.
        ShadowOut = 1.0;
    }
    else
    {
        float3 LightToWorldPos = normalize(float3(WorldPos - LightPos));

        if (dot(LightDirection, LightToWorldPos) > CosOfCutoff)
        {
            float4 LightProjPos = mul(WorldPos, WorldToLightProjMat);
            float3 ShadowTexC = LightProjPos.xyz / LightProjPos.w;               
            ShadowTexC.xy =( 0.5 * ShadowTexC.xy) + float2( 0.5, 0.5 );
            ShadowTexC.y = 1.0f - ShadowTexC.y;
            float LightSpaceDepth = clamp(ShadowTexC.z - ShadowBias, 
                0.0, 1.0);
            float2 ShadowMapSizeInverse = 1.0 / ShadowMapSize;
            float2 lerps = frac( ShadowTexC.xy * ShadowMapSize);

            float4 SourceVals;
            SourceVals.x = tex2D( ShadowMap, ShadowTexC.xy ).r;

            ShadowTexC.x += ShadowMapSizeInverse;
            SourceVals.y = tex2D( ShadowMap, ShadowTexC.xy).r;  

            ShadowTexC.y += ShadowMapSizeInverse;                
            SourceVals.w = tex2D( ShadowMap, ShadowTexC.xy).r;
                
            ShadowTexC.x -= ShadowMapSizeInverse;                
            SourceVals.z = tex2D( ShadowMap, ShadowTexC.xy).r;
                
            float4 Shade = (LightSpaceDepth <= SourceVals);

            // lerp between the shadow values to calculate our light amount
            ShadowOut = lerp(
                lerp(Shade.x, Shade.y, lerps.x),
                lerp(Shade.z, Shade.w, lerps.x), lerps.y );
        }
        else
        {
            // Outside of the light cone is shadowed completely
            ShadowOut = 0.0;
        }
    }    
     
    if (LightType == 0 || LightType == 2)
    {
        // This version only supports point lights.
        ShadowOut = 1.0;
    }
    else
    {
        float3 ViewVector = WorldPos - LightPos;    
        ViewVector.z = -ViewVector.z;
        float3 ViewVectorNrm = normalize(ViewVector);

        float fDepth = dot(ViewVector, ViewVector);
        fDepth = sqrt(fDepth) * ShadowBias;
        float ShadowLookup = texCUBE(ShadowMap, ViewVectorNrm).r;
         
        if (ShadowLookup == 0 || ShadowLookup > fDepth )
            ShadowOut = 1.0;
        else
            ShadowOut = 0.0;
    }
         
    if (LightType != 2)
    {
        // This version only supports spotlights.
        ShadowOut = 1.0;
    }
    else
    {
        float3 LightToWorldPos = normalize(float3(WorldPos - LightPos));

        if (dot(LightDirection, LightToWorldPos) > CosOfCutoff)
        {
            float4 LightProjPos = mul(WorldPos, WorldToLightProjMat);
            float3 ShadowTexC = LightProjPos.xyz / LightProjPos.w;               
            ShadowTexC.xy =( 0.5 * ShadowTexC.xy) + float2( 0.5, 0.5 );
            ShadowTexC.y = 1.0f - ShadowTexC.y;
            float LightSpaceDepth = clamp(ShadowTexC.z - ShadowBias, 
                0.0, 1.0);
                                                        
            float4 vVSM   = tex2D( ShadowMap, ShadowTexC.xy );
            float  fAvgZ  = vVSM.r; // Filtered z
            float  fAvgZ2 = vVSM.g; // Filtered z-squared
            
            // Standard shadow map comparison
            if( (LightSpaceDepth - ShadowBias) <= fAvgZ)
            {
                ShadowOut = 1.0f;
            }
            else
            {               
                // Use variance shadow mapping to compute the maximum 
                // probability that the pixel is in shadow
                float variance = ( fAvgZ2 ) - ( fAvgZ * fAvgZ );
                variance       = 
                    min( 1.0f, max( 0.0f, variance + ShadowVSMPowerEpsilon.y));
                ShadowOut = variance;
                
                float mean     = fAvgZ;
                float d        = LightSpaceDepth - mean;
                float p_max    = variance / ( variance + d*d );
                
                ShadowOut = pow( p_max, ShadowVSMPowerEpsilon.x);
            }

        }
        else
        {
            // Outside of the light cone is shadowed completely
            ShadowOut = 0.0;
        }
    }
           
    if (LightType != 2)
    {
        // This version only supports spotlights.
        ShadowOut = 1.0;
    }
    else
    {
        float3 LightToWorldPos = normalize(float3(WorldPos - LightPos));

        if (dot(LightDirection, LightToWorldPos) > CosOfCutoff)
        {
            float4 LightProjPos = mul(WorldPos, WorldToLightProjMat);

            float3 ShadowTexC = LightProjPos.xyz / LightProjPos.w;               
            ShadowTexC.xy =( 0.5 * ShadowTexC.xy) + float2( 0.5, 0.5 );
            ShadowTexC.y = 1.0f - ShadowTexC.y;

            float LightSpaceDepth = clamp(ShadowTexC.z - ShadowBias, 
                0.0, 1.0);
            float ShadowLookup = tex2D(ShadowMap, ShadowTexC.xy).r;                
            ShadowOut = ShadowLookup < LightSpaceDepth ? 0.0 : 1.0;
        }
        else
        {
            // Outside of the light cone is shadowed completely
            ShadowOut = 0.0;
        }
    }
        (0.0005)    CosOfCutoff     
    
    if ( LightType != 0)
    {
      // This fragment only supports directional lights.
        ShadowOut = 0.0;
    }
    else
    {
        float4 LightProjPos = mul(WorldPos, WorldToLightProjMat);
        float2 ShadowTexC = 0.5 * LightProjPos.xy / LightProjPos.w + 
                  float2( 0.5, 0.5 );
        
        ShadowTexC.y = 1.0f - ShadowTexC.y;
        
        float ShadowMapSizeInverse = 1.0f / ShadowMapSize;
        float LightSpaceDepth = (LightProjPos.z / LightProjPos.w);
        float2 borderTest = saturate(ShadowTexC) - ShadowTexC;

        if (any(borderTest))
        {
            ShadowOut = 1.0;
        }
        else
        {    
            LightSpaceDepth -= ShadowBias;
        
            ShadowOut = 0;
            float4 fOnes = float4(1.0, 1.0, 1.0, 1.0);
            float4 fKernels = float4(1.0, 1.0, 1.0, 1.0);
            float faKernels[4] = {1.0, 1.0, 1.0, 1.0};
            
            faKernels[0] = 1-frac(ShadowTexC.y * ShadowMapSize.y);
            faKernels[3]= frac(ShadowTexC.y  * ShadowMapSize.y); 
            
            fKernels.x = 1-frac(ShadowTexC.x * ShadowMapSize.x);
            fKernels.w = frac(ShadowTexC.x  * ShadowMapSize.x);
                      
            float fTotalPercent = 0;
            
            // This loop is manually unrolled here to avoid long
            // shader compilation times.
            //for (int i=0; i < 4; i++)
            // i == 0
            {
                float4 shadowMapDepth = 0;
                float2 pos = ShadowTexC;                
                shadowMapDepth.x = tex2D(ShadowMap, pos).x; 
                pos.x += ShadowMapSizeInverse;
                shadowMapDepth.y = tex2D(ShadowMap, pos).x;
                pos.x += ShadowMapSizeInverse;        
                shadowMapDepth.z = tex2D(ShadowMap, pos).x;
                pos.x += ShadowMapSizeInverse;                
                shadowMapDepth.w = tex2D(ShadowMap, pos).x;
                
                float4 shad = (LightSpaceDepth < shadowMapDepth);
    
                ShadowOut += dot(shad, fKernels) * faKernels[0];
                fTotalPercent += dot(fOnes, fKernels) * faKernels[0];
            }
            // i == 1
            {
                float4 shadowMapDepth = 0;
                float2 pos = ShadowTexC;                
                pos.y += ShadowMapSizeInverse;
                shadowMapDepth.x = tex2D(ShadowMap, pos).x; 
                pos.x += ShadowMapSizeInverse;
                shadowMapDepth.y = tex2D(ShadowMap, pos).x;
                pos.x += ShadowMapSizeInverse;        
                shadowMapDepth.z = tex2D(ShadowMap, pos).x;
                pos.x += ShadowMapSizeInverse;                
                shadowMapDepth.w = tex2D(ShadowMap, pos).x;
                
                float4 shad = (LightSpaceDepth < shadowMapDepth);
    
                ShadowOut += dot(shad, fKernels) * faKernels[1];
                fTotalPercent += dot(fOnes, fKernels) * faKernels[1];
            }
            // i == 2
            {
                float4 shadowMapDepth = 0;
                float2 pos = ShadowTexC;                
                pos.y += 2 * ShadowMapSizeInverse;
                shadowMapDepth.x = tex2D(ShadowMap, pos).x; 
                pos.x += ShadowMapSizeInverse;
                shadowMapDepth.y = tex2D(ShadowMap, pos).x;
                pos.x += ShadowMapSizeInverse;        
                shadowMapDepth.z = tex2D(ShadowMap, pos).x;
                pos.x += ShadowMapSizeInverse;                
                shadowMapDepth.w = tex2D(ShadowMap, pos).x;
                
                float4 shad = (LightSpaceDepth < shadowMapDepth);
    
                ShadowOut += dot(shad, fKernels) * faKernels[2];
                fTotalPercent += dot(fOnes, fKernels) * faKernels[2];
            }
            // i == 3
            {
                float4 shadowMapDepth = 0;
                float2 pos = ShadowTexC;                
                pos.y += 3 * ShadowMapSizeInverse;
                shadowMapDepth.x = tex2D(ShadowMap, pos).x; 
                pos.x += ShadowMapSizeInverse;
                shadowMapDepth.y = tex2D(ShadowMap, pos).x;
                pos.x += ShadowMapSizeInverse;        
                shadowMapDepth.z = tex2D(ShadowMap, pos).x;
                pos.x += ShadowMapSizeInverse;                
                shadowMapDepth.w = tex2D(ShadowMap, pos).x;
                
                float4 shad = (LightSpaceDepth < shadowMapDepth);
    
                ShadowOut += dot(shad, fKernels) * faKernels[3];
                fTotalPercent += dot(fOnes, fKernels) * faKernels[3];
            }
            
            ShadowOut = ShadowOut / fTotalPercent;         
           }
       }

      ps_3_0/ps_4_0   DX9/D3D10/Xenon/PS3     
    
    if ( LightType != 0)
    {
      // This fragment only supports directional lights.
        ShadowOut = 0.0;
    }
    else
    {
        float4 LightProjPos = mul(WorldPos, WorldToLightProjMat);
        float2 ShadowTexC = 0.5 * LightProjPos.xy / LightProjPos.w + 
                  float2( 0.5, 0.5 );
    
        ShadowTexC.y = 1.0f - ShadowTexC.y;
    
        float ShadowMapSizeInverse = 1.0f / ShadowMapSize;
        float2 lerps = frac( ShadowTexC * ShadowMapSize);
        float LightSpaceDepth = (LightProjPos.z / LightProjPos.w);
        float2 borderTest = saturate(ShadowTexC) - ShadowTexC;

        if (any(borderTest))
        {
            ShadowOut = 1.0;
        }
        else
        {
            LightSpaceDepth -= ShadowBias;
                   
            float4 SourceVals;
            SourceVals.x = tex2D( ShadowMap, ShadowTexC ).r;
    
            ShadowTexC.x += ShadowMapSizeInverse;
            SourceVals.y = tex2D( ShadowMap, ShadowTexC).r;  
    
            ShadowTexC.y += ShadowMapSizeInverse;                
            SourceVals.w = tex2D( ShadowMap, ShadowTexC ).r;
                
            ShadowTexC.x -= ShadowMapSizeInverse;                
            SourceVals.z = tex2D( ShadowMap, ShadowTexC).r;
                
            float4 Shade = (LightSpaceDepth < SourceVals);
    
            // lerp between the shadow values to calculate our light amount
            ShadowOut = lerp(
                lerp(Shade.x, Shade.y, lerps.x),
                lerp(Shade.z, Shade.w, lerps.x), lerps.y );        
        }
    }

       
    
    if ( LightType != 0)
    {
      // This fragment only supports directional lights.
        ShadowOut = 0.0;
    }
    else
    { 
        float4 LightProjPos = mul(WorldPos, WorldToLightProjMat);
        float2 ShadowTexC = 0.5 * LightProjPos.xy / LightProjPos.w + 
            float2( 0.5, 0.5 );
        ShadowTexC.y = 1.0f - ShadowTexC.y;
        
        float LightSpaceDepth = (LightProjPos.z / LightProjPos.w);
        float2 borderTest = saturate(ShadowTexC) - ShadowTexC;

        float4 vVSM   = tex2D( ShadowMap, ShadowTexC.xy );
        float  fAvgZ  = vVSM.r; // Filtered z
        float  fAvgZ2 = vVSM.g; // Filtered z-squared
        
        // Standard shadow map comparison
        if((LightSpaceDepth) - ShadowBias <= fAvgZ || any(borderTest))
        {
            ShadowOut = 1.0f;
        }
        else
        {            
            // Use variance shadow mapping to compute the maximum probability 
            // that the pixel is in shadow
            float variance = ( fAvgZ2 ) - ( fAvgZ * fAvgZ );
            variance       = 
                min( 1.0f, max( 0.0f, variance + ShadowVSMPowerEpsilon.y ) );
            ShadowOut = variance;
            
            float mean     = fAvgZ;
            float d        = LightSpaceDepth - mean;
            float p_max    = variance / ( variance + d*d );
            
            ShadowOut = pow( p_max, ShadowVSMPowerEpsilon.x);
        }
    }

      (10.0, 0.001)       
    
    if ( LightType != 0)
    {
      // This fragment only supports directional lights.
        ShadowOut = 0.0;
    }
    else
    {
        float4 LightProjPos = mul(WorldPos, WorldToLightProjMat);
        float2 ShadowTexC = 0.5 * LightProjPos.xy / LightProjPos.w + 
                  float2( 0.5, 0.5 );
    
        ShadowTexC.y = 1.0f - ShadowTexC.y;

        float ShadowLookup = tex2D(ShadowMap, ShadowTexC.xy).r;
        float LightSpaceDepth = (LightProjPos.z / LightProjPos.w) ;
        float2 borderTest = saturate(ShadowTexC) - ShadowTexC;

        if ( (ShadowLookup > LightSpaceDepth - ShadowBias) || 
            any(borderTest))
        {
            ShadowOut = 1.0;
        }
        else
        {
            ShadowOut = 0.0;
        }
        
       }

      (0.005) (512,512)   
    This fragment is responsible for calculating the Shadow coefficient.
      
    Output = Input.r;
         
    This fragment implements the operation:
    Output = Input.r;
     
    Output = Input.rrrr;
      
    This fragment implements the operation:
    Output = float4(Input, Input, Input, Input);
      
    Output = Input.rrr;
           
    This fragment implements the operation:
    Output = float3(Input, Input, Input);
     
    Output = (V1 * V2) + V3;
      
    This fragment implements the equation:
    Output = (V1 * V2) + V3
        
    Output = V1 * saturate(V2.rgb + Scalar.rrr);
      
    This fragment is responsible for accumulating into the current color by
    multiplying the sampled texture color with the current color. The 
    original input alpha channel is preserved. The scalar value is added to the
    sampled color value and then clamped to the range [0.0, 1.0].
          
    This fragment is responsible for normalizing a float2.
            
    This fragment is responsible for normalizing a float3.
        
    VectorOut = normalize(VectorIn);
      
    This fragment is responsible for normalizing a float4.
            
    This fragment is responsible for linearly interpolating two floats.   
            
    This fragment is responsible for linearly interpolating two float2's.   
          
    This fragment is responsible for linearly interpolating two float3's. 
        
    Output = lerp(V1, V2, LerpAmount);
        (0.5)       
    This fragment is responsible for linearly interpolating two float4's. 
            
    This fragment is responsible for saturating a float. 
     
    This fragment is responsible for saturating a float2. 
            
    This fragment is responsible for saturating a float3. 
        
    Output = saturate(V1);
        
    This fragment is responsible for saturating a float4. 
            
    This fragment is responsible for scaling a float2 by a constant. 
             
    This fragment is responsible for scaling a float3 by a constant. 
     
    Output = Scale * V1;
      
    This fragment is responsible for scaling a float4 by a constant. 
         
    This fragment is responsible for multiplying two floats. 
         
    This fragment is responsible for multiplying two float2's. 
       
    This fragment is responsible for multiplying two float3's. 
       
    Output = V1 * V2;
         
    This fragment is responsible for multiplying two float4's. 
       
    This fragment is responsible for adding two floats. 
      
    This fragment is responsible for adding two float2's. 
            
    This fragment is responsible for adding two float3's. 
        
    Output = V1 + V2;
     
    This fragment is responsible for adding two float4's. 
            
    OutputColor.rgb = FinalColor.rgb;
    OutputColor.a = saturate(FinalOpacity);
     
    This fragment is responsible for computing the final RGBA color.
          
    OutputColor.rgb = DiffuseColor.rgb + SpecularColor.rgb;
           
    This fragment is responsible for computing the final RGB color.
           
    Red = ColorAndOpacity.r;
    Green = ColorAndOpacity.g;
    Blue = ColorAndOpacity.b;
    Alpha = ColorAndOpacity.a;
      
    Separate a float4 into 4 floats.   
       
    Color.rgb = ColorAndOpacity.rgb;
    Opacity = ColorAndOpacity.a;
     
    Separate a float4 into a float3 and a float.   
       
    Diffuse = MatEmissive + MatAmbient * LightAmbientAccum + 
        MatDiffuse * LightDiffuseAccum;
    Specular = MatSpecular * LightSpecularAccum;
    
    if (Saturate)
    {
        Diffuse = saturate(Diffuse);
        Specular = saturate(Specular);
    }
         
    This fragment is responsible for computing the coefficients for the 
    following equations:
    
    Kdiffuse = MatEmissive + 
        MatAmbient * Summation(0...N){LightAmbientContribution[N]} + 
        MatDiffuse * Summation(0..N){LightDiffuseContribution[N]}
        
    Kspecular = MatSpecular * Summation(0..N){LightSpecularContribution[N]}
    
        
    // These tests will evaluate to less than 0 if they are true.
    float fLessTest = (AlphaTestValue - AlphaTestRef);
    float fGreaterTest = -fLessTest;
    float fEqualTest = 0.0;
    if (fLessTest == 0.0)
        fEqualTest = -1.0;

    // Clip if AlphaTestValue < AlphaTestRef for:
    //  TEST_LESS 
    //  TEST_EQUAL 
    //  TEST_LESSEQUAL 
    clip(fGreaterTest * AlphaTestFunction.x);
    
    // Clip if AlphaTestValue > AlphaTestRef for:
    //  TEST_EQUAL 
    //  TEST_GREATER 
    //  TEST_GREATEREQUAL 
    clip(fLessTest * AlphaTestFunction.y);
    
    // Clip if AlphaTestValue == AlphaTestRef for:
    //  TEST_LESS 
    //  TEST_GREATER 
    //  TEST_NOTEQUAL 
    clip(fEqualTest * AlphaTestFunction.z);
     (0.0)   
    This fragment is responsible for alpha testing based on the alpha
    reference value and alpha test function.
            
    FoggedColor = lerp(FogColor, UnfoggedColor, FogAmount);
           
    This fragment is responsible for applying the fog based on the 
    calculations in the vertex shader.
    
       Pixel/Vertex       
    // Get the world space light vector.
    float3 LightVector;
    float DistanceToLight;
    float DistanceToLightSquared;
        
    if (LightType == 0)
    {
        LightVector = -LightDirection;
    }
    else
    {
        LightVector = LightPos - WorldPos;
        DistanceToLightSquared = dot(LightVector, LightVector);
        DistanceToLight = length(LightVector);
        LightVector = normalize(LightVector);
    }
    
    // Take N dot L as intensity.
    float LightNDotL = dot(LightVector, WorldNrm);
    float LightIntensity = max(0, LightNDotL);

    float Attenuate = Shadow;
    
    if (LightType != 0)
    {
        // Attenuate Here
        Attenuate = LightAttenuation.x +
            LightAttenuation.y * DistanceToLight +
            LightAttenuation.z * DistanceToLightSquared;
        Attenuate = max(1.0, Attenuate);
        Attenuate = 1.0 / Attenuate;
        Attenuate *= Shadow;

        if (LightType == 2)
        {
            // Get intensity as cosine of light vector and direction.
            float CosAlpha = dot(-LightVector, LightDirection);

            // Factor in inner and outer cone angles.
            CosAlpha = saturate((CosAlpha - LightSpotAttenuation.y) / 
                (LightSpotAttenuation.x - LightSpotAttenuation.y));

            // Power to falloff.
            CosAlpha = pow(CosAlpha, LightSpotAttenuation.z);

            // Multiply the spot attenuation into the overall attenuation.
            Attenuate *= CosAlpha;
        }

    }
    // Determine the interaction of diffuse color of light and material.
    // Scale by the attenuated intensity.
    DiffuseAccumOut = DiffuseAccum;
    DiffuseAccumOut.rgb += LightDiffuse.rgb * LightIntensity * Attenuate;

    // Determine ambient contribution - Is affected by shadow
    AmbientAccumOut = AmbientAccum;
    AmbientAccumOut.rgb += LightAmbient.rgb * Attenuate;

    SpecularAccumOut = SpecularAccum;
    if (SpecularEnable)
    {
        // Get the half vector.
        float3 LightHalfVector = LightVector + WorldViewVector;
        LightHalfVector = normalize(LightHalfVector);

        // Determine specular intensity.
        float LightNDotH = max(0, dot(WorldNrm, LightHalfVector));
        float LightSpecIntensity = pow(LightNDotH, SpecularPower.x);
        
        //if (LightNDotL < 0.0)
        //    LightSpecIntensity = 0.0;
        // Must use the code below rather than code above.
        // Using previous lines will cause the compiler to generate incorrect
        // output.
        float SpecularMultiplier = LightNDotL > 0.0 ? 1.0 : 0.0;
        
        // Attenuate Here
        LightSpecIntensity = LightSpecIntensity * Attenuate * 
            SpecularMultiplier;
        
        // Determine the interaction of specular color of light and material.
        // Scale by the attenuated intensity.
        SpecularAccumOut.rgb += LightSpecIntensity * LightSpecular;
    }       

    
       (-1.0, -1.0, 0.0)   (0.0, 1.0, 0.0) (0.0, 0.0, 0.0, 0.0)    Specularity     
    This fragment is responsible for accumulating the effect of a light
    on the current pixel.
    
    LightType can be one of three values:
        0 - Directional
        1 - Point 
        2 - Spot
        
    Note that the LightType must be a compile-time variable,
    not a runtime constant/uniform variable on most Shader Model 2.0 cards.
    
    The compiler will optimize out any constants that aren't used.
    
    Attenuation is defined as (const, linear, quad, range).
    Range is not implemented at this time.
    
    SpotAttenuation is stored as (cos(theta/2), cos(phi/2), falloff)
    theta is the angle of the inner cone and phi is the angle of the outer
    cone in the traditional DX manner. Gamebryo only allows setting of
    phi, so cos(theta/2) will typically be cos(0) or 1. To disable spot
    effects entirely, set cos(theta/2) and cos(phi/2) to -1 or lower.
                 
    float fDistance = dot(WorldClipPlane.xyz, WorldPos.xyz) - WorldClipPlane.w;
    if (InvertClip)
        Scalar = fDistance > 0.0 ? 0.0 : 1.0;
    else
        Scalar = fDistance > 0.0 ? 1.0 : 0.0;
       (1.0, 0.0, 0.0, 0.0)    
    This fragment is responsible for calculating whether or not the current
    position is on the positive or negative side of a clipping plane. If the
    point is on the positive side, the return value will be 1.0. If the value 
    is on the negative side, the return value will be 0.0. If the point is on
    the plane, the return value will be 0.0. If InvertClip is true, then the
    fragment returns the opposite of the above.
    
    A plane is assumed to be the points X satisfying the expression:
        X * normal = plane_constant
        
    The WorldClipPlane must match the form of NiPlane, which is of the form:
        (normal.x, normal.y, normal.z, plane_constant)
     
    WorldViewVector = CameraPos - WorldPos;
       CameraPosition  
    This fragment is responsible for calculating the camera view vector.
      
    if (NormalizeNormal)
        WorldNrm = normalize(WorldNrm);
    WorldReflect = reflect(-WorldViewVector, WorldNrm);
      
    This fragment is responsible for computing the reflection vector.
    The WorldViewVector is negated because the HLSL "reflect" function
    expects a world-to-camera vector, rather than a camera-to-world vector.
      
    float d;
    if (FogRange)
    {
        d = length(ViewPosition);
    }
    else
    {
        d = ViewPosition.z;
    }
    
    if (FogType == 0) // NONE
    {
        FogOut = 1.0;
    }
    else if (FogType == 1) // EXP
    {
        FogOut = 1.0 / exp( d * FogDensity);
    }
    else if (FogType == 2) // EXP2
    {
        FogOut = 1.0 / exp( pow( d * FogDensity, 2));
    }
    else if (FogType == 3) // LINEAR
    {
        FogOut = saturate( (FogStartEnd.y - d) / 
            (FogStartEnd.y - FogStartEnd.x));
    }
       (0.0, 1.0)  (1.0)   
    This fragment is responsible for handling fogging calculations.
    FogType can be one of 4 values:
    
        NONE   - 0
        EXP    - 1
        EXP2   - 2
        LINEAR - 3
      
    ColorOut.rgb = texCUBE(Sampler, TexCoord).rgb;
    if (Saturate)
    {
        ColorOut.rgb = saturate(ColorOut.rgb);
    }
       
    float4 ProjTexCoord = TexCoord.xyzz;
    ColorOut.rgb = tex2Dproj(Sampler, ProjTexCoord).rgb;
    if (Saturate)
    {
        ColorOut.rgb = saturate(ColorOut.rgb);
    }
        
    ColorOut = tex2D(Sampler, TexCoord);
    if (Saturate)
    {
        ColorOut = saturate(ColorOut);
    }
         
    This fragment is responsible for sampling a texture and returning its value
    as a RGB value and an A value.
            
    ColorOut.rgb = tex2D(Sampler, TexCoord).rgb;
    if (Saturate)
    {
        ColorOut.rgb = saturate(ColorOut.rgb);
    }
     Texture     
    This fragment is responsible for sampling a texture and returning its value
    as a RGB value.
           
  
    TexCoordOut = mul(float4(TexCoord, 1.0), TexTransform);
    
           
    This fragment is responsible for applying a projection to the input set
    of texture coordinates.
       
    
    TexCoordOut = mul(float4(TexCoord.x, TexCoord.y, 0.0, 1.0), TexTransform);
           
    This fragment is responsible for applying a transform to the input set
    of texture coordinates.
        
    TexCoordOut = TexCoordIn + 
        float4(TexCoordOffset.x, TexCoordOffset.y, 0.0, 0.0);
         
    TexCoordOut = TexCoordIn + float3(TexCoordOffset.x, TexCoordOffset.y, 0.0);
       
    TexCoordOut = TexCoordIn + TexCoordOffset;
        
    This fragment is responsible for applying a UV offset to a texture
    coordinate set.
            
    BumpOffset.x = DuDv.x * BumpMatrix[0] + DuDv.y * BumpMatrix[2];
    BumpOffset.y = DuDv.x * BumpMatrix[1] + DuDv.y * BumpMatrix[3];
       UVSet   (1.0, 1.0, 1.0, 1.0)    
    This fragment is responsible for calculating the UV offset to apply
    as a result of a bump map.
        
    // Calculate offset scaling constant bias.
    float2 Bias = float2(OffsetScale, OffsetScale) * -0.5;

    // Calculate offset
    float2 Offset = Height.rg * OffsetScale + Bias;

    // Get texcoord.
    ParallaxOffsetUV = TexCoord + Offset * TangentSpaceEyeVec.xy;
        (1.0, 0.0, 0.0) ViewVector  (0.05)  ParallaxOffsetScale 
    This fragment is responsible for calculating the UV offset to apply
    as a result of a parallax map.
            
    
    NormalMap = NormalMap * 2.0 - 1.0;
    
    // Do nothing extra for Standard
    // Handle compressed types:
    if (NormalMapType == 1) // DXN
    {
        NormalMap.rgb = float3(NormalMap.r, NormalMap.g, 
            sqrt(1 - NormalMap.r * NormalMap.r - NormalMap.g * NormalMap.g));
    }
    else if (NormalMapType == 2) // DXT5
    {
        NormalMap.rg = NormalMap.ag;
        NormalMap.b = sqrt(1 - NormalMap.r*NormalMap.r -  
            NormalMap.g * NormalMap.g);
    }
       
    float3x3 xForm = float3x3(WorldTangentIn, WorldBinormalIn, WorldNormalIn);
    xForm = transpose(xForm);
    WorldNormalOut = mul(xForm, NormalMap.rgb);
    
    WorldNormalOut = normalize(WorldNormalOut);
       ps_2_0/ps_4_0   (0) 
    This fragment is responsible for sampling a normal map to generate the
    new world-space normal.
    
    The normal map type is an enumerated value that indicates the following:
        0 - Standard (rgb = normal/binormal/tangent)
        1 - DXN (rg = normal.xy need to calculate z)
        2 - DXT5 (ag = normal.xy need to calculate z)
      
    DiffuseColorOut  = SHCoefficients[0];
    DiffuseColorOut += SHCoefficients[1] * WorldNormal.x;
    DiffuseColorOut += SHCoefficients[2] * WorldNormal.y;
    DiffuseColorOut += SHCoefficients[3] * WorldNormal.z;
    DiffuseColorOut += SHCoefficients[4] * WorldNormal.x * WorldNormal.z;
    DiffuseColorOut += SHCoefficients[5] * WorldNormal.y * WorldNormal.z;
    DiffuseColorOut += SHCoefficients[6] * WorldNormal.x * WorldNormal.y;
    DiffuseColorOut += SHCoefficients[7] * 
        (3.0 * WorldNormal.z * WorldNormal.z  - 1.0);
    DiffuseColorOut += SHCoefficients[8] * 
        (WorldNormal.x * WorldNormal.x  - WorldNormal.y * WorldNormal.y);
     DiffuseColorOut SHCoefficients      
    This fragment is responsible for generating the diffuse 
    lighting environment as compressed in spherical harmonics.
       9thOrderSphericalHarmonicLighting   
    ViewPos = mul(WorldPosition, ViewTransform);
    ProjPos = mul(ViewPos, ProjTransform);
       ProjMatrix  ViewMatrix  
    ProjPos = mul(WorldPosition, ViewProjection);
     ViewProjMatrix      
    This fragment is responsible for applying the view projection transform
    to the input world position.
          
    // TransformSkinnedPosition *********************************************
    // Transform the skinned position into world space
    // Composite the skinning transform which will take the vertex
    // and normal to world space.
    float fWeight3 = 1.0 - BlendWeights[0] - BlendWeights[1] - BlendWeights[2];
    float4x3 ShortSkinBoneTransform;
    ShortSkinBoneTransform  = Bones[0] * BlendWeights[0];
    ShortSkinBoneTransform += Bones[1] * BlendWeights[1];
    ShortSkinBoneTransform += Bones[2] * BlendWeights[2];
    ShortSkinBoneTransform += Bones[3] * fWeight3;
    SkinBoneTransform = float4x4(ShortSkinBoneTransform[0], 0.0f, 
        ShortSkinBoneTransform[1], 0.0f, 
        ShortSkinBoneTransform[2], 0.0f, 
        ShortSkinBoneTransform[3], 1.0f);

    // Transform into world space.
    WorldPos.xyz = mul(float4(Position, 1.0), ShortSkinBoneTransform);
    WorldPos = mul(float4(WorldPos.xyz, 1.0), SkinToWorldTransform);

     
    // TransformSkinnedPosition *********************************************
    // Transform the skinned position into world space
    // Composite the skinning transform which will take the vertex
    // and normal to world space.
    float fWeight3 = 1.0 - BlendWeights[0] - BlendWeights[1] - BlendWeights[2];
    float4x3 ShortSkinBoneTransform;
    ShortSkinBoneTransform  = Bones[BlendIndices[0]] * BlendWeights[0];
    ShortSkinBoneTransform += Bones[BlendIndices[1]] * BlendWeights[1];
    ShortSkinBoneTransform += Bones[BlendIndices[2]] * BlendWeights[2];
    ShortSkinBoneTransform += Bones[BlendIndices[3]] * fWeight3;
    SkinBoneTransform = float4x4(ShortSkinBoneTransform[0], 0.0f, 
        ShortSkinBoneTransform[1], 0.0f, 
        ShortSkinBoneTransform[2], 0.0f, 
        ShortSkinBoneTransform[3], 1.0f);

    // Transform into world space.
    WorldPos.xyz = mul(float4(Position, 1.0), ShortSkinBoneTransform);
    WorldPos = mul(float4(WorldPos.xyz, 1.0), SkinToWorldTransform);
      SkinBoneMatrix  
    This fragment is responsible for applying the view projection and skinning 
    transform to the input position. Additionally, this fragment applies the 
    computed world transform to the input position. The weighted world 
    transform defined by the blendweights is output for use in normals or
    other calculations as the new world matrix.
       
    float3x3 xForm = float3x3(WorldTangentIn, WorldBinormalIn, WorldNormalIn);
    VectorOut = mul(xForm, VectorIn.xyz);
      
    This fragment is responsible for transforming a vector from world space
    to tangent space.
     
    // Transform the position into world space for lighting, and projected 
    // space for display
    WorldPos = mul( float4(Position, 1.0f), World );
     
    This fragment is responsible for applying the view projection transform
    to the input position. Additionally, this fragment applies the world 
    transform to the input position. 
           
    // Transform the normal into world space for lighting
    WorldNrm      = mul( Normal, (float3x3)World );
    WorldBinormal = mul( Binormal, (float3x3)World );
    WorldTangent  = mul( Tangent, (float3x3)World );
    
    // Should not need to normalize here since we will normalize in the pixel 
    // shader due to linear interpolation across triangle not preserving
    // normality.
       
    This fragment is responsible for applying the world transform to the
    normal, binormal, and tangent.
           
    // Transform the normal into world space for lighting
    WorldNrm = mul( Normal, (float3x3)World );

    // Should not need to normalize here since we will normalize in the pixel 
    // shader due to linear interpolation across triangle not preserving
    // normality.
       vs_1_1/ps_2_0/vs_4_0/ps_4_0 D3D10/DX9/Xenon/PS3 hlsl/Cg WorldMatrix 
    This fragment is responsible for applying the world transform to the
    normal.
      Vertex/Pixel

0x55FD19

    Output1 = Input;
    Output2 = Input;
     
    This fragment splits and passes through a single float4 input into two 
    float4 outputs.
       
    float Depth = dot(WorldViewVector, WorldViewVector);
    OutputColor.x = sqrt(Depth);
    OutputColor.yzw = 1.0f;
         
    This fragment writes projected depth to all color component outputs.
      
    This fragment is responsible for linearly interpolating two float3's.   
          
    This fragment is responsible for linearly interpolating two float4's.   
          
    This fragment is responsible for saturating a float.   
           
    This fragment is responsible for saturating a float2.   
          
    This fragment is responsible for saturating a float3.   
          
    This fragment is responsible for saturating a float4.   
          
    This fragment is responsible for scaling a float2 by a constant.   
           
    This fragment is responsible for scaling a float3 by a constant.   
           
    This fragment is responsible for scaling a float4 by a constant.     
     
    This fragment is responsible for multiplying two floats.   
       
    This fragment is responsible for multiplying two float2's.   
     
    This fragment is responsible for multiplying two float3's.   
     
    This fragment is responsible for multiplying two float4's.   
     
    This fragment is responsible for adding two floats.   
            
    This fragment is responsible for adding two float2's.   
          
    This fragment is responsible for adding two float3's.   
          
    This fragment is responsible for adding two float4's.   
          
    ViewPos = mul(WorldPosition, ViewTransform );
    ProjPos = mul(ViewPos, ProjTransform );
     
    ProjPos = mul(WorldPosition, ViewProjection );
        
      Output1 = Input;
      Output2 = Input;
         
      This fragment splits and passes through a single float4 input into two
      float4 outputs.
            
    float Depth = WorldPosProjected.z / WorldPosProjected.w;
            
    OutputColor.x = Depth;
    OutputColor.y = Depth * Depth;
    OutputColor.zw = 1.0;
     
        
    float Depth = WorldPosProjected.z / WorldPosProjected.w;    
    OutputColor.x = Depth;
    OutputColor.yzw = 1.0f;
      
    float Depth = WorldPosProjected.z / WorldPosProjected.w;
    OutputColor.x = Depth;
    OutputColor.yzw = 1.0f;

0x562160

    ;
  In.     Out.     :      //---------------------------------------------------------------------------
  
}
 {
  )
  out     ,
      (   
void   
*/
    /*
         	// Function call #%d
  );  %s_CallOut%d    
           ,   €”~ ÀCu @—~ P„~ à€~ `€~ }

     return Out;
    
};

   Out.    Output Main(Input In)
{
    Output Out;
        //---------------------------------------------------------------------------
// Main():
//---------------------------------------------------------------------------

    struct Output
{
    //---------------------------------------------------------------------------
// Output:
//---------------------------------------------------------------------------

    struct Input
{
     //---------------------------------------------------------------------------
// Input:
//---------------------------------------------------------------------------

 //---------------------------------------------------------------------------
// Functions:
//---------------------------------------------------------------------------

     //---------------------------------------------------------------------------
// Constant variables:
//---------------------------------------------------------------------------

    
*/

   /*
Shader description:

    // Blurs the texel at vTexCoord in the Y direction.   
    float fInvTexSize = 1.0 / MapSize.y;
    float fHalfBlurKernelSize = KernelSize * 0.5f;
    float fInvTotalWeights = 1.0 / (KernelSize * KernelSize);    
    float fBlurWeight = 2;
   
    float4 fTotalColor = 0;   
    float2 vTexCoord = TexCoord;
    vTexCoord.y -= fInvTexSize * fHalfBlurKernelSize;    
    float i = 0;

    // Blur x2
    if ( 2 <= KernelSize)    
    {
        fTotalColor += tex2D(Sampler, vTexCoord) * 
            fBlurWeight * fInvTotalWeights;        
        vTexCoord.y += fInvTexSize;
        
        float fSign = sign( i + 1 - fHalfBlurKernelSize);
        fBlurWeight -= fSign * 4;
        
        fTotalColor += tex2D(Sampler, vTexCoord) * 
            fBlurWeight * fInvTotalWeights;
        vTexCoord.y += fInvTexSize;            
        
        fSign = sign( i + 2 - fHalfBlurKernelSize);
        fBlurWeight -= fSign * 4;        
        i+=2;
    }
    
    // Blur x4
    if ( 4 <= KernelSize)    
    {
        fTotalColor += tex2D(Sampler, vTexCoord) * 
            fBlurWeight * fInvTotalWeights;        
        vTexCoord.y += fInvTexSize;
        
        float fSign = sign( i + 1 - fHalfBlurKernelSize);
        fBlurWeight -= fSign * 4;
        
        fTotalColor += tex2D(Sampler, vTexCoord) * 
            fBlurWeight * fInvTotalWeights;
        vTexCoord.y += fInvTexSize;            
        
        fSign = sign( i + 2 - fHalfBlurKernelSize);
        fBlurWeight -= fSign * 4;        
        i+=2;
    }    

    // Blur x6
    if ( 6 <= KernelSize)    
    {
        fTotalColor += tex2D(Sampler, vTexCoord) * 
            fBlurWeight * fInvTotalWeights;        
        vTexCoord.y += fInvTexSize;
        
        float fSign = sign( i + 1 - fHalfBlurKernelSize);
        fBlurWeight -= fSign * 4;
        
        fTotalColor += tex2D(Sampler, vTexCoord) * 
            fBlurWeight * fInvTotalWeights;
        vTexCoord.y += fInvTexSize;            
        
        fSign = sign( i + 2 - fHalfBlurKernelSize);
        fBlurWeight -= fSign * 4;        
        i+=2;
    }

    // Blur x8
    if ( 8 <= KernelSize)    
    {
        fTotalColor += tex2D(Sampler, vTexCoord) * 
            fBlurWeight * fInvTotalWeights;        
        vTexCoord.y += fInvTexSize;
        
        float fSign = sign( i + 1 - fHalfBlurKernelSize);
        fBlurWeight -= fSign * 4;
        
        fTotalColor += tex2D(Sampler, vTexCoord) * 
            fBlurWeight * fInvTotalWeights;
        vTexCoord.y += fInvTexSize;            
        
        fSign = sign( i + 2 - fHalfBlurKernelSize);
        fBlurWeight -= fSign * 4;        
        i+=2;
    }

    // Blur x10
    if ( 10 <= KernelSize)    
    {
        fTotalColor += tex2D(Sampler, vTexCoord) * 
            fBlurWeight * fInvTotalWeights;        
        vTexCoord.y += fInvTexSize;
        
        float fSign = sign( i + 1 - fHalfBlurKernelSize);
        fBlurWeight -= fSign * 4;
        
        fTotalColor += tex2D(Sampler, vTexCoord) * 
            fBlurWeight * fInvTotalWeights;
        vTexCoord.y += fInvTexSize;            
        
        fSign = sign( i + 2 - fHalfBlurKernelSize);
        fBlurWeight -= fSign * 4;        
        i+=2;
    }

    // Blur x12
    if ( 12 <= KernelSize)    
    {
        fTotalColor += tex2D(Sampler, vTexCoord) * 
            fBlurWeight * fInvTotalWeights;        
        vTexCoord.y += fInvTexSize;
        
        float fSign = sign( i + 1 - fHalfBlurKernelSize);
        fBlurWeight -= fSign * 4;
        
        fTotalColor += tex2D(Sampler, vTexCoord) * 
            fBlurWeight * fInvTotalWeights;
        vTexCoord.y += fInvTexSize;            
        
        fSign = sign( i + 2 - fHalfBlurKernelSize);
        fBlurWeight -= fSign * 4;        
        i+=2;
    }
    
    // Blur x14
    if ( 14 <= KernelSize)    
    {
        fTotalColor += tex2D(Sampler, vTexCoord) * 
            fBlurWeight * fInvTotalWeights;        
        vTexCoord.y += fInvTexSize;
        
        float fSign = sign( i + 1 - fHalfBlurKernelSize);
        fBlurWeight -= fSign * 4;
        
        fTotalColor += tex2D(Sampler, vTexCoord) * 
            fBlurWeight * fInvTotalWeights;
        vTexCoord.y += fInvTexSize;            
        
        fSign = sign( i + 2 - fHalfBlurKernelSize);
        fBlurWeight -= fSign * 4;        
        i+=2;
    }    

    // Blur x16
    if ( 16 <= KernelSize)    
    {
        fTotalColor += tex2D(Sampler, vTexCoord) * 
            fBlurWeight * fInvTotalWeights;        
        vTexCoord.y += fInvTexSize;
        
        float fSign = sign( i + 1 - fHalfBlurKernelSize);
        fBlurWeight -= fSign * 4;
        
        fTotalColor += tex2D(Sampler, vTexCoord) * 
            fBlurWeight * fInvTotalWeights;
        vTexCoord.y += fInvTexSize;            
        
        fSign = sign( i + 2 - fHalfBlurKernelSize);
        fBlurWeight -= fSign * 4;        
        i+=2;
    }

    ColorOut = fTotalColor;
      

    // Blurs the texel at vTexCoord in the X direction.   
    float fInvTexSize = 1.0 / MapSize.x;
    float fHalfBlurKernelSize = KernelSize * 0.5f;
    float fInvTotalWeights = 1.0 / (KernelSize * KernelSize);    
    float fBlurWeight = 2;
   
    float4 fTotalColor = 0;   
    float2 vTexCoord = TexCoord;
    vTexCoord.x -= fInvTexSize * fHalfBlurKernelSize;    
    float i = 0;

    // Blur x2
    if ( 2 <= KernelSize)
    {
        fTotalColor += tex2D(Sampler, vTexCoord) * 
            fBlurWeight * fInvTotalWeights;        
        vTexCoord.x += fInvTexSize;
        
        float fSign = sign( i + 1 - fHalfBlurKernelSize);
        fBlurWeight -= fSign * 4;
        
        fTotalColor += tex2D(Sampler, vTexCoord) * 
            fBlurWeight * fInvTotalWeights;
        vTexCoord.x += fInvTexSize;            
        
        fSign = sign( i + 2 - fHalfBlurKernelSize);
        fBlurWeight -= fSign * 4;        
        i+=2;
    }

    // Blur x4
    if ( 4 <= KernelSize)
    {
        fTotalColor += tex2D(Sampler, vTexCoord) * 
            fBlurWeight * fInvTotalWeights;        
        vTexCoord.x += fInvTexSize;
        
        float fSign = sign( i + 1 - fHalfBlurKernelSize);
        fBlurWeight -= fSign * 4;
        
        fTotalColor += tex2D(Sampler, vTexCoord) * 
            fBlurWeight * fInvTotalWeights;
        vTexCoord.x += fInvTexSize;            
        
        fSign = sign( i + 2 - fHalfBlurKernelSize);
        fBlurWeight -= fSign * 4;        
        i+=2;
    }
    
    // Blur x6
    if ( 6 <= KernelSize)
    {
        fTotalColor += tex2D(Sampler, vTexCoord) * 
            fBlurWeight * fInvTotalWeights;        
        vTexCoord.x += fInvTexSize;
        
        float fSign = sign( i + 1 - fHalfBlurKernelSize);
        fBlurWeight -= fSign * 4;
        
        fTotalColor += tex2D(Sampler, vTexCoord) * 
            fBlurWeight * fInvTotalWeights;
        vTexCoord.x += fInvTexSize;            
        
        fSign = sign( i + 2 - fHalfBlurKernelSize);
        fBlurWeight -= fSign * 4;        
        i+=2;
    }    
    
    // Blur x8
    if ( 8 <= KernelSize)
    {
        fTotalColor += tex2D(Sampler, vTexCoord) * 
            fBlurWeight * fInvTotalWeights;        
        vTexCoord.x += fInvTexSize;
        
        float fSign = sign( i + 1 - fHalfBlurKernelSize);
        fBlurWeight -= fSign * 4;
        
        fTotalColor += tex2D(Sampler, vTexCoord) * 
            fBlurWeight * fInvTotalWeights;
        vTexCoord.x += fInvTexSize;            
        
        fSign = sign( i + 2 - fHalfBlurKernelSize);
        fBlurWeight -= fSign * 4;        
        i+=2;
    }    
    
    // Blur x10
    if ( 10 <= KernelSize)
    {
        fTotalColor += tex2D(Sampler, vTexCoord) * 
            fBlurWeight * fInvTotalWeights;        
        vTexCoord.x += fInvTexSize;
        
        float fSign = sign( i + 1 - fHalfBlurKernelSize);
        fBlurWeight -= fSign * 4;
        
        fTotalColor += tex2D(Sampler, vTexCoord) * 
            fBlurWeight * fInvTotalWeights;
        vTexCoord.x += fInvTexSize;            
        
        fSign = sign( i + 2 - fHalfBlurKernelSize);
        fBlurWeight -= fSign * 4;        
        i+=2;
    }

    // Blur x12
    if ( 12 <= KernelSize)
    {
        fTotalColor += tex2D(Sampler, vTexCoord) * 
            fBlurWeight * fInvTotalWeights;        
        vTexCoord.x += fInvTexSize;
        
        float fSign = sign( i + 1 - fHalfBlurKernelSize);
        fBlurWeight -= fSign * 4;
        
        fTotalColor += tex2D(Sampler, vTexCoord) * 
            fBlurWeight * fInvTotalWeights;
        vTexCoord.x += fInvTexSize;            
        
        fSign = sign( i + 2 - fHalfBlurKernelSize);
        fBlurWeight -= fSign * 4;        
        i+=2;
    }
       
    // Blur x14
    if ( 14 <= KernelSize)
    {
        fTotalColor += tex2D(Sampler, vTexCoord) * 
            fBlurWeight * fInvTotalWeights;        
        vTexCoord.x += fInvTexSize;
        
        float fSign = sign( i + 1 - fHalfBlurKernelSize);
        fBlurWeight -= fSign * 4;
        
        fTotalColor += tex2D(Sampler, vTexCoord) * 
            fBlurWeight * fInvTotalWeights;
        vTexCoord.x += fInvTexSize;            
        
        fSign = sign( i + 2 - fHalfBlurKernelSize);
        fBlurWeight -= fSign * 4;        
        i+=2;
    }    
    
    // Blur x16
    if ( 16 <= KernelSize)
    {
        fTotalColor += tex2D(Sampler, vTexCoord) * 
            fBlurWeight * fInvTotalWeights;        
        vTexCoord.x += fInvTexSize;
        
        float fSign = sign( i + 1 - fHalfBlurKernelSize);
        fBlurWeight -= fSign * 4;
        
        fTotalColor += tex2D(Sampler, vTexCoord) * 
            fBlurWeight * fInvTotalWeights;
        vTexCoord.x += fInvTexSize;            
        
        fSign = sign( i + 2 - fHalfBlurKernelSize);
        fBlurWeight -= fSign * 4;        
        i+=2;
    }
        
    ColorOut = fTotalColor;
       ps_2_0/vs_4_0/ps_4_0        
    ColorOut.a = 1.0f;
    ColorOut.rgb = tex2D(Sampler, TexCoord).rgb;
    if (Saturate)
    {
        ColorOut.rgb = saturate(ColorOut.rgb);
    }
          
    ColorOut.a = 1.0f;
    ColorOut.rgb = texCUBE(Sampler, TexCoord).rgb;
    if (Saturate)
    {
        ColorOut.rgb = saturate(ColorOut.rgb);
    }
        
    float4 ProjTexCoord = TexCoord.xyzz;
    ColorOut.a = 1.0f;    
    ColorOut.rgb = tex2Dproj(Sampler, ProjTexCoord).rgb;    
    if (Saturate)
    {
        ColorOut.rgb = saturate(ColorOut.rgb);
    }
         
    float Depth = WorldPosProjected.z / WorldPosProjected.w;
            
    OutputColor.x = Depth;
    OutputColor.y = Depth * Depth;
    OutputColor.z = 1.0;
    OutputColor.w = 1.0;

            
    float Depth = WorldPosProjected.z / WorldPosProjected.w;
    OutputColor = Depth;
     BlurColor