//Cg
//
//Cg profile arbvp1 arbfp1
void vshader(float4 vtx_position : POSITION,
float2 vtx_texcoord0: TEXCOORD0,
float4 vtx_normal : NORMAL,
float4 vtx_color,
//in uniform float4 mspos_plight0,
in uniform float4x4 mat_modelproj,
in uniform float4 mspos_light,
//in uniform float4 wspos_dumbdfhdf,
//in uniform float4x4 inv_modelview,
in uniform float4x4 trans_model_to_light,
in uniform float4 k_projmat1,
in uniform float4 k_projmat2,
in uniform float4 k_projmat3,
in uniform float4 k_projmat4,
out float4 l_position : POSITION,
out float2 l_texcoord0 : TEXCOORD0,
out float4 l_texcoord1 : TEXCOORD1,
out float4 l_color0 : COLOR0,
out float4 l_light,
out float4 l_lightvec0,
out float4 l_normal)
{
//make some matrices for coordinate space transformations
float4x4 projMatrix = float4x4(k_projmat1,k_projmat2,k_projmat3,k_projmat4);
float4x4 scaleMatrix = {0.5f,0.0f,0.0f,0.5f,
0.0f,0.5f,0.0f,0.5f,
0.0f,0.0f,0.5f,0.5f,
0.0f,0.0f,0.0f,1.0f};
float4x4 clipSpaceMatrix = mul(projMatrix, trans_model_to_light);
float4x4 textureMat = mul(scaleMatrix, clipSpaceMatrix);
l_texcoord0 = vtx_texcoord0;
l_texcoord1 = mul(textureMat, vtx_position);
//vertex position
l_position = mul(mat_modelproj, vtx_position);
l_color0 = vtx_color;
float4 normal = vtx_normal;//mul(mat_modelproj,vtx_normal);
l_normal = normal;
float4 lightvec0 = mspos_light - vtx_position;
l_lightvec0 = lightvec0;
l_light = 1.0;//max(0.0,dot(normal,normalize(lightvec0)));
//l_normal = 1.0;
}
void fshader(float4 l_position : POSITION,
float2 l_texcoord0 : TEXCOORD0,
float4 l_texcoord1 : TEXCOORD1, //projection texcoord
float4 l_color0 : COLOR0,
float4 l_light,
float4 l_lightvec0,
float4 l_normal,
in uniform sampler2D tex_0 : TEXUNIT0,
in uniform sampler2D k_depthMap : TEXUNIT1,
in uniform float4 k_textelSize,
out float4 o_color:COLOR)
{
float4 baseColor = tex2D(tex_0, l_texcoord0);
//float4 lightcolor = max(0.0,dot(l_normal,l_lightvec0));
//float dist = distance(l_lightvec0,0);
o_color = l_color0baseColor(l_normal);//(.3distdist)+.4);
// Normal Shadow Mapping with no PCF ///////////////////////////////////////////////
//uncomment the next line and comment the rest for non PCF shadow mapping
float depth = tex2Dproj(k_depthMap,l_texcoord1);
if(depth < l_texcoord1.z/l_texcoord1.w) o_color *= .5;
//o_color = baseColor;
}