   Projective mapping, Shadow mapping
  Hello,i would like to sort few things in my head, hehei know, how to project a texture. I just multiply texcoord of texture with View matrix of projector andi divide each part of texcoord by w component and make it in range -1.0 - 1.0.It's same with shadow mapping, i project a depth map and compare real depth and projected to get shadows, right ?Problem is, how to project texture bigger than screen ? I can usually set a texture size for shadowmap, so how to render depth to texture bigger than screen ? if i want 1024x1024 i guess, i have to set projection right, for example ratio 1:1 and render depth, is it true?thank you very much for help ;-)   
  The size of the texture being projected doesn't matter. You're dealing with texture coordinates, which are in the normalised range of 0 to 1. The texture could be 10 pixels wide or 1000 wide and the projection would work the same.[edit]I think I misunderstood :/Yeah, when you're rendering the actual shadow-map into your texture, if the texture is 1024x1024 then you should use a projection matrix with an aspect ratio of 1:1.   ;  I successfully projected texture onto different object and i understand, how it works .. so, I wanted to try a own shadow mapping in RenderMonkey.In First pass, i made a Depth map from LightView.In Second Pass, I projected light depth map onto terrain + calculate depth map from camera and compare depths .. unfortunately, it doesn't work for me :( perhaps, i forgot something .. projecting is working.ftp://78.102.70.147/Data/CustomShadows.rarCould anybody here test it and figure out, what i did wrong ? It's using materials from RenderMonkey, copy it in DX9 folder in examples, Also, you need to set camera far range to 10000 at least, because terrain is big.I set up LightViewProjective manually from camera matrix, when i was on a place with camera.thank you !this is code for first pass:VS:float4x4 matLightWorldViewProjection;struct VS_INPUT {   float4 Position : POSITION0;   };struct VS_OUTPUT {   float4 Position : POSITION0;   float2 Position2D : TEXCOORD0;};VS_OUTPUT vs_main( VS_INPUT Input ){   VS_OUTPUT Output;   Output.Position = mul( Input.Position, matLightWorldViewProjection );   Output.Position2D.x = Output.Position.z;   Output.Position2D.y = Output.Position.w;   return( Output );   }PS:struct PS_INPUT {   float2 Texcoord : TEXCOORD0;   };float4 ps_main(PS_INPUT input) : COLOR0{   return (input.Texcoord.x / input.Texcoord.y);}and this is for second pass:VS:float4x4 matLightWorldViewProjection;float4x4 matWorldViewProjection;struct VS_INPUT {   float4 Position : POSITION0;   float2 Tex : TEXCOORD0;   };struct VS_OUTPUT {   float4 Position : POSITION0;   float2 Tex : TEXCOORD0;   float4 Shadow : TEXCOORD1;   float2 Depth : TEXCOORD2; };VS_OUTPUT vs_main( VS_INPUT Input ){   VS_OUTPUT Output;   Output.Position = mul( Input.Position, matWorldViewProjection );   Output.Tex = Input.Tex; Output.Shadow = mul( float4((Input.Position).xyz,1.0), matLightWorldViewProjection ); Output.Depth.x = Output.Position.z;   Output.Depth.y = Output.Position.w;   return( Output );   }PS:sampler2D Texture0;sampler2D Texture1;struct PS_INPUT {   float2 Texcoord : TEXCOORD0;    float4 Shadow : TEXCOORD1;   float2 Depth : TEXCOORD2;  };float4 ps_main(PS_INPUT input) : COLOR0{ float4 Coords = input.Shadow;   Coords.x = ((input.Shadow.x / input.Shadow.w)*0.5)+0.5;   Coords.y = -((input.Shadow.y / input.Shadow.w)*0.5)+0.5;   Coords.w = (input.Shadow.w / input.Shadow.w);   float Proj_Depth = tex2D(Texture1, Coords).r;    float shadow = 1.0;   float realdepth = input.Depth.x / input.Depth.y; if( realdepth < Proj_Depth+0.001 ) shadow=1.0; else shadow = 0.2; return tex2D( Texture0, input.Texcoord ) * shadow; }