//Nie robi absolutnie nic oprócz nałozenia tekstury.
texture     texL0;
texture     texL1;
texture     texL2;
textureCUBE     texL3;

float4x4    World;
float4x3    WorldView;
float4x4    View;       //co klatke
float4x4    ViewProj;   //co klatke
float4x4    Projection; //co klatke
float Time;
float4 Lgh;
float4 Cam;

struct VS_OUTPUT
{
    float4 Pos      : POSITION;
    float4 Diffuse  : COLOR;
    float3 TexL0    : TEXCOORD0;
    float3 TexL1    : TEXCOORD1;               
    float3 TexL2    : TEXCOORD2;    
    float3 TexL3    : TEXCOORD3;
};


VS_OUTPUT VS
    (    
    float3 Pos         :  POSITION,
    float3 Norm        :  NORMAL,
    float4 Diffuse     :  COLOR,
    float3 Tci0        :  TEXCOORD0,
    float3 Tci1        :  TEXCOORD1,
    float3 Tci2        :  TEXCOORD2,
    float3 Tci3        :  TEXCOORD3
    )
{

 VS_OUTPUT Out = (VS_OUTPUT)0;
 
 Out.Diffuse.r =Out.Diffuse.g =Out.Diffuse.b =Out.Diffuse.a=1.0f;
 
 float3 P = mul(float4(Pos, 1), (float4x3)WorldView);
 Out.Pos = mul(float4(P, 1), Projection);
 float3 N =  normalize(mul(Norm, (float3x3)WorldView));
 float3 V = -normalize(P);

 float3 ViewVEC= (Pos-Cam);
                     
 float3 NormP=normalize( Norm + float3(0,-0.25f,0));
 float3 G =  normalize(2 * dot(NormP, ViewVEC) * NormP - ViewVEC);
 G.y*=-1;

 Out.TexL0=Tci0;        //BAZOWA
 Out.TexL1=Tci1;        //LIGHTMAP
 Out.TexL2=Tci0;        //SPECULAR 
 Out.TexL3=G;           //SPEC. LVL

 return Out;
}


VS_OUTPUT VS1
    (    
    float3 Pos         :  POSITION,
    float3 Norm        :  NORMAL,
    float4 Diffuse     :  COLOR,
    float3 Tci0        :  TEXCOORD0,
    float3 Tci1        :  TEXCOORD1,
    float3 Tci2        :  TEXCOORD2,
    float3 Tci3        :  TEXCOORD3
    )
{

 VS_OUTPUT Out = (VS_OUTPUT)0;
 
 Out.Diffuse.r =Out.Diffuse.g =Out.Diffuse.b =Out.Diffuse.a=1.0f;
 
 float3 P = mul(float4(Pos, 1), (float4x3)WorldView);
 Out.Pos = mul(float4(P, 1), Projection);
 float3 N =  normalize(mul(Norm, (float3x3)WorldView));
 float3 V = -normalize(P);

 float3 ViewVEC= (Pos-Cam);
                     
 float3 NormP=normalize( Norm + float3(0,-0.25f,0));
 float3 G =  normalize(2 * dot(NormP, ViewVEC) * NormP - ViewVEC);
 G.y*=-1;

 Out.TexL0=Tci0;        //BAZOWA
 Out.TexL3=Tci1;        //LIGHTMAP
 Out.TexL2=Tci0;        //SPECULAR 
 Out.TexL1=G;           //SPEC. LVL

 return Out;
}



samplerCUBE SamplerSP= sampler_state
{
    Texture   = < texL3 >;
    MipFilter = LINEAR;
    MinFilter = LINEAR;
    MagFilter = LINEAR;
};
sampler base= sampler_state
{
    Texture   = < texL0 >;
    //MipFilter = LINEAR;
    //MinFilter = LINEAR;
    //MagFilter = LINEAR;
};
sampler lightmap= sampler_state
{
    Texture   = < texL1 >;
    MipFilter = LINEAR;
    MinFilter = LINEAR;
    MagFilter = LINEAR;
};
sampler speclevel = sampler_state
{
    Texture   = < texL2 >;
    MipFilter = LINEAR;
    MinFilter = LINEAR;
    MagFilter = LINEAR;
};





technique t2
{
    pass p1
  {
    VertexShader =  compile vs_1_1 VS();
    PixelShader  =  NULL; 
    Texture[0]   = < texL0 >;
    Texture[1]   = < texL1 >;
    Texture[2]   = < texL2 >;
    Texture[3]   = < texL3 >; 
    Texcoordindex[0]   = 0;
    Texcoordindex[1]   = 1;
    Texcoordindex[2]   = 2;
    Texcoordindex[3]   = 3;
    lighting=false;
    ColorOp[0]=SelectArg1;
    ColorArg1[0]=Texture;
    ColorOp[1]=Modulate;
    ColorArg1[0]=Texture;
    ColorArg2[1]=Current;

  }

   pass p0
   {
       VertexShader =  compile vs_1_1 VS1();
       PixelShader  =  NULL; 


        Texture[0]   = < texL2 >;
        Texture[1]   = < texL3 >;
        
        Texture[2]   = < texL2 >;
        Texture[3]   = < texL1 >; 

        Texcoordindex[0]   = 0;
        Texcoordindex[1]   = 0;
        Texcoordindex[2]   = 0;
        Texcoordindex[3]   = 0;

        lighting=false;
        bumpenvmat00[0]=0.175f;
        bumpenvmat01[0]=0.175f;
        bumpenvmat10[0]=0.175f;
        bumpenvmat11[0]=0.17f;

        ColorOp[0]=BumpEnvMap;
        ColorArg1[0]=Texture;

        ColorOp[1]=SelectArg1;
        ColorArg1[1]=Texture;
        ColorArg2[1]=Current;
        
        ColorOp[2]=Modulate;
        ColorArg1[2]=Current;
        ColorArg2[2]=Texture;

        ColorOp[3]=Modulate;
        ColorArg1[3]=Current;
        ColorArg2[3]=Texture;

        ColorOp[4]=Disable;

        magfilter[3]=linear;
        minfilter[3]=linear;
        mipfilter[3]=linear;

        magfilter[2]=linear;
        minfilter[2]=linear;

        fogenable=false;
        fogstart=0;
        fogend=150;
        fogtablemode=linear;//exp;
        fogdensity=0.008f;
        fogcolor=0x00BD8F2B;

        alphablendenable=true;
        srcblend=one;
        destblend=one;
   }
}


