home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
GameStar 2006 April
/
Gamestar_83_2006-04_dvd.iso
/
Dema
/
demowot_english.exe
/
InfDX
/
x
/
notused
/
deferred-point2-pixel.hlsl
< prev
next >
Wrap
Text File
|
2005-03-22
|
2KB
|
57 lines
struct VS_OUTPUT
{
float4 Transformed : TEXCOORD0;
float4 Attrib : TEXCOORD1;
float4 Color : TEXCOORD2;
float3 LightInView : TEXCOORD3;
float4 FustrumPos : TEXCOORD4;
float4 ViewToLight0 : TEXCOORD5;
float4 ViewToLight1 : TEXCOORD6;
float4 ViewToLight2 : TEXCOORD7;
};
float4x4 TDX_CONST_INVPROJ;
float4x4 TDX_CONST_INVVIEW;
float4x4 TDX_CONST_INVVIEWPROJ;
float4 TDX_CONST_LIGHTCONTRIB;
sampler sampler_normal : register(s0); // normal
sampler sampler_position : register(s1); // position
sampler sampler_projector : register(s3); // projector
float4 main(VS_OUTPUT In) : COLOR
{
float4 FinalColor;
// normalvector
float4 Normal=tex2Dproj(sampler_normal, In.Transformed)*2-1;
// extracting view space position
float4 Depth=tex2Dproj(sampler_position, In.Transformed);
float3 ViewSpacePos=(In.FustrumPos/In.FustrumPos.w)*Depth.r;
// lighting parameters
float3 LightToFragment=ViewSpacePos-In.LightInView;
float Distance=length(LightToFragment);
float3 LightToFragmentNorm=LightToFragment/Distance;
float4 Factor=(1-saturate(Distance/In.Attrib.y*1.75-0.75))*In.Color;
float DotProduct=saturate(dot(Normal, -LightToFragmentNorm));
FinalColor=DotProduct*Factor;
/*#if TDX_SHADERFLAG_SPECULAR
float3 Reflected=normalize(reflect(ViewSpacePos, Normal.xyz));
float Specular=pow(saturate(dot(Reflected, -LightToFragmentNorm)),Normal.w*100);
FinalColor.rgb+=Factor*Specular*Albedo.a;
#endif*/
float3 LightToFragmentLS;
LightToFragmentLS.x=mul(LightToFragmentNorm, In.ViewToLight0);
LightToFragmentLS.y=mul(LightToFragmentNorm, In.ViewToLight1);
LightToFragmentLS.z=mul(LightToFragmentNorm, In.ViewToLight2);
FinalColor*=texCUBE(sampler_projector, LightToFragmentLS);
return FinalColor*0.25;
}