home *** CD-ROM | disk | FTP | other *** search
/ GameStar 2006 April / Gamestar_83_2006-04_dvd.iso / Dema / demowot_english.exe / InfDX / x / notused / deferred-directional2-pixel.hlsl < prev    next >
Text File  |  2005-03-22  |  2KB  |  63 lines

  1. struct VS_OUTPUT
  2. {
  3.     float2 UV            : TEXCOORD0;
  4. #if TDX_SHADERFLAG_SPECULAR
  5.     float4 FustrumPos   : TEXCOORD1;
  6. #endif
  7. };
  8.  
  9. struct ViewSpaceDir
  10. {
  11.     float4 Direction;
  12.     float4 Color;
  13. };
  14.  
  15. ViewSpaceDir TDX_CONST_VIEWDIR;
  16.  
  17. float4x4 TDX_CONST_INVVIEW;
  18. float4 TDX_CONST_LIGHTCONTRIB;
  19.  
  20. sampler sampler_normal : register(s0); // normal
  21. sampler sampler_position : register(s1); // position
  22.  
  23. float4 main(VS_OUTPUT In) : COLOR
  24. {
  25.     float4 FinalColor;
  26.     
  27.     // normalvector
  28.     float4 Normal=tex2D(sampler_normal, In.UV)*2-1;
  29.  
  30.     float DotProduct = dot(TDX_CONST_VIEWDIR.Direction.xyz, Normal.xyz);
  31.     FinalColor=saturate(DotProduct)*TDX_CONST_VIEWDIR.Color;
  32.  
  33. /*#if TDX_SHADERFLAG_SPECULAR
  34.     // extracting view space position
  35.     float4 Depth=tex2D(sampler_position, In.UV);
  36.     float3 ViewSpacePos=(In.FustrumPos/In.FustrumPos.w)*Depth.r;
  37.     
  38.     float3 Reflected=normalize(reflect(ViewSpacePos, Normal.xyz));
  39.     float Specular=pow(saturate(dot(Reflected,TDX_CONST_VIEWDIR.Direction.xyz)),Normal.w*100);
  40.     FinalColor+=TDX_CONST_VIEWDIR.Color*Specular*Albedo.a;
  41. #endif*/
  42.  
  43.  
  44. #if 0
  45.     float4 CubeLightDiffuse=texCUBE(sampler_sky, mul((float3)Normal,TDX_CONST_INVVIEW));
  46.     FinalColor=CubeLightDiffuse;
  47.  
  48. #if TDX_SHADERFLAG_SPECULAR
  49.     // extracting view space position
  50.     float4 Depth=tex2D(sampler_position, In.UV);
  51.     float3 ViewSpacePos=(In.FustrumPos/In.FustrumPos.w)*Depth.r;
  52.     
  53.     float3 ReflectionVector=reflect(ViewSpacePos, (float3)Normal);
  54.     float4 CubeLightSpecular=texCUBE(sampler_sky, mul(ReflectionVector,TDX_CONST_INVVIEW));
  55.     FinalColor=CubeLightSpecular;
  56. #endif
  57. #endif
  58.  
  59. //    FinalColor.a=dot((float3)FinalColor.rgb,(float3)TDX_CONST_LIGHTCONTRIB);
  60. //    FinalColor.rgb*=Albedo;
  61.     return FinalColor*0.25;
  62. }  
  63.